diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 13 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCGNU.cpp | 17 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 17 |
3 files changed, 22 insertions, 25 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 70eeb942b7..d55d0f81bc 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -19,12 +19,9 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclObjC.h" #include "llvm/ADT/StringExtras.h" - using namespace clang; using namespace CodeGen; -using llvm::utostr; - // FIXME: Name mangling should be moved to a separate class. @@ -35,7 +32,7 @@ static void mangleDeclContextInternal(const DeclContext *D, std::string &S) "Only one level of decl context mangling is currently supported!"); if (const FunctionDecl* FD = dyn_cast<FunctionDecl>(D)) { - S += utostr(FD->getIdentifier()->getLength()); + S += llvm::utostr(FD->getIdentifier()->getLength()); S += FD->getIdentifier()->getName(); if (FD->param_size() == 0) @@ -48,11 +45,11 @@ static void mangleDeclContextInternal(const DeclContext *D, std::string &S) std::string Name; Name += MD->isInstance() ? '-' : '+'; Name += '['; - Name += MD->getClassInterface()->getName(); + Name += MD->getClassInterface()->getNameAsString(); Name += ' '; - Name += MD->getSelector().getName(); + Name += MD->getSelector().getAsString(); Name += ']'; - S += utostr(Name.length()); + S += llvm::utostr(Name.length()); S += Name; } else assert(0 && "Unsupported decl type!"); @@ -64,7 +61,7 @@ static void mangleVarDeclInternal(const VarDecl &D, std::string &S) mangleDeclContextInternal(D.getDeclContext(), S); S += 'E'; - S += utostr(D.getIdentifier()->getLength()); + S += llvm::utostr(D.getIdentifier()->getLength()); S += D.getIdentifier()->getName(); } diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 25e3915049..9bcd816c6d 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -205,7 +205,7 @@ llvm::Value *CGObjCGNU::GetClass(CGBuilderTy &Builder, /// GetSelector - Return the pointer to the unique'd string for this selector. llvm::Value *CGObjCGNU::GetSelector(CGBuilderTy &Builder, Selector Sel) { // FIXME: uniquing on the string is wasteful, unique on Sel instead! - llvm::GlobalAlias *&US = UntypedSelectors[Sel.getName()]; + llvm::GlobalAlias *&US = UntypedSelectors[Sel.getAsString()]; if (US == 0) US = new llvm::GlobalAlias(llvm::PointerType::getUnqual(SelectorTy), llvm::GlobalValue::InternalLinkage, @@ -370,13 +370,14 @@ llvm::Constant *CGObjCGNU::GenerateMethodList(const std::string &ClassName, std::vector<llvm::Constant*> Elements; for (unsigned int i = 0, e = MethodTypes.size(); i < e; ++i) { Elements.clear(); - llvm::Constant *C = CGM.GetAddrOfConstantCString(MethodSels[i].getName()); + llvm::Constant *C = + CGM.GetAddrOfConstantCString(MethodSels[i].getAsString()); Elements.push_back(llvm::ConstantExpr::getGetElementPtr(C, Zeros, 2)); Elements.push_back( llvm::ConstantExpr::getGetElementPtr(MethodTypes[i], Zeros, 2)); llvm::Constant *Method = TheModule.getFunction(SymbolNameForMethod(ClassName, CategoryName, - MethodSels[i].getName(), + MethodSels[i].getAsString(), isClassMethodList)); Method = llvm::ConstantExpr::getBitCast(Method, llvm::PointerType::getUnqual(IMPTy)); @@ -581,7 +582,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) { std::string TypeStr; Context.getObjCEncodingForMethodDecl(*iter, TypeStr); InstanceMethodNames.push_back( - CGM.GetAddrOfConstantCString((*iter)->getSelector().getName())); + CGM.GetAddrOfConstantCString((*iter)->getSelector().getAsString())); InstanceMethodTypes.push_back(CGM.GetAddrOfConstantCString(TypeStr)); } // Collect information about class methods: @@ -592,7 +593,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) { std::string TypeStr; Context.getObjCEncodingForMethodDecl((*iter),TypeStr); ClassMethodNames.push_back( - CGM.GetAddrOfConstantCString((*iter)->getSelector().getName())); + CGM.GetAddrOfConstantCString((*iter)->getSelector().getAsString())); ClassMethodTypes.push_back(CGM.GetAddrOfConstantCString(TypeStr)); } @@ -932,9 +933,9 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { llvm::Function *CGObjCGNU::GenerateMethod(const ObjCMethodDecl *OMD) { const ObjCCategoryImplDecl *OCD = dyn_cast<ObjCCategoryImplDecl>(OMD->getMethodContext()); - const std::string &CategoryName = OCD ? OCD->getName() : ""; - const std::string &ClassName = OMD->getClassInterface()->getName(); - const std::string &MethodName = OMD->getSelector().getName(); + std::string CategoryName = OCD ? OCD->getNameAsString() : ""; + std::string ClassName = OMD->getClassInterface()->getNameAsString(); + std::string MethodName = OMD->getSelector().getAsString(); bool isClassMethod = !OMD->isInstance(); const llvm::FunctionType *MethodTy = diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 8eb81a4b4b..f9a4d77925 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -2065,7 +2065,8 @@ llvm::Constant *CGObjCMac::GetMethodVarName(Selector Sel) { llvm::GlobalVariable *&Entry = MethodVarNames[Sel]; if (!Entry) { - llvm::Constant *C = llvm::ConstantArray::get(Sel.getName()); + // FIXME: Avoid std::string copying. + llvm::Constant *C = llvm::ConstantArray::get(Sel.getAsString()); Entry = new llvm::GlobalVariable(C->getType(), false, llvm::GlobalValue::InternalLinkage, @@ -2143,14 +2144,12 @@ llvm::Constant *CGObjCMac::GetPropertyTypeString(const ObjCPropertyDecl *PD, void CGObjCMac::GetNameForMethod(const ObjCMethodDecl *D, std::string &NameOut) { // FIXME: Find the mangling GCC uses. - std::stringstream s; - s << (D->isInstance() ? "-" : "+"); - s << "["; - s << D->getClassInterface()->getName(); - s << " "; - s << D->getSelector().getName(); - s << "]"; - NameOut = s.str(); + NameOut = (D->isInstance() ? "-" : "+"); + NameOut += '['; + NameOut += D->getClassInterface()->getName(); + NameOut += ' '; + NameOut += D->getSelector().getAsString(); + NameOut += ']'; } void CGObjCMac::FinishModule() { |