"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 =
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());
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());
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)
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);
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)
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);
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;
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)
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);
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);
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);
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);
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;
}
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();
}
/// 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;
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);
/// 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) &&
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();
}
#include "llvm/ADT/DenseMap.h"
namespace llvm {
-class raw_ostream;
+template<typename T>
+class SmallVectorImpl;
}
namespace clang {
/// @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> &);
/// @}
};