[llvm-branch-commits] [cfe-branch] r195729 - Merging r195669:

Bill Wendling isanbard at gmail.com
Tue Nov 26 02:45:43 PST 2013


Author: void
Date: Tue Nov 26 04:45:43 2013
New Revision: 195729

URL: http://llvm.org/viewvc/llvm-project?rev=195729&view=rev
Log:
Merging r195669:
------------------------------------------------------------------------
r195669 | majnemer | 2013-11-25 09:50:19 -0800 (Mon, 25 Nov 2013) | 13 lines

[-cxx-abi microsoft] Create backrefs for <unnamed-type-`id'>

It wasn't possible for an anonymous type to show up inside of function arguments.
However, decltype (which MSVC added support for in 2010) makes this
possible.  Further, backrefs to these anonymous types can now be formed.

This fixes PR18022.

N.B. We do not, and very likely _will not_, support MSVC's bug where
subsequent typedefs of anonymous types leak into the linkage name; this
is a gross violation of the ABI.  A warning should be introduced to
inform our users of this particular shortcoming.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_34/   (props changed)
    cfe/branches/release_34/lib/AST/MicrosoftMangle.cpp
    cfe/branches/release_34/test/CodeGenCXX/mangle-ms.cpp

Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 26 04:45:43 2013
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195326,195329,195367,195384,195420,195422,195501,195547,195556,195558,195587,195620,195687,195710
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195326,195329,195367,195384,195420,195422,195501,195547,195556,195558,195587,195620,195669,195687,195710
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_34/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/AST/MicrosoftMangle.cpp?rev=195729&r1=195728&r2=195729&view=diff
==============================================================================
--- cfe/branches/release_34/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/branches/release_34/lib/AST/MicrosoftMangle.cpp Tue Nov 26 04:45:43 2013
@@ -135,7 +135,7 @@ private:
     mangleUnqualifiedName(ND, ND->getDeclName());
   }
   void mangleUnqualifiedName(const NamedDecl *ND, DeclarationName Name);
-  void mangleSourceName(const IdentifierInfo *II);
+  void mangleSourceName(StringRef Name);
   void mangleOperatorName(OverloadedOperatorKind OO, SourceLocation Loc);
   void mangleCXXDtorType(CXXDtorType T);
   void mangleQualifiers(Qualifiers Quals, bool IsMember);
@@ -510,7 +510,7 @@ MicrosoftCXXNameMangler::mangleUnqualifi
   switch (Name.getNameKind()) {
     case DeclarationName::Identifier: {
       if (const IdentifierInfo *II = Name.getAsIdentifierInfo()) {
-        mangleSourceName(II);
+        mangleSourceName(II->getName());
         break;
       }
       
@@ -531,19 +531,22 @@ MicrosoftCXXNameMangler::mangleUnqualifi
                "Typedef should not be in another decl context!");
         assert(D->getDeclName().getAsIdentifierInfo() &&
                "Typedef was not named!");
-        mangleSourceName(D->getDeclName().getAsIdentifierInfo());
+        mangleSourceName(D->getDeclName().getAsIdentifierInfo()->getName());
         break;
       }
 
-      if (TD->hasDeclaratorForAnonDecl())
+      if (TD->hasDeclaratorForAnonDecl()) {
         // Anonymous types with no tag or typedef get the name of their
         // declarator mangled in.
-        Out << "<unnamed-type-" << TD->getDeclaratorForAnonDecl()->getName()
-            << ">@";
-      else
+        llvm::SmallString<64> Name("<unnamed-type-");
+        Name += TD->getDeclaratorForAnonDecl()->getName();
+        Name += ">";
+        mangleSourceName(Name.str());
+      } else {
         // Anonymous types with no tag, no typedef, or declarator get
-        // '<unnamed-tag>@'.
-        Out << "<unnamed-tag>@";
+        // '<unnamed-tag>'.
+        mangleSourceName("<unnamed-tag>");
+      }
       break;
     }
       
@@ -787,17 +790,16 @@ void MicrosoftCXXNameMangler::mangleOper
   }
 }
 
-void MicrosoftCXXNameMangler::mangleSourceName(const IdentifierInfo *II) {
+void MicrosoftCXXNameMangler::mangleSourceName(StringRef Name) {
   // <source name> ::= <identifier> @
-  std::string key = II->getNameStart();
   BackRefMap::iterator Found;
   if (UseNameBackReferences)
-    Found = NameBackReferences.find(key);
+    Found = NameBackReferences.find(Name);
   if (!UseNameBackReferences || Found == NameBackReferences.end()) {
-    Out << II->getName() << '@';
+    Out << Name << '@';
     if (UseNameBackReferences && NameBackReferences.size() < 10) {
       size_t Size = NameBackReferences.size();
-      NameBackReferences[key] = Size;
+      NameBackReferences[Name] = Size;
     }
   } else {
     Out << Found->second;

Modified: cfe/branches/release_34/test/CodeGenCXX/mangle-ms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/CodeGenCXX/mangle-ms.cpp?rev=195729&r1=195728&r2=195729&view=diff
==============================================================================
--- cfe/branches/release_34/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/branches/release_34/test/CodeGenCXX/mangle-ms.cpp Tue Nov 26 04:45:43 2013
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
-// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s
+// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=x86_64-pc-win32 -std=c++11| FileCheck -check-prefix X64 %s
 
 int a;
 // CHECK-DAG: @"\01?a@@3HA"
@@ -356,3 +356,11 @@ void TypedefNewDelete::operator delete[]
 // CHECK-DAG: ??_UTypedefNewDelete@@SAPAXI at Z
 // CHECK-DAG: ??3TypedefNewDelete@@SAXPAX at Z
 // CHECK-DAG: ??_VTypedefNewDelete@@SAXPAX at Z
+
+namespace PR18022 {
+
+struct { } a;
+decltype(a) fun(decltype(a) x, decltype(a)) { return x; }
+// CHECK-DAG: ?fun at PR18022@@YA?AU<unnamed-type-a>@1 at U21@0 at Z
+
+}





More information about the llvm-branch-commits mailing list