[PATCH] D43075: [clang-move] Don't dump macro symbols.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 9 08:00:49 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE324742: [clang-move] Don't dump macro symbols. (authored by hokein, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43075?vs=133621&id=133623#toc
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D43075
Files:
clang-move/ClangMove.cpp
unittests/clang-move/ClangMoveTests.cpp
Index: unittests/clang-move/ClangMoveTests.cpp
===================================================================
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -391,6 +391,26 @@
}
}
+TEST(ClangMove, IgnoreMacroSymbolsAndMoveAll) {
+ const char TestCode[] = "#include \"foo.h\"";
+ std::vector<std::string> TestHeaders = {
+ "#define DEFINE_Foo int Foo = 1;\nDEFINE_Foo;\nclass Bar {};\n",
+ "#define DEFINE(x) int var_##x = 1;\nDEFINE(foo);\nclass Bar {};\n",
+ };
+ move::MoveDefinitionSpec Spec;
+ Spec.Names.push_back("Bar");
+ Spec.OldHeader = "foo.h";
+ Spec.OldCC = "foo.cc";
+ Spec.NewHeader = "new_foo.h";
+ Spec.NewCC = "new_foo.cc";
+
+ for (const auto& Header : TestHeaders) {
+ auto Results = runClangMoveOnCode(Spec, Header.c_str(), TestCode);
+ EXPECT_EQ("", Results[Spec.OldHeader]);
+ EXPECT_EQ(Header, Results[Spec.NewHeader]);
+ }
+}
+
TEST(ClangMove, MacroInFunction) {
const char TestHeader[] = "#define INT int\n"
"class A {\npublic:\n int f();\n};\n"
@@ -570,7 +590,9 @@
"extern int kGlobalInt;\n"
"extern const char* const kGlobalStr;\n"
"} // namespace b\n"
- "} // namespace a\n";
+ "} // namespace a\n"
+ "#define DEFINE_FOO class Foo {};\n"
+ "DEFINE_FOO\n";
const char TestCode[] = "#include \"foo.h\"\n";
move::MoveDefinitionSpec Spec;
Spec.Names.push_back("B");
Index: clang-move/ClangMove.cpp
===================================================================
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -523,6 +523,7 @@
auto AllDeclsInHeader = namedDecl(
unless(ForwardClassDecls), unless(namespaceDecl()),
unless(usingDirectiveDecl()), // using namespace decl.
+ notInMacro(),
InOldHeader,
hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl()))),
hasDeclContext(decl(anyOf(namespaceDecl(), translationUnitDecl()))));
@@ -905,10 +906,9 @@
if (RemovedDecls.empty())
return;
- // Ignore symbols that are not supported (e.g. typedef and enum) when
- // checking if there is unremoved symbol in old header. This makes sure that
- // we always move old files to new files when all symbols produced from
- // dump_decls are moved.
+ // Ignore symbols that are not supported when checking if there is unremoved
+ // symbol in old header. This makes sure that we always move old files to new
+ // files when all symbols produced from dump_decls are moved.
auto IsSupportedKind = [](const clang::NamedDecl *Decl) {
switch (Decl->getKind()) {
case Decl::Kind::Function:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43075.133623.patch
Type: text/x-patch
Size: 2806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180209/6e722b8f/attachment-0001.bin>
More information about the cfe-commits
mailing list