raw_ostream &Out) = 0;
virtual void mangleCXXThrowInfo(QualType T, bool IsConst, bool IsVolatile,
- uint32_t NumEntries, raw_ostream &Out) = 0;
+ bool IsUnaligned, uint32_t NumEntries,
+ raw_ostream &Out) = 0;
virtual void mangleCXXCatchableTypeArray(QualType T, uint32_t NumEntries,
raw_ostream &Out) = 0;
const CXXRecordDecl *DstRD,
raw_ostream &Out) override;
void mangleCXXThrowInfo(QualType T, bool IsConst, bool IsVolatile,
- uint32_t NumEntries, raw_ostream &Out) override;
+ bool IsUnaligned, uint32_t NumEntries,
+ raw_ostream &Out) override;
void mangleCXXCatchableTypeArray(QualType T, uint32_t NumEntries,
raw_ostream &Out) override;
void mangleCXXCatchableType(QualType T, const CXXConstructorDecl *CD,
Mangler.mangleName(DstRD);
}
-void MicrosoftMangleContextImpl::mangleCXXThrowInfo(QualType T,
- bool IsConst,
+void MicrosoftMangleContextImpl::mangleCXXThrowInfo(QualType T, bool IsConst,
bool IsVolatile,
+ bool IsUnaligned,
uint32_t NumEntries,
raw_ostream &Out) {
msvc_hashing_ostream MHO(Out);
Mangler.getStream() << 'C';
if (IsVolatile)
Mangler.getStream() << 'V';
+ if (IsUnaligned)
+ Mangler.getStream() << 'U';
Mangler.getStream() << NumEntries;
Mangler.mangleType(T, SourceRange(), MicrosoftCXXNameMangler::QMM_Result);
}
}
static QualType decomposeTypeForEH(ASTContext &Context, QualType T,
- bool &IsConst, bool &IsVolatile) {
+ bool &IsConst, bool &IsVolatile,
+ bool &IsUnaligned) {
T = Context.getExceptionObjectType(T);
// C++14 [except.handle]p3:
// - a qualification conversion
IsConst = false;
IsVolatile = false;
+ IsUnaligned = false;
QualType PointeeType = T->getPointeeType();
if (!PointeeType.isNull()) {
IsConst = PointeeType.isConstQualified();
IsVolatile = PointeeType.isVolatileQualified();
+ IsUnaligned = PointeeType.getQualifiers().hasUnaligned();
}
// Member pointer types like "const int A::*" are represented by having RTTI
// TypeDescriptors for exceptions never have qualified pointer types,
// qualifiers are stored seperately in order to support qualification
// conversions.
- bool IsConst, IsVolatile;
- Type = decomposeTypeForEH(getContext(), Type, IsConst, IsVolatile);
+ bool IsConst, IsVolatile, IsUnaligned;
+ Type =
+ decomposeTypeForEH(getContext(), Type, IsConst, IsVolatile, IsUnaligned);
bool IsReference = CatchHandlerType->isReferenceType();
Flags |= 1;
if (IsVolatile)
Flags |= 2;
+ if (IsUnaligned)
+ Flags |= 4;
if (IsReference)
Flags |= 8;
}
llvm::GlobalVariable *MicrosoftCXXABI::getThrowInfo(QualType T) {
- bool IsConst, IsVolatile;
- T = decomposeTypeForEH(getContext(), T, IsConst, IsVolatile);
+ bool IsConst, IsVolatile, IsUnaligned;
+ T = decomposeTypeForEH(getContext(), T, IsConst, IsVolatile, IsUnaligned);
// The CatchableTypeArray enumerates the various (CV-unqualified) types that
// the exception object may be caught as.
SmallString<256> MangledName;
{
llvm::raw_svector_ostream Out(MangledName);
- getMangleContext().mangleCXXThrowInfo(T, IsConst, IsVolatile, NumEntries,
- Out);
+ getMangleContext().mangleCXXThrowInfo(T, IsConst, IsVolatile, IsUnaligned,
+ NumEntries, Out);
}
// Reuse a previously generated ThrowInfo if we have generated an appropriate
Flags |= 1;
if (IsVolatile)
Flags |= 2;
+ if (IsUnaligned)
+ Flags |= 4;
// The cleanup-function (a destructor) must be called when the exception
// object's lifetime ends.
// CHECK-DAG: @"_CT??_R0P6AXXZ@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0P6AXXZ@8" to i8*), i32 0, i32 -1, i32 0, i32 4, i8* null }, section ".xdata", comdat
// CHECK-DAG: @_CTA1P6AXXZ = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0P6AXXZ@84"] }, section ".xdata", comdat
// CHECK-DAG: @_TI1P6AXXZ = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @_CTA1P6AXXZ to i8*) }, section ".xdata", comdat
+// CHECK-DAG: @_TIU2PAPFAH = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 4, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.2* @_CTA2PAPFAH to i8*) }, section ".xdata", comdat
+// CHECK-DAG: @_CTA2PAPFAH = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.2 { i32 2, [2 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0PAPFAH@84", %eh.CatchableType* @"_CT??_R0PAX@84"] }, section ".xdata", comdat
struct N { ~N(); };
throw y;
}
+void h(__unaligned int * __unaligned *y) {
+ // CHECK-LABEL: @"\01?h@@YAXPFAPFAH@Z"
+ // CHECK: call void @_CxxThrowException(i8* %{{.*}}, %eh.ThrowInfo* @_TIU2PAPFAH)
+ throw y;
+}
+
struct Default {
Default(Default &, int = 42);
};