]> granicus.if.org Git - clang/commitdiff
CodeGen: Strip qualifiers from qualified array types in catches
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 12 Oct 2014 06:58:22 +0000 (06:58 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 12 Oct 2014 06:58:22 +0000 (06:58 +0000)
While we ran getUnqualifiedType over the catch type,
it isn't enough for array types.  Use getUnqualifiedArrayType instead.

This fixes PR21252.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219582 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGException.cpp
test/CodeGenCXX/try-catch.cpp

index 0b7e57a3c5f56d6753b82cc5bf93a3b8889f39e7..9da910d9d0810869d954864330e3ca314e99c074 100644 (file)
@@ -610,8 +610,9 @@ void CodeGenFunction::EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {
       // 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())
index 89f229fee37558220af2c925511674d5652637f1..b50214ecdb97a5df5af4e0aa2b8eb6594c802ac8 100644 (file)
@@ -11,3 +11,11 @@ void f() {
   } catch (const X x) {
   }
 }
+
+void h() {
+  try {
+    throw "ABC";
+    // CHECK: @_ZTIPKc to i8
+  } catch (char const(&)[4]) {
+  }
+}