зеркало из https://github.com/microsoft/clang-1.git
Fixed problem with rewriting stand-alone @implementation (with no matching @interface).
A new test case added. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43568 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
8ee529b567
Коммит
3a3ca1b35a
|
@ -259,7 +259,8 @@ private:
|
|||
/// 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.
|
||||
|
|
|
@ -1253,10 +1253,12 @@ Sema::DeclTy *Sema::ActOnStartClassImplementation(
|
|||
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);
|
||||
|
@ -1273,7 +1275,8 @@ Sema::DeclTy *Sema::ActOnStartClassImplementation(
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -1282,7 +1285,7 @@ void Sema::CheckImplementationIvars(ObjcImplementationDecl *ImpDecl,
|
|||
/// (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;
|
||||
}
|
||||
|
||||
|
@ -1795,7 +1798,7 @@ void Sema::ActOnFields(Scope* S,
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,19 +72,21 @@ class ObjcInterfaceDecl : public TypeDecl {
|
|||
/// 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);
|
||||
}
|
||||
|
||||
|
@ -148,7 +150,7 @@ public:
|
|||
/// 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; }
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// RUN: clang -rewrite-test %s
|
||||
|
||||
@implementation Intf
|
||||
{
|
||||
id ivar;
|
||||
id ivar1[12];
|
||||
|
||||
id **ivar3;
|
||||
|
||||
id (*ivar4) (id, id);
|
||||
}
|
||||
@end
|
Загрузка…
Ссылка в новой задаче