r219582 - CodeGen: Strip qualifiers from qualified array types in catches

David Majnemer david.majnemer at gmail.com
Sat Oct 11 23:58:22 PDT 2014


Author: majnemer
Date: Sun Oct 12 01:58:22 2014
New Revision: 219582

URL: http://llvm.org/viewvc/llvm-project?rev=219582&view=rev
Log:
CodeGen: Strip qualifiers from qualified array types in catches

While we ran getUnqualifiedType over the catch type,
it isn't enough for array types.  Use getUnqualifiedArrayType instead.

This fixes PR21252.

Modified:
    cfe/trunk/lib/CodeGen/CGException.cpp
    cfe/trunk/test/CodeGenCXX/try-catch.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=219582&r1=219581&r2=219582&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Sun Oct 12 01:58:22 2014
@@ -610,8 +610,9 @@ void CodeGenFunction::EnterCXXTryStmt(co
       // existing compilers do, and it's not clear that the standard
       // personality routine is capable of doing this right.  See C++ DR 388:
       //   http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#388
-      QualType CaughtType = C->getCaughtType();
-      CaughtType = CaughtType.getNonReferenceType().getUnqualifiedType();
+      Qualifiers CaughtTypeQuals;
+      QualType CaughtType = CGM.getContext().getUnqualifiedArrayType(
+          C->getCaughtType().getNonReferenceType(), CaughtTypeQuals);
 
       llvm::Constant *TypeInfo = nullptr;
       if (CaughtType->isObjCObjectPointerType())

Modified: cfe/trunk/test/CodeGenCXX/try-catch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/try-catch.cpp?rev=219582&r1=219581&r2=219582&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/try-catch.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/try-catch.cpp Sun Oct 12 01:58:22 2014
@@ -11,3 +11,11 @@ void f() {
   } catch (const X x) {
   }
 }
+
+void h() {
+  try {
+    throw "ABC";
+    // CHECK: @_ZTIPKc to i8
+  } catch (char const(&)[4]) {
+  }
+}





More information about the cfe-commits mailing list