[cfe-commits] r89547 - in /cfe/trunk/lib/CodeGen: CGCXX.cpp CGRtti.cpp CGVtable.cpp CodeGenModule.cpp Mangle.cpp Mangle.h

Daniel Dunbar daniel at zuster.org
Sat Nov 21 01:06:10 PST 2009


Author: ddunbar
Date: Sat Nov 21 03:06:10 2009
New Revision: 89547

URL: http://llvm.org/viewvc/llvm-project?rev=89547&view=rev
Log:
Sink free mangle* methods into MangleContext.

Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp
    cfe/trunk/lib/CodeGen/CGRtti.cpp
    cfe/trunk/lib/CodeGen/CGVtable.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/lib/CodeGen/Mangle.cpp
    cfe/trunk/lib/CodeGen/Mangle.h

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Sat Nov 21 03:06:10 2009
@@ -152,7 +152,7 @@
 
   llvm::SmallString<256> GuardVName;
   llvm::raw_svector_ostream GuardVOut(GuardVName);
-  mangleGuardVariable(CGM.getMangleContext(), &D, GuardVOut);
+  CGM.getMangleContext().mangleGuardVariable(&D, GuardVOut);
 
   // Create the guard variable.
   llvm::GlobalValue *GuardV =
@@ -756,7 +756,7 @@
                                                  CXXCtorType Type) {
   llvm::SmallString<256> Name;
   llvm::raw_svector_ostream Out(Name);
-  mangleCXXCtor(getMangleContext(), D, Type, Out);
+  getMangleContext().mangleCXXCtor(D, Type, Out);
 
   Name += '\0';
   return UniqueMangledName(Name.begin(), Name.end());
@@ -794,7 +794,7 @@
                                                  CXXDtorType Type) {
   llvm::SmallString<256> Name;
   llvm::raw_svector_ostream Out(Name);
-  mangleCXXDtor(getMangleContext(), D, Type, Out);
+  getMangleContext().mangleCXXDtor(D, Type, Out);
 
   Name += '\0';
   return UniqueMangledName(Name.begin(), Name.end());
@@ -946,7 +946,7 @@
                                           int64_t nv, int64_t v) {
   llvm::SmallString<256> OutName;
   llvm::raw_svector_ostream Out(OutName);
-  mangleThunk(getMangleContext(), MD, nv, v, Out);
+  getMangleContext().mangleThunk(MD, nv, v, Out);
   llvm::GlobalVariable::LinkageTypes linktype;
   linktype = llvm::GlobalValue::WeakAnyLinkage;
   if (!Extern)
@@ -970,7 +970,7 @@
                                                    int64_t v_r) {
   llvm::SmallString<256> OutName;
   llvm::raw_svector_ostream Out(OutName);
-  mangleCovariantThunk(getMangleContext(), MD, nv_t, v_t, nv_r, v_r, Out);
+  getMangleContext().mangleCovariantThunk(MD, nv_t, v_t, nv_r, v_r, Out);
   llvm::GlobalVariable::LinkageTypes linktype;
   linktype = llvm::GlobalValue::WeakAnyLinkage;
   if (!Extern)

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGRtti.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRtti.cpp Sat Nov 21 03:06:10 2009
@@ -50,7 +50,7 @@
   llvm::Constant *BuildName(QualType Ty, bool Hidden, bool Extern) {
     llvm::SmallString<256> OutName;
     llvm::raw_svector_ostream Out(OutName);
-    mangleCXXRttiName(CGM.getMangleContext(), Ty, Out);
+    CGM.getMangleContext().mangleCXXRttiName(Ty, Out);
     llvm::StringRef Name = Out.str();
 
     llvm::GlobalVariable::LinkageTypes linktype;
@@ -100,7 +100,7 @@
 
     llvm::SmallString<256> OutName;
     llvm::raw_svector_ostream Out(OutName);
-    mangleCXXRtti(CGM.getMangleContext(), Ty, Out);
+    CGM.getMangleContext().mangleCXXRtti(Ty, Out);
     llvm::StringRef Name = Out.str();
 
     C = CGM.getModule().getGlobalVariable(Name);
@@ -195,8 +195,8 @@
 
     llvm::SmallString<256> OutName;
     llvm::raw_svector_ostream Out(OutName);
-    mangleCXXRtti(CGM.getMangleContext(), CGM.getContext().getTagDeclType(RD),
-                  Out);
+    CGM.getMangleContext().mangleCXXRtti(CGM.getContext().getTagDeclType(RD),
+                                         Out);
     llvm::StringRef Name = Out.str();
 
     llvm::GlobalVariable *GV;
@@ -291,7 +291,7 @@
 
     llvm::SmallString<256> OutName;
     llvm::raw_svector_ostream Out(OutName);
-    mangleCXXRtti(CGM.getMangleContext(), Ty, Out);
+    CGM.getMangleContext().mangleCXXRtti(Ty, Out);
     llvm::StringRef Name = Out.str();
 
     llvm::GlobalVariable *GV;
@@ -345,7 +345,7 @@
 
     llvm::SmallString<256> OutName;
     llvm::raw_svector_ostream Out(OutName);
-    mangleCXXRtti(CGM.getMangleContext(), Ty, Out);
+    CGM.getMangleContext().mangleCXXRtti(Ty, Out);
     llvm::StringRef Name = Out.str();
 
     llvm::GlobalVariable *GV;

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Sat Nov 21 03:06:10 2009
@@ -793,9 +793,9 @@
   llvm::SmallString<256> OutName;
   llvm::raw_svector_ostream Out(OutName);
   if (LayoutClass != RD)
-    mangleCXXCtorVtable(getMangleContext(), LayoutClass, Offset/8, RD, Out);
+    getMangleContext().mangleCXXCtorVtable(LayoutClass, Offset/8, RD, Out);
   else
-    mangleCXXVtable(getMangleContext(), RD, Out);
+    getMangleContext().mangleCXXVtable(RD, Out);
   llvm::StringRef Name = Out.str();
 
   std::vector<llvm::Constant *> methods;
@@ -1043,7 +1043,7 @@
 
   llvm::SmallString<256> OutName;
   llvm::raw_svector_ostream Out(OutName);
-  mangleCXXVTT(getMangleContext(), RD, Out);
+  getMangleContext().mangleCXXVTT(RD, Out);
   llvm::StringRef Name = Out.str();
 
   llvm::GlobalVariable::LinkageTypes linktype;

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Nov 21 03:06:10 2009
@@ -168,7 +168,7 @@
 
   llvm::SmallString<256> Name;
   llvm::raw_svector_ostream Out(Name);
-  if (!mangleName(getMangleContext(), ND, Out)) {
+  if (!getMangleContext().mangleName(ND, Out)) {
     assert(ND->getIdentifier() && "Attempt to mangle unnamed decl.");
     return ND->getNameAsCString();
   }

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

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Sat Nov 21 03:06:10 2009
@@ -29,94 +29,95 @@
 using namespace clang;
 
 namespace {
-  class VISIBILITY_HIDDEN CXXNameMangler {
-    MangleContext &Context;
-    llvm::raw_ostream &Out;
-
-    const CXXMethodDecl *Structor;
-    unsigned StructorType;
-    CXXCtorType CtorType;
+/// CXXNameMangler - Manage the mangling of a single name.
+class VISIBILITY_HIDDEN CXXNameMangler {
+  MangleContext &Context;
+  llvm::raw_ostream &Out;
+
+  const CXXMethodDecl *Structor;
+  unsigned StructorType;
+  CXXCtorType CtorType;
 
-    llvm::DenseMap<uintptr_t, unsigned> Substitutions;
+  llvm::DenseMap<uintptr_t, unsigned> Substitutions;
 
   public:
-    CXXNameMangler(MangleContext &C, llvm::raw_ostream &os)
-      : Context(C), Out(os), Structor(0), StructorType(0) { }
+  CXXNameMangler(MangleContext &C, llvm::raw_ostream &os)
+    : Context(C), Out(os), Structor(0), StructorType(0) { }
 
-    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 mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type);
-    void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type);
-
-  private:
-    bool mangleSubstitution(const NamedDecl *ND);
-    bool mangleSubstitution(QualType T);
-    bool mangleSubstitution(uintptr_t Ptr);
-
-    bool mangleStandardSubstitution(const NamedDecl *ND);
-
-    void addSubstitution(const NamedDecl *ND) {
-      ND = cast<NamedDecl>(ND->getCanonicalDecl());
-
-      addSubstitution(reinterpret_cast<uintptr_t>(ND));
-    }
-    void addSubstitution(QualType T);
-    void addSubstitution(uintptr_t Ptr);
+  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);
 
-    bool mangleFunctionDecl(const FunctionDecl *FD);
+  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 mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type);
+  void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type);
 
-    void mangleFunctionEncoding(const FunctionDecl *FD);
-    void mangleName(const NamedDecl *ND);
-    void mangleName(const TemplateDecl *TD,
-                    const TemplateArgument *TemplateArgs,
-                    unsigned NumTemplateArgs);
-    void mangleUnqualifiedName(const NamedDecl *ND);
-    void mangleUnscopedName(const NamedDecl *ND);
-    void mangleUnscopedTemplateName(const TemplateDecl *ND);
-    void mangleSourceName(const IdentifierInfo *II);
-    void mangleLocalName(const NamedDecl *ND);
-    void mangleNestedName(const NamedDecl *ND);
-    void mangleNestedName(const TemplateDecl *TD,
-                          const TemplateArgument *TemplateArgs,
-                          unsigned NumTemplateArgs);
-    void manglePrefix(const DeclContext *DC);
-    void mangleTemplatePrefix(const TemplateDecl *ND);
-    void mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity);
-    void mangleQualifiers(Qualifiers Quals);
-    void mangleType(QualType T);
+  private:
+  bool mangleSubstitution(const NamedDecl *ND);
+  bool mangleSubstitution(QualType T);
+  bool mangleSubstitution(uintptr_t Ptr);
+
+  bool mangleStandardSubstitution(const NamedDecl *ND);
+
+  void addSubstitution(const NamedDecl *ND) {
+    ND = cast<NamedDecl>(ND->getCanonicalDecl());
+
+    addSubstitution(reinterpret_cast<uintptr_t>(ND));
+  }
+  void addSubstitution(QualType T);
+  void addSubstitution(uintptr_t Ptr);
+
+  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);
+  void mangleUnqualifiedName(const NamedDecl *ND);
+  void mangleUnscopedName(const NamedDecl *ND);
+  void mangleUnscopedTemplateName(const TemplateDecl *ND);
+  void mangleSourceName(const IdentifierInfo *II);
+  void mangleLocalName(const NamedDecl *ND);
+  void mangleNestedName(const NamedDecl *ND);
+  void mangleNestedName(const TemplateDecl *TD,
+                        const TemplateArgument *TemplateArgs,
+                        unsigned NumTemplateArgs);
+  void manglePrefix(const DeclContext *DC);
+  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.
+  // Declare manglers for every type class.
 #define ABSTRACT_TYPE(CLASS, PARENT)
 #define NON_CANONICAL_TYPE(CLASS, PARENT)
 #define TYPE(CLASS, PARENT) void mangleType(const CLASS##Type *T);
 #include "clang/AST/TypeNodes.def"
 
-    void mangleType(const TagType*);
-    void mangleBareFunctionType(const FunctionType *T,
-                                bool MangleReturnType);
-    void mangleExpression(const Expr *E);
-    void mangleCXXCtorType(CXXCtorType T);
-    void mangleCXXDtorType(CXXDtorType T);
-
-    void mangleTemplateArgs(const TemplateArgument *TemplateArgs,
-                            unsigned NumTemplateArgs);
-    void mangleTemplateArgumentList(const TemplateArgumentList &L);
-    void mangleTemplateArgument(const TemplateArgument &A);
+  void mangleType(const TagType*);
+  void mangleBareFunctionType(const FunctionType *T,
+                              bool MangleReturnType);
+  void mangleExpression(const Expr *E);
+  void mangleCXXCtorType(CXXCtorType T);
+  void mangleCXXDtorType(CXXDtorType T);
+
+  void mangleTemplateArgs(const TemplateArgument *TemplateArgs,
+                          unsigned NumTemplateArgs);
+  void mangleTemplateArgumentList(const TemplateArgumentList &L);
+  void mangleTemplateArgument(const TemplateArgument &A);
 
-    void mangleTemplateParameter(unsigned Index);
-  };
+  void mangleTemplateParameter(unsigned Index);
+};
 }
 
 static bool isInCLinkageSpecification(const Decl *D) {
@@ -425,9 +426,9 @@
   mangleFunctionEncoding(FD);
 }
 
-  void CXXNameMangler::mangleCovariantThunk(const FunctionDecl *FD,
-                                            int64_t nv_t, int64_t v_t,
-                                            int64_t nv_r, int64_t v_r) {
+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
@@ -1376,126 +1377,122 @@
   Substitutions[Ptr] = SeqID;
 }
 
-namespace clang {
-  /// \brief Mangles the name of the declaration D and emits that name to the
-  /// given output stream.
-  ///
-  /// If the declaration D requires a mangled name, this routine will emit that
-  /// mangled name to \p os and return true. Otherwise, \p os will be unchanged
-  /// and this routine will return false. In this case, the caller should just
-  /// emit the identifier of the declaration (\c D->getIdentifier()) as its
-  /// name.
-  bool mangleName(MangleContext &Context, const NamedDecl *D,
-                  llvm::raw_ostream &os) {
-    assert(!isa<CXXConstructorDecl>(D) &&
-           "Use mangleCXXCtor for constructor decls!");
-    assert(!isa<CXXDestructorDecl>(D) &&
-           "Use mangleCXXDtor for destructor decls!");
-
-    PrettyStackTraceDecl CrashInfo(const_cast<NamedDecl *>(D), SourceLocation(),
-                                   Context.getASTContext().getSourceManager(),
-                                   "Mangling declaration");
+//
 
-    CXXNameMangler Mangler(Context, os);
-    if (!Mangler.mangle(D))
-      return false;
+/// \brief Mangles the name of the declaration D and emits that name to the
+/// given output stream.
+///
+/// If the declaration D requires a mangled name, this routine will emit that
+/// mangled name to \p os and return true. Otherwise, \p os will be unchanged
+/// and this routine will return false. In this case, the caller should just
+/// emit the identifier of the declaration (\c D->getIdentifier()) as its
+/// name.
+bool MangleContext::mangleName(const NamedDecl *D, llvm::raw_ostream &os) {
+  assert(!isa<CXXConstructorDecl>(D) &&
+         "Use mangleCXXCtor for constructor decls!");
+  assert(!isa<CXXDestructorDecl>(D) &&
+         "Use mangleCXXDtor for destructor decls!");
+
+  PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
+                                 getASTContext().getSourceManager(),
+                                 "Mangling declaration");
 
-    os.flush();
-    return true;
-  }
+  CXXNameMangler Mangler(*this, os);
+  if (!Mangler.mangle(D))
+    return false;
 
-  /// \brief Mangles the a thunk with the offset n for the declaration D and
-  /// emits that name to the given output stream.
-  void mangleThunk(MangleContext &Context, const FunctionDecl *FD,
-                   int64_t nv, int64_t v, llvm::raw_ostream &os) {
-    // FIXME: Hum, we might have to thunk these, fix.
-    assert(!isa<CXXDestructorDecl>(FD) &&
-           "Use mangleCXXDtor for destructor decls!");
-
-    CXXNameMangler Mangler(Context, os);
-    Mangler.mangleThunk(FD, nv, v);
-    os.flush();
-  }
-
-  /// \brief Mangles the a covariant thunk for the declaration D and emits that
-  /// name to the given output stream.
-  void mangleCovariantThunk(MangleContext &Context, const FunctionDecl *FD,
-                            int64_t nv_t, int64_t v_t,
-                            int64_t nv_r, int64_t v_r,
-                            llvm::raw_ostream &os) {
-    // FIXME: Hum, we might have to thunk these, fix.
-    assert(!isa<CXXDestructorDecl>(FD) &&
-           "Use mangleCXXDtor for destructor decls!");
+  os.flush();
+  return true;
+}
 
-    CXXNameMangler Mangler(Context, os);
-    Mangler.mangleCovariantThunk(FD, nv_t, v_t, nv_r, v_r);
-    os.flush();
-  }
+/// \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,
+                                llvm::raw_ostream &os) {
+  // FIXME: Hum, we might have to thunk these, fix.
+  assert(!isa<CXXDestructorDecl>(FD) &&
+         "Use mangleCXXDtor for destructor decls!");
 
-  /// mangleGuardVariable - Returns the mangled name for a guard variable
-  /// for the passed in VarDecl.
-  void mangleGuardVariable(MangleContext &Context, const VarDecl *D,
-                           llvm::raw_ostream &os) {
-    CXXNameMangler Mangler(Context, os);
-    Mangler.mangleGuardVariable(D);
+  CXXNameMangler Mangler(*this, os);
+  Mangler.mangleThunk(FD, nv, v);
+  os.flush();
+}
 
-    os.flush();
-  }
+/// \brief Mangles the a covariant thunk for the declaration D and emits that
+/// name to the given output stream.
+void MangleContext::mangleCovariantThunk(const FunctionDecl *FD, int64_t nv_t,
+                                         int64_t v_t, int64_t nv_r, int64_t v_r,
+                                         llvm::raw_ostream &os) {
+  // FIXME: Hum, we might have to thunk these, fix.
+  assert(!isa<CXXDestructorDecl>(FD) &&
+         "Use mangleCXXDtor for destructor decls!");
 
-  void mangleCXXCtor(MangleContext &Context, const CXXConstructorDecl *D,
-                     CXXCtorType Type, llvm::raw_ostream &os) {
-    CXXNameMangler Mangler(Context, os);
-    Mangler.mangleCXXCtor(D, Type);
+  CXXNameMangler Mangler(*this, os);
+  Mangler.mangleCovariantThunk(FD, nv_t, v_t, nv_r, v_r);
+  os.flush();
+}
 
-    os.flush();
-  }
+/// mangleGuardVariable - Returns the mangled name for a guard variable
+/// for the passed in VarDecl.
+void MangleContext::mangleGuardVariable(const VarDecl *D,
+                                        llvm::raw_ostream &os) {
+  CXXNameMangler Mangler(*this, os);
+  Mangler.mangleGuardVariable(D);
 
-  void mangleCXXDtor(MangleContext &Context, const CXXDestructorDecl *D,
-                     CXXDtorType Type, llvm::raw_ostream &os) {
-    CXXNameMangler Mangler(Context, os);
-    Mangler.mangleCXXDtor(D, Type);
+  os.flush();
+}
 
-    os.flush();
-  }
+void MangleContext::mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
+                                  llvm::raw_ostream &os) {
+  CXXNameMangler Mangler(*this, os);
+  Mangler.mangleCXXCtor(D, Type);
 
-  void mangleCXXVtable(MangleContext &Context, const CXXRecordDecl *RD,
-                       llvm::raw_ostream &os) {
-    CXXNameMangler Mangler(Context, os);
-    Mangler.mangleCXXVtable(RD);
+  os.flush();
+}
 
-    os.flush();
-  }
+void MangleContext::mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
+                                  llvm::raw_ostream &os) {
+  CXXNameMangler Mangler(*this, os);
+  Mangler.mangleCXXDtor(D, Type);
 
-  void mangleCXXVTT(MangleContext &Context, const CXXRecordDecl *RD,
-                       llvm::raw_ostream &os) {
-    CXXNameMangler Mangler(Context, os);
-    Mangler.mangleCXXVTT(RD);
+  os.flush();
+}
 
-    os.flush();
-  }
+void MangleContext::mangleCXXVtable(const CXXRecordDecl *RD,
+                                    llvm::raw_ostream &os) {
+  CXXNameMangler Mangler(*this, os);
+  Mangler.mangleCXXVtable(RD);
 
-  void mangleCXXCtorVtable(MangleContext &Context, const CXXRecordDecl *RD,
-                           int64_t Offset, const CXXRecordDecl *Type,
-                           llvm::raw_ostream &os) {
-    CXXNameMangler Mangler(Context, os);
-    Mangler.mangleCXXCtorVtable(RD, Offset, Type);
+  os.flush();
+}
 
-    os.flush();
-  }
+void MangleContext::mangleCXXVTT(const CXXRecordDecl *RD,
+                                 llvm::raw_ostream &os) {
+  CXXNameMangler Mangler(*this, os);
+  Mangler.mangleCXXVTT(RD);
 
-  void mangleCXXRtti(MangleContext &Context, QualType Ty,
-                     llvm::raw_ostream &os) {
-    CXXNameMangler Mangler(Context, os);
-    Mangler.mangleCXXRtti(Ty);
+  os.flush();
+}
 
-    os.flush();
-  }
+void MangleContext::mangleCXXCtorVtable(const CXXRecordDecl *RD, int64_t Offset,
+                                        const CXXRecordDecl *Type,
+                                        llvm::raw_ostream &os) {
+  CXXNameMangler Mangler(*this, os);
+  Mangler.mangleCXXCtorVtable(RD, Offset, Type);
 
-  void mangleCXXRttiName(MangleContext &Context, QualType Ty,
-                         llvm::raw_ostream &os) {
-    CXXNameMangler Mangler(Context, os);
-    Mangler.mangleCXXRttiName(Ty);
+  os.flush();
+}
 
-    os.flush();
-  }
+void MangleContext::mangleCXXRtti(QualType Ty, llvm::raw_ostream &os) {
+  CXXNameMangler Mangler(*this, os);
+  Mangler.mangleCXXRtti(Ty);
+
+  os.flush();
+}
+
+void MangleContext::mangleCXXRttiName(QualType Ty, llvm::raw_ostream &os) {
+  CXXNameMangler Mangler(*this, os);
+  Mangler.mangleCXXRttiName(Ty);
+
+  os.flush();
 }

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

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.h (original)
+++ cfe/trunk/lib/CodeGen/Mangle.h Sat Nov 21 03:06:10 2009
@@ -23,61 +23,59 @@
 #include "llvm/ADT/DenseMap.h"
 
 namespace llvm {
-  class raw_ostream;
+class raw_ostream;
 }
 
 namespace clang {
-  class ASTContext;
-  class CXXConstructorDecl;
-  class CXXDestructorDecl;
-  class FunctionDecl;
-  class NamedDecl;
-  class VarDecl;
-
-  class MangleContext {
-    ASTContext &Context;
-    
-    llvm::DenseMap<const TagDecl *, uint64_t> AnonStructIds;
+class ASTContext;
+class CXXConstructorDecl;
+class CXXDestructorDecl;
+class FunctionDecl;
+class NamedDecl;
+class VarDecl;
+
+/// MangleContext - Context for tracking state which persists across multiple
+/// calls to the C++ name mangler.
+class MangleContext {
+  ASTContext &Context;
 
-  public:
-    explicit MangleContext(ASTContext &Context)
+  llvm::DenseMap<const TagDecl *, uint64_t> AnonStructIds;
+
+public:
+  explicit MangleContext(ASTContext &Context)
     : Context(Context) { }
-    
-    ASTContext &getASTContext() const { return Context; }
-    
-    uint64_t getAnonymousStructId(const TagDecl *TD) {
-      std::pair<llvm::DenseMap<const TagDecl *, 
-                               uint64_t>::iterator, bool> Result =
+
+  ASTContext &getASTContext() const { return Context; }
+
+  uint64_t getAnonymousStructId(const TagDecl *TD) {
+    std::pair<llvm::DenseMap<const TagDecl *,
+      uint64_t>::iterator, bool> Result =
       AnonStructIds.insert(std::make_pair(TD, AnonStructIds.size()));
-      return Result.first->second;
-    }
-  };
-
-  bool mangleName(MangleContext &Context, const NamedDecl *D,
-                  llvm::raw_ostream &os);
-  void mangleThunk(MangleContext &Context, const FunctionDecl *FD, 
-                   int64_t n, int64_t vn, llvm::raw_ostream &os);
-  void mangleCovariantThunk(MangleContext &Context, const FunctionDecl *FD, 
-                            int64_t nv_t, int64_t v_t,
-                            int64_t nv_r, int64_t v_r,
-                            llvm::raw_ostream &os);
-  void mangleGuardVariable(MangleContext &Context, const VarDecl *D,
-                           llvm::raw_ostream &os);
-  void mangleCXXVtable(MangleContext &Context, const CXXRecordDecl *RD,
-                       llvm::raw_ostream &os);
-  void mangleCXXVTT(MangleContext &Context, const CXXRecordDecl *RD,
-                       llvm::raw_ostream &os);
-  void mangleCXXCtorVtable(MangleContext &Context, const CXXRecordDecl *RD,
-                           int64_t Offset, const CXXRecordDecl *Type,
-                       llvm::raw_ostream &os);
-  void mangleCXXRtti(MangleContext &Context, QualType T, 
+    return Result.first->second;
+  }
+
+  /// @name Mangler Entry Points
+  /// @{
+
+  bool mangleName(const NamedDecl *D, llvm::raw_ostream &os);
+  void mangleThunk(const FunctionDecl *FD, int64_t n, int64_t vn,
+                   llvm::raw_ostream &os);
+  void mangleCovariantThunk(const FunctionDecl *FD, int64_t nv_t, int64_t v_t,
+                            int64_t nv_r, int64_t v_r, llvm::raw_ostream &os);
+  void mangleGuardVariable(const VarDecl *D, llvm::raw_ostream &os);
+  void mangleCXXVtable(const CXXRecordDecl *RD, llvm::raw_ostream &os);
+  void mangleCXXVTT(const CXXRecordDecl *RD, llvm::raw_ostream &os);
+  void mangleCXXCtorVtable(const CXXRecordDecl *RD, int64_t Offset,
+                           const CXXRecordDecl *Type, llvm::raw_ostream &os);
+  void mangleCXXRtti(QualType T, llvm::raw_ostream &os);
+  void mangleCXXRttiName(QualType T, llvm::raw_ostream &os);
+  void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
+                     llvm::raw_ostream &os);
+  void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
                      llvm::raw_ostream &os);
-  void mangleCXXRttiName(MangleContext &Context, QualType T, 
-                         llvm::raw_ostream &os);
-  void mangleCXXCtor(MangleContext &Context, const CXXConstructorDecl *D, 
-                     CXXCtorType Type, llvm::raw_ostream &os);
-  void mangleCXXDtor(MangleContext &Context, const CXXDestructorDecl *D, 
-                     CXXDtorType Type, llvm::raw_ostream &os);  
+
+  /// @}
+};
 }
 
 #endif





More information about the cfe-commits mailing list