r246659 - [MS ABI] Number unnamed TagDecls which aren't externally visible
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 2 08:50:39 PDT 2015
Author: majnemer
Date: Wed Sep 2 10:50:38 2015
New Revision: 246659
URL: http://llvm.org/viewvc/llvm-project?rev=246659&view=rev
Log:
[MS ABI] Number unnamed TagDecls which aren't externally visible
TagDecls (structs, enums, etc.) may have the same name for linkage
purposes of one another; to disambiguate, we add a number to the mangled
named. However, we didn't do this if the TagDecl has a pseudo-name for
linkage purposes (it was defined alongside a DeclaratorDecl or a
TypeNameDecl).
This fixes PR24651.
Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=246659&r1=246658&r2=246659&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Sep 2 10:50:38 2015
@@ -180,7 +180,9 @@ public:
// Anonymous tags are already numbered.
if (const TagDecl *Tag = dyn_cast<TagDecl>(ND)) {
- if (Tag->getName().empty() && !Tag->getTypedefNameForAnonDecl())
+ if (!Tag->hasNameForLinkage() &&
+ !getASTContext().getDeclaratorForUnnamedTagDecl(Tag) &&
+ !getASTContext().getTypedefNameForUnnamedTagDecl(Tag))
return false;
}
Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp?rev=246659&r1=246658&r2=246659&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp Wed Sep 2 10:50:38 2015
@@ -261,3 +261,19 @@ struct B {
void f(decltype(B<int>::e)) {}
// CHECK-DAG: @"\01?f at UnnamedType@@YAXPAW4<unnamed-type-e>@?$B at H@1@@Z
}
+
+namespace PR24651 {
+template <typename T>
+void f(T) {}
+
+void g() {
+ enum {} E;
+ f(E);
+ {
+ enum {} E;
+ f(E);
+ }
+}
+// CHECK-DAG: @"\01??$f at W4<unnamed-type-E>@?1??g at PR24651@@YAXXZ@@PR24651@@YAXW4<unnamed-type-E>@?1??g at 0@YAXXZ@@Z"
+// CHECK-DAG: @"\01??$f at W4<unnamed-type-E>@?2??g at PR24651@@YAXXZ@@PR24651@@YAXW4<unnamed-type-E>@?2??g at 0@YAXXZ@@Z"
+}
More information about the cfe-commits
mailing list