aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclObjC.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-04-02 20:10:03 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-04-02 20:10:03 +0000
commita06549226f45d5b72169a3d054415616dd1014a2 (patch)
treeb37f780c6eda613fa74815b11e9cca82cd037042 /lib/AST/DeclObjC.cpp
parent6aae87d3839fad00b46159b5b67ef1da5f6c19e9 (diff)
Sema/Obj-C: Narrow type of ObjCIvarDecl::Create, and check additional invariants on the provided DeclContext.
- Doug, please see the FIXME in DeclObjC.cpp -- I am not sure what the right fix is. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100213 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r--lib/AST/DeclObjC.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index ab6b9e1f45..63f3e04772 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -561,10 +561,26 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto,
// ObjCIvarDecl
//===----------------------------------------------------------------------===//
-ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, DeclContext *DC,
+ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, ObjCContainerDecl *DC,
SourceLocation L, IdentifierInfo *Id,
QualType T, TypeSourceInfo *TInfo,
AccessControl ac, Expr *BW) {
+ if (DC) {
+ // Ivar's can only appear in interfaces, implementations (via synthesized
+ // properties), and class extensions (via direct declaration, or synthesized
+ // properties).
+ //
+ // FIXME: This should really be asserting this:
+ // (isa<ObjCCategoryDecl>(DC) &&
+ // cast<ObjCCategoryDecl>(DC)->IsClassExtension()))
+ // but unfortunately we sometimes place ivars into non-class extension
+ // categories on error. This breaks an AST invariant, and should not be
+ // fixed.
+ assert((isa<ObjCInterfaceDecl>(DC) || isa<ObjCImplementationDecl>(DC) ||
+ isa<ObjCCategoryDecl>(DC)) &&
+ "Invalid ivar decl context!");
+ }
+
return new (C) ObjCIvarDecl(DC, L, Id, T, TInfo, ac, BW);
}