[cfe-commits] r89553 - /cfe/trunk/lib/CodeGen/Mangle.cpp

Daniel Dunbar daniel at zuster.org
Sat Nov 21 01:12:13 PST 2009


Author: ddunbar
Date: Sat Nov 21 03:12:13 2009
New Revision: 89553

URL: http://llvm.org/viewvc/llvm-project?rev=89553&view=rev
Log:
Mangler: Inline a bunch of functions into their sole caller, not that I don't love typing for typings sake, but...

Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp

Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=89553&r1=89552&r2=89553&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Sat Nov 21 03:12:13 2009
@@ -30,7 +30,7 @@
 
 namespace {
 /// CXXNameMangler - Manage the mangling of a single name.
-class VISIBILITY_HIDDEN CXXNameMangler {
+class CXXNameMangler {
   MangleContext &Context;
   llvm::raw_svector_ostream Out;
 
@@ -39,7 +39,7 @@
 
   llvm::DenseMap<uintptr_t, unsigned> Substitutions;
 
-  public:
+public:
   CXXNameMangler(MangleContext &C, llvm::SmallVectorImpl<char> &Res)
     : Context(C), Out(Res), Structor(0), StructorType(0) { }
   CXXNameMangler(MangleContext &C, llvm::SmallVectorImpl<char> &Res,
@@ -49,22 +49,15 @@
                  const CXXDestructorDecl *D, CXXDtorType Type)
     : Context(C), Out(Res), Structor(D), StructorType(Type) { }
 
+  llvm::raw_svector_ostream &getStream() { return Out; }
+
   bool mangle(const NamedDecl *D);
   void mangleCalloffset(int64_t nv, int64_t v);
-  void mangleThunk(const FunctionDecl *FD, int64_t nv, int64_t v);
-  void mangleCovariantThunk(const FunctionDecl *FD,
-                            int64_t nv_t, int64_t v_t,
-                            int64_t nv_r, int64_t v_r);
-  void mangleGuardVariable(const VarDecl *D);
-
-  void mangleCXXVtable(const CXXRecordDecl *RD);
-  void mangleCXXVTT(const CXXRecordDecl *RD);
-  void mangleCXXCtorVtable(const CXXRecordDecl *RD, int64_t Offset,
-                           const CXXRecordDecl *Type);
-  void mangleCXXRtti(QualType Ty);
-  void mangleCXXRttiName(QualType Ty);
+  void mangleFunctionEncoding(const FunctionDecl *FD);
+  void mangleName(const NamedDecl *ND);
+  void mangleType(QualType T);
 
-  private:
+private:
   bool mangleSubstitution(const NamedDecl *ND);
   bool mangleSubstitution(QualType T);
   bool mangleSubstitution(uintptr_t Ptr);
@@ -81,8 +74,6 @@
 
   bool mangleFunctionDecl(const FunctionDecl *FD);
 
-  void mangleFunctionEncoding(const FunctionDecl *FD);
-  void mangleName(const NamedDecl *ND);
   void mangleName(const TemplateDecl *TD,
                   const TemplateArgument *TemplateArgs,
                   unsigned NumTemplateArgs);
@@ -99,7 +90,6 @@
   void mangleTemplatePrefix(const TemplateDecl *ND);
   void mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity);
   void mangleQualifiers(Qualifiers Quals);
-  void mangleType(QualType T);
 
   // Declare manglers for every type class.
 #define ABSTRACT_TYPE(CLASS, PARENT)
@@ -193,51 +183,6 @@
   return false;
 }
 
-void CXXNameMangler::mangleCXXVtable(const CXXRecordDecl *RD) {
-  // <special-name> ::= TV <type>  # virtual table
-  Out << "_ZTV";
-  mangleName(RD);
-}
-
-void CXXNameMangler::mangleCXXVTT(const CXXRecordDecl *RD) {
-  // <special-name> ::= TT <type>  # VTT structure
-  Out << "_ZTT";
-  mangleName(RD);
-}
-
-void CXXNameMangler::mangleCXXCtorVtable(const CXXRecordDecl *RD,
-                                         int64_t Offset,
-                                         const CXXRecordDecl *Type) {
-  // <special-name> ::= TC <type> <offset number> _ <base type>
-  Out << "_ZTC";
-  mangleName(RD);
-  Out << Offset;
-  Out << "_";
-  mangleName(Type);
-}
-
-void CXXNameMangler::mangleCXXRtti(QualType Ty) {
-  // <special-name> ::= TI <type>  # typeinfo structure
-  Out << "_ZTI";
-
-  mangleType(Ty);
-}
-
-void CXXNameMangler::mangleCXXRttiName(QualType Ty) {
-  // <special-name> ::= TS <type>  # typeinfo name (null terminated byte string)
-  Out << "_ZTS";
-
-  mangleType(Ty);
-}
-
-void CXXNameMangler::mangleGuardVariable(const VarDecl *D) {
-  //  <special-name> ::= GV <object name>       # Guard variable for one-time
-  //                                            # initialization
-
-  Out << "_ZGV";
-  mangleName(D);
-}
-
 void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) {
   // <encoding> ::= <function name> <bare-function-type>
   mangleName(FD);
@@ -403,28 +348,6 @@
   Out << "_";
 }
 
-void CXXNameMangler::mangleThunk(const FunctionDecl *FD, int64_t nv,
-                                 int64_t v) {
-  //  <special-name> ::= T <call-offset> <base encoding>
-  //                      # base is the nominal target function of thunk
-  Out << "_ZT";
-  mangleCalloffset(nv, v);
-  mangleFunctionEncoding(FD);
-}
-
-void CXXNameMangler::mangleCovariantThunk(const FunctionDecl *FD,
-                                          int64_t nv_t, int64_t v_t,
-                                          int64_t nv_r, int64_t v_r) {
-  //  <special-name> ::= Tc <call-offset> <call-offset> <base encoding>
-  //                      # base is the nominal target function of thunk
-  //                      # first call-offset is 'this' adjustment
-  //                      # second call-offset is result adjustment
-  Out << "_ZTc";
-  mangleCalloffset(nv_t, v_t);
-  mangleCalloffset(nv_r, v_r);
-  mangleFunctionEncoding(FD);
-}
-
 void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND) {
   //  <unqualified-name> ::= <operator-name>
   //                     ::= <ctor-dtor-name>
@@ -1388,6 +1311,18 @@
   return Mangler.mangle(D);
 }
 
+void MangleContext::mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
+                                  llvm::SmallVectorImpl<char> &Res) {
+  CXXNameMangler Mangler(*this, Res, D, Type);
+  Mangler.mangle(D);
+}
+
+void MangleContext::mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
+                                  llvm::SmallVectorImpl<char> &Res) {
+  CXXNameMangler Mangler(*this, Res, D, Type);
+  Mangler.mangle(D);
+}
+
 /// \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 nv, int64_t v,
@@ -1396,8 +1331,12 @@
   assert(!isa<CXXDestructorDecl>(FD) &&
          "Use mangleCXXDtor for destructor decls!");
 
+  //  <special-name> ::= T <call-offset> <base encoding>
+  //                      # base is the nominal target function of thunk
   CXXNameMangler Mangler(*this, Res);
-  Mangler.mangleThunk(FD, nv, v);
+  Mangler.getStream() << "_ZT";
+  Mangler.mangleCalloffset(nv, v);
+  Mangler.mangleFunctionEncoding(FD);
 }
 
 /// \brief Mangles the a covariant thunk for the declaration D and emits that
@@ -1409,57 +1348,68 @@
   assert(!isa<CXXDestructorDecl>(FD) &&
          "Use mangleCXXDtor for destructor decls!");
 
+  //  <special-name> ::= Tc <call-offset> <call-offset> <base encoding>
+  //                      # base is the nominal target function of thunk
+  //                      # first call-offset is 'this' adjustment
+  //                      # second call-offset is result adjustment
   CXXNameMangler Mangler(*this, Res);
-  Mangler.mangleCovariantThunk(FD, nv_t, v_t, nv_r, v_r);
+  Mangler.getStream() << "_ZTc";
+  Mangler.mangleCalloffset(nv_t, v_t);
+  Mangler.mangleCalloffset(nv_r, v_r);
+  Mangler.mangleFunctionEncoding(FD);
 }
 
 /// mangleGuardVariable - Returns the mangled name for a guard variable
 /// for the passed in VarDecl.
 void MangleContext::mangleGuardVariable(const VarDecl *D,
                                         llvm::SmallVectorImpl<char> &Res) {
+  //  <special-name> ::= GV <object name>       # Guard variable for one-time
+  //                                            # initialization
   CXXNameMangler Mangler(*this, Res);
-  Mangler.mangleGuardVariable(D);
-}
-
-void MangleContext::mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
-                                  llvm::SmallVectorImpl<char> &Res) {
-  CXXNameMangler Mangler(*this, Res, D, Type);
-  Mangler.mangle(D);
-}
-
-void MangleContext::mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
-                                  llvm::SmallVectorImpl<char> &Res) {
-  CXXNameMangler Mangler(*this, Res, D, Type);
-  Mangler.mangle(D);
+  Mangler.getStream() << "_ZGV";
+  Mangler.mangleName(D);
 }
 
 void MangleContext::mangleCXXVtable(const CXXRecordDecl *RD,
                                     llvm::SmallVectorImpl<char> &Res) {
+  // <special-name> ::= TV <type>  # virtual table
   CXXNameMangler Mangler(*this, Res);
-  Mangler.mangleCXXVtable(RD);
+  Mangler.getStream() << "_ZTV";
+  Mangler.mangleName(RD);
 }
 
 void MangleContext::mangleCXXVTT(const CXXRecordDecl *RD,
                                  llvm::SmallVectorImpl<char> &Res) {
+  // <special-name> ::= TT <type>  # VTT structure
   CXXNameMangler Mangler(*this, Res);
-  Mangler.mangleCXXVTT(RD);
+  Mangler.getStream() << "_ZTT";
+  Mangler.mangleName(RD);
 }
 
 void MangleContext::mangleCXXCtorVtable(const CXXRecordDecl *RD, int64_t Offset,
                                         const CXXRecordDecl *Type,
                                         llvm::SmallVectorImpl<char> &Res) {
+  // <special-name> ::= TC <type> <offset number> _ <base type>
   CXXNameMangler Mangler(*this, Res);
-  Mangler.mangleCXXCtorVtable(RD, Offset, Type);
+  Mangler.getStream() << "_ZTC";
+  Mangler.mangleName(RD);
+  Mangler.getStream() << Offset;
+  Mangler.getStream() << "_";
+  Mangler.mangleName(Type);
 }
 
 void MangleContext::mangleCXXRtti(QualType Ty,
                                   llvm::SmallVectorImpl<char> &Res) {
+  // <special-name> ::= TI <type>  # typeinfo structure
   CXXNameMangler Mangler(*this, Res);
-  Mangler.mangleCXXRtti(Ty);
+  Mangler.getStream() << "_ZTI";
+  Mangler.mangleType(Ty);
 }
 
 void MangleContext::mangleCXXRttiName(QualType Ty,
                                       llvm::SmallVectorImpl<char> &Res) {
+  // <special-name> ::= TS <type>  # typeinfo name (null terminated byte string)
   CXXNameMangler Mangler(*this, Res);
-  Mangler.mangleCXXRttiName(Ty);
+  Mangler.getStream() << "_ZTS";
+  Mangler.mangleType(Ty);
 }





More information about the cfe-commits mailing list