| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json |
| 4 |
|
| 5 |
//--- cdb.json.in |
| 6 |
[{ |
| 7 |
"directory": "DIR", |
| 8 |
"command": "clang -c DIR/tu.c -o DIR/tu.o -IDIR/include", |
| 9 |
"file": "DIR/tu.c" |
| 10 |
}] |
| 11 |
//--- include/header.h |
| 12 |
//--- include/header2.h |
| 13 |
//--- include/header3.h |
| 14 |
//--- include/header4.h |
| 15 |
//--- include/header5.h |
| 16 |
//--- include/header6.h |
| 17 |
//--- include/header7.h |
| 18 |
//--- include/header8.h |
| 19 |
//--- include/header9.h |
| 20 |
//--- include/header10.h |
| 21 |
//--- include/header11.h |
| 22 |
//--- include/header12.h |
| 23 |
//--- include/header13.h |
| 24 |
//--- include/header14.h |
| 25 |
//--- tu.c |
| 26 |
#if 0 |
| 27 |
R"x()x" |
| 28 |
#endif |
| 29 |
|
| 30 |
#include "header.h" |
| 31 |
|
| 32 |
#if 0 |
| 33 |
R"y("; |
| 34 |
#endif |
| 35 |
#include "header2.h" |
| 36 |
|
| 37 |
#if 0 |
| 38 |
//")y" |
| 39 |
#endif |
| 40 |
|
| 41 |
#if 0 |
| 42 |
R"y("; |
| 43 |
R"z()y"; |
| 44 |
#endif |
| 45 |
#include "header3.h" |
| 46 |
#if 0 |
| 47 |
//")z" |
| 48 |
#endif |
| 49 |
|
| 50 |
#if 0 |
| 51 |
R\ |
| 52 |
"y("; |
| 53 |
R"z()y"; |
| 54 |
#endif |
| 55 |
#include "header4.h" |
| 56 |
#if 0 |
| 57 |
//")z" |
| 58 |
#endif |
| 59 |
|
| 60 |
// Test u8 prefix with escaped newline |
| 61 |
#if 0 |
| 62 |
u8R\ |
| 63 |
"prefix(test)prefix" |
| 64 |
#endif |
| 65 |
#include "header5.h" |
| 66 |
|
| 67 |
// Test u prefix with multiple escaped newlines |
| 68 |
#if 0 |
| 69 |
uR\ |
| 70 |
\ |
| 71 |
"multi(test)multi" |
| 72 |
#endif |
| 73 |
#include "header6.h" |
| 74 |
|
| 75 |
// Test U prefix with escaped newline |
| 76 |
#if 0 |
| 77 |
UR\ |
| 78 |
"upper(test)upper" |
| 79 |
#endif |
| 80 |
#include "header7.h" |
| 81 |
|
| 82 |
// Test L prefix with escaped newline |
| 83 |
#if 0 |
| 84 |
LR\ |
| 85 |
"wide(test)wide" |
| 86 |
#endif |
| 87 |
#include "header8.h" |
| 88 |
|
| 89 |
// Test escaped newline with \r\n style |
| 90 |
#if 0 |
| 91 |
R\ |
| 92 |
"crlf(test)crlf" |
| 93 |
#endif |
| 94 |
#include "header9.h" |
| 95 |
|
| 96 |
// Test multiple escaped newlines in different positions |
| 97 |
#if 0 |
| 98 |
u\ |
| 99 |
8\ |
| 100 |
R\ |
| 101 |
"complex(test)complex" |
| 102 |
#endif |
| 103 |
#include "header10.h" |
| 104 |
|
| 105 |
// Test raw string that should NOT be treated as raw (no R prefix due to identifier continuation) |
| 106 |
#if 0 |
| 107 |
identifierR"notraw(test)notraw" |
| 108 |
#endif |
| 109 |
#include "header11.h" |
| 110 |
|
| 111 |
// Test raw string with whitespace before escaped newline |
| 112 |
#if 0 |
| 113 |
R \ |
| 114 |
"whitespace(test)whitespace" |
| 115 |
#endif |
| 116 |
#include "header12.h" |
| 117 |
|
| 118 |
// Test nested raw strings in disabled code |
| 119 |
#if 0 |
| 120 |
R"outer( |
| 121 |
R"inner(content)inner" |
| 122 |
)outer" |
| 123 |
#endif |
| 124 |
#include "header13.h" |
| 125 |
|
| 126 |
// Test raw string with empty delimiter |
| 127 |
#if 0 |
| 128 |
R\ |
| 129 |
"(empty delimiter)"; |
| 130 |
#endif |
| 131 |
#include "header14.h" |
| 132 |
|
| 133 |
// RUN: clang-scan-deps -compilation-database %t/cdb.json -mode preprocess | FileCheck %s |
| 134 |
// RUN: clang-scan-deps -compilation-database %t/cdb.json -mode preprocess-dependency-directives | FileCheck %s |
| 135 |
// CHECK: tu.c |
| 136 |
// CHECK-NEXT: header.h |
| 137 |
// CHECK-NEXT: header3.h |
| 138 |
// CHECK-NEXT: header4.h |
| 139 |
// CHECK-NEXT: header5.h |
| 140 |
// CHECK-NEXT: header6.h |
| 141 |
// CHECK-NEXT: header7.h |
| 142 |
// CHECK-NEXT: header8.h |
| 143 |
// CHECK-NEXT: header9.h |
| 144 |
// CHECK-NEXT: header10.h |
| 145 |
// CHECK-NEXT: header11.h |
| 146 |
// CHECK-NEXT: header12.h |
| 147 |
// CHECK-NEXT: header13.h |
| 148 |
// CHECK-NEXT: header14.h |