erik.pilkington created this revision. erik.pilkington added reviewers: rsmith, majnemer, rjmccall.
Since "Da" and "Dc" (auto and decltype(auto)) are under <builtin-type> in the mangling grammer, they shouldn't have a substitution (https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-compression). I believe that a deduced AutoType shouldn't be able to reach mangleType(AutoType) because it's deduced type would have been canonicalized in mangleType(QualType) before, so I removed that branch and added an assert. FWIW, with this patch applied Clang and GCC agree on the manglings in the affected file. Thanks for taking a look! Erik Repository: rC Clang https://reviews.llvm.org/D45451 Files: clang/lib/AST/ItaniumMangle.cpp clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp Index: clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp =================================================================== --- clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp +++ clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp @@ -52,10 +52,10 @@ template<class T> auto foo() { return [](const T&) { return 42; }; } }; -//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES5_(%class.anon +//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES4_(%class.anon int run2 = A<double>{}.func()(3.14); -//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES5_(%class.anon +//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES4_(%class.anon int run3 = A<char>{}.func()('a'); } // end inline_member_function Index: clang/lib/AST/ItaniumMangle.cpp =================================================================== --- clang/lib/AST/ItaniumMangle.cpp +++ clang/lib/AST/ItaniumMangle.cpp @@ -2338,7 +2338,8 @@ return true; if (Ty->isBuiltinType()) return false; - + if (isa<AutoType>(Ty)) + return false; return true; } @@ -3250,14 +3251,13 @@ } 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) {
Index: clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp =================================================================== --- clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp +++ clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp @@ -52,10 +52,10 @@ template<class T> auto foo() { return [](const T&) { return 42; }; } }; -//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES5_(%class.anon +//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES4_(%class.anon int run2 = A<double>{}.func()(3.14); -//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES5_(%class.anon +//CHECK-LABEL: define linkonce_odr i32 @_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES4_(%class.anon int run3 = A<char>{}.func()('a'); } // end inline_member_function Index: clang/lib/AST/ItaniumMangle.cpp =================================================================== --- clang/lib/AST/ItaniumMangle.cpp +++ clang/lib/AST/ItaniumMangle.cpp @@ -2338,7 +2338,8 @@ return true; if (Ty->isBuiltinType()) return false; - + if (isa<AutoType>(Ty)) + return false; return true; } @@ -3250,14 +3251,13 @@ } 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) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits