aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-07-30 00:47:46 +0000
committerTed Kremenek <kremenek@apple.com>2010-07-30 00:47:46 +0000
commit2d6c906585c292c9de78eff3b42af06332857252 (patch)
treef8a4b84ff1190c95fb35a9e35b81a5ba0b860619
parentffaab3e2bb13991bb3357e80f14bcae3745b2347 (diff)
Don't print out ivars twice in Decl::print(). Fixes <rdar://problem/8253668>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109833 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/DeclPrinter.cpp6
-rw-r--r--test/SemaObjC/static-ivar-ref-1.m18
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp
index 765772dd13..fae1e724a1 100644
--- a/lib/AST/DeclPrinter.cpp
+++ b/lib/AST/DeclPrinter.cpp
@@ -198,6 +198,12 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) {
llvm::SmallVector<Decl*, 2> Decls;
for (DeclContext::decl_iterator D = DC->decls_begin(), DEnd = DC->decls_end();
D != DEnd; ++D) {
+
+ // Don't print ObjCIvarDecls, as they are printed when visiting the
+ // containing ObjCInterfaceDecl.
+ if (isa<ObjCIvarDecl>(*D))
+ continue;
+
if (!Policy.Dump) {
// Skip over implicit declarations in pretty-printing mode.
if (D->isImplicit()) continue;
diff --git a/test/SemaObjC/static-ivar-ref-1.m b/test/SemaObjC/static-ivar-ref-1.m
index cd5e05558c..d9f99f513d 100644
--- a/test/SemaObjC/static-ivar-ref-1.m
+++ b/test/SemaObjC/static-ivar-ref-1.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -ast-print %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ast-print %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -ast-print %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ast-print %s 2>&1 | FileCheck %s
@interface current
{
@@ -14,5 +14,17 @@ current *pc;
int foo()
{
- return pc->ivar2 + (*pc).ivar + pc->ivar1;
+ return pc->ivar2 + (*pc).ivar + pc->ivar1;
}
+
+// CHECK: @interface current{
+// CHECK: int ivar;
+// CHECK: int ivar1;
+// CHECK: int ivar2;
+// CHECK: }
+// CHECK: @end
+// CHECK: current *pc;
+// CHECK: int foo() {
+// CHECK: return pc->ivar2 + (*pc).ivar + pc->ivar1;
+// CHECK: }
+