diff options
| author | Anders Carlsson <andersca@mac.com> | 2010-06-02 04:29:50 +0000 | 
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2010-06-02 04:29:50 +0000 | 
| commit | d563923cf16394f0c6f75db7919c6b684e831700 (patch) | |
| tree | 85ccc83a2d38548d7cc740d48ba08f41481e2890 /clang/lib | |
| parent | 58ec0483b77e1b4ad195ad93138e322bd8312484 (diff) | |
| download | bcm5719-llvm-d563923cf16394f0c6f75db7919c6b684e831700.tar.gz bcm5719-llvm-d563923cf16394f0c6f75db7919c6b684e831700.zip  | |
When mangling member function pointers, fake adding a substitution corresponding to the function type.
llvm-svn: 105310
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/Mangle.cpp | 31 | 
1 files changed, 25 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/Mangle.cpp b/clang/lib/CodeGen/Mangle.cpp index 6c2a64898fe..4d98deec3d3 100644 --- a/clang/lib/CodeGen/Mangle.cpp +++ b/clang/lib/CodeGen/Mangle.cpp @@ -125,19 +125,24 @@ class CXXNameMangler {    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 @@ void CXXNameMangler::mangleType(const MemberPointerType *T) {    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(TemplateName Template) {  }  void CXXNameMangler::addSubstitution(uintptr_t Ptr) { -  unsigned SeqID = Substitutions.size(); -    assert(!Substitutions.count(Ptr) && "Substitution already exists!"); -  Substitutions[Ptr] = SeqID; +  Substitutions[Ptr] = SeqID++;  }  //  | 

