[cfe-commits] r97702 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/Mangle.cpp lib/CodeGen/Mangle.h test/CodeGenCXX/mangle-local-class-names.cpp
Fariborz Jahanian
fjahanian at apple.com
Wed Mar 3 17:02:03 PST 2010
Author: fjahanian
Date: Wed Mar 3 19:02:03 2010
New Revision: 97702
URL: http://llvm.org/viewvc/llvm-project?rev=97702&view=rev
Log:
Refactor local class name mangling and make it
ABI conforming.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/lib/CodeGen/Mangle.h
cfe/trunk/test/CodeGenCXX/mangle-local-class-names.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=97702&r1=97701&r2=97702&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Mar 3 19:02:03 2010
@@ -1204,7 +1204,7 @@
void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) {
const FunctionDecl *D = cast<FunctionDecl>(GD.getDecl());
const llvm::FunctionType *Ty = getTypes().GetFunctionType(GD);
-
+ getMangleContext().mangleInitDiscriminator();
// Get or create the prototype for the function.
llvm::Constant *Entry = GetAddrOfFunction(GD, Ty);
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=97702&r1=97701&r2=97702&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Wed Mar 3 19:02:03 2010
@@ -65,8 +65,6 @@
}
static const unsigned UnknownArity = ~0U;
-static unsigned Discriminator = 0;
-static llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
/// CXXNameMangler - Manage the mangling of a single name.
class CXXNameMangler {
@@ -672,17 +670,14 @@
Out << 'E';
mangleNestedName(ND, DC, true /*NoFunction*/);
- // FIXME. This still does not conform to ABI and does not cover all cases.
- unsigned &discriminator = Uniquifier[ND];
- if (!discriminator)
- discriminator = ++Discriminator;
- if (discriminator == 1)
- return;
- unsigned disc = discriminator-2;
- if (disc < 10)
- Out << '_' << disc;
- else
- Out << "__" << disc << '_';
+ // FIXME. This still does not cover all cases.
+ unsigned disc;
+ if (Context.getNextDiscriminator(ND, disc)) {
+ if (disc < 10)
+ Out << '_' << disc;
+ else
+ Out << "__" << disc << '_';
+ }
return;
}
Modified: cfe/trunk/lib/CodeGen/Mangle.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.h?rev=97702&r1=97701&r2=97702&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.h (original)
+++ cfe/trunk/lib/CodeGen/Mangle.h Wed Mar 3 19:02:03 2010
@@ -44,7 +44,9 @@
ASTContext &Context;
llvm::DenseMap<const TagDecl *, uint64_t> AnonStructIds;
-
+ unsigned Discriminator;
+ llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
+
public:
explicit MangleContext(ASTContext &Context)
: Context(Context) { }
@@ -85,7 +87,20 @@
llvm::SmallVectorImpl<char> &);
void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
llvm::SmallVectorImpl<char> &);
+
+ void mangleInitDiscriminator() {
+ Discriminator = 0;
+ }
+ bool getNextDiscriminator(const NamedDecl *ND, unsigned &disc) {
+ unsigned &discriminator = Uniquifier[ND];
+ if (!discriminator)
+ discriminator = ++Discriminator;
+ if (discriminator == 1)
+ return false;
+ disc = discriminator-2;
+ return true;
+ }
/// @}
};
Modified: cfe/trunk/test/CodeGenCXX/mangle-local-class-names.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-local-class-names.cpp?rev=97702&r1=97701&r2=97702&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-local-class-names.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-local-class-names.cpp Wed Mar 3 19:02:03 2010
@@ -2,6 +2,8 @@
// CHECK: @_ZZ4FUNCvEN4SSSSC1ERKf
// CHECK: @_ZZ4FUNCvEN4SSSSC2E_0RKf
+// CHECK: @_ZZ4GORFfEN4SSSSC1ERKf
+// CHECK: @_ZZ4GORFfEN4SSSSC2E_0RKf
void FUNC ()
{
@@ -28,3 +30,28 @@
SSSS VAR2(IVAR2);
}
}
+
+void GORF (float IVAR1)
+{
+ {
+ struct SSSS
+ {
+ float bv;
+ SSSS( const float& from): bv(from) { }
+ };
+
+ SSSS VAR1(IVAR1);
+ }
+
+ {
+ float IVAR2 ;
+
+ struct SSSS
+ {
+ SSSS( const float& from) {}
+ };
+
+ SSSS VAR2(IVAR2);
+ }
+}
+
More information about the cfe-commits
mailing list