Index: test/Tooling/clang-diff-args.test =================================================================== --- test/Tooling/clang-diff-args.test +++ test/Tooling/clang-diff-args.test @@ -6,3 +6,7 @@ RUN: clang-diff -ast-dump -extra-arg=-Da=X %t.cpp -- 2>&1 | FileCheck %s RUN: clang-diff -ast-dump -extra-arg-before=-Da=X %t.cpp -- 2>&1 | FileCheck %s RUN: clang-diff -ast-dump %t.cpp -- 2>&1 -Da=X | FileCheck %s + +NOMATCH-CHECK-NOT: {{.}} +RUN: clang-diff %S/clang-diff-ast.cpp %S/clang-diff-ast.cpp -- 2>&1 -std=c++11 \ +RUN: | FileCheck -check-prefix=NOMATCH-CHECK -allow-empty %s Index: test/Tooling/clang-diff-basic.cpp =================================================================== --- test/Tooling/clang-diff-basic.cpp +++ test/Tooling/clang-diff-basic.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 %T/src.cpp %T/dst.cpp -- | FileCheck %s +// RUN: clang-diff -dump-matches %T/src.cpp %T/dst.cpp -- | FileCheck %s #ifndef DEST namespace src { Index: tools/clang-diff/ClangDiff.cpp =================================================================== --- tools/clang-diff/ClangDiff.cpp +++ tools/clang-diff/ClangDiff.cpp @@ -33,6 +33,10 @@ cl::desc("Print the internal representation of the AST as JSON."), cl::init(false), cl::cat(ClangDiffCategory)); +static cl::opt + PrintMatches("dump-matches", cl::desc("Print the matched nodes."), + cl::init(false), cl::cat(ClangDiffCategory)); + static cl::opt SourcePath(cl::Positional, cl::desc(""), cl::Required, cl::cat(ClangDiffCategory)); @@ -267,7 +271,7 @@ for (diff::NodeId Dst : DstTree) { diff::NodeId Src = Diff.getMapped(DstTree, Dst); - if (Src.isValid()) { + if (PrintMatches && Src.isValid()) { llvm::outs() << "Match "; printNode(llvm::outs(), SrcTree, Src); llvm::outs() << " to ";