diff options
author | Eric Liu <ioeric@google.com> | 2016-12-06 10:12:23 +0000 |
---|---|---|
committer | Eric Liu <ioeric@google.com> | 2016-12-06 10:12:23 +0000 |
commit | 1c687daf81345e81ffb7acbf7fcdbfdf002ea66d (patch) | |
tree | e50a06281419e17d2bd0483484cb7c3281117253 /clang-move | |
parent | d9631705b2ba0032107d6fe40ec5ae36b8042cda (diff) | |
download | clang-tools-extra-1c687daf81345e81ffb7acbf7fcdbfdf002ea66d.tar.gz |
[clang-move] ignore unsupported symbol kinds when checking if all symbols are moved.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@288791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-move')
-rw-r--r-- | clang-move/ClangMove.cpp | 19 | ||||
-rw-r--r-- | clang-move/ClangMove.h | 4 |
2 files changed, 21 insertions, 2 deletions
diff --git a/clang-move/ClangMove.cpp b/clang-move/ClangMove.cpp index a4088a34..050b53a1 100644 --- a/clang-move/ClangMove.cpp +++ b/clang-move/ClangMove.cpp @@ -713,7 +713,24 @@ void ClangMoveTool::onEndOfTranslationUnit() { if (RemovedDecls.empty()) return; - if (UnremovedDeclsInOldHeader.empty() && !Context->Spec.OldHeader.empty()) { + // 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. + auto IsSupportedKind = [](const clang::NamedDecl *Decl) { + switch (Decl->getKind()) { + case Decl::Kind::Function: + case Decl::Kind::FunctionTemplate: + case Decl::Kind::ClassTemplate: + case Decl::Kind::CXXRecord: + return true; + default: + return false; + } + }; + if (std::none_of(UnremovedDeclsInOldHeader.begin(), + UnremovedDeclsInOldHeader.end(), IsSupportedKind) && + !Context->Spec.OldHeader.empty()) { auto &SM = RemovedDecls[0]->getASTContext().getSourceManager(); moveAll(SM, Context->Spec.OldHeader, Context->Spec.NewHeader); moveAll(SM, Context->Spec.OldCC, Context->Spec.NewCC); diff --git a/clang-move/ClangMove.h b/clang-move/ClangMove.h index e4e145cf..dcc23077 100644 --- a/clang-move/ClangMove.h +++ b/clang-move/ClangMove.h @@ -95,7 +95,9 @@ struct ClangMoveContext { // The goal of this tool is to make the new files as compliable as possible. // // Note: When all declarations in old header are being moved, all code in -// old.h/cc will be moved, which means old.h/cc are empty. +// old.h/cc will be moved, which means old.h/cc are empty. This ignores symbols +// that are not supported (e.g. typedef and enum) so that we always move old +// files to new files when all symbols produced from dump_decls are moved. class ClangMoveTool : public ast_matchers::MatchFinder::MatchCallback { public: ClangMoveTool(ClangMoveContext *const Context, |