diff options
author | Erik Pilkington <erik.pilkington@gmail.com> | 2018-04-28 02:40:28 +0000 |
---|---|---|
committer | Erik Pilkington <erik.pilkington@gmail.com> | 2018-04-28 02:40:28 +0000 |
commit | 81684cc58243b49af786438d33fcbbf12a596c56 (patch) | |
tree | 3d8008316cfe722e7cd64e1c971d8529468e3379 /lib/AST/ItaniumMangle.cpp | |
parent | 62f2197fb468b46c8b990b769aa275a4b571a426 (diff) |
[ItaniumMangle] Undeduced auto type shouldn't be substitutable.
We still support the old mangling if we're trying to be ABI-compatible with
Clang 6.0, though.
Differential revision: https://reviews.llvm.org/D45451
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ItaniumMangle.cpp')
-rw-r--r-- | lib/AST/ItaniumMangle.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index d42d705d09..609d0ebc84 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -2329,7 +2329,8 @@ void CXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) { Context.mangleObjCMethodName(MD, Out); } -static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty) { +static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty, + ASTContext &Ctx) { if (Quals) return true; if (Ty->isSpecificBuiltinType(BuiltinType::ObjCSel)) @@ -2338,7 +2339,11 @@ static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty) { return true; if (Ty->isBuiltinType()) return false; - + // Through to Clang 6.0, we accidentally treated undeduced auto types as + // substitution candidates. + if (Ctx.getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver6 && + isa<AutoType>(Ty)) + return false; return true; } @@ -2399,7 +2404,8 @@ void CXXNameMangler::mangleType(QualType T) { Qualifiers quals = split.Quals; const Type *ty = split.Ty; - bool isSubstitutable = isTypeSubstitutable(quals, ty); + bool isSubstitutable = + isTypeSubstitutable(quals, ty, Context.getASTContext()); if (isSubstitutable && mangleSubstitution(T)) return; @@ -3250,14 +3256,13 @@ void CXXNameMangler::mangleType(const UnaryTransformType *T) { } void CXXNameMangler::mangleType(const AutoType *T) { - QualType D = T->getDeducedType(); - // <builtin-type> ::= Da # dependent auto - if (D.isNull()) { - assert(T->getKeyword() != AutoTypeKeyword::GNUAutoType && - "shouldn't need to mangle __auto_type!"); - Out << (T->isDecltypeAuto() ? "Dc" : "Da"); - } else - mangleType(D); + assert(T->getDeducedType().isNull() && + "Deduced AutoType shouldn't be handled here!"); + assert(T->getKeyword() != AutoTypeKeyword::GNUAutoType && + "shouldn't need to mangle __auto_type!"); + // <builtin-type> ::= Da # auto + // ::= Dc # decltype(auto) + Out << (T->isDecltypeAuto() ? "Dc" : "Da"); } void CXXNameMangler::mangleType(const DeducedTemplateSpecializationType *T) { |