1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

Don't call utostr in Twine/raw_ostream contexts.

Creating temporary std::strings there is unnecessary.

llvm-svn: 238412
This commit is contained in:
Benjamin Kramer 2015-05-28 11:24:24 +00:00
parent b027528ed0
commit 5a56e44e39
5 changed files with 18 additions and 27 deletions

View File

@ -11,7 +11,6 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/StringExtras.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCAssembler.h"
@ -134,7 +133,7 @@ void MCWinCOFFStreamer::EmitCOFFSymbolStorageClass(int StorageClass) {
FatalError("storage class specified outside of symbol definition");
if (StorageClass & ~COFF::SSC_Invalid)
FatalError(Twine("storage class value '") + itostr(StorageClass) +
FatalError("storage class value '" + Twine(StorageClass) +
"' out of range");
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*CurSymbol);
@ -146,7 +145,7 @@ void MCWinCOFFStreamer::EmitCOFFSymbolType(int Type) {
FatalError("symbol type specified outside of a symbol definition");
if (Type & ~0xffff)
FatalError(Twine("type value '") + itostr(Type) + "' out of range");
FatalError("type value '" + Twine(Type) + "' out of range");
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*CurSymbol);
SD.modifyFlags(Type << COFF::SF_TypeShift, COFF::SF_TypeMask);

View File

@ -118,7 +118,7 @@ bool TGParser::SetValue(Record *CurRec, SMLoc Loc, Init *ValName,
for (unsigned i = 0, e = BitList.size(); i != e; ++i) {
unsigned Bit = BitList[i];
if (NewBits[Bit])
return Error(Loc, "Cannot set bit #" + utostr(Bit) + " of value '" +
return Error(Loc, "Cannot set bit #" + Twine(Bit) + " of value '" +
ValName->getAsUnquotedString() + "' more than once");
NewBits[Bit] = BInit->getBit(i);
}
@ -178,7 +178,7 @@ bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) {
} else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
return Error(SubClass.RefRange.Start,
"Value not specified for template argument #" +
utostr(i) + " (" + TArgs[i]->getAsUnquotedString() +
Twine(i) + " (" + TArgs[i]->getAsUnquotedString() +
") of subclass '" + SC->getNameInitAsString() + "'!");
}
}
@ -272,7 +272,7 @@ bool TGParser::AddSubMultiClass(MultiClass *CurMC,
} else if (!CurRec->getValue(SMCTArgs[i])->getValue()->isComplete()) {
return Error(SubMultiClass.RefRange.Start,
"Value not specified for template argument #" +
utostr(i) + " (" + SMCTArgs[i]->getAsUnquotedString() +
Twine(i) + " (" + SMCTArgs[i]->getAsUnquotedString() +
") of subclass '" + SMC->Rec.getNameInitAsString() + "'!");
}
}
@ -1296,7 +1296,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
// All other values must be convertible to just a single bit.
Init *Bit = Vals[i]->convertInitializerTo(BitRecTy::get());
if (!Bit) {
Error(BraceLoc, "Element #" + utostr(i) + " (" + Vals[i]->getAsString()+
Error(BraceLoc, "Element #" + Twine(i) + " (" + Vals[i]->getAsString() +
") is not convertable to a bit");
return nullptr;
}
@ -1315,11 +1315,8 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
if (ItemType) {
ListRecTy *ListType = dyn_cast<ListRecTy>(ItemType);
if (!ListType) {
std::string s;
raw_string_ostream ss(s);
ss << "Type mismatch for list, expected list type, got "
<< ItemType->getAsString();
TokError(ss.str());
TokError(Twine("Type mismatch for list, expected list type, got ") +
ItemType->getAsString());
return nullptr;
}
GivenListTy = ListType;
@ -2468,7 +2465,7 @@ bool TGParser::ResolveMulticlassDefArgs(MultiClass &MC,
} else if (!CurRec->getValue(TArgs[i])->getValue()->isComplete()) {
return Error(SubClassLoc, "value not specified for template argument #" +
utostr(i) + " (" + TArgs[i]->getAsUnquotedString() +
Twine(i) + " (" + TArgs[i]->getAsUnquotedString() +
") of multiclassclass '" + MC.Rec.getNameInitAsString() +
"'");
}

View File

@ -645,8 +645,7 @@ void CppWriter::printType(Type* Ty) {
if (DefinedTypes.find(Ty) == DefinedTypes.end()) {
std::string elemName(getCppName(ET));
Out << "ArrayType* " << typeName << " = ArrayType::get("
<< elemName
<< ", " << utostr(AT->getNumElements()) << ");";
<< elemName << ", " << AT->getNumElements() << ");";
nl(Out);
}
break;
@ -658,8 +657,7 @@ void CppWriter::printType(Type* Ty) {
if (DefinedTypes.find(Ty) == DefinedTypes.end()) {
std::string elemName(getCppName(ET));
Out << "PointerType* " << typeName << " = PointerType::get("
<< elemName
<< ", " << utostr(PT->getAddressSpace()) << ");";
<< elemName << ", " << PT->getAddressSpace() << ");";
nl(Out);
}
break;
@ -671,8 +669,7 @@ void CppWriter::printType(Type* Ty) {
if (DefinedTypes.find(Ty) == DefinedTypes.end()) {
std::string elemName(getCppName(ET));
Out << "VectorType* " << typeName << " = VectorType::get("
<< elemName
<< ", " << utostr(PT->getNumElements()) << ");";
<< elemName << ", " << PT->getNumElements() << ");";
nl(Out);
}
break;
@ -1029,7 +1026,7 @@ void CppWriter::printVariableHead(const GlobalVariable *GV) {
}
if (GV->getAlignment()) {
printCppName(GV);
Out << "->setAlignment(" << utostr(GV->getAlignment()) << ");";
Out << "->setAlignment(" << GV->getAlignment() << ");";
nl(Out);
}
if (GV->getVisibility() != GlobalValue::DefaultVisibility) {

View File

@ -1189,11 +1189,9 @@ 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() +
"' is not allowed in addrspace(" +
Twine(llvm::utostr_32(PTy->getAddressSpace())) + ")").str();
report_fatal_error(warnMsg.c_str());
report_fatal_error("initial value of '" + GVar->getName() +
"' is not allowed in addrspace(" +
Twine(PTy->getAddressSpace()) + ")");
}
}
}
@ -1368,7 +1366,7 @@ void NVPTXAsmPrinter::emitPTXGlobalVariable(const GlobalVariable *GVar,
ElementSize = TD->getTypeStoreSize(ETy);
O << " .b8 " << *getSymbol(GVar) << "[";
if (ElementSize) {
O << itostr(ElementSize);
O << ElementSize;
}
O << "]";
break;

View File

@ -774,7 +774,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
Idxs[1] = ConstantInt::get(Type::getInt32Ty(F->getContext()), i);
Value *Idx = GetElementPtrInst::Create(
STy, *AI, Idxs, (*AI)->getName() + "." + utostr(i), Call);
STy, *AI, Idxs, (*AI)->getName() + "." + Twine(i), Call);
// TODO: Tell AA about the new values?
Args.push_back(new LoadInst(Idx, Idx->getName()+".val", Call));
}