зеркало из https://github.com/microsoft/clang-1.git
Switch over to the new caching version of getMangledName.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106549 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
793a990774
Коммит
9a20d55807
|
@ -166,8 +166,7 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
|
|||
new llvm::GlobalAlias(AliasType, Linkage, "", Aliasee, &getModule());
|
||||
|
||||
// Switch any previous uses to the alias.
|
||||
MangleBuffer MangledName;
|
||||
getMangledName(MangledName, AliasDecl);
|
||||
llvm::StringRef MangledName = getMangledName(AliasDecl);
|
||||
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
|
||||
if (Entry) {
|
||||
assert(Entry->isDeclaration() && "definition already exists for alias");
|
||||
|
@ -177,7 +176,7 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
|
|||
Entry->replaceAllUsesWith(Alias);
|
||||
Entry->eraseFromParent();
|
||||
} else {
|
||||
Alias->setName(MangledName.getString());
|
||||
Alias->setName(MangledName);
|
||||
}
|
||||
|
||||
// Finally, set up the alias with its proper name and attributes.
|
||||
|
@ -220,8 +219,7 @@ CodeGenModule::GetAddrOfCXXConstructor(const CXXConstructorDecl *D,
|
|||
CXXCtorType Type) {
|
||||
GlobalDecl GD(D, Type);
|
||||
|
||||
MangleBuffer Name;
|
||||
getMangledName(Name, GD);
|
||||
llvm::StringRef Name = getMangledName(GD);
|
||||
if (llvm::GlobalValue *V = GetGlobalValue(Name))
|
||||
return V;
|
||||
|
||||
|
@ -279,8 +277,7 @@ CodeGenModule::GetAddrOfCXXDestructor(const CXXDestructorDecl *D,
|
|||
CXXDtorType Type) {
|
||||
GlobalDecl GD(D, Type);
|
||||
|
||||
MangleBuffer Name;
|
||||
getMangledName(Name, GD);
|
||||
llvm::StringRef Name = getMangledName(GD);
|
||||
if (llvm::GlobalValue *V = GetGlobalValue(Name))
|
||||
return V;
|
||||
|
||||
|
|
|
@ -567,9 +567,9 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method,
|
|||
|
||||
// Since a single ctor/dtor corresponds to multiple functions, it doesn't
|
||||
// make sense to give a single ctor/dtor a linkage name.
|
||||
MangleBuffer MethodLinkageName;
|
||||
llvm::StringRef MethodLinkageName;
|
||||
if (!IsCtorOrDtor)
|
||||
CGM.getMangledName(MethodLinkageName, Method);
|
||||
MethodLinkageName = CGM.getMangledName(Method);
|
||||
|
||||
// Get the location for the method.
|
||||
llvm::DIFile MethodDefUnit = getOrCreateFile(Method->getLocation());
|
||||
|
@ -1289,7 +1289,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType,
|
|||
CGBuilderTy &Builder) {
|
||||
|
||||
llvm::StringRef Name;
|
||||
MangleBuffer LinkageName;
|
||||
llvm::StringRef LinkageName;
|
||||
|
||||
const Decl *D = GD.getDecl();
|
||||
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
|
||||
|
@ -1307,11 +1307,11 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType,
|
|||
}
|
||||
Name = getFunctionName(FD);
|
||||
// Use mangled name as linkage name for c/c++ functions.
|
||||
CGM.getMangledName(LinkageName, GD);
|
||||
LinkageName = CGM.getMangledName(GD);
|
||||
} else {
|
||||
// Use llvm function name as linkage name.
|
||||
Name = Fn->getName();
|
||||
LinkageName.setString(Name);
|
||||
LinkageName = Name;
|
||||
}
|
||||
if (!Name.empty() && Name[0] == '\01')
|
||||
Name = Name.substr(1);
|
||||
|
|
|
@ -139,16 +139,14 @@ static std::string GetStaticDeclName(CodeGenFunction &CGF, const VarDecl &D,
|
|||
const char *Separator) {
|
||||
CodeGenModule &CGM = CGF.CGM;
|
||||
if (CGF.getContext().getLangOptions().CPlusPlus) {
|
||||
MangleBuffer Name;
|
||||
CGM.getMangledName(Name, &D);
|
||||
return Name.getString().str();
|
||||
llvm::StringRef Name = CGM.getMangledName(&D);
|
||||
return Name.str();
|
||||
}
|
||||
|
||||
std::string ContextName;
|
||||
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CGF.CurFuncDecl)) {
|
||||
MangleBuffer Name;
|
||||
CGM.getMangledName(Name, FD);
|
||||
ContextName = Name.getString().str();
|
||||
llvm::StringRef Name = CGM.getMangledName(FD);
|
||||
ContextName = Name.str();
|
||||
} else if (isa<ObjCMethodDecl>(CGF.CurFuncDecl))
|
||||
ContextName = CGF.CurFn->getName();
|
||||
else
|
||||
|
|
|
@ -245,25 +245,6 @@ llvm::StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
|
|||
return Str;
|
||||
}
|
||||
|
||||
void CodeGenModule::getMangledName(MangleBuffer &Buffer, GlobalDecl GD) {
|
||||
const NamedDecl *ND = cast<NamedDecl>(GD.getDecl());
|
||||
|
||||
if (const CXXConstructorDecl *D = dyn_cast<CXXConstructorDecl>(ND))
|
||||
return getMangleContext().mangleCXXCtor(D, GD.getCtorType(),
|
||||
Buffer.getBuffer());
|
||||
if (const CXXDestructorDecl *D = dyn_cast<CXXDestructorDecl>(ND))
|
||||
return getMangleContext().mangleCXXDtor(D, GD.getDtorType(),
|
||||
Buffer.getBuffer());
|
||||
|
||||
if (!getMangleContext().shouldMangleDeclName(ND)) {
|
||||
assert(ND->getIdentifier() && "Attempt to mangle unnamed decl.");
|
||||
Buffer.setString(ND->getNameAsCString());
|
||||
return;
|
||||
}
|
||||
|
||||
getMangleContext().mangleName(ND, Buffer.getBuffer());
|
||||
}
|
||||
|
||||
void CodeGenModule::getMangledName(MangleBuffer &Buffer, const BlockDecl *BD) {
|
||||
getMangleContext().mangleBlock(BD, Buffer.getBuffer());
|
||||
}
|
||||
|
@ -585,8 +566,7 @@ void CodeGenModule::EmitDeferred() {
|
|||
// ignore these cases.
|
||||
//
|
||||
// TODO: That said, looking this up multiple times is very wasteful.
|
||||
MangleBuffer Name;
|
||||
getMangledName(Name, D);
|
||||
llvm::StringRef Name = getMangledName(D);
|
||||
llvm::GlobalValue *CGRef = GetGlobalValue(Name);
|
||||
assert(CGRef && "Deferred decl wasn't referenced?");
|
||||
|
||||
|
@ -807,8 +787,7 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
|
|||
|
||||
// If the value has already been used, add it directly to the
|
||||
// DeferredDeclsToEmit list.
|
||||
MangleBuffer MangledName;
|
||||
getMangledName(MangledName, GD);
|
||||
llvm::StringRef MangledName = getMangledName(GD);
|
||||
if (GetGlobalValue(MangledName))
|
||||
DeferredDeclsToEmit.push_back(GD);
|
||||
else {
|
||||
|
@ -948,8 +927,7 @@ llvm::Constant *CodeGenModule::GetAddrOfFunction(GlobalDecl GD,
|
|||
// If there was no specific requested type, just convert it now.
|
||||
if (!Ty)
|
||||
Ty = getTypes().ConvertType(cast<ValueDecl>(GD.getDecl())->getType());
|
||||
MangleBuffer MangledName;
|
||||
getMangledName(MangledName, GD);
|
||||
llvm::StringRef MangledName = getMangledName(GD);
|
||||
return GetOrCreateLLVMFunction(MangledName, Ty, GD);
|
||||
}
|
||||
|
||||
|
@ -1052,8 +1030,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
|
|||
const llvm::PointerType *PTy =
|
||||
llvm::PointerType::get(Ty, ASTTy.getAddressSpace());
|
||||
|
||||
MangleBuffer MangledName;
|
||||
getMangledName(MangledName, D);
|
||||
llvm::StringRef MangledName = getMangledName(D);
|
||||
return GetOrCreateLLVMGlobal(MangledName, PTy, D);
|
||||
}
|
||||
|
||||
|
@ -1072,8 +1049,7 @@ void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {
|
|||
// If we have not seen a reference to this variable yet, place it
|
||||
// into the deferred declarations table to be emitted if needed
|
||||
// later.
|
||||
MangleBuffer MangledName;
|
||||
getMangledName(MangledName, D);
|
||||
llvm::StringRef MangledName = getMangledName(D);
|
||||
if (!GetGlobalValue(MangledName)) {
|
||||
DeferredDecls[MangledName] = D;
|
||||
return;
|
||||
|
@ -1417,8 +1393,7 @@ void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) {
|
|||
const AliasAttr *AA = D->getAttr<AliasAttr>();
|
||||
assert(AA && "Not an alias?");
|
||||
|
||||
MangleBuffer MangledName;
|
||||
getMangledName(MangledName, GD);
|
||||
llvm::StringRef MangledName = getMangledName(GD);
|
||||
|
||||
// If there is a definition in the module, then it wins over the alias.
|
||||
// This is dubious, but allow it to be safe. Just ignore the alias.
|
||||
|
@ -1459,7 +1434,7 @@ void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) {
|
|||
Entry->getType()));
|
||||
Entry->eraseFromParent();
|
||||
} else {
|
||||
GA->setName(MangledName.getString());
|
||||
GA->setName(MangledName);
|
||||
}
|
||||
|
||||
// Set attributes which are particular to an alias; this is a
|
||||
|
|
|
@ -465,7 +465,6 @@ public:
|
|||
unsigned &CallingConv);
|
||||
|
||||
llvm::StringRef getMangledName(GlobalDecl GD);
|
||||
void getMangledName(MangleBuffer &Buffer, GlobalDecl D);
|
||||
void getMangledName(MangleBuffer &Buffer, const BlockDecl *BD);
|
||||
|
||||
void EmitTentativeDefinition(const VarDecl *D);
|
||||
|
|
Загрузка…
Ссылка в новой задаче