summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/MicrosoftCXXABI.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-03-06 23:45:20 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-03-06 23:45:20 +0000
commitd3d7669cedc58bec2a320317b68456cbfceb127c (patch)
tree51974fbee537fd173b783fdafb04f6d8ce7d914c /clang/lib/CodeGen/MicrosoftCXXABI.cpp
parent6661a67d50d240a9a1cd882cf5fb312144499a56 (diff)
downloadbcm5719-llvm-d3d7669cedc58bec2a320317b68456cbfceb127c.tar.gz
bcm5719-llvm-d3d7669cedc58bec2a320317b68456cbfceb127c.zip
MS ABI: Correctly generate throw-info for pointer to const qual types
We didn't create type info based on the unqualified pointee type, causing RTTI mismatches. llvm-svn: 231533
Diffstat (limited to 'clang/lib/CodeGen/MicrosoftCXXABI.cpp')
-rw-r--r--clang/lib/CodeGen/MicrosoftCXXABI.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 4e3d50b408e..9cb7d22e92f 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3367,7 +3367,7 @@ llvm::GlobalVariable *MicrosoftCXXABI::getCatchableTypeArray(QualType T) {
// - a standard pointer conversion (4.10) not involving conversions to
// pointers to private or protected or ambiguous classes
//
- // All pointers are convertible to void so ensure that it is in the
+ // All pointers are convertible to pointer-to-void so ensure that it is in the
// CatchableTypeArray.
if (IsPointer)
CatchableTypes.insert(getCatchableType(getContext().VoidPtrTy));
@@ -3398,6 +3398,8 @@ llvm::GlobalVariable *MicrosoftCXXABI::getCatchableTypeArray(QualType T) {
}
llvm::GlobalVariable *MicrosoftCXXABI::getThrowInfo(QualType T) {
+ T = getContext().getExceptionObjectType(T);
+
// C++14 [except.handle]p3:
// A handler is a match for an exception object of type E if [...]
// - the handler is of type cv T or const T& where T is a pointer type and
@@ -3409,7 +3411,17 @@ llvm::GlobalVariable *MicrosoftCXXABI::getThrowInfo(QualType T) {
IsConst = PointeeType.isConstQualified();
IsVolatile = PointeeType.isVolatileQualified();
}
- T = getContext().getExceptionObjectType(T);
+
+ // Member pointer types like "const int A::*" are represented by having RTTI
+ // for "int A::*" and separately storing the const qualifier.
+ if (const auto *MPTy = T->getAs<MemberPointerType>())
+ T = getContext().getMemberPointerType(PointeeType.getUnqualifiedType(),
+ MPTy->getClass());
+
+ // Pointer types like "const int * const *" are represented by having RTTI
+ // for "const int **" and separately storing the const qualifier.
+ if (T->isPointerType())
+ T = getContext().getPointerType(PointeeType.getUnqualifiedType());
// The CatchableTypeArray enumerates the various (CV-unqualified) types that
// the exception object may be caught as.
OpenPOWER on IntegriCloud