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 | 30a2805c2c85e6abfe3149293f83f60da018b2df (patch) | |
tree | 5ec91f7955e6dc8c1240a7d3bef67af92dfda822 /tools/libclang | |
parent | ec5a306dd4e8911f22997d84ce029affbb582132 (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153354 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang')
-rw-r--r-- | tools/libclang/IndexDecl.cpp | 8 | ||||
-rw-r--r-- | tools/libclang/IndexingContext.h | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/tools/libclang/IndexDecl.cpp b/tools/libclang/IndexDecl.cpp index 3f2c8b5710..c257c342aa 100644 --- a/tools/libclang/IndexDecl.cpp +++ b/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/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h index d828b17ca5..93d4718e27 100644 --- a/tools/libclang/IndexingContext.h +++ b/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; |