@@ -342,9 +342,7 @@ B func12() {
342
342
343
343
{
344
344
auto FN = getFunctionNode (" func1" );
345
-
346
- EXPECT_EQ (dumpASTString (ast_type_traits::TK_AsIs, FN),
347
- R"cpp(
345
+ llvm::StringRef Expected = R"cpp(
348
346
FunctionDecl 'func1'
349
347
`-CompoundStmt
350
348
`-ReturnStmt
@@ -354,129 +352,143 @@ FunctionDecl 'func1'
354
352
`-ImplicitCastExpr
355
353
`-CXXConstructExpr
356
354
`-IntegerLiteral
357
- )cpp" ) ;
355
+ )cpp" ;
358
356
359
- EXPECT_EQ (
360
- dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource, FN),
361
- R"cpp(
357
+ EXPECT_EQ (dumpASTString (ast_type_traits::TK_AsIs, FN), Expected);
358
+
359
+ Expected = R"cpp(
362
360
FunctionDecl 'func1'
363
361
`-CompoundStmt
364
362
`-ReturnStmt
365
363
`-IntegerLiteral
366
- )cpp" );
364
+ )cpp" ;
365
+ EXPECT_EQ (
366
+ dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource, FN),
367
+ Expected);
367
368
}
368
369
369
- EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
370
- getFunctionNode (" func2" )),
371
- R"cpp(
370
+ llvm::StringRef Expected = R"cpp(
372
371
FunctionDecl 'func2'
373
372
`-CompoundStmt
374
373
`-ReturnStmt
375
374
`-CXXTemporaryObjectExpr
376
375
`-IntegerLiteral
377
- )cpp" );
378
-
376
+ )cpp" ;
379
377
EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
380
- getFunctionNode (" func3" )),
381
- R"cpp(
378
+ getFunctionNode (" func2" )),
379
+ Expected);
380
+
381
+ Expected = R"cpp(
382
382
FunctionDecl 'func3'
383
383
`-CompoundStmt
384
384
`-ReturnStmt
385
385
`-CXXFunctionalCastExpr
386
386
`-IntegerLiteral
387
- )cpp" );
388
-
387
+ )cpp" ;
389
388
EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
390
- getFunctionNode (" func4" )),
391
- R"cpp(
389
+ getFunctionNode (" func3" )),
390
+ Expected);
391
+
392
+ Expected = R"cpp(
392
393
FunctionDecl 'func4'
393
394
`-CompoundStmt
394
395
`-ReturnStmt
395
396
`-CXXTemporaryObjectExpr
396
- )cpp" );
397
-
397
+ )cpp" ;
398
398
EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
399
- getFunctionNode (" func5" )),
400
- R"cpp(
399
+ getFunctionNode (" func4" )),
400
+ Expected);
401
+
402
+ Expected = R"cpp(
401
403
FunctionDecl 'func5'
402
404
`-CompoundStmt
403
405
`-ReturnStmt
404
406
`-CXXTemporaryObjectExpr
405
- )cpp" );
406
-
407
+ )cpp" ;
407
408
EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
408
- getFunctionNode (" func6" )),
409
- R"cpp(
409
+ getFunctionNode (" func5" )),
410
+ Expected);
411
+
412
+ Expected = R"cpp(
410
413
FunctionDecl 'func6'
411
414
`-CompoundStmt
412
415
`-ReturnStmt
413
416
`-CXXTemporaryObjectExpr
414
- )cpp" );
415
-
417
+ )cpp" ;
416
418
EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
417
- getFunctionNode (" func7" )),
418
- R"cpp(
419
+ getFunctionNode (" func6" )),
420
+ Expected);
421
+
422
+ Expected = R"cpp(
419
423
FunctionDecl 'func7'
420
424
`-CompoundStmt
421
425
`-ReturnStmt
422
426
`-CXXTemporaryObjectExpr
423
- )cpp" );
424
-
427
+ )cpp" ;
425
428
EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
426
- getFunctionNode (" func8" )),
427
- R"cpp(
429
+ getFunctionNode (" func7" )),
430
+ Expected);
431
+
432
+ Expected = R"cpp(
428
433
FunctionDecl 'func8'
429
434
`-CompoundStmt
430
435
`-ReturnStmt
431
436
`-CXXFunctionalCastExpr
432
437
`-InitListExpr
433
- )cpp" );
434
-
438
+ )cpp" ;
435
439
EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
436
- getFunctionNode (" func9" )),
437
- R"cpp(
440
+ getFunctionNode (" func8" )),
441
+ Expected);
442
+
443
+ Expected = R"cpp(
438
444
FunctionDecl 'func9'
439
445
`-CompoundStmt
440
446
`-ReturnStmt
441
447
`-CXXFunctionalCastExpr
442
448
`-InitListExpr
443
- )cpp" );
444
-
449
+ )cpp" ;
445
450
EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
446
- getFunctionNode (" func10" )),
447
- R"cpp(
451
+ getFunctionNode (" func9" )),
452
+ Expected);
453
+
454
+ Expected = R"cpp(
448
455
FunctionDecl 'func10'
449
456
`-CompoundStmt
450
457
|-DeclStmt
451
458
| `-VarDecl 'a'
452
459
| `-CXXConstructExpr
453
460
`-ReturnStmt
454
461
`-DeclRefExpr 'a'
455
- )cpp" );
456
-
462
+ )cpp" ;
457
463
EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
458
- getFunctionNode (" func11" )),
459
- R"cpp(
464
+ getFunctionNode (" func10" )),
465
+ Expected);
466
+
467
+ Expected = R"cpp(
460
468
FunctionDecl 'func11'
461
469
`-CompoundStmt
462
470
|-DeclStmt
463
471
| `-VarDecl 'b'
464
472
| `-CXXConstructExpr
465
473
`-ReturnStmt
466
474
`-DeclRefExpr 'b'
467
- )cpp" );
468
-
475
+ )cpp" ;
469
476
EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
470
- getFunctionNode (" func12" )),
471
- R"cpp(
477
+ getFunctionNode (" func11" )),
478
+ Expected);
479
+
480
+ Expected = R"cpp(
472
481
FunctionDecl 'func12'
473
482
`-CompoundStmt
474
483
|-DeclStmt
475
484
| `-VarDecl 'c'
476
485
| `-CXXConstructExpr
477
486
`-ReturnStmt
478
487
`-DeclRefExpr 'c'
479
- )cpp" );
488
+ )cpp" ;
489
+ EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource,
490
+ getFunctionNode (" func12" )),
491
+ Expected);
480
492
}
481
493
482
494
TEST (Traverse, LambdaUnlessSpelledInSource) {
@@ -521,8 +533,7 @@ struct SomeStruct {
521
533
{
522
534
auto L = getLambdaNode (" captures" );
523
535
524
- EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
525
- R"cpp(
536
+ llvm::StringRef Expected = R"cpp(
526
537
LambdaExpr
527
538
|-DeclRefExpr 'a'
528
539
|-DeclRefExpr 'b'
@@ -534,10 +545,11 @@ LambdaExpr
534
545
|-ParmVarDecl 'h'
535
546
| `-IntegerLiteral
536
547
`-CompoundStmt
537
- )cpp" );
548
+ )cpp" ;
549
+ EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
550
+ Expected);
538
551
539
- EXPECT_EQ (dumpASTString (ast_type_traits::TK_AsIs, L),
540
- R"cpp(
552
+ Expected = R"cpp(
541
553
LambdaExpr
542
554
|-CXXRecordDecl ''
543
555
| |-CXXMethodDecl 'operator()'
@@ -557,44 +569,48 @@ LambdaExpr
557
569
| `-DeclRefExpr 'd'
558
570
|-DeclRefExpr 'f'
559
571
`-CompoundStmt
560
- )cpp" );
572
+ )cpp" ;
573
+ EXPECT_EQ (dumpASTString (ast_type_traits::TK_AsIs, L), Expected);
561
574
}
562
575
563
576
{
564
577
auto L = getLambdaNode (" templated" );
565
578
566
- EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
567
- R"cpp(
579
+ llvm::StringRef Expected = R"cpp(
568
580
LambdaExpr
569
581
|-DeclRefExpr 'a'
570
582
|-TemplateTypeParmDecl 'T'
571
583
|-ParmVarDecl 't'
572
584
`-CompoundStmt
573
- )cpp" );
585
+ )cpp" ;
586
+ EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
587
+ Expected);
574
588
}
575
589
576
590
{
577
591
auto L = getLambdaNode (" capture_this" );
578
592
579
- EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
580
- R"cpp(
593
+ llvm::StringRef Expected = R"cpp(
581
594
LambdaExpr
582
595
|-CXXThisExpr
583
596
`-CompoundStmt
584
- )cpp" );
597
+ )cpp" ;
598
+ EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
599
+ Expected);
585
600
}
586
601
587
602
{
588
603
auto L = getLambdaNode (" capture_this_copy" );
589
604
590
- EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
591
- R"cpp(
605
+ llvm::StringRef Expected = R"cpp(
592
606
LambdaExpr
593
607
|-VarDecl 'self'
594
608
| `-UnaryOperator
595
609
| `-CXXThisExpr
596
610
`-CompoundStmt
597
- )cpp" );
611
+ )cpp" ;
612
+ EXPECT_EQ (dumpASTString (ast_type_traits::TK_IgnoreUnlessSpelledInSource, L),
613
+ Expected);
598
614
}
599
615
}
600
616
0 commit comments