[cfe-commits] r42319 - in /cfe/trunk: Sema/SemaDecl.cpp include/clang/AST/Decl.h test/Sema/objc-legacy-implementation-1.m
Fariborz Jahanian
fjahanian at apple.com
Tue Sep 25 14:00:20 PDT 2007
Author: fjahanian
Date: Tue Sep 25 16:00:20 2007
New Revision: 42319
URL: http://llvm.org/viewvc/llvm-project?rev=42319&view=rev
Log:
Patch to make ObjcImplementationDecl derived from TypeDecl and supprt legacy
objective-c code with no @interface declaration.
Added:
cfe/trunk/test/Sema/objc-legacy-implementation-1.m
Modified:
cfe/trunk/Sema/SemaDecl.cpp
cfe/trunk/include/clang/AST/Decl.h
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=42319&r1=42318&r2=42319&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Tue Sep 25 16:00:20 2007
@@ -1105,6 +1105,14 @@
ObjcImplementationDecl* IMPDecl =
new ObjcImplementationDecl(AtClassImplLoc, ClassName, SDecl);
+ if (!IDecl) {
+ // Legacy case of @implementation with no corresponding @interface.
+ // Build, chain & install the interface decl into the identifier.
+ IDecl = new ObjcInterfaceDecl(AtClassImplLoc, 0, ClassName);
+ IDecl->setNext(ClassName->getFETokenInfo<ScopedDecl>());
+ ClassName->setFETokenInfo(IDecl);
+
+ }
// Check that there is no duplicate implementation of this class.
bool err = false;
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=42319&r1=42318&r2=42319&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Sep 25 16:00:20 2007
@@ -858,7 +858,7 @@
static bool classof(const ObjcCategoryDecl *D) { return true; }
};
-class ObjcImplementationDecl : public ScopedDecl {
+class ObjcImplementationDecl : public TypeDecl {
/// Implementation Class's super class.
ObjcInterfaceDecl *SuperClass;
@@ -878,7 +878,7 @@
public:
ObjcImplementationDecl(SourceLocation L, IdentifierInfo *Id,
ObjcInterfaceDecl* superDecl)
- : ScopedDecl(ObjcImplementation, L, Id, 0),
+ : TypeDecl(ObjcImplementation, L, Id, 0),
SuperClass(superDecl),
Ivars(0), NumIvars(-1),
InsMethods(0), NumInsMethods(-1), ClsMethods(0), NumClsMethods(-1) {}
Added: cfe/trunk/test/Sema/objc-legacy-implementation-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-legacy-implementation-1.m?rev=42319&view=auto
==============================================================================
--- cfe/trunk/test/Sema/objc-legacy-implementation-1.m (added)
+++ cfe/trunk/test/Sema/objc-legacy-implementation-1.m Tue Sep 25 16:00:20 2007
@@ -0,0 +1,9 @@
+ at implementation INTF // expected-warning {{cannot find interface declaration for 'INTF'}}
+ at end
+
+INTF* pi;
+
+INTF* FUNC()
+{
+ return pi;
+}
More information about the cfe-commits
mailing list