[cfe-commits] [PATCH] Fix for -ast-dump-filter
Alexander Kornienko
alexfh at google.com
Wed Oct 31 10:04:06 PDT 2012
Hi djasper, klimek, rsmith,
-ast-dump-filter implementation used to stop AST traversal after traversing a NULL Decl node.
Added test and fixed.
http://llvm-reviews.chandlerc.com/D93
Files:
tools/clang/test/Tooling/clang-check-ast-dump.cpp
tools/clang/lib/Frontend/ASTConsumers.cpp
Index: tools/clang/test/Tooling/clang-check-ast-dump.cpp
===================================================================
--- tools/clang/test/Tooling/clang-check-ast-dump.cpp
+++ tools/clang/test/Tooling/clang-check-ast-dump.cpp
@@ -26,6 +26,9 @@
// RUN: clang-check -ast-dump -ast-dump-filter test_namespace::TheClass::n "%s" -- 2>&1 | FileCheck -check-prefix CHECK-ATTR %s
// CHECK-ATTR: test_namespace
// CHECK-ATTR-NEXT: int n __attribute__((aligned((BinaryOperator
+//
+// RUN: clang-check -ast-dump -ast-dump-filter test_namespace::AfterNullNode "%s" -- 2>&1 | FileCheck -check-prefix CHECK-AFTER-NULL %s
+// CHECK-AFTER-NULL: class AfterNullNode
namespace test_namespace {
@@ -40,4 +43,7 @@
// Used to fail with -ast-dump-filter X
template<template<typename T> class C> class Z {};
+// Check that traversal continues after the previous construct.
+class AfterNullNode {};
+
}
Index: tools/clang/lib/Frontend/ASTConsumers.cpp
===================================================================
--- tools/clang/lib/Frontend/ASTConsumers.cpp
+++ tools/clang/lib/Frontend/ASTConsumers.cpp
@@ -58,9 +58,7 @@
bool shouldWalkTypesOfTypeLocs() const { return false; }
bool TraverseDecl(Decl *D) {
- if (D == NULL)
- return false;
- if (filterMatches(D)) {
+ if (D != NULL && filterMatches(D)) {
Out.changeColor(llvm::raw_ostream::BLUE) <<
(Dump ? "Dumping " : "Printing ") << getName(D) << ":\n";
Out.resetColor();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93.1.patch
Type: text/x-patch
Size: 1496 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121031/b70f41a4/attachment.bin>
More information about the cfe-commits
mailing list