@@ -33,7 +33,7 @@ const DeclType *findDecl(ASTContext &Ctx, StringRef Name) {
3333}
3434
3535TEST (ASTEntityMappingTest, FunctionDecl) {
36- auto AST = tooling::buildASTFromCode (" void foo() {}" );
36+ auto AST = tooling::buildASTFromCode (R"cpp( void foo() {})cpp " );
3737 auto &Ctx = AST->getASTContext ();
3838
3939 const auto *FD = findDecl<FunctionDecl>(Ctx, " foo" );
@@ -44,7 +44,7 @@ TEST(ASTEntityMappingTest, FunctionDecl) {
4444}
4545
4646TEST (ASTEntityMappingTest, VarDecl) {
47- auto AST = tooling::buildASTFromCode (" int x = 42;" );
47+ auto AST = tooling::buildASTFromCode (R"cpp( int x = 42;)cpp " );
4848 auto &Ctx = AST->getASTContext ();
4949
5050 const auto *VD = findDecl<VarDecl>(Ctx, " x" );
@@ -55,7 +55,7 @@ TEST(ASTEntityMappingTest, VarDecl) {
5555}
5656
5757TEST (ASTEntityMappingTest, ParmVarDecl) {
58- auto AST = tooling::buildASTFromCode (" void foo(int x) {}" );
58+ auto AST = tooling::buildASTFromCode (R"cpp( void foo(int x) {})cpp " );
5959 auto &Ctx = AST->getASTContext ();
6060
6161 const auto *FD = findDecl<FunctionDecl>(Ctx, " foo" );
@@ -70,7 +70,7 @@ TEST(ASTEntityMappingTest, ParmVarDecl) {
7070}
7171
7272TEST (ASTEntityMappingTest, RecordDecl) {
73- auto AST = tooling::buildASTFromCode (" struct S {};" );
73+ auto AST = tooling::buildASTFromCode (R"cpp( struct S {};)cpp " );
7474 auto &Ctx = AST->getASTContext ();
7575
7676 const auto *RD = findDecl<RecordDecl>(Ctx, " S" );
@@ -81,7 +81,7 @@ TEST(ASTEntityMappingTest, RecordDecl) {
8181}
8282
8383TEST (ASTEntityMappingTest, FieldDecl) {
84- auto AST = tooling::buildASTFromCode (" struct S { int field; };" );
84+ auto AST = tooling::buildASTFromCode (R"cpp( struct S { int field; };)cpp " );
8585 auto &Ctx = AST->getASTContext ();
8686
8787 const auto *FD = findDecl<FieldDecl>(Ctx, " field" );
@@ -97,9 +97,11 @@ TEST(ASTEntityMappingTest, NullDecl) {
9797}
9898
9999TEST (ASTEntityMappingTest, ImplicitDeclLambda) {
100- auto AST = tooling::buildASTFromCode (R"(
100+ auto AST = tooling::buildASTFromCode (
101+ R"cpp(
101102 auto L = [](){};
102- )" , " test.cpp" , std::make_shared<PCHContainerOperations>());
103+ )cpp" ,
104+ " test.cpp" , std::make_shared<PCHContainerOperations>());
103105 auto &Ctx = AST->getASTContext ();
104106
105107 auto Matcher = cxxRecordDecl (isImplicit ()).bind (" decl" );
@@ -114,11 +116,11 @@ TEST(ASTEntityMappingTest, ImplicitDeclLambda) {
114116}
115117
116118TEST (ASTEntityMappingTest, BuiltinFunction) {
117- auto AST = tooling::buildASTFromCode (R"(
119+ auto AST = tooling::buildASTFromCode (R"cpp (
118120 void test() {
119121 __builtin_memcpy(0, 0, 0);
120122 }
121- )" );
123+ )cpp " );
122124 auto &Ctx = AST->getASTContext ();
123125
124126 // Find the builtin call
@@ -138,7 +140,7 @@ TEST(ASTEntityMappingTest, BuiltinFunction) {
138140}
139141
140142TEST (ASTEntityMappingTest, UnsupportedDecl) {
141- auto AST = tooling::buildASTFromCode (" namespace N {}" );
143+ auto AST = tooling::buildASTFromCode (R"cpp( namespace N {})cpp " );
142144 auto &Ctx = AST->getASTContext ();
143145
144146 const auto *ND = findDecl<NamespaceDecl>(Ctx, " N" );
@@ -149,7 +151,7 @@ TEST(ASTEntityMappingTest, UnsupportedDecl) {
149151}
150152
151153TEST (ASTEntityMappingTest, FunctionReturn) {
152- auto AST = tooling::buildASTFromCode (" int foo() { return 42; }" );
154+ auto AST = tooling::buildASTFromCode (R"cpp( int foo() { return 42; })cpp " );
153155 auto &Ctx = AST->getASTContext ();
154156
155157 const auto *FD = findDecl<FunctionDecl>(Ctx, " foo" );
@@ -165,11 +167,11 @@ TEST(ASTEntityMappingTest, FunctionReturnNull) {
165167}
166168
167169TEST (ASTEntityMappingTest, FunctionReturnBuiltin) {
168- auto AST = tooling::buildASTFromCode (R"(
170+ auto AST = tooling::buildASTFromCode (R"cpp (
169171 void test() {
170172 __builtin_memcpy(0, 0, 0);
171173 }
172- )" );
174+ )cpp " );
173175 auto &Ctx = AST->getASTContext ();
174176
175177 // Find the builtin call
@@ -188,10 +190,10 @@ TEST(ASTEntityMappingTest, FunctionReturnBuiltin) {
188190}
189191
190192TEST (ASTEntityMappingTest, DifferentFunctionsDifferentNames) {
191- auto AST = tooling::buildASTFromCode (R"(
193+ auto AST = tooling::buildASTFromCode (R"cpp (
192194 void foo() {}
193195 void bar() {}
194- )" );
196+ )cpp " );
195197 auto &Ctx = AST->getASTContext ();
196198
197199 const auto *Foo = findDecl<FunctionDecl>(Ctx, " foo" );
@@ -210,10 +212,10 @@ TEST(ASTEntityMappingTest, DifferentFunctionsDifferentNames) {
210212// Redeclaration tests
211213
212214TEST (ASTEntityMappingTest, FunctionRedeclaration) {
213- auto AST = tooling::buildASTFromCode (R"(
215+ auto AST = tooling::buildASTFromCode (R"cpp (
214216 void foo();
215217 void foo() {}
216- )" );
218+ )cpp " );
217219 auto &Ctx = AST->getASTContext ();
218220
219221 auto Matcher = functionDecl (hasName (" foo" )).bind (" decl" );
@@ -237,10 +239,10 @@ TEST(ASTEntityMappingTest, FunctionRedeclaration) {
237239}
238240
239241TEST (ASTEntityMappingTest, VarRedeclaration) {
240- auto AST = tooling::buildASTFromCode (R"(
242+ auto AST = tooling::buildASTFromCode (R"cpp (
241243 extern int x;
242244 int x = 42;
243- )" );
245+ )cpp " );
244246 auto &Ctx = AST->getASTContext ();
245247
246248 auto Matcher = varDecl (hasName (" x" )).bind (" decl" );
@@ -264,10 +266,10 @@ TEST(ASTEntityMappingTest, VarRedeclaration) {
264266}
265267
266268TEST (ASTEntityMappingTest, RecordRedeclaration) {
267- auto AST = tooling::buildASTFromCode (R"(
269+ auto AST = tooling::buildASTFromCode (R"cpp (
268270 struct S;
269271 struct S {};
270- )" );
272+ )cpp " );
271273 auto &Ctx = AST->getASTContext ();
272274
273275 auto Matcher = recordDecl (hasName (" S" ), unless (isImplicit ())).bind (" decl" );
@@ -291,12 +293,12 @@ TEST(ASTEntityMappingTest, RecordRedeclaration) {
291293}
292294
293295TEST (ASTEntityMappingTest, ParmVarDeclRedeclaration) {
294- auto AST = tooling::buildASTFromCode (R"(
296+ auto AST = tooling::buildASTFromCode (R"cpp (
295297 void foo(int);
296298 void foo(int x);
297299 void foo(int y);
298300 void foo(int x) {}
299- )" );
301+ )cpp " );
300302 auto &Ctx = AST->getASTContext ();
301303
302304 auto Matcher = functionDecl (hasName (" foo" )).bind (" decl" );
@@ -321,10 +323,10 @@ TEST(ASTEntityMappingTest, ParmVarDeclRedeclaration) {
321323}
322324
323325TEST (ASTEntityMappingTest, FunctionReturnRedeclaration) {
324- auto AST = tooling::buildASTFromCode (R"(
326+ auto AST = tooling::buildASTFromCode (R"cpp (
325327 int foo();
326328 int foo() { return 42; }
327- )" );
329+ )cpp " );
328330 auto &Ctx = AST->getASTContext ();
329331
330332 auto Matcher = functionDecl (hasName (" foo" )).bind (" decl" );
0 commit comments