[cfe-commits] r105310 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle-subst.cpp
Anders Carlsson
andersca at mac.com
Tue Jun 1 21:29:50 PDT 2010
Author: andersca
Date: Tue Jun 1 23:29:50 2010
New Revision: 105310
URL: http://llvm.org/viewvc/llvm-project?rev=105310&view=rev
Log:
When mangling member function pointers, fake adding a substitution corresponding to the function type.
Modified:
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-subst.cpp
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=105310&r1=105309&r2=105310&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Tue Jun 1 23:29:50 2010
@@ -125,19 +125,24 @@
const CXXMethodDecl *Structor;
unsigned StructorType;
+ /// SeqID - The next subsitution sequence number.
+ unsigned SeqID;
+
llvm::DenseMap<uintptr_t, unsigned> Substitutions;
ASTContext &getASTContext() const { return Context.getASTContext(); }
public:
CXXNameMangler(MangleContext &C, llvm::SmallVectorImpl<char> &Res)
- : Context(C), Out(Res), Structor(0), StructorType(0) { }
+ : Context(C), Out(Res), Structor(0), StructorType(0), SeqID(0) { }
CXXNameMangler(MangleContext &C, llvm::SmallVectorImpl<char> &Res,
const CXXConstructorDecl *D, CXXCtorType Type)
- : Context(C), Out(Res), Structor(getStructor(D)), StructorType(Type) { }
+ : Context(C), Out(Res), Structor(getStructor(D)), StructorType(Type),
+ SeqID(0) { }
CXXNameMangler(MangleContext &C, llvm::SmallVectorImpl<char> &Res,
const CXXDestructorDecl *D, CXXDtorType Type)
- : Context(C), Out(Res), Structor(getStructor(D)), StructorType(Type) { }
+ : Context(C), Out(Res), Structor(getStructor(D)), StructorType(Type),
+ SeqID(0) { }
#if MANGLE_CHECKER
~CXXNameMangler() {
@@ -1204,6 +1209,22 @@
if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(PointeeType)) {
mangleQualifiers(Qualifiers::fromCVRMask(FPT->getTypeQuals()));
mangleType(FPT);
+
+ // Itanium C++ ABI 5.1.8:
+ //
+ // The type of a non-static member function is considered to be different,
+ // for the purposes of substitution, from the type of a namespace-scope or
+ // static member function whose type appears similar. The types of two
+ // non-static member functions are considered to be different, for the
+ // purposes of substitution, if the functions are members of different
+ // classes. In other words, for the purposes of substitution, the class of
+ // which the function is a member is considered part of the type of
+ // function.
+
+ // We increment the SeqID here to emulate adding an entry to the
+ // substitution table. We can't actually add it because we don't want this
+ // particular function type to be substituted.
+ ++SeqID;
} else
mangleType(PointeeType);
}
@@ -2049,10 +2070,8 @@
}
void CXXNameMangler::addSubstitution(uintptr_t Ptr) {
- unsigned SeqID = Substitutions.size();
-
assert(!Substitutions.count(Ptr) && "Substitution already exists!");
- Substitutions[Ptr] = SeqID;
+ Substitutions[Ptr] = SeqID++;
}
//
Modified: cfe/trunk/test/CodeGenCXX/mangle-subst.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-subst.cpp?rev=105310&r1=105309&r2=105310&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-subst.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-subst.cpp Tue Jun 1 23:29:50 2010
@@ -67,3 +67,16 @@
// CHECK: @_ZN2NS1fERNS_1CE
void f(C&) { }
}
+
+namespace Test1 {
+
+struct A { };
+struct B { };
+
+// CHECK: @_ZN5Test11fEMNS_1BEFvvENS_1AES3_
+void f(void (B::*)(), A, A) { }
+
+// CHECK: @_ZN5Test11fEMNS_1BEFvvENS_1AES3_MS0_FvS3_EMS3_FvvE
+void f(void (B::*)(), A, A, void (B::*)(A), void (A::*)()) { }
+
+}
More information about the cfe-commits
mailing list