Remove more superfluous .str() and replace std::string concatenation with Twine.

Following r233392, http://llvm.org/viewvc/llvm-project?rev=233392&view=rev.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233555 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Yaron Keren 2015-03-30 15:42:36 +00:00
parent 65e878bd80
commit 6e92e7b09a
22 changed files with 52 additions and 53 deletions

View File

@ -95,16 +95,15 @@ static ExFunc lookupFunction(const Function *F) {
FunctionType *FT = F->getFunctionType();
for (unsigned i = 0, e = FT->getNumContainedTypes(); i != e; ++i)
ExtName += getTypeID(FT->getContainedType(i));
ExtName += "_" + F->getName().str();
ExtName += ("_" + F->getName()).str();
sys::ScopedLock Writer(*FunctionsLock);
ExFunc FnPtr = (*FuncNames)[ExtName];
if (!FnPtr)
FnPtr = (*FuncNames)["lle_X_" + F->getName().str()];
FnPtr = (*FuncNames)[("lle_X_" + F->getName()).str()];
if (!FnPtr) // Try calling a generic function... if it exists...
FnPtr = (ExFunc)(intptr_t)
sys::DynamicLibrary::SearchForAddressOfSymbol("lle_X_" +
F->getName().str());
FnPtr = (ExFunc)(intptr_t)sys::DynamicLibrary::SearchForAddressOfSymbol(
("lle_X_" + F->getName()).str());
if (FnPtr)
ExportedFunctions->insert(std::make_pair(F, FnPtr)); // Cache for later
return FnPtr;

View File

@ -298,12 +298,12 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
//
if (isStringAttribute()) {
std::string Result;
Result += '\"' + getKindAsString().str() + '"';
Result += (Twine('"') + getKindAsString() + Twine('"')).str();
StringRef Val = pImpl->getValueAsString();
if (Val.empty()) return Result;
Result += "=\"" + Val.str() + '"';
Result += ("=\"" + Val + Twine('"')).str();
return Result;
}

View File

@ -745,7 +745,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
return;
}
std::string Name = CI->getName().str();
llvm::StringRef Name = CI->getName();
if (!Name.empty())
CI->setName(Name + ".old");

View File

@ -147,7 +147,7 @@ const std::string DiagnosticInfoOptimizationBase::getLocationStr() const {
unsigned Column = 0;
if (isLocationAvailable())
getLocation(&Filename, &Line, &Column);
return Twine(Filename + ":" + Twine(Line) + ":" + Twine(Column)).str();
return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str();
}
void DiagnosticInfoOptimizationBase::print(DiagnosticPrinter &DP) const {

View File

@ -555,7 +555,7 @@ FileInfo::openCoveragePath(StringRef CoveragePath) {
return llvm::make_unique<raw_null_ostream>();
std::error_code EC;
auto OS = llvm::make_unique<raw_fd_ostream>(CoveragePath.str(), EC,
auto OS = llvm::make_unique<raw_fd_ostream>(CoveragePath, EC,
sys::fs::F_Text);
if (EC) {
errs() << EC.message() << "\n";

View File

@ -267,7 +267,7 @@ LTOModule::objcClassNameFromExpression(const Constant *c, std::string &name) {
Constant *cn = gvn->getInitializer();
if (ConstantDataArray *ca = dyn_cast<ConstantDataArray>(cn)) {
if (ca->isCString()) {
name = ".objc_class_name_" + ca->getAsCString().str();
name = (".objc_class_name_" + ca->getAsCString()).str();
return true;
}
}

View File

@ -4606,7 +4606,7 @@ bool AsmParser::parseMSInlineAsm(
++InputIdx;
OutputDecls.push_back(OpDecl);
OutputDeclsAddressOf.push_back(Operand.needAddressOf());
OutputConstraints.push_back('=' + Operand.getConstraint().str());
OutputConstraints.push_back(("=" + Operand.getConstraint()).str());
AsmStrRewrites.push_back(AsmRewrite(AOK_Output, Start, SymName.size()));
} else {
InputDecls.push_back(OpDecl);

View File

@ -382,9 +382,7 @@ void WinCOFFObjectWriter::DefineSymbol(MCSymbolData const &SymbolData,
coff_symbol->Other = GetOrCreateCOFFSymbol(&SymRef->getSymbol());
} else {
std::string WeakName = std::string(".weak.")
+ Symbol.getName().str()
+ ".default";
std::string WeakName = (".weak." + Symbol.getName() + ".default").str();
COFFSymbol *WeakDefault = createSymbol(WeakName);
WeakDefault->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
WeakDefault->Data.StorageClass = COFF::IMAGE_SYM_CLASS_EXTERNAL;

View File

@ -1537,7 +1537,7 @@ bool ExportEntry::operator==(const ExportEntry &Other) const {
if (Stack.size() != Other.Stack.size())
return false;
// Not equal if different cumulative strings.
if (!CumulativeString.str().equals(Other.CumulativeString.str()))
if (!CumulativeString.equals(Other.CumulativeString))
return false;
// Equal if all nodes in both stacks match.
for (unsigned i=0; i < Stack.size(); ++i) {
@ -1559,7 +1559,7 @@ uint64_t ExportEntry::readULEB128(const uint8_t *&Ptr) {
}
StringRef ExportEntry::name() const {
return CumulativeString.str();
return CumulativeString;
}
uint64_t ExportEntry::flags() const {

View File

@ -395,7 +395,7 @@ Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option Opt,
Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option Opt,
StringRef Value) const {
unsigned Index = BaseArgs.MakeIndex(Opt.getName().str() + Value.str());
unsigned Index = BaseArgs.MakeIndex((Opt.getName() + Value).str());
SynthesizedArgs.push_back(make_unique<Arg>(
Opt, MakeArgString(Opt.getPrefix() + Opt.getName()), Index,
BaseArgs.getArgString(Index) + Opt.getName().size(), BaseArg));

View File

@ -313,7 +313,7 @@ static Option *LookupNearestOption(StringRef Arg,
if (RHS.empty() || !PermitValue)
NearestString = OptionNames[i];
else
NearestString = std::string(OptionNames[i]) + "=" + RHS.str();
NearestString = (Twine(OptionNames[i]) + "=" + RHS).str();
}
}
}

View File

@ -92,7 +92,7 @@ static bool ExecGraphViewer(StringRef ExecPath, std::vector<const char *> &args,
errs() << " done. \n";
} else {
sys::ExecuteNoWait(ExecPath, args.data(), nullptr, nullptr, 0, &ErrMsg);
errs() << "Remember to erase graph file: " << Filename.str() << "\n";
errs() << "Remember to erase graph file: " << Filename << "\n";
}
return false;
}

View File

@ -15,6 +15,7 @@
#include "regex_impl.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include <string>
using namespace llvm;
@ -158,7 +159,7 @@ std::string Regex::sub(StringRef Repl, StringRef String,
RefValue < Matches.size())
Res += Matches[RefValue];
else if (Error && Error->empty())
*Error = "invalid backreference string '" + Ref.str() + "'";
*Error = ("invalid backreference string '" + Twine(Ref) + "'").str();
break;
}
}

View File

@ -207,7 +207,7 @@ GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const {
SmallString<60> Name;
raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "JTI"
<< getFunctionNumber() << '_' << uid << '_' << uid2;
return OutContext.GetOrCreateSymbol(Name.str());
return OutContext.GetOrCreateSymbol(Name);
}
@ -216,7 +216,7 @@ MCSymbol *ARMAsmPrinter::GetARMSJLJEHLabel() const {
SmallString<60> Name;
raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "SJLJEH"
<< getFunctionNumber();
return OutContext.GetOrCreateSymbol(Name.str());
return OutContext.GetOrCreateSymbol(Name);
}
bool ARMAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
@ -597,7 +597,7 @@ void ARMAsmPrinter::emitAttributes() {
std::string ArchFS = ARM_MC::ParseARMTriple(TT, CPU);
if (!FS.empty()) {
if (!ArchFS.empty())
ArchFS = ArchFS + "," + FS.str();
ArchFS = (Twine(ArchFS) + "," + FS).str();
else
ArchFS = FS;
}

View File

@ -190,7 +190,7 @@ void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
ARM_MC::ParseARMTriple(TargetTriple.getTriple(), CPUString);
if (!FS.empty()) {
if (!ArchFS.empty())
ArchFS = ArchFS + "," + FS.str();
ArchFS = (Twine(ArchFS) + "," + FS).str();
else
ArchFS = FS;
}

View File

@ -255,7 +255,7 @@ MCSubtargetInfo *ARM_MC::createARMMCSubtargetInfo(StringRef TT, StringRef CPU,
std::string ArchFS = ARM_MC::ParseARMTriple(TT, CPU);
if (!FS.empty()) {
if (!ArchFS.empty())
ArchFS = ArchFS + "," + FS.str();
ArchFS = (Twine(ArchFS) + "," + FS).str();
else
ArchFS = FS;
}

View File

@ -72,7 +72,7 @@ HexagonSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
HexagonSubtarget::HexagonSubtarget(StringRef TT, StringRef CPU, StringRef FS,
const TargetMachine &TM)
: HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU.str()),
: HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU),
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
TSInfo(*TM.getDataLayout()), FrameLowering() {

View File

@ -62,7 +62,7 @@ GetJumpTableSymbol(const MachineOperand &MO) const {
}
// Create a symbol for the name.
return Ctx.GetOrCreateSymbol(Name.str());
return Ctx.GetOrCreateSymbol(Name);
}
MCSymbol *MSP430MCInstLower::
@ -79,7 +79,7 @@ GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
}
// Create a symbol for the name.
return Ctx.GetOrCreateSymbol(Name.str());
return Ctx.GetOrCreateSymbol(Name);
}
MCSymbol *MSP430MCInstLower::

View File

@ -2571,7 +2571,7 @@ bool MipsAsmParser::parseRelocOperand(const MCExpr *&Res) {
if (Tok.isNot(AsmToken::Identifier))
return true;
std::string Str = Tok.getIdentifier().str();
std::string Str = Tok.getIdentifier();
Parser.Lex(); // Eat the identifier.
// Now make an expression from the rest of the operand.

View File

@ -145,20 +145,20 @@ void NVPTXAsmPrinter::emitLineNumberAsDotLoc(const MachineInstr &MI) {
SmallString<128> FullPathName = dirName;
if (!dirName.empty() && !sys::path::is_absolute(fileName)) {
sys::path::append(FullPathName, fileName);
fileName = FullPathName.str();
fileName = FullPathName;
}
if (filenameMap.find(fileName.str()) == filenameMap.end())
if (filenameMap.find(fileName) == filenameMap.end())
return;
// Emit the line from the source file.
if (InterleaveSrc)
this->emitSrcInText(fileName.str(), curLoc.getLine());
this->emitSrcInText(fileName, curLoc.getLine());
std::stringstream temp;
temp << "\t.loc " << filenameMap[fileName.str()] << " " << curLoc.getLine()
temp << "\t.loc " << filenameMap[fileName] << " " << curLoc.getLine()
<< " " << curLoc.getCol();
OutStreamer.EmitRawText(Twine(temp.str().c_str()));
OutStreamer.EmitRawText(temp.str());
}
void NVPTXAsmPrinter::EmitInstruction(const MachineInstr *MI) {
@ -641,7 +641,7 @@ static bool usedInGlobalVarDef(const Constant *C) {
return false;
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
if (GV->getName().str() == "llvm.used")
if (GV->getName() == "llvm.used")
return false;
return true;
}
@ -656,7 +656,7 @@ static bool usedInGlobalVarDef(const Constant *C) {
static bool usedInOneFunc(const User *U, Function const *&oneFunc) {
if (const GlobalVariable *othergv = dyn_cast<GlobalVariable>(U)) {
if (othergv->getName().str() == "llvm.used")
if (othergv->getName() == "llvm.used")
return true;
}
@ -786,12 +786,12 @@ void NVPTXAsmPrinter::recordAndEmitFilenames(Module &M) {
SmallString<128> FullPathName = Dirname;
if (!Dirname.empty() && !sys::path::is_absolute(Filename)) {
sys::path::append(FullPathName, Filename);
Filename = FullPathName.str();
Filename = FullPathName;
}
if (filenameMap.find(Filename.str()) != filenameMap.end())
if (filenameMap.find(Filename) != filenameMap.end())
continue;
filenameMap[Filename.str()] = i;
OutStreamer.EmitDwarfFileDirective(i, "", Filename.str());
filenameMap[Filename] = i;
OutStreamer.EmitDwarfFileDirective(i, "", Filename);
++i;
}
@ -801,11 +801,11 @@ void NVPTXAsmPrinter::recordAndEmitFilenames(Module &M) {
SmallString<128> FullPathName = Dirname;
if (!Dirname.empty() && !sys::path::is_absolute(Filename)) {
sys::path::append(FullPathName, Filename);
Filename = FullPathName.str();
Filename = FullPathName;
}
if (filenameMap.find(Filename.str()) != filenameMap.end())
if (filenameMap.find(Filename) != filenameMap.end())
continue;
filenameMap[Filename.str()] = i;
filenameMap[Filename] = i;
++i;
}
}
@ -1011,7 +1011,7 @@ void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V,
msg.append("Error: ");
msg.append("Symbol ");
if (V->hasName())
msg.append(V->getName().str());
msg.append(V->getName());
msg.append("has unsupported appending linkage type");
llvm_unreachable(msg.c_str());
} else if (!V->hasInternalLinkage() &&
@ -1147,7 +1147,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
const Function *demotedFunc = nullptr;
if (!processDemoted && canDemoteGlobalVar(GVar, demotedFunc)) {
O << "// " << GVar->getName().str() << " has been demoted\n";
O << "// " << GVar->getName() << " has been demoted\n";
if (localDecls.find(demotedFunc) != localDecls.end())
localDecls[demotedFunc].push_back(GVar);
else {
@ -1195,9 +1195,10 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
// The frontend adds zero-initializer to variables that don't have an
// initial value, so skip warning for this case.
if (!GVar->getInitializer()->isNullValue()) {
std::string warnMsg = "initial value of '" + GVar->getName().str() +
"' is not allowed in addrspace(" +
llvm::utostr_32(PTy->getAddressSpace()) + ")";
std::string warnMsg =
("initial value of '" + GVar->getName() +
"' is not allowed in addrspace(" +
Twine(llvm::utostr_32(PTy->getAddressSpace())) + ")").str();
report_fatal_error(warnMsg.c_str());
}
}
@ -2086,7 +2087,7 @@ void NVPTXAsmPrinter::printMemOperand(const MachineInstr *MI, int opNum,
void NVPTXAsmPrinter::emitSrcInText(StringRef filename, unsigned line) {
std::stringstream temp;
LineReader *reader = this->getReader(filename.str());
LineReader *reader = this->getReader(filename);
temp << "\n//";
temp << filename.str();
temp << ":";
@ -2094,7 +2095,7 @@ void NVPTXAsmPrinter::emitSrcInText(StringRef filename, unsigned line) {
temp << " ";
temp << reader->readLine(line);
temp << "\n";
this->OutStreamer.EmitRawText(Twine(temp.str()));
this->OutStreamer.EmitRawText(temp.str());
}
LineReader *NVPTXAsmPrinter::getReader(std::string filename) {

View File

@ -104,7 +104,7 @@ void SITypeRewriter::visitCallInst(CallInst &I) {
SmallVector <Type*, 8> Types;
bool NeedToReplace = false;
Function *F = I.getCalledFunction();
std::string Name = F->getName().str();
std::string Name = F->getName();
for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i) {
Value *Arg = I.getArgOperand(i);
if (Arg->getType() == v16i8) {

View File

@ -2571,7 +2571,7 @@ bool X86AsmParser::MatchAndEmitATTInstruction(SMLoc IDLoc, unsigned &Opcode,
SmallString<16> Tmp;
Tmp += Base;
Tmp += ' ';
Op.setTokenValue(Tmp.str());
Op.setTokenValue(Tmp);
// If this instruction starts with an 'f', then it is a floating point stack
// instruction. These come in up to three forms for 32-bit, 64-bit, and