summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclObjC.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2015-07-07 06:20:12 +0000
committerDouglas Gregor <dgregor@apple.com>2015-07-07 06:20:12 +0000
commitab7f0b342f2f5dd85c6ede23bc843c5128f6ed10 (patch)
treed8f0a47688af0f31df19d658c0eb2306edb5eac3 /clang/lib/AST/DeclObjC.cpp
parentbc4c89a9775f01531350c057f527fcc707c84184 (diff)
downloadbcm5719-llvm-ab7f0b342f2f5dd85c6ede23bc843c5128f6ed10.tar.gz
bcm5719-llvm-ab7f0b342f2f5dd85c6ede23bc843c5128f6ed10.zip
The AST importer had a bug where it would enter into an infinite recursion
when importing type parameter lists. The reason is that type parameters have their DeclContexts set to the interface that is parameterized with those types, and the importer would follow that loop and blow the stack out. I've changed the way this works so that the type parameters are only imported after the interface that contains them has been registered via the Imported() function. This is tested by LLDB. <rdar://problem/20315663> llvm-svn: 241556
Diffstat (limited to 'clang/lib/AST/DeclObjC.cpp')
-rw-r--r--clang/lib/AST/DeclObjC.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index da4bc549cf4..b540e37cd07 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -259,6 +259,15 @@ ObjCTypeParamList *ObjCInterfaceDecl::getTypeParamList() const {
return nullptr;
}
+void ObjCInterfaceDecl::setTypeParamList(ObjCTypeParamList *TPL) {
+ TypeParamList = TPL;
+ if (!TPL)
+ return;
+ // Set the declaration context of each of the type parameters.
+ for (auto typeParam : *TypeParamList)
+ typeParam->setDeclContext(this);
+}
+
ObjCInterfaceDecl *ObjCInterfaceDecl::getSuperClass() const {
// FIXME: Should make sure no callers ever do this.
if (!hasDefinition())
@@ -1302,7 +1311,7 @@ ObjCInterfaceDecl::ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC,
ObjCInterfaceDecl *PrevDecl,
bool IsInternal)
: ObjCContainerDecl(ObjCInterface, DC, Id, CLoc, AtLoc),
- redeclarable_base(C), TypeForDecl(nullptr), TypeParamList(typeParamList),
+ redeclarable_base(C), TypeForDecl(nullptr), TypeParamList(nullptr),
Data() {
setPreviousDecl(PrevDecl);
@@ -1312,11 +1321,7 @@ ObjCInterfaceDecl::ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC,
setImplicit(IsInternal);
- // Update the declaration context of the type parameters.
- if (typeParamList) {
- for (auto typeParam : *typeParamList)
- typeParam->setDeclContext(this);
- }
+ setTypeParamList(typeParamList);
}
void ObjCInterfaceDecl::LoadExternalDefinition() const {
@@ -1799,16 +1804,11 @@ ObjCCategoryDecl::ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc,
SourceLocation IvarLBraceLoc,
SourceLocation IvarRBraceLoc)
: ObjCContainerDecl(ObjCCategory, DC, Id, ClassNameLoc, AtLoc),
- ClassInterface(IDecl), TypeParamList(typeParamList),
+ ClassInterface(IDecl), TypeParamList(nullptr),
NextClassCategory(nullptr), CategoryNameLoc(CategoryNameLoc),
IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc)
{
- // Set the declaration context of each of the type parameters.
- if (typeParamList) {
- for (auto typeParam : *typeParamList) {
- typeParam->setDeclContext(this);
- }
- }
+ setTypeParamList(typeParamList);
}
ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC,
@@ -1853,6 +1853,15 @@ void ObjCCategoryDecl::setImplementation(ObjCCategoryImplDecl *ImplD) {
getASTContext().setObjCImplementation(this, ImplD);
}
+void ObjCCategoryDecl::setTypeParamList(ObjCTypeParamList *TPL) {
+ TypeParamList = TPL;
+ if (!TPL)
+ return;
+ // Set the declaration context of each of the type parameters.
+ for (auto typeParam : *TypeParamList)
+ typeParam->setDeclContext(this);
+}
+
//===----------------------------------------------------------------------===//
// ObjCCategoryImplDecl
OpenPOWER on IntegriCloud