[cfe-commits] r133747 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/CodeGen/CGException.cpp lib/CodeGen/CGObjCGNU.cpp lib/CodeGen/CGObjCMac.cpp lib/CodeGen/CGObjCRuntime.h lib/Sema/SemaDeclCXX.cpp test/CodeGenObjCXX/catch-id-type.mm test/SemaObjCXX/exceptions-fragile.mm
Fariborz Jahanian
fjahanian at apple.com
Thu Jun 23 12:00:08 PDT 2011
Author: fjahanian
Date: Thu Jun 23 14:00:08 2011
New Revision: 133747
URL: http://llvm.org/viewvc/llvm-project?rev=133747&view=rev
Log:
Support for catching objc pointer objects in c++ catch-statement
in fragile abi mode and some other cleanups. // rdar://8940528
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenObjCXX/catch-id-type.mm
cfe/trunk/test/SemaObjCXX/exceptions-fragile.mm
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=133747&r1=133746&r2=133747&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jun 23 14:00:08 2011
@@ -296,3 +296,6 @@
// A warning group for warnings about Microsoft extensions.
def Microsoft : DiagGroup<"microsoft">;
+
+def ObjCNonUnifiedException : DiagGroup<"objc-nonunified-exceptions">;
+
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=133747&r1=133746&r2=133747&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun 23 14:00:08 2011
@@ -3154,11 +3154,8 @@
def err_objc_pointer_cxx_catch_gnu : Error<
"can't catch Objective C exceptions in C++ in the GNU runtime">;
def warn_objc_pointer_cxx_catch_fragile : Warning<
- "catching Objective C id's exceptions in C++ in the non-unified "
- "exception model">;
-def err_objc_pointer_cxx_catch_fragile : Error<
-"can't catch Objective C exceptions in C++ in the non-unified "
-"exception model">;
+ "catching Objective C exceptions in C++ in the non-unified "
+ "exception model">, InGroup<ObjCNonUnifiedException>;
def err_objc_object_catch : Error<
"can't catch an Objective C object by value">;
def err_incomplete_type_objc_at_encode : Error<
Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=133747&r1=133746&r2=133747&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Jun 23 14:00:08 2011
@@ -521,7 +521,7 @@
llvm::Value *TypeInfo = 0;
if (CaughtType->isObjCObjectPointerType())
- TypeInfo = CGM.getObjCRuntime().GetEHType(CaughtType, this);
+ TypeInfo = CGM.getObjCRuntime().GetEHType(CaughtType);
else
TypeInfo = CGM.GetAddrOfRTTIDescriptor(CaughtType, /*ForEH=*/true);
CatchScope->setHandler(I, TypeInfo, Handler);
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=133747&r1=133746&r2=133747&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Thu Jun 23 14:00:08 2011
@@ -438,7 +438,7 @@
bool lval = false);
virtual llvm::Value *GetSelector(CGBuilderTy &Builder, const ObjCMethodDecl
*Method);
- virtual llvm::Constant *GetEHType(QualType T, const CodeGenFunction *CGF=0);
+ virtual llvm::Constant *GetEHType(QualType T);
virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD,
const ObjCContainerDecl *CD);
@@ -832,7 +832,7 @@
return GetSelector(Builder, Method->getSelector(), SelTypes, false);
}
-llvm::Constant *CGObjCGNU::GetEHType(QualType T, const CodeGenFunction *CGF) {
+llvm::Constant *CGObjCGNU::GetEHType(QualType T) {
if (!CGM.getLangOptions().CPlusPlus) {
if (T->isObjCIdType()
|| T->isObjCQualifiedIdType()) {
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=133747&r1=133746&r2=133747&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Jun 23 14:00:08 2011
@@ -1010,7 +1010,7 @@
virtual llvm::Value *GetSelector(CGBuilderTy &Builder,
const ObjCMethodDecl *Method);
- virtual llvm::Constant *GetEHType(QualType T, const CodeGenFunction *CGF=0);
+ virtual llvm::Constant *GetEHType(QualType T);
virtual void GenerateCategory(const ObjCCategoryImplDecl *CMD);
@@ -1271,7 +1271,7 @@
virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD);
- virtual llvm::Constant *GetEHType(QualType T, const CodeGenFunction *CGF=0);
+ virtual llvm::Constant *GetEHType(QualType T);
virtual llvm::Constant *GetPropertyGetFunction() {
return ObjCTypes.getGetPropertyFn();
@@ -1414,12 +1414,20 @@
return EmitSelector(Builder, Method->getSelector());
}
-llvm::Constant *CGObjCMac::GetEHType(QualType T, const CodeGenFunction *CGF) {
+llvm::Constant *CGObjCMac::GetEHType(QualType T) {
if (T->isObjCIdType() ||
T->isObjCQualifiedIdType()) {
return CGM.GetAddrOfRTTIDescriptor(
- CGF->getContext().ObjCIdRedefinitionType, /*ForEH=*/true);
+ CGM.getContext().ObjCIdRedefinitionType, /*ForEH=*/true);
}
+ if (T->isObjCClassType() ||
+ T->isObjCQualifiedClassType()) {
+ return CGM.GetAddrOfRTTIDescriptor(
+ CGM.getContext().ObjCClassRedefinitionType, /*ForEH=*/true);
+ }
+ if (T->isObjCObjectPointerType())
+ return CGM.GetAddrOfRTTIDescriptor(T, /*ForEH=*/true);
+
llvm_unreachable("asking for catch type for ObjC type in fragile runtime");
return 0;
}
@@ -6021,7 +6029,7 @@
}
llvm::Constant *
-CGObjCNonFragileABIMac::GetEHType(QualType T, const CodeGenFunction *CGF) {
+CGObjCNonFragileABIMac::GetEHType(QualType T) {
// There's a particular fixed type info for 'id'.
if (T->isObjCIdType() ||
T->isObjCQualifiedIdType()) {
Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=133747&r1=133746&r2=133747&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Thu Jun 23 14:00:08 2011
@@ -128,8 +128,7 @@
/// This is used externally to implement catching ObjC types in C++.
/// Runtimes which don't support this should add the appropriate
/// error to Sema.
- virtual llvm::Constant *GetEHType(QualType T,
- const CodeGenFunction *CGF=0) = 0;
+ virtual llvm::Constant *GetEHType(QualType T) = 0;
/// Generate a constant string object.
virtual llvm::Constant *GenerateConstantString(const StringLiteral *) = 0;
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=133747&r1=133746&r2=133747&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jun 23 14:00:08 2011
@@ -8045,14 +8045,8 @@
Diag(Loc, diag::err_objc_object_catch);
Invalid = true;
} else if (T->isObjCObjectPointerType()) {
- if (!getLangOptions().ObjCNonFragileABI) {
- if (T->isObjCIdType() || T->isObjCQualifiedIdType())
- Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
- else {
- Diag(Loc, diag::err_objc_pointer_cxx_catch_fragile);
- Invalid = true;
- }
- }
+ if (!getLangOptions().ObjCNonFragileABI)
+ Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
}
}
Modified: cfe/trunk/test/CodeGenObjCXX/catch-id-type.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/catch-id-type.mm?rev=133747&r1=133746&r2=133747&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/catch-id-type.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/catch-id-type.mm Thu Jun 23 14:00:08 2011
@@ -11,18 +11,33 @@
id Groups();
+ at protocol P @end;
+
+ at interface INTF<P> {
+ double dd;
+}
+ at end
+
id FUNC() {
id groups;
try
{
groups = Groups(); // throws on errors.
}
+ catch( INTF<P>* error )
+ {
+ Groups();
+ }
catch( id error )
{
- // CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector({{.*}} @__gxx_personality_v0 {{.*}} @_ZTIP11objc_object
+ // CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector({{.*}} @__gxx_personality_v0 {{.*}} @_ZTIP4INTF {{.*}} @_ZTIP11objc_object {{.*}} @_ZTIP10objc_class
error = error;
groups = [ns_array array];
}
+ catch (Class cl) {
+ cl = cl;
+ groups = [ns_array array];
+ }
return groups;
}
Modified: cfe/trunk/test/SemaObjCXX/exceptions-fragile.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/exceptions-fragile.mm?rev=133747&r1=133746&r2=133747&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/exceptions-fragile.mm (original)
+++ cfe/trunk/test/SemaObjCXX/exceptions-fragile.mm Thu Jun 23 14:00:08 2011
@@ -6,7 +6,7 @@
namespace test0 {
void test() {
try {
- } catch (NSException *e) { // expected-error {{can't catch Objective C exceptions in C++ in the non-unified exception model}}
+ } catch (NSException *e) { // expected-warning {{catching Objective C exceptions in C++ in the non-unified exception model [-Wobjc-nonunified-exceptions]}}
}
}
}
More information about the cfe-commits
mailing list