diff options
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/CGVtable.h | 4 | ||||
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 25 | ||||
-rw-r--r-- | lib/CodeGen/Mangle.h | 22 |
4 files changed, 30 insertions, 24 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 9674146825..7dc4b1e961 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -968,8 +968,7 @@ CodeGenModule::BuildThunk(const CXXMethodDecl *MD, bool Extern, const ThunkAdjustment &ThisAdjustment) { llvm::SmallString<256> OutName; - getMangleContext().mangleThunk(MD, ThisAdjustment.NonVirtual, - ThisAdjustment.Virtual, OutName); + getMangleContext().mangleThunk(MD, ThisAdjustment, OutName); llvm::GlobalVariable::LinkageTypes linktype; linktype = llvm::GlobalValue::WeakAnyLinkage; diff --git a/lib/CodeGen/CGVtable.h b/lib/CodeGen/CGVtable.h index af718b3632..1d98bed4b2 100644 --- a/lib/CodeGen/CGVtable.h +++ b/lib/CodeGen/CGVtable.h @@ -17,6 +17,10 @@ #include "llvm/ADT/DenseMap.h" #include "GlobalDecl.h" +namespace llvm { + class Constant; +} + namespace clang { class CXXMethodDecl; class CXXRecordDecl; diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index e2ae86bd45..37061f144c 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -26,7 +26,9 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/ErrorHandling.h" +#include "CGVtable.h" using namespace clang; +using namespace CodeGen; namespace { @@ -67,8 +69,7 @@ public: llvm::raw_svector_ostream &getStream() { return Out; } void mangle(const NamedDecl *D, llvm::StringRef Prefix = "_Z"); - void mangleCallOffset(int64_t NonVirtualOffset, - int64_t VirtualOffset); + void mangleCallOffset(const ThunkAdjustment &Adjustment); void mangleNumber(int64_t Number); void mangleFunctionEncoding(const FunctionDecl *FD); void mangleName(const NamedDecl *ND); @@ -348,24 +349,23 @@ void CXXNameMangler::mangleNumber(int64_t Number) { Out << Number; } -void CXXNameMangler::mangleCallOffset(int64_t NonVirtualOffset, - int64_t VirtualOffset) { +void CXXNameMangler::mangleCallOffset(const ThunkAdjustment &Adjustment) { // <call-offset> ::= h <nv-offset> _ // ::= v <v-offset> _ // <nv-offset> ::= <offset number> # non-virtual base override // <v-offset> ::= <offset number> _ <virtual offset number> // # virtual base override, with vcall offset - if (!VirtualOffset) { + if (!Adjustment.Virtual) { Out << 'h'; - mangleNumber(NonVirtualOffset); + mangleNumber(Adjustment.NonVirtual); Out << '_'; return; } Out << 'v'; - mangleNumber(NonVirtualOffset); + mangleNumber(Adjustment.NonVirtual); Out << '_'; - mangleNumber(VirtualOffset); + mangleNumber(Adjustment.Virtual); Out << '_'; } @@ -1355,8 +1355,7 @@ void MangleContext::mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type, /// \brief Mangles the a thunk with the offset n for the declaration D and /// emits that name to the given output stream. void MangleContext::mangleThunk(const FunctionDecl *FD, - int64_t NonVirtualOffset, - int64_t VirtualOffset, + const ThunkAdjustment &ThisAdjustment, llvm::SmallVectorImpl<char> &Res) { // FIXME: Hum, we might have to thunk these, fix. assert(!isa<CXXDestructorDecl>(FD) && @@ -1366,7 +1365,7 @@ void MangleContext::mangleThunk(const FunctionDecl *FD, // # base is the nominal target function of thunk CXXNameMangler Mangler(*this, Res); Mangler.getStream() << "_ZT"; - Mangler.mangleCallOffset(NonVirtualOffset, VirtualOffset); + Mangler.mangleCallOffset(ThisAdjustment); Mangler.mangleFunctionEncoding(FD); } @@ -1385,8 +1384,8 @@ void MangleContext::mangleCovariantThunk(const FunctionDecl *FD, int64_t nv_t, // # second call-offset is result adjustment CXXNameMangler Mangler(*this, Res); Mangler.getStream() << "_ZTc"; - Mangler.mangleCallOffset(nv_t, v_t); - Mangler.mangleCallOffset(nv_r, v_r); + Mangler.mangleCallOffset(ThunkAdjustment(nv_t, v_t)); + Mangler.mangleCallOffset(ThunkAdjustment(nv_r, v_r)); Mangler.mangleFunctionEncoding(FD); } diff --git a/lib/CodeGen/Mangle.h b/lib/CodeGen/Mangle.h index 15951fe876..81b73197d3 100644 --- a/lib/CodeGen/Mangle.h +++ b/lib/CodeGen/Mangle.h @@ -23,18 +23,20 @@ #include "llvm/ADT/DenseMap.h" namespace llvm { -template<typename T> -class SmallVectorImpl; + template<typename T> class SmallVectorImpl; } namespace clang { -class ASTContext; -class CXXConstructorDecl; -class CXXDestructorDecl; -class FunctionDecl; -class NamedDecl; -class VarDecl; + class ASTContext; + class CXXConstructorDecl; + class CXXDestructorDecl; + class FunctionDecl; + class NamedDecl; + class VarDecl; +namespace CodeGen { + class ThunkAdjustment; + /// MangleContext - Context for tracking state which persists across multiple /// calls to the C++ name mangler. class MangleContext { @@ -62,7 +64,7 @@ public: void mangleName(const NamedDecl *D, llvm::SmallVectorImpl<char> &); void mangleThunk(const FunctionDecl *FD, - int64_t NonVirtualOffset, int64_t VirtualOffset, + const ThunkAdjustment &ThisAdjustment, llvm::SmallVectorImpl<char> &); void mangleCovariantThunk(const FunctionDecl *FD, int64_t nv_t, int64_t v_t, int64_t nv_r, int64_t v_r, @@ -82,6 +84,8 @@ public: /// @} }; + +} } #endif |