forked from OSchip/llvm-project
[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
This commit is contained in:
parent
e505a5abe9
commit
aaf9743f56
|
@ -11,7 +11,13 @@
|
||||||
@synthesize prop = _prop;
|
@synthesize prop = _prop;
|
||||||
@end
|
@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-class | name: I | {{.*}} | loc: 1:12
|
||||||
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 3:2
|
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 3:2
|
||||||
// CHECK: [indexDeclaration]: kind: objc-property | name: prop | {{.*}} | loc: 2:25
|
// CHECK: [indexDeclaration]: kind: objc-property | name: prop | {{.*}} | loc: 2:25
|
||||||
|
|
|
@ -328,7 +328,9 @@ void IndexingContext::indexDeclGroupRef(DeclGroupRef DG) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IndexingContext::indexTUDeclsInObjCContainer() {
|
void IndexingContext::indexTUDeclsInObjCContainer() {
|
||||||
for (unsigned i = 0, e = TUDeclsInObjCContainer.size(); i != e; ++i)
|
while (!TUDeclsInObjCContainer.empty()) {
|
||||||
indexDeclGroupRef(TUDeclsInObjCContainer[i]);
|
DeclGroupRef DG = TUDeclsInObjCContainer.front();
|
||||||
TUDeclsInObjCContainer.clear();
|
TUDeclsInObjCContainer.pop_front();
|
||||||
|
indexDeclGroupRef(DG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "clang/AST/DeclObjC.h"
|
#include "clang/AST/DeclObjC.h"
|
||||||
#include "clang/AST/DeclGroup.h"
|
#include "clang/AST/DeclGroup.h"
|
||||||
#include "llvm/ADT/DenseSet.h"
|
#include "llvm/ADT/DenseSet.h"
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
class FileEntry;
|
class FileEntry;
|
||||||
|
@ -285,7 +286,7 @@ class IndexingContext {
|
||||||
|
|
||||||
llvm::DenseSet<RefFileOccurence> RefFileOccurences;
|
llvm::DenseSet<RefFileOccurence> RefFileOccurences;
|
||||||
|
|
||||||
SmallVector<DeclGroupRef, 8> TUDeclsInObjCContainer;
|
std::deque<DeclGroupRef> TUDeclsInObjCContainer;
|
||||||
|
|
||||||
llvm::BumpPtrAllocator StrScratch;
|
llvm::BumpPtrAllocator StrScratch;
|
||||||
unsigned StrAdapterCount;
|
unsigned StrAdapterCount;
|
||||||
|
|
Loading…
Reference in New Issue