[PATCH] D45451: [ItaniumMangle] Undeduced auto type doesn't belong in the substitution table
Erik Pilkington via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 9 12:25:10 PDT 2018
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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45451.141700.patch
Type: text/x-patch
Size: 2139 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180409/dea6fb6d/attachment.bin>
More information about the cfe-commits
mailing list