diff options
| author | Ted Kremenek <kremenek@apple.com> | 2010-07-30 00:47:46 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2010-07-30 00:47:46 +0000 |
| commit | 28e1c9155e0e42eb5cd3e6ef71c519284fdc8777 (patch) | |
| tree | 175a2943495946161cf140a65c9d4f87609fbc22 | |
| parent | 07a89a83d4db0b3f241c70d5bbb518631ff90cfd (diff) | |
| download | bcm5719-llvm-28e1c9155e0e42eb5cd3e6ef71c519284fdc8777.tar.gz bcm5719-llvm-28e1c9155e0e42eb5cd3e6ef71c519284fdc8777.zip | |
Don't print out ivars twice in Decl::print(). Fixes <rdar://problem/8253668>.
llvm-svn: 109833
| -rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 6 | ||||
| -rw-r--r-- | clang/test/SemaObjC/static-ivar-ref-1.m | 18 |
2 files changed, 21 insertions, 3 deletions
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 765772dd13f..fae1e724a17 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/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/clang/test/SemaObjC/static-ivar-ref-1.m b/clang/test/SemaObjC/static-ivar-ref-1.m index cd5e05558c3..d9f99f513da 100644 --- a/clang/test/SemaObjC/static-ivar-ref-1.m +++ b/clang/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: } + |

