Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of
uses of getName() with uses of getDeclName(). This upgrades a bunch of
diags to take DeclNames instead of std::strings.
This also tweaks a couple of diagnostics to be cleaner and changes
CheckInitializerTypes/PerformInitializationByConstructor to pass
around DeclarationNames instead of std::strings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59947 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 444ee7c..e862808 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -291,7 +291,7 @@
// Create DIEnumerator elements for each enumerator.
for (EnumConstantDecl *Elt = Decl->getEnumConstantList(); Elt;
Elt = dyn_cast_or_null<EnumConstantDecl>(Elt->getNextDeclarator())) {
- Enumerators.push_back(DebugFactory.CreateEnumerator(Elt->getName(),
+ Enumerators.push_back(DebugFactory.CreateEnumerator(Elt->getNameAsString(),
Elt->getInitVal().getZExtValue()));
}
@@ -484,7 +484,7 @@
// Create the descriptor for the variable.
llvm::DIVariable D =
- DebugFactory.CreateVariable(Tag, RegionStack.back(), Decl->getName(),
+ DebugFactory.CreateVariable(Tag, RegionStack.back(),Decl->getNameAsString(),
Unit, Line,
getOrCreateType(Decl->getType(), Unit));
// Insert an llvm.dbg.declare into the current block.
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 4ad698a..bdbd5ca 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -649,7 +649,7 @@
std::string FunctionName;
if(const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurFuncDecl)) {
- FunctionName = FD->getName();
+ FunctionName = FD->getNameAsString();
} else {
// Just get the mangled name.
FunctionName = CurFn->getName();
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 32da770..3f2f99c 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -193,7 +193,7 @@
// techniques can modify the name -> class mapping.
llvm::Value *CGObjCGNU::GetClass(CGBuilderTy &Builder,
const ObjCInterfaceDecl *OID) {
- llvm::Value *ClassName = CGM.GetAddrOfConstantCString(OID->getName());
+ llvm::Value *ClassName = CGM.GetAddrOfConstantCString(OID->getNameAsString());
ClassName = Builder.CreateStructGEP(ClassName, 0);
llvm::Constant *ClassLookupFn =
@@ -565,7 +565,7 @@
llvm::Value *CGObjCGNU::GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD) {
- return ExistingProtocols[PD->getName()];
+ return ExistingProtocols[PD->getNameAsString()];
}
void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
@@ -574,7 +574,7 @@
llvm::SmallVector<std::string, 16> Protocols;
for (ObjCProtocolDecl::protocol_iterator PI = PD->protocol_begin(),
E = PD->protocol_end(); PI != E; ++PI)
- Protocols.push_back((*PI)->getName());
+ Protocols.push_back((*PI)->getNameAsString());
llvm::SmallVector<llvm::Constant*, 16> InstanceMethodNames;
llvm::SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
for (ObjCProtocolDecl::instmeth_iterator iter = PD->instmeth_begin(),
@@ -655,7 +655,7 @@
const ObjCList<ObjCProtocolDecl> &Protos =ClassDecl->getReferencedProtocols();
for (ObjCList<ObjCProtocolDecl>::iterator I = Protos.begin(),
E = Protos.end(); I != E; ++I)
- Protocols.push_back((*I)->getName());
+ Protocols.push_back((*I)->getNameAsString());
std::vector<llvm::Constant*> Elements;
Elements.push_back(MakeConstantString(CategoryName));
@@ -713,7 +713,8 @@
for (ObjCInterfaceDecl::ivar_iterator iter = ClassDecl->ivar_begin(),
endIter = ClassDecl->ivar_end() ; iter != endIter ; iter++) {
// Store the name
- IvarNames.push_back(CGM.GetAddrOfConstantCString((*iter)->getName()));
+ IvarNames.push_back(CGM.GetAddrOfConstantCString((*iter)
+ ->getNameAsString()));
// Get the type encoding for this ivar
std::string TypeStr;
Context.getObjCEncodingForType((*iter)->getType(), TypeStr);
@@ -751,7 +752,7 @@
const ObjCList<ObjCProtocolDecl> &Protos =ClassDecl->getReferencedProtocols();
for (ObjCList<ObjCProtocolDecl>::iterator I = Protos.begin(),
E = Protos.end(); I != E; ++I)
- Protocols.push_back((*I)->getName());
+ Protocols.push_back((*I)->getNameAsString());
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 975e386..67f6559 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -695,17 +695,17 @@
Values[0] = EmitProtocolExtension(PD, OptInstanceMethods, OptClassMethods);
Values[1] = GetClassName(PD->getIdentifier());
Values[2] =
- EmitProtocolList(std::string("\01L_OBJC_PROTOCOL_REFS_")+PD->getName(),
+ EmitProtocolList("\01L_OBJC_PROTOCOL_REFS_" + PD->getNameAsString(),
PD->protocol_begin(),
PD->protocol_end());
Values[3] =
- EmitMethodDescList(std::string("\01L_OBJC_PROTOCOL_INSTANCE_METHODS_")
- + PD->getName(),
+ EmitMethodDescList("\01L_OBJC_PROTOCOL_INSTANCE_METHODS_"
+ + PD->getNameAsString(),
"__OBJC,__cat_inst_meth,regular,no_dead_strip",
InstanceMethods);
Values[4] =
- EmitMethodDescList(std::string("\01L_OBJC_PROTOCOL_CLASS_METHODS_")
- + PD->getName(),
+ EmitMethodDescList("\01L_OBJC_PROTOCOL_CLASS_METHODS_"
+ + PD->getNameAsString(),
"__OBJC,__cat_cls_meth,regular,no_dead_strip",
ClassMethods);
llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.ProtocolTy,
@@ -742,7 +742,7 @@
new llvm::GlobalVariable(ObjCTypes.ProtocolTy, false,
llvm::GlobalValue::ExternalLinkage,
0,
- std::string("\01L_OBJC_PROTOCOL_")+PD->getName(),
+ "\01L_OBJC_PROTOCOL_" + PD->getNameAsString(),
&CGM.getModule());
Entry->setSection("__OBJC,__protocol,regular,no_dead_strip");
UsedGlobals.push_back(Entry);
@@ -770,17 +770,17 @@
std::vector<llvm::Constant*> Values(4);
Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
Values[1] =
- EmitMethodDescList(std::string("\01L_OBJC_PROTOCOL_INSTANCE_METHODS_OPT_")
- + PD->getName(),
+ EmitMethodDescList("\01L_OBJC_PROTOCOL_INSTANCE_METHODS_OPT_"
+ + PD->getNameAsString(),
"__OBJC,__cat_inst_meth,regular,no_dead_strip",
OptInstanceMethods);
Values[2] =
- EmitMethodDescList(std::string("\01L_OBJC_PROTOCOL_CLASS_METHODS_OPT_")
- + PD->getName(),
+ EmitMethodDescList("\01L_OBJC_PROTOCOL_CLASS_METHODS_OPT_"
+ + PD->getNameAsString(),
"__OBJC,__cat_cls_meth,regular,no_dead_strip",
OptClassMethods);
- Values[3] = EmitPropertyList(std::string("\01L_OBJC_$_PROP_PROTO_LIST_") +
- PD->getName(),
+ Values[3] = EmitPropertyList("\01L_OBJC_$_PROP_PROTO_LIST_" +
+ PD->getNameAsString(),
0,
PD->classprop_begin(),
PD->classprop_end());
@@ -796,8 +796,7 @@
new llvm::GlobalVariable(ObjCTypes.ProtocolExtensionTy, false,
llvm::GlobalValue::InternalLinkage,
Init,
- (std::string("\01L_OBJC_PROTOCOLEXT_") +
- PD->getName()),
+ "\01L_OBJC_PROTOCOLEXT_" + PD->getNameAsString(),
&CGM.getModule());
// No special section, but goes in llvm.used
UsedGlobals.push_back(GV);
@@ -962,9 +961,8 @@
const ObjCInterfaceDecl *Interface = OCD->getClassInterface();
const ObjCCategoryDecl *Category =
Interface->FindCategoryDeclaration(OCD->getIdentifier());
- std::string ExtName(std::string(Interface->getName()) +
- "_" +
- OCD->getName());
+ std::string ExtName(Interface->getNameAsString() + "_" +
+ OCD->getNameAsString());
std::vector<llvm::Constant*> InstanceMethods, ClassMethods;
for (ObjCCategoryImplDecl::instmeth_iterator i = OCD->instmeth_begin(),
@@ -1081,7 +1079,7 @@
ObjCInterfaceDecl *Interface =
const_cast<ObjCInterfaceDecl*>(ID->getClassInterface());
llvm::Constant *Protocols =
- EmitProtocolList(std::string("\01L_OBJC_CLASS_PROTOCOLS_") + ID->getName(),
+ EmitProtocolList("\01L_OBJC_CLASS_PROTOCOLS_" + ID->getNameAsString(),
Interface->protocol_begin(),
Interface->protocol_end());
const llvm::Type *InterfaceTy =
@@ -1140,7 +1138,7 @@
Values[ 5] = llvm::ConstantInt::get(ObjCTypes.LongTy, Size);
Values[ 6] = EmitIvarList(ID, false, InterfaceTy);
Values[ 7] =
- EmitMethodList(std::string("\01L_OBJC_INSTANCE_METHODS_") + ID->getName(),
+ EmitMethodList("\01L_OBJC_INSTANCE_METHODS_" + ID->getNameAsString(),
"__OBJC,__inst_meth,regular,no_dead_strip",
InstanceMethods);
// cache is always NULL.
@@ -1200,7 +1198,7 @@
Values[ 5] = llvm::ConstantInt::get(ObjCTypes.LongTy, Size);
Values[ 6] = EmitIvarList(ID, true, InterfaceTy);
Values[ 7] =
- EmitMethodList(std::string("\01L_OBJC_CLASS_METHODS_") + ID->getName(),
+ EmitMethodList("\01L_OBJC_CLASS_METHODS_" + ID->getNameAsString(),
"__OBJC,__inst_meth,regular,no_dead_strip",
Methods);
// cache is always NULL.
@@ -1238,8 +1236,7 @@
}
llvm::Constant *CGObjCMac::EmitMetaClassRef(const ObjCInterfaceDecl *ID) {
- std::string Name("\01L_OBJC_METACLASS_");
- Name += ID->getName();
+ std::string Name = "\01L_OBJC_METACLASS_" + ID->getNameAsString();
// FIXME: Should we look these up somewhere other than the
// module. Its a bit silly since we only generate these while
@@ -1278,8 +1275,7 @@
Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
// FIXME: Output weak_ivar_layout string.
Values[1] = llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy);
- Values[2] = EmitPropertyList(std::string("\01L_OBJC_$_PROP_LIST_") +
- ID->getName(),
+ Values[2] = EmitPropertyList("\01L_OBJC_$_PROP_LIST_" + ID->getNameAsString(),
ID,
ID->getClassInterface()->classprop_begin(),
ID->getClassInterface()->classprop_end());
@@ -1294,8 +1290,7 @@
new llvm::GlobalVariable(ObjCTypes.ClassExtensionTy, false,
llvm::GlobalValue::InternalLinkage,
Init,
- (std::string("\01L_OBJC_CLASSEXT_") +
- ID->getName()),
+ "\01L_OBJC_CLASSEXT_" + ID->getNameAsString(),
&CGM.getModule());
// No special section, but goes in llvm.used
UsedGlobals.push_back(GV);
@@ -1361,7 +1356,7 @@
new llvm::GlobalVariable(Init->getType(), false,
llvm::GlobalValue::InternalLinkage,
Init,
- std::string(Prefix) + ID->getName(),
+ Prefix + ID->getNameAsString(),
&CGM.getModule());
if (ForClass) {
GV->setSection("__OBJC,__cls_vars,regular,no_dead_strip");
@@ -2145,7 +2140,7 @@
// FIXME: Find the mangling GCC uses.
NameOut = (D->isInstance() ? "-" : "+");
NameOut += '[';
- NameOut += D->getClassInterface()->getName();
+ NameOut += D->getClassInterface()->getNameAsString();
NameOut += ' ';
NameOut += D->getSelector().getAsString();
NameOut += ']';
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 2ff2bee..f0aa8b7 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -321,9 +321,7 @@
llvm::GlobalValue *GA =
new llvm::GlobalAlias(aliasee->getType(),
llvm::Function::ExternalLinkage,
- D->getName(),
- aliasee,
- &getModule());
+ D->getNameAsString(), aliasee, &getModule());
llvm::GlobalValue *&Entry = GlobalDeclMap[D->getIdentifier()];
if (Entry) {
@@ -482,7 +480,7 @@
if (!Entry)
Entry = new llvm::GlobalVariable(Ty, false,
llvm::GlobalValue::ExternalLinkage,
- 0, D->getName(), &getModule(), 0,
+ 0, D->getNameAsString(), &getModule(), 0,
ASTTy.getAddressSpace());
// Make sure the result is of the correct type.
@@ -518,7 +516,7 @@
if (!GV) {
GV = new llvm::GlobalVariable(InitType, false,
llvm::GlobalValue::ExternalLinkage,
- 0, D->getName(), &getModule(), 0,
+ 0, D->getNameAsString(), &getModule(), 0,
ASTTy.getAddressSpace());
} else if (GV->getType() !=
llvm::PointerType::get(InitType, ASTTy.getAddressSpace())) {
@@ -542,7 +540,7 @@
// Make a new global with the correct type
GV = new llvm::GlobalVariable(InitType, false,
llvm::GlobalValue::ExternalLinkage,
- 0, D->getName(), &getModule(), 0,
+ 0, D->getNameAsString(), &getModule(), 0,
ASTTy.getAddressSpace());
// Steal the name of the old global
GV->takeName(OldGV);
@@ -630,7 +628,7 @@
const llvm::Type *Ty = getTypes().ConvertType(D->getType());
llvm::Function *F = llvm::Function::Create(cast<llvm::FunctionType>(Ty),
llvm::Function::ExternalLinkage,
- D->getName(), &getModule());
+ D->getNameAsString(),&getModule());
SetFunctionAttributes(D, F);
return F;
}
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index e49281d..18cfdea 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -291,7 +291,7 @@
std::vector<const llvm::Type*> IvarTypes;
CollectObjCIvarTypes(OIT.getDecl(), IvarTypes);
llvm::Type *T = llvm::StructType::get(IvarTypes);
- TheModule.addTypeName(std::string("struct.") + OIT.getDecl()->getName(), T);
+ TheModule.addTypeName("struct." + OIT.getDecl()->getNameAsString(), T);
return T;
}
@@ -315,9 +315,9 @@
// Name the codegen type after the typedef name
// if there is no tag type name available
if (TD->getIdentifier())
- TypeName += TD->getName();
+ TypeName += TD->getNameAsString();
else if (const TypedefType *TdT = dyn_cast<TypedefType>(T))
- TypeName += TdT->getDecl()->getName();
+ TypeName += TdT->getDecl()->getNameAsString();
else
TypeName += "anon";