[cfe-commits] r89548 - 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:23 PST 2009
Author: ddunbar
Date: Sat Nov 21 03:06:22 2009
New Revision: 89548
URL: http://llvm.org/viewvc/llvm-project?rev=89548&view=rev
Log:
IRgen: Switch the C++ mangler interfaces to take the SmallVector to write into,
instead of requiring clients to make a raw_svector_ostream, which is just an
implementation detail.
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=89548&r1=89547&r2=89548&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Sat Nov 21 03:06:22 2009
@@ -151,8 +151,7 @@
"thread safe statics are currently not supported!");
llvm::SmallString<256> GuardVName;
- llvm::raw_svector_ostream GuardVOut(GuardVName);
- CGM.getMangleContext().mangleGuardVariable(&D, GuardVOut);
+ CGM.getMangleContext().mangleGuardVariable(&D, GuardVName);
// Create the guard variable.
llvm::GlobalValue *GuardV =
@@ -755,8 +754,7 @@
const char *CodeGenModule::getMangledCXXCtorName(const CXXConstructorDecl *D,
CXXCtorType Type) {
llvm::SmallString<256> Name;
- llvm::raw_svector_ostream Out(Name);
- getMangleContext().mangleCXXCtor(D, Type, Out);
+ getMangleContext().mangleCXXCtor(D, Type, Name);
Name += '\0';
return UniqueMangledName(Name.begin(), Name.end());
@@ -793,8 +791,7 @@
const char *CodeGenModule::getMangledCXXDtorName(const CXXDestructorDecl *D,
CXXDtorType Type) {
llvm::SmallString<256> Name;
- llvm::raw_svector_ostream Out(Name);
- getMangleContext().mangleCXXDtor(D, Type, Out);
+ getMangleContext().mangleCXXDtor(D, Type, Name);
Name += '\0';
return UniqueMangledName(Name.begin(), Name.end());
@@ -945,8 +942,7 @@
llvm::Constant *CodeGenModule::BuildThunk(const CXXMethodDecl *MD, bool Extern,
int64_t nv, int64_t v) {
llvm::SmallString<256> OutName;
- llvm::raw_svector_ostream Out(OutName);
- getMangleContext().mangleThunk(MD, nv, v, Out);
+ getMangleContext().mangleThunk(MD, nv, v, OutName);
llvm::GlobalVariable::LinkageTypes linktype;
linktype = llvm::GlobalValue::WeakAnyLinkage;
if (!Extern)
@@ -957,7 +953,7 @@
getTypes().GetFunctionType(getTypes().getFunctionInfo(MD),
FPT->isVariadic());
- llvm::Function *Fn = llvm::Function::Create(FTy, linktype, Out.str(),
+ llvm::Function *Fn = llvm::Function::Create(FTy, linktype, OutName.str(),
&getModule());
CodeGenFunction(*this).GenerateThunk(Fn, MD, Extern, nv, v);
llvm::Constant *m = llvm::ConstantExpr::getBitCast(Fn, Ptr8Ty);
@@ -969,8 +965,7 @@
int64_t v_t, int64_t nv_r,
int64_t v_r) {
llvm::SmallString<256> OutName;
- llvm::raw_svector_ostream Out(OutName);
- getMangleContext().mangleCovariantThunk(MD, nv_t, v_t, nv_r, v_r, Out);
+ getMangleContext().mangleCovariantThunk(MD, nv_t, v_t, nv_r, v_r, OutName);
llvm::GlobalVariable::LinkageTypes linktype;
linktype = llvm::GlobalValue::WeakAnyLinkage;
if (!Extern)
@@ -981,7 +976,7 @@
getTypes().GetFunctionType(getTypes().getFunctionInfo(MD),
FPT->isVariadic());
- llvm::Function *Fn = llvm::Function::Create(FTy, linktype, Out.str(),
+ llvm::Function *Fn = llvm::Function::Create(FTy, linktype, OutName.str(),
&getModule());
CodeGenFunction(*this).GenerateCovariantThunk(Fn, MD, Extern, nv_t, v_t, nv_r,
v_r);
Modified: cfe/trunk/lib/CodeGen/CGRtti.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRtti.cpp?rev=89548&r1=89547&r2=89548&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRtti.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRtti.cpp Sat Nov 21 03:06:22 2009
@@ -49,9 +49,8 @@
llvm::Constant *BuildName(QualType Ty, bool Hidden, bool Extern) {
llvm::SmallString<256> OutName;
- llvm::raw_svector_ostream Out(OutName);
- CGM.getMangleContext().mangleCXXRttiName(Ty, Out);
- llvm::StringRef Name = Out.str();
+ CGM.getMangleContext().mangleCXXRttiName(Ty, OutName);
+ llvm::StringRef Name = OutName.str();
llvm::GlobalVariable::LinkageTypes linktype;
linktype = llvm::GlobalValue::LinkOnceODRLinkage;
@@ -99,9 +98,8 @@
return llvm::Constant::getNullValue(Int8PtrTy);
llvm::SmallString<256> OutName;
- llvm::raw_svector_ostream Out(OutName);
- CGM.getMangleContext().mangleCXXRtti(Ty, Out);
- llvm::StringRef Name = Out.str();
+ CGM.getMangleContext().mangleCXXRtti(Ty, OutName);
+ llvm::StringRef Name = OutName.str();
C = CGM.getModule().getGlobalVariable(Name);
if (C)
@@ -194,10 +192,9 @@
llvm::Constant *C;
llvm::SmallString<256> OutName;
- llvm::raw_svector_ostream Out(OutName);
CGM.getMangleContext().mangleCXXRtti(CGM.getContext().getTagDeclType(RD),
- Out);
- llvm::StringRef Name = Out.str();
+ OutName);
+ llvm::StringRef Name = OutName.str();
llvm::GlobalVariable *GV;
GV = CGM.getModule().getGlobalVariable(Name);
@@ -290,9 +287,8 @@
llvm::Constant *C;
llvm::SmallString<256> OutName;
- llvm::raw_svector_ostream Out(OutName);
- CGM.getMangleContext().mangleCXXRtti(Ty, Out);
- llvm::StringRef Name = Out.str();
+ CGM.getMangleContext().mangleCXXRtti(Ty, OutName);
+ llvm::StringRef Name = OutName.str();
llvm::GlobalVariable *GV;
GV = CGM.getModule().getGlobalVariable(Name);
@@ -344,9 +340,8 @@
llvm::Constant *C;
llvm::SmallString<256> OutName;
- llvm::raw_svector_ostream Out(OutName);
- CGM.getMangleContext().mangleCXXRtti(Ty, Out);
- llvm::StringRef Name = Out.str();
+ CGM.getMangleContext().mangleCXXRtti(Ty, OutName);
+ llvm::StringRef Name = OutName.str();
llvm::GlobalVariable *GV;
GV = CGM.getModule().getGlobalVariable(Name);
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=89548&r1=89547&r2=89548&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Sat Nov 21 03:06:22 2009
@@ -791,12 +791,11 @@
const CXXRecordDecl *RD,
uint64_t Offset) {
llvm::SmallString<256> OutName;
- llvm::raw_svector_ostream Out(OutName);
if (LayoutClass != RD)
- getMangleContext().mangleCXXCtorVtable(LayoutClass, Offset/8, RD, Out);
+ getMangleContext().mangleCXXCtorVtable(LayoutClass, Offset/8, RD, OutName);
else
- getMangleContext().mangleCXXVtable(RD, Out);
- llvm::StringRef Name = Out.str();
+ getMangleContext().mangleCXXVtable(RD, OutName);
+ llvm::StringRef Name = OutName.str();
std::vector<llvm::Constant *> methods;
llvm::Type *Ptr8Ty=llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext),0);
@@ -1042,9 +1041,8 @@
return 0;
llvm::SmallString<256> OutName;
- llvm::raw_svector_ostream Out(OutName);
- getMangleContext().mangleCXXVTT(RD, Out);
- llvm::StringRef Name = Out.str();
+ getMangleContext().mangleCXXVTT(RD, OutName);
+ llvm::StringRef Name = OutName.str();
llvm::GlobalVariable::LinkageTypes linktype;
linktype = llvm::GlobalValue::LinkOnceODRLinkage;
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=89548&r1=89547&r2=89548&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Nov 21 03:06:22 2009
@@ -167,8 +167,7 @@
}
llvm::SmallString<256> Name;
- llvm::raw_svector_ostream Out(Name);
- if (!getMangleContext().mangleName(ND, Out)) {
+ if (!getMangleContext().mangleName(ND, Name)) {
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=89548&r1=89547&r2=89548&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Sat Nov 21 03:06:22 2009
@@ -32,7 +32,7 @@
/// CXXNameMangler - Manage the mangling of a single name.
class VISIBILITY_HIDDEN CXXNameMangler {
MangleContext &Context;
- llvm::raw_ostream &Out;
+ llvm::raw_svector_ostream Out;
const CXXMethodDecl *Structor;
unsigned StructorType;
@@ -41,8 +41,8 @@
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::SmallVectorImpl<char> &Res)
+ : Context(C), Out(Res), Structor(0), StructorType(0) { }
bool mangle(const NamedDecl *D);
void mangleCalloffset(int64_t nv, int64_t v);
@@ -1387,7 +1387,8 @@
/// 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) {
+bool MangleContext::mangleName(const NamedDecl *D,
+ llvm::SmallVectorImpl<char> &Res) {
assert(!isa<CXXConstructorDecl>(D) &&
"Use mangleCXXCtor for constructor decls!");
assert(!isa<CXXDestructorDecl>(D) &&
@@ -1397,102 +1398,82 @@
getASTContext().getSourceManager(),
"Mangling declaration");
- CXXNameMangler Mangler(*this, os);
- if (!Mangler.mangle(D))
- return false;
-
- os.flush();
- return true;
+ CXXNameMangler Mangler(*this, Res);
+ return 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,
- llvm::raw_ostream &os) {
+ llvm::SmallVectorImpl<char> &Res) {
// FIXME: Hum, we might have to thunk these, fix.
assert(!isa<CXXDestructorDecl>(FD) &&
"Use mangleCXXDtor for destructor decls!");
- CXXNameMangler Mangler(*this, os);
+ CXXNameMangler Mangler(*this, Res);
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 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) {
+ llvm::SmallVectorImpl<char> &Res) {
// FIXME: Hum, we might have to thunk these, fix.
assert(!isa<CXXDestructorDecl>(FD) &&
"Use mangleCXXDtor for destructor decls!");
- CXXNameMangler Mangler(*this, os);
+ CXXNameMangler Mangler(*this, Res);
Mangler.mangleCovariantThunk(FD, nv_t, v_t, nv_r, v_r);
- 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);
+ llvm::SmallVectorImpl<char> &Res) {
+ CXXNameMangler Mangler(*this, Res);
Mangler.mangleGuardVariable(D);
-
- os.flush();
}
void MangleContext::mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
- llvm::raw_ostream &os) {
- CXXNameMangler Mangler(*this, os);
+ llvm::SmallVectorImpl<char> &Res) {
+ CXXNameMangler Mangler(*this, Res);
Mangler.mangleCXXCtor(D, Type);
-
- os.flush();
}
void MangleContext::mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
- llvm::raw_ostream &os) {
- CXXNameMangler Mangler(*this, os);
+ llvm::SmallVectorImpl<char> &Res) {
+ CXXNameMangler Mangler(*this, Res);
Mangler.mangleCXXDtor(D, Type);
-
- os.flush();
}
void MangleContext::mangleCXXVtable(const CXXRecordDecl *RD,
- llvm::raw_ostream &os) {
- CXXNameMangler Mangler(*this, os);
+ llvm::SmallVectorImpl<char> &Res) {
+ CXXNameMangler Mangler(*this, Res);
Mangler.mangleCXXVtable(RD);
-
- os.flush();
}
void MangleContext::mangleCXXVTT(const CXXRecordDecl *RD,
- llvm::raw_ostream &os) {
- CXXNameMangler Mangler(*this, os);
+ llvm::SmallVectorImpl<char> &Res) {
+ CXXNameMangler Mangler(*this, Res);
Mangler.mangleCXXVTT(RD);
-
- os.flush();
}
void MangleContext::mangleCXXCtorVtable(const CXXRecordDecl *RD, int64_t Offset,
const CXXRecordDecl *Type,
- llvm::raw_ostream &os) {
- CXXNameMangler Mangler(*this, os);
+ llvm::SmallVectorImpl<char> &Res) {
+ CXXNameMangler Mangler(*this, Res);
Mangler.mangleCXXCtorVtable(RD, Offset, Type);
-
- os.flush();
}
-void MangleContext::mangleCXXRtti(QualType Ty, llvm::raw_ostream &os) {
- CXXNameMangler Mangler(*this, os);
+void MangleContext::mangleCXXRtti(QualType Ty,
+ llvm::SmallVectorImpl<char> &Res) {
+ CXXNameMangler Mangler(*this, Res);
Mangler.mangleCXXRtti(Ty);
-
- os.flush();
}
-void MangleContext::mangleCXXRttiName(QualType Ty, llvm::raw_ostream &os) {
- CXXNameMangler Mangler(*this, os);
+void MangleContext::mangleCXXRttiName(QualType Ty,
+ llvm::SmallVectorImpl<char> &Res) {
+ CXXNameMangler Mangler(*this, Res);
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=89548&r1=89547&r2=89548&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.h (original)
+++ cfe/trunk/lib/CodeGen/Mangle.h Sat Nov 21 03:06:22 2009
@@ -23,7 +23,8 @@
#include "llvm/ADT/DenseMap.h"
namespace llvm {
-class raw_ostream;
+template<typename T>
+class SmallVectorImpl;
}
namespace clang {
@@ -57,22 +58,24 @@
/// @name Mangler Entry Points
/// @{
- bool mangleName(const NamedDecl *D, llvm::raw_ostream &os);
+ bool mangleName(const NamedDecl *D, llvm::SmallVectorImpl<char> &);
void mangleThunk(const FunctionDecl *FD, int64_t n, int64_t vn,
- llvm::raw_ostream &os);
+ llvm::SmallVectorImpl<char> &);
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);
+ int64_t nv_r, int64_t v_r,
+ llvm::SmallVectorImpl<char> &);
+ void mangleGuardVariable(const VarDecl *D, llvm::SmallVectorImpl<char> &);
+ void mangleCXXVtable(const CXXRecordDecl *RD, llvm::SmallVectorImpl<char> &);
+ void mangleCXXVTT(const CXXRecordDecl *RD, llvm::SmallVectorImpl<char> &);
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);
+ const CXXRecordDecl *Type,
+ llvm::SmallVectorImpl<char> &);
+ void mangleCXXRtti(QualType T, llvm::SmallVectorImpl<char> &);
+ void mangleCXXRttiName(QualType T, llvm::SmallVectorImpl<char> &);
void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
- llvm::raw_ostream &os);
+ llvm::SmallVectorImpl<char> &);
void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
- llvm::raw_ostream &os);
+ llvm::SmallVectorImpl<char> &);
/// @}
};
More information about the cfe-commits
mailing list