jgravelle-google created this revision. Herald added subscribers: aheejin, klimek.
Rename stop-after to stop-after-topdown. When building LLVM with -DLLVM_BUILD_LLVM_DYLIB=ON, stop-after collides with the stop-after already present in LLVM. This also refactors the flag to a boolean, to reflect that it can only be in two states. https://reviews.llvm.org/D36989 Files: lib/Tooling/ASTDiff/ASTDiff.cpp test/Tooling/clang-diff-topdown.cpp tools/clang-diff/ClangDiff.cpp Index: tools/clang-diff/ClangDiff.cpp =================================================================== --- tools/clang-diff/ClangDiff.cpp +++ tools/clang-diff/ClangDiff.cpp @@ -21,7 +21,7 @@ using namespace clang; using namespace clang::tooling; -static cl::OptionCategory ClangDiffCategory("clang-diff options"); +cl::OptionCategory ClangDiffCategory("clang-diff options"); static cl::opt<bool> ASTDump("ast-dump", @@ -50,11 +50,6 @@ cl::Optional, cl::cat(ClangDiffCategory)); -static cl::opt<std::string> StopAfter("stop-after", - cl::desc("<topdown|bottomup>"), - cl::Optional, cl::init(""), - cl::cat(ClangDiffCategory)); - static cl::opt<int> MaxSize("s", cl::desc("<maxsize>"), cl::Optional, cl::init(-1), cl::cat(ClangDiffCategory)); @@ -442,14 +437,6 @@ diff::ComparisonOptions Options; if (MaxSize != -1) Options.MaxSize = MaxSize; - if (!StopAfter.empty()) { - if (StopAfter == "topdown") - Options.StopAfterTopDown = true; - else if (StopAfter != "bottomup") { - llvm::errs() << "Error: Invalid argument for -stop-after\n"; - return 1; - } - } diff::SyntaxTree SrcTree(Src->getASTContext()); diff::SyntaxTree DstTree(Dst->getASTContext()); diff::ASTDiff Diff(SrcTree, DstTree, Options); Index: test/Tooling/clang-diff-topdown.cpp =================================================================== --- test/Tooling/clang-diff-topdown.cpp +++ test/Tooling/clang-diff-topdown.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -E %s > %t.src.cpp // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST -// RUN: clang-diff -dump-matches -stop-after=topdown %t.src.cpp %t.dst.cpp -- -std=c++11 | FileCheck %s +// RUN: clang-diff -dump-matches -stop-after-topdown %t.src.cpp %t.dst.cpp -- -std=c++11 | FileCheck %s // // Test the top-down matching of identical subtrees only. Index: lib/Tooling/ASTDiff/ASTDiff.cpp =================================================================== --- lib/Tooling/ASTDiff/ASTDiff.cpp +++ lib/Tooling/ASTDiff/ASTDiff.cpp @@ -16,14 +16,21 @@ #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Lex/Lexer.h" #include "llvm/ADT/PriorityQueue.h" +#include "llvm/Support/CommandLine.h" #include <limits> #include <memory> #include <unordered_set> using namespace llvm; using namespace clang; +extern cl::OptionCategory ClangDiffCategory; +static cl::opt<bool> StopAfterTopDown("stop-after-topdown", + cl::desc("Stops after top-down matching"), + cl::Optional, cl::init(false), + cl::cat(ClangDiffCategory)); + namespace clang { namespace diff { @@ -891,7 +898,7 @@ void ASTDiff::Impl::computeMapping() { TheMapping = matchTopDown(); - if (Options.StopAfterTopDown) + if (StopAfterTopDown) return; matchBottomUp(TheMapping); }
Index: tools/clang-diff/ClangDiff.cpp =================================================================== --- tools/clang-diff/ClangDiff.cpp +++ tools/clang-diff/ClangDiff.cpp @@ -21,7 +21,7 @@ using namespace clang; using namespace clang::tooling; -static cl::OptionCategory ClangDiffCategory("clang-diff options"); +cl::OptionCategory ClangDiffCategory("clang-diff options"); static cl::opt<bool> ASTDump("ast-dump", @@ -50,11 +50,6 @@ cl::Optional, cl::cat(ClangDiffCategory)); -static cl::opt<std::string> StopAfter("stop-after", - cl::desc("<topdown|bottomup>"), - cl::Optional, cl::init(""), - cl::cat(ClangDiffCategory)); - static cl::opt<int> MaxSize("s", cl::desc("<maxsize>"), cl::Optional, cl::init(-1), cl::cat(ClangDiffCategory)); @@ -442,14 +437,6 @@ diff::ComparisonOptions Options; if (MaxSize != -1) Options.MaxSize = MaxSize; - if (!StopAfter.empty()) { - if (StopAfter == "topdown") - Options.StopAfterTopDown = true; - else if (StopAfter != "bottomup") { - llvm::errs() << "Error: Invalid argument for -stop-after\n"; - return 1; - } - } diff::SyntaxTree SrcTree(Src->getASTContext()); diff::SyntaxTree DstTree(Dst->getASTContext()); diff::ASTDiff Diff(SrcTree, DstTree, Options); Index: test/Tooling/clang-diff-topdown.cpp =================================================================== --- test/Tooling/clang-diff-topdown.cpp +++ test/Tooling/clang-diff-topdown.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -E %s > %t.src.cpp // RUN: %clang_cc1 -E %s > %t.dst.cpp -DDEST -// RUN: clang-diff -dump-matches -stop-after=topdown %t.src.cpp %t.dst.cpp -- -std=c++11 | FileCheck %s +// RUN: clang-diff -dump-matches -stop-after-topdown %t.src.cpp %t.dst.cpp -- -std=c++11 | FileCheck %s // // Test the top-down matching of identical subtrees only. Index: lib/Tooling/ASTDiff/ASTDiff.cpp =================================================================== --- lib/Tooling/ASTDiff/ASTDiff.cpp +++ lib/Tooling/ASTDiff/ASTDiff.cpp @@ -16,14 +16,21 @@ #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Lex/Lexer.h" #include "llvm/ADT/PriorityQueue.h" +#include "llvm/Support/CommandLine.h" #include <limits> #include <memory> #include <unordered_set> using namespace llvm; using namespace clang; +extern cl::OptionCategory ClangDiffCategory; +static cl::opt<bool> StopAfterTopDown("stop-after-topdown", + cl::desc("Stops after top-down matching"), + cl::Optional, cl::init(false), + cl::cat(ClangDiffCategory)); + namespace clang { namespace diff { @@ -891,7 +898,7 @@ void ASTDiff::Impl::computeMapping() { TheMapping = matchTopDown(); - if (Options.StopAfterTopDown) + if (StopAfterTopDown) return; matchBottomUp(TheMapping); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits