@@ -391,6 +391,26 @@ TEST(ClangMove, DontMoveAll) {
391
391
}
392
392
}
393
393
394
+ TEST (ClangMove, IgnoreMacroSymbolsAndMoveAll) {
395
+ const char TestCode[] = " #include \" foo.h\" " ;
396
+ std::vector<std::string> TestHeaders = {
397
+ " #define DEFINE_Foo int Foo = 1;\n DEFINE_Foo;\n class Bar {};\n " ,
398
+ " #define DEFINE(x) int var_##x = 1;\n DEFINE(foo);\n class Bar {};\n " ,
399
+ };
400
+ move::MoveDefinitionSpec Spec;
401
+ Spec.Names .push_back (" Bar" );
402
+ Spec.OldHeader = " foo.h" ;
403
+ Spec.OldCC = " foo.cc" ;
404
+ Spec.NewHeader = " new_foo.h" ;
405
+ Spec.NewCC = " new_foo.cc" ;
406
+
407
+ for (const auto & Header : TestHeaders) {
408
+ auto Results = runClangMoveOnCode (Spec, Header.c_str (), TestCode);
409
+ EXPECT_EQ (" " , Results[Spec.OldHeader ]);
410
+ EXPECT_EQ (Header, Results[Spec.NewHeader ]);
411
+ }
412
+ }
413
+
394
414
TEST (ClangMove, MacroInFunction) {
395
415
const char TestHeader[] = " #define INT int\n "
396
416
" class A {\n public:\n int f();\n };\n "
@@ -570,7 +590,9 @@ TEST(ClangMove, DumpDecls) {
570
590
" extern int kGlobalInt;\n "
571
591
" extern const char* const kGlobalStr;\n "
572
592
" } // namespace b\n "
573
- " } // namespace a\n " ;
593
+ " } // namespace a\n "
594
+ " #define DEFINE_FOO class Foo {};\n "
595
+ " DEFINE_FOO\n " ;
574
596
const char TestCode[] = " #include \" foo.h\"\n " ;
575
597
move::MoveDefinitionSpec Spec;
576
598
Spec.Names .push_back (" B" );
0 commit comments