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. llvm-svn: 100213
This commit is contained in:
parent
a9f8675e02
commit
fe3ead7c48
|
@ -624,14 +624,14 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
ObjCIvarDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
|
||||
ObjCIvarDecl(ObjCContainerDecl *DC, SourceLocation L, IdentifierInfo *Id,
|
||||
QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW)
|
||||
: FieldDecl(ObjCIvar, DC, L, Id, T, TInfo, BW, /*Mutable=*/false),
|
||||
DeclAccess(ac) {}
|
||||
|
||||
public:
|
||||
static ObjCIvarDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T,
|
||||
static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC,
|
||||
SourceLocation L, IdentifierInfo *Id, QualType T,
|
||||
TypeSourceInfo *TInfo,
|
||||
AccessControl ac, Expr *BW = NULL);
|
||||
|
||||
|
|
|
@ -2013,7 +2013,8 @@ Decl *ASTNodeImporter::VisitObjCIvarDecl(ObjCIvarDecl *D) {
|
|||
if (!BitWidth && D->getBitWidth())
|
||||
return 0;
|
||||
|
||||
ObjCIvarDecl *ToIvar = ObjCIvarDecl::Create(Importer.getToContext(), DC,
|
||||
ObjCIvarDecl *ToIvar = ObjCIvarDecl::Create(Importer.getToContext(),
|
||||
cast<ObjCContainerDecl>(DC),
|
||||
Loc, Name.getAsIdentifierInfo(),
|
||||
T, TInfo, D->getAccessControl(),
|
||||
BitWidth);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue