[cfe-commits] r153354 - in /cfe/trunk: test/Index/index-decls.m tools/libclang/IndexDecl.cpp tools/libclang/IndexingContext.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Mar 23 16:24:18 PDT 2012
Author: akirtzidis
Date: Fri Mar 23 18:24:18 2012
New Revision: 153354
URL: http://llvm.org/viewvc/llvm-project?rev=153354&view=rev
Log:
[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.
Modified:
cfe/trunk/test/Index/index-decls.m
cfe/trunk/tools/libclang/IndexDecl.cpp
cfe/trunk/tools/libclang/IndexingContext.h
Modified: cfe/trunk/test/Index/index-decls.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-decls.m?rev=153354&r1=153353&r2=153354&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-decls.m (original)
+++ cfe/trunk/test/Index/index-decls.m Fri Mar 23 18:24:18 2012
@@ -11,7 +11,13 @@
@synthesize prop = _prop;
@end
-// RUN: c-index-test -index-file %s | FileCheck %s
+rdar://11015325
+ at interface I1
+__attribute__((something)) @interface I2 @end
+ at 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
Modified: cfe/trunk/tools/libclang/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexDecl.cpp?rev=153354&r1=153353&r2=153354&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexDecl.cpp (original)
+++ cfe/trunk/tools/libclang/IndexDecl.cpp Fri Mar 23 18:24:18 2012
@@ -328,7 +328,9 @@
}
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);
+ }
}
Modified: cfe/trunk/tools/libclang/IndexingContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.h?rev=153354&r1=153353&r2=153354&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.h (original)
+++ cfe/trunk/tools/libclang/IndexingContext.h Fri Mar 23 18:24:18 2012
@@ -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 @@
llvm::DenseSet<RefFileOccurence> RefFileOccurences;
- SmallVector<DeclGroupRef, 8> TUDeclsInObjCContainer;
+ std::deque<DeclGroupRef> TUDeclsInObjCContainer;
llvm::BumpPtrAllocator StrScratch;
unsigned StrAdapterCount;
More information about the cfe-commits
mailing list