diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-03-23 23:24:18 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-03-23 23:24:18 +0000 |
| commit | aaf9743f5614285029cf004fd098ca32cc3ba2de (patch) | |
| tree | 0b0719571c41ee88052294badf388fd59e755b3f | |
| parent | e505a5abe9fc28a1bb50d900f23ef29766aaf38a (diff) | |
| download | bcm5719-llvm-aaf9743f5614285029cf004fd098ca32cc3ba2de.tar.gz bcm5719-llvm-aaf9743f5614285029cf004fd098ca32cc3ba2de.zip | |
[libclang] Make sure we don't crash when trying to index code that
managed to insert an @interface as top level decl contained by another
@interface.
A commit to also not allow this as valid code will be coming.
rdar://11105114.
llvm-svn: 153354
| -rw-r--r-- | clang/test/Index/index-decls.m | 8 | ||||
| -rw-r--r-- | clang/tools/libclang/IndexDecl.cpp | 8 | ||||
| -rw-r--r-- | clang/tools/libclang/IndexingContext.h | 3 |
3 files changed, 14 insertions, 5 deletions
diff --git a/clang/test/Index/index-decls.m b/clang/test/Index/index-decls.m index dc808ea5137..9e4e620497f 100644 --- a/clang/test/Index/index-decls.m +++ b/clang/test/Index/index-decls.m @@ -11,7 +11,13 @@ @synthesize prop = _prop; @end -// RUN: c-index-test -index-file %s | FileCheck %s +rdar://11015325 +@interface I1 +__attribute__((something)) @interface I2 @end +@end + +// RUN: c-index-test -index-file %s > %t +// RUN: FileCheck %s -input-file=%t // CHECK: [indexDeclaration]: kind: objc-class | name: I | {{.*}} | loc: 1:12 // CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 3:2 // CHECK: [indexDeclaration]: kind: objc-property | name: prop | {{.*}} | loc: 2:25 diff --git a/clang/tools/libclang/IndexDecl.cpp b/clang/tools/libclang/IndexDecl.cpp index 3f2c8b57101..c257c342aa7 100644 --- a/clang/tools/libclang/IndexDecl.cpp +++ b/clang/tools/libclang/IndexDecl.cpp @@ -328,7 +328,9 @@ void IndexingContext::indexDeclGroupRef(DeclGroupRef DG) { } void IndexingContext::indexTUDeclsInObjCContainer() { - for (unsigned i = 0, e = TUDeclsInObjCContainer.size(); i != e; ++i) - indexDeclGroupRef(TUDeclsInObjCContainer[i]); - TUDeclsInObjCContainer.clear(); + while (!TUDeclsInObjCContainer.empty()) { + DeclGroupRef DG = TUDeclsInObjCContainer.front(); + TUDeclsInObjCContainer.pop_front(); + indexDeclGroupRef(DG); + } } diff --git a/clang/tools/libclang/IndexingContext.h b/clang/tools/libclang/IndexingContext.h index d828b17ca5c..93d4718e27c 100644 --- a/clang/tools/libclang/IndexingContext.h +++ b/clang/tools/libclang/IndexingContext.h @@ -13,6 +13,7 @@ #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclGroup.h" #include "llvm/ADT/DenseSet.h" +#include <deque> namespace clang { class FileEntry; @@ -285,7 +286,7 @@ class IndexingContext { llvm::DenseSet<RefFileOccurence> RefFileOccurences; - SmallVector<DeclGroupRef, 8> TUDeclsInObjCContainer; + std::deque<DeclGroupRef> TUDeclsInObjCContainer; llvm::BumpPtrAllocator StrScratch; unsigned StrAdapterCount; |

