/// CheckImplementationIvars - This routine checks if the instance variables
/// listed in the implelementation match those listed in the interface.
void CheckImplementationIvars(ObjcImplementationDecl *ImpDecl,
- ObjcIvarDecl **Fields, unsigned nIvars);
+ ObjcIvarDecl **Fields, unsigned nIvars,
+ SourceLocation Loc);
/// ImplMethodsVsClassMethods - This is main routine to warn if any method
/// remains unimplemented in the @implementation class.
if (!IDecl) {
// Legacy case of @implementation with no corresponding @interface.
// Build, chain & install the interface decl into the identifier.
- IDecl = new ObjcInterfaceDecl(SourceLocation(), 0, ClassName);
+ IDecl = new ObjcInterfaceDecl(AtClassImplLoc, 0, ClassName,
+ false, true);
IDecl->setNext(ClassName->getFETokenInfo<ScopedDecl>());
ClassName->setFETokenInfo(IDecl);
IDecl->setSuperClass(SDecl);
+ IDecl->setLocEnd(ClassLoc);
// Remember that this needs to be removed when the scope is popped.
TUScope->AddDecl(IDecl);
}
void Sema::CheckImplementationIvars(ObjcImplementationDecl *ImpDecl,
- ObjcIvarDecl **ivars, unsigned numIvars) {
+ ObjcIvarDecl **ivars, unsigned numIvars,
+ SourceLocation RBrace) {
assert(ImpDecl && "missing implementation decl");
ObjcInterfaceDecl* IDecl = getObjCInterfaceDecl(ImpDecl->getIdentifier());
if (!IDecl)
/// (legacy objective-c @implementation decl without an @interface decl).
/// Add implementations's ivar to the synthesize class's ivar list.
if (IDecl->ImplicitInterfaceDecl()) {
- IDecl->addInstanceVariablesToClass(ivars, numIvars, SourceLocation());
+ IDecl->addInstanceVariablesToClass(ivars, numIvars, RBrace);
return;
}
cast<ObjcImplementationDecl>(static_cast<Decl*>(RecDecl));
assert(IMPDecl && "ActOnFields - missing ObjcImplementationDecl");
IMPDecl->ObjcAddInstanceVariablesToClassImpl(ClsFields, RecFields.size());
- CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size());
+ CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
}
}
}
/// List of categories defined for this class.
ObjcCategoryDecl *CategoryList;
- bool ForwardDecl; // declared with @class.
+ bool ForwardDecl:1; // declared with @class.
+ bool InternalInterface:1; // true - no @interface for @implementation
SourceLocation EndLoc; // marks the '>', '}', or identifier.
SourceLocation AtEndLoc; // marks the end of the entire interface.
public:
ObjcInterfaceDecl(SourceLocation atLoc, unsigned numRefProtos,
- IdentifierInfo *Id, bool FD = false)
+ IdentifierInfo *Id, bool FD = false,
+ bool isInternal = false)
: TypeDecl(ObjcInterface, atLoc, Id, 0), SuperClass(0),
ReferencedProtocols(0), NumReferencedProtocols(-1), Ivars(0),
NumIvars(-1),
InstanceMethods(0), NumInstanceMethods(-1),
ClassMethods(0), NumClassMethods(-1),
- CategoryList(0), ForwardDecl(FD) {
+ CategoryList(0), ForwardDecl(FD), InternalInterface(isInternal) {
AllocIntfRefProtocols(numRefProtos);
}
/// ImplicitInterfaceDecl - check that this is an implicitely declared
/// ObjcInterfaceDecl node. This is for legacy objective-c @implementation
/// declaration without an @interface declaration.
- bool ImplicitInterfaceDecl() const { return getLocation().isInvalid(); }
+ bool ImplicitInterfaceDecl() const { return InternalInterface; }
static bool classof(const Decl *D) { return D->getKind() == ObjcInterface; }
static bool classof(const ObjcInterfaceDecl *D) { return true; }
--- /dev/null
+// RUN: clang -rewrite-test %s
+
+@implementation Intf
+{
+ id ivar;
+ id ivar1[12];
+
+ id **ivar3;
+
+ id (*ivar4) (id, id);
+}
+@end