Index: lib/Tooling/ASTDiff/ASTDiff.cpp =================================================================== --- lib/Tooling/ASTDiff/ASTDiff.cpp +++ lib/Tooling/ASTDiff/ASTDiff.cpp @@ -16,6 +16,7 @@ #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Lex/Lexer.h" #include "llvm/ADT/PriorityQueue.h" +#include "llvm/Support/CommandLine.h" #include #include @@ -24,6 +25,12 @@ using namespace llvm; using namespace clang; +extern cl::OptionCategory ClangDiffCategory; +static cl::opt 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: 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: 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 ASTDump("ast-dump", @@ -50,11 +50,6 @@ cl::Optional, cl::cat(ClangDiffCategory)); -static cl::opt StopAfter("stop-after", - cl::desc(""), - cl::Optional, cl::init(""), - cl::cat(ClangDiffCategory)); - static cl::opt MaxSize("s", cl::desc(""), 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);