Skip to content

Commit

Permalink
[clang-diff] Make printing of matches optional
Browse files Browse the repository at this point in the history
Reviewers: arphaman

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D36181

llvm-svn: 311237
  • Loading branch information
krobelus committed Aug 19, 2017
1 parent ba0954c commit 683876c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions clang/test/Tooling/clang-diff-args.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ check adding compiler cflags
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
2 changes: 1 addition & 1 deletion clang/test/Tooling/clang-diff-basic.cpp
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion clang/tools/clang-diff/ClangDiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ static cl::opt<bool> ASTDumpJson(
cl::desc("Print the internal representation of the AST as JSON."),
cl::init(false), cl::cat(ClangDiffCategory));

static cl::opt<bool>
PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
cl::init(false), cl::cat(ClangDiffCategory));

static cl::opt<std::string> SourcePath(cl::Positional, cl::desc("<source>"),
cl::Required,
cl::cat(ClangDiffCategory));
Expand Down Expand Up @@ -267,7 +271,7 @@ int main(int argc, const char **argv) {

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 ";
Expand Down

0 comments on commit 683876c

Please sign in to comment.