enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };
+ // Corresponds to _MSC_VER
enum MSVCMajorVersion {
- MSVC2010 = 16,
- MSVC2012 = 17,
- MSVC2013 = 18,
- MSVC2015 = 19
+ MSVC2010 = 1600,
+ MSVC2012 = 1700,
+ MSVC2013 = 1800,
+ MSVC2015 = 1900,
+ MSVC2017 = 1910,
+ MSVC2017_5 = 1912
};
/// Clang versions with different platform ABI conformance.
}
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const {
- return MSCompatibilityVersion >= MajorVersion * 10000000U;
+ return MSCompatibilityVersion >= MajorVersion * 100000U;
}
/// Reset all of the options that are not considered when building a
QualifierMangleMode QMM = QMM_Mangle);
void mangleFunctionType(const FunctionType *T,
const FunctionDecl *D = nullptr,
- bool ForceThisQuals = false);
+ bool ForceThisQuals = false,
+ bool MangleExceptionSpec = true);
void mangleNestedName(const NamedDecl *ND);
private:
mangleFunctionClass(FD);
- mangleFunctionType(FT, FD);
+ mangleFunctionType(FT, FD, false, false);
} else {
Out << '9';
}
void MicrosoftCXXNameMangler::mangleFunctionType(const FunctionType *T,
const FunctionDecl *D,
- bool ForceThisQuals) {
+ bool ForceThisQuals,
+ bool MangleExceptionSpec) {
// <function-type> ::= <this-cvr-qualifiers> <calling-convention>
// <return-type> <argument-list> <throw-spec>
const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(T);
Out << '@';
}
- mangleThrowSpecification(Proto);
+ if (MangleExceptionSpec && getASTContext().getLangOpts().CPlusPlus17 &&
+ getASTContext().getLangOpts().isCompatibleWithMSVC(
+ LangOptions::MSVC2017_5))
+ mangleThrowSpecification(Proto);
+ else
+ Out << 'Z';
}
void MicrosoftCXXNameMangler::mangleFunctionClass(const FunctionDecl *FD) {
void MicrosoftCXXNameMangler::mangleCallingConvention(const FunctionType *T) {
mangleCallingConvention(T->getCallConv());
}
+
void MicrosoftCXXNameMangler::mangleThrowSpecification(
const FunctionProtoType *FT) {
- // <throw-spec> ::= Z # throw(...) (default)
- // ::= @ # throw() or __declspec/__attribute__((nothrow))
- // ::= <type>+
- // NOTE: Since the Microsoft compiler ignores throw specifications, they are
- // all actually mangled as 'Z'. (They're ignored because their associated
- // functionality isn't implemented, and probably never will be.)
- Out << 'Z';
+ // <throw-spec> ::= Z # (default)
+ // ::= _E # noexcept
+ if (FT->canThrow())
+ Out << 'Z';
+ else
+ Out << "_E";
}
void MicrosoftCXXNameMangler::mangleType(const UnresolvedUsingType *T,
if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(0), Version))
return;
+ // The attribute expects a "major" version number like 19, but new versions of
+ // MSVC have moved to updating the "minor", or less significant numbers, so we
+ // have to multiply by 100 now.
+ Version *= 100;
+
// TODO: Investigate what happens with the next major version of MSVC.
if (Version != LangOptions::MSVC2015) {
S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds)