[cfe-commits] r130019 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/DiagnosticSemaKinds.td lib/CodeGen/CGObjCMac.cpp lib/Parse/ParseObjc.cpp lib/Sema/SemaDeclObjC.cpp test/CodeGenObjC/instance-method-metadata.m test/CodeGenObjC/missing-atend-metadata.m test/Index/rdar-8288645-invalid-code.mm test/Parser/objc-missing-impl.m test/SemaObjC/missing-atend-metadata.m
Fariborz Jahanian
fjahanian at apple.com
Fri Apr 22 15:02:28 PDT 2011
Author: fjahanian
Date: Fri Apr 22 17:02:28 2011
New Revision: 130019
URL: http://llvm.org/viewvc/llvm-project?rev=130019&view=rev
Log:
Fixes an instance method meta-data generation bug in
ObjC NeXt runtime where method pointer registered in
metadata belongs to an unrelated method. Ast part of this fix,
I turned at @end missing warning (for class
implementations) into an error as we can never
be sure that meta-data being generated is correct.
// rdar://9072317
Added:
cfe/trunk/test/CodeGenObjC/instance-method-metadata.m
cfe/trunk/test/SemaObjC/missing-atend-metadata.m
- copied, changed from r129989, cfe/trunk/test/CodeGenObjC/missing-atend-metadata.m
Removed:
cfe/trunk/test/CodeGenObjC/missing-atend-metadata.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/Index/rdar-8288645-invalid-code.mm
cfe/trunk/test/Parser/objc-missing-impl.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=130019&r1=130018&r2=130019&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Apr 22 17:02:28 2011
@@ -286,7 +286,7 @@
def err_missing_proto_definition : Error<
"cannot find definition of 'Protocol'">;
def err_missing_class_definition : Error<"cannot find definition of 'Class'">;
-def warn_expected_implementation : Warning<
+def err_expected_implementation : Error<
"@end must appear in an @implementation context">;
def error_property_ivar_decl : Error<
"property synthesize requires specification of an ivar">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=130019&r1=130018&r2=130019&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr 22 17:02:28 2011
@@ -393,7 +393,7 @@
def note_method_declared_at : Note<"method declared here">;
def err_setter_type_void : Error<"type of setter must be void">;
def err_duplicate_method_decl : Error<"duplicate declaration of method %0">;
-def warn_missing_atend : Warning<"'@end' is missing in implementation context">;
+def err_missing_atend : Error<"'@end' is missing in implementation context">;
def err_objc_var_decl_inclass :
Error<"cannot declare variable inside @interface or @protocol">;
def error_missing_method_context : Error<
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=130019&r1=130018&r2=130019&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Apr 22 17:02:28 2011
@@ -2069,6 +2069,8 @@
4, true);
DefinedCategories.push_back(GV);
DefinedCategoryNames.insert(ExtName.str());
+ // method definition entries must be clear for next implementation.
+ MethodDefinitions.clear();
}
// FIXME: Get from somewhere?
@@ -2196,6 +2198,8 @@
else
GV = CreateMetadataVar(Name, Init, Section, 4, true);
DefinedClasses.push_back(GV);
+ // method definition entries must be clear for next implementation.
+ MethodDefinitions.clear();
}
llvm::Constant *CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID,
@@ -4978,6 +4982,8 @@
// Force the definition of the EHType if necessary.
if (flags & CLS_EXCEPTION)
GetInterfaceEHType(ID->getClassInterface(), true);
+ // Make sure method definition entries are all clear for next implementation.
+ MethodDefinitions.clear();
}
/// GenerateProtocolRef - This routine is called to generate code for
@@ -5106,6 +5112,8 @@
// Determine if this category is also "non-lazy".
if (ImplementationIsNonLazy(OCD))
DefinedNonLazyCategories.push_back(GCATV);
+ // method definition entries must be clear for next implementation.
+ MethodDefinitions.clear();
}
/// GetMethodConstant - Return a struct objc_method constant for the
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=130019&r1=130018&r2=130019&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Fri Apr 22 17:02:28 2011
@@ -1387,7 +1387,7 @@
}
else {
// missing @implementation
- Diag(atEnd.getBegin(), diag::warn_expected_implementation);
+ Diag(atEnd.getBegin(), diag::err_expected_implementation);
}
return Result;
}
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=130019&r1=130018&r2=130019&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Apr 22 17:02:28 2011
@@ -1536,7 +1536,7 @@
SourceLocation L = ClassDecl->getLocation();
AtEnd.setBegin(L);
AtEnd.setEnd(L);
- Diag(L, diag::warn_missing_atend);
+ Diag(L, diag::err_missing_atend);
}
// FIXME: Remove these and use the ObjCContainerDecl/DeclContext.
Added: cfe/trunk/test/CodeGenObjC/instance-method-metadata.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/instance-method-metadata.m?rev=130019&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/instance-method-metadata.m (added)
+++ cfe/trunk/test/CodeGenObjC/instance-method-metadata.m Fri Apr 22 17:02:28 2011
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -S -o %t %s
+// RUN: FileCheck < %t %s
+
+// rdar://9072317
+
+/** The problem looks like clang getting confused when a single translation unit
+ contains a protocol with a property and two classes that implement that protocol
+ and synthesize the property.
+*/
+
+ at protocol Proto
+ at property (assign) id prop;
+ at end
+
+ at interface NSObject @end
+
+ at interface Foo : NSObject <Proto> { int x; } @end
+
+ at interface Bar : NSObject <Proto> @end
+
+ at implementation Foo
+ at synthesize prop;
+ at end
+
+ at implementation Bar
+ at synthesize prop;
+ at end
+
+// CHECK: l_OBJC_$_INSTANCE_METHODS_Bar:
+// CHECK-NEXT .long 24
+// CHECK-NEXT .long 2
+// CHECK-NEXT .quad L_OBJC_METH_VAR_NAME_
+// CHECK-NEXT .quad L_OBJC_METH_VAR_TYPE_
+// CHECK-NEXT .quad "-[Bar prop]"
Removed: cfe/trunk/test/CodeGenObjC/missing-atend-metadata.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/missing-atend-metadata.m?rev=130018&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/missing-atend-metadata.m (original)
+++ cfe/trunk/test/CodeGenObjC/missing-atend-metadata.m (removed)
@@ -1,24 +0,0 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck %s
-
- at interface I0
- at end
-
- at implementation I0 // expected-warning {{'@end' is missing in implementation context}}
-- meth { return 0; }
-
- at interface I1 : I0
- at end
-
- at implementation I1 // expected-warning {{'@end' is missing in implementation context}}
--(void) im0 { self = [super init]; }
-
- at interface I2 : I0
-- I2meth;
- at end
-
- at implementation I2 // expected-warning {{'@end' is missing in implementation context}}
-- I2meth { return 0; }
-
- at implementation I2(CAT) // expected-warning {{'@end' is missing in implementation context}}
-
-// CHECK: @"\01L_OBJC_CLASS_I1" = internal global
Modified: cfe/trunk/test/Index/rdar-8288645-invalid-code.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/rdar-8288645-invalid-code.mm?rev=130019&r1=130018&r2=130019&view=diff
==============================================================================
--- cfe/trunk/test/Index/rdar-8288645-invalid-code.mm (original)
+++ cfe/trunk/test/Index/rdar-8288645-invalid-code.mm Fri Apr 22 17:02:28 2011
@@ -5,4 +5,4 @@
extern "C" { @implementation Foo - (id)initWithBar:(Baz<WozBar>)pepper {
// CHECK: warning: cannot find interface declaration for 'Foo'
-// CHECK: warning: '@end' is missing in implementation context
+// CHECK: error: '@end' is missing in implementation context
Modified: cfe/trunk/test/Parser/objc-missing-impl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-missing-impl.m?rev=130019&r1=130018&r2=130019&view=diff
==============================================================================
--- cfe/trunk/test/Parser/objc-missing-impl.m (original)
+++ cfe/trunk/test/Parser/objc-missing-impl.m Fri Apr 22 17:02:28 2011
@@ -1,2 +1,2 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
- at end // expected-warning {{@end must appear in an @implementation context}}
+ at end // expected-error {{@end must appear in an @implementation context}}
Copied: cfe/trunk/test/SemaObjC/missing-atend-metadata.m (from r129989, cfe/trunk/test/CodeGenObjC/missing-atend-metadata.m)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/missing-atend-metadata.m?p2=cfe/trunk/test/SemaObjC/missing-atend-metadata.m&p1=cfe/trunk/test/CodeGenObjC/missing-atend-metadata.m&r1=129989&r2=130019&rev=130019&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/missing-atend-metadata.m (original)
+++ cfe/trunk/test/SemaObjC/missing-atend-metadata.m Fri Apr 22 17:02:28 2011
@@ -1,24 +1,22 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
@interface I0
@end
- at implementation I0 // expected-warning {{'@end' is missing in implementation context}}
+ at implementation I0 // expected-error {{'@end' is missing in implementation context}}
- meth { return 0; }
@interface I1 : I0
@end
- at implementation I1 // expected-warning {{'@end' is missing in implementation context}}
--(void) im0 { self = [super init]; }
+ at implementation I1 // expected-error {{'@end' is missing in implementation context}}
+-(void) im0 { self = [super init]; } // expected-warning {{nstance method '-init' not found }}
@interface I2 : I0
- I2meth;
@end
- at implementation I2 // expected-warning {{'@end' is missing in implementation context}}
+ at implementation I2 // expected-error {{'@end' is missing in implementation context}}
- I2meth { return 0; }
- at implementation I2(CAT) // expected-warning {{'@end' is missing in implementation context}}
-
-// CHECK: @"\01L_OBJC_CLASS_I1" = internal global
+ at implementation I2(CAT) // expected-error {{'@end' is missing in implementation context}}
More information about the cfe-commits
mailing list