[llvm] Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.
This commit is contained in:
Kazu Hirata 2021-01-12 21:43:46 -08:00
parent 5f9a319f66
commit dfbe37a54f
17 changed files with 26 additions and 26 deletions

View File

@ -114,10 +114,10 @@ struct Config {
std::string SplitDwarfOutput;
/// Optimization remarks file path.
std::string RemarksFilename = "";
std::string RemarksFilename;
/// Optimization remarks pass filter.
std::string RemarksPasses = "";
std::string RemarksPasses;
/// Whether to emit optimization remarks with hotness informations.
bool RemarksWithHotness = false;
@ -138,7 +138,7 @@ struct Config {
llvm::Optional<uint64_t> RemarksHotnessThreshold = 0;
/// The format used for serializing remarks (default: YAML).
std::string RemarksFormat = "";
std::string RemarksFormat;
/// Whether to emit the pass manager debuggging informations.
bool DebugPassManager = false;

View File

@ -196,7 +196,7 @@ struct DOTGraphTraits<CallGraphDOTInfo *> : public DefaultDOTGraphTraits {
Function *F = Node->getFunction();
if (F == nullptr)
return "";
std::string attrs = "";
std::string attrs;
if (ShowHeatColors) {
uint64_t freq = CGInfo->getFreq(F);
std::string color = getHeatColor(freq, CGInfo->getMaxFreq());

View File

@ -116,7 +116,7 @@ void ConstraintSystem::dump(ArrayRef<std::string> Names) const {
for (unsigned I = 1, S = Row.size(); I < S; ++I) {
if (Row[I] == 0)
continue;
std::string Coefficient = "";
std::string Coefficient;
if (Row[I] != 1)
Coefficient = std::to_string(Row[I]) + " * ";
Parts.push_back(Coefficient + Names[I - 1]);

View File

@ -41,7 +41,7 @@ static cl::opt<std::string>
cl::desc("Record GlobalISel rule coverage files of this "
"prefix if instrumentation was generated"));
#else
static const std::string CoveragePrefix = "";
static const std::string CoveragePrefix;
#endif
char InstructionSelect::ID = 0;

View File

@ -917,7 +917,7 @@ MCSection *TargetLoweringObjectFileELF::getSectionForMachineBasicBlock(
}
unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_EXECINSTR;
std::string GroupName = "";
std::string GroupName;
if (F.hasComdat()) {
Flags |= ELF::SHF_GROUP;
GroupName = F.getComdat()->getName().str();

View File

@ -352,7 +352,7 @@ private:
RemainingExpr = RemainingExpr.substr(1).ltrim();
uint64_t StubAddr;
std::string ErrorMsg = "";
std::string ErrorMsg;
std::tie(StubAddr, ErrorMsg) = Checker.getStubOrGOTAddrFor(
StubContainerName, Symbol, PCtx.IsInsideLoad, IsStubAddr);
@ -389,7 +389,7 @@ private:
RemainingExpr = RemainingExpr.substr(1).ltrim();
uint64_t StubAddr;
std::string ErrorMsg = "";
std::string ErrorMsg;
std::tie(StubAddr, ErrorMsg) = Checker.getSectionAddr(
FileName, SectionName, PCtx.IsInsideLoad);

View File

@ -150,7 +150,7 @@ private:
class TypeInfoForMF {
/// MachineFunction name is used to recognise when MF changes.
std::string MFName = "";
std::string MFName;
/// <key, value> : value is vector of all MachineInstrs that are waiting for
/// key to figure out type of some of its ambiguous operands.
DenseMap<const MachineInstr *, SmallVector<const MachineInstr *, 2>>

View File

@ -2459,7 +2459,7 @@ template <> struct DOTGraphTraits<AADepGraph *> : public DefaultDOTGraphTraits {
static std::string getNodeLabel(const AADepGraphNode *Node,
const AADepGraph *DG) {
std::string AAString = "";
std::string AAString;
raw_string_ostream O(AAString);
Node->print(O);
return AAString;

View File

@ -1596,7 +1596,7 @@ public:
write(StringRef(Intrinsic::getName(II->getIntrinsicID(), {}))
.drop_front(StringRef("llvm.matrix.").size()));
write(".");
std::string Tmp = "";
std::string Tmp;
raw_string_ostream SS(Tmp);
switch (II->getIntrinsicID()) {

View File

@ -248,7 +248,7 @@ const char *ReportTitleTag = "h2";
const char *CreatedTimeTag = "h4";
std::string getPathToStyle(StringRef ViewPath) {
std::string PathToStyle = "";
std::string PathToStyle;
std::string PathSep = std::string(sys::path::get_separator());
unsigned NumSeps = ViewPath.count(PathSep);
for (unsigned I = 0, E = NumSeps; I < E; ++I)
@ -617,7 +617,7 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
void SourceCoverageViewHTML::renderLineCoverageColumn(
raw_ostream &OS, const LineCoverageStats &Line) {
std::string Count = "";
std::string Count;
if (Line.isMapped())
Count = tag("pre", formatCount(Line.getExecutionCount()));
std::string CoverageClass =

View File

@ -384,7 +384,7 @@ int main(int argc, char *argv[]) {
IFSStub Stub;
std::map<std::string, IFSSymbol> SymbolMap;
std::string PreviousInputFilePath = "";
std::string PreviousInputFilePath;
for (const std::string &InputFilePath : InputFilenames) {
Expected<std::unique_ptr<IFSStub>> StubOrErr = readInputFile(InputFilePath);
if (!StubOrErr) {

View File

@ -2395,7 +2395,7 @@ void objdump::parseInputMachO(MachOUniversalBinary *UB) {
ArchFound = true;
Expected<std::unique_ptr<ObjectFile>> ObjOrErr =
I->getAsObjectFile();
std::string ArchitectureName = "";
std::string ArchitectureName;
if (ArchFlags.size() > 1)
ArchitectureName = I->getArchFlagName();
if (ObjOrErr) {
@ -2511,7 +2511,7 @@ void objdump::parseInputMachO(MachOUniversalBinary *UB) {
E = UB->end_objects();
I != E; ++I) {
Expected<std::unique_ptr<ObjectFile>> ObjOrErr = I->getAsObjectFile();
std::string ArchitectureName = "";
std::string ArchitectureName;
if (moreThanOneArch)
ArchitectureName = I->getArchFlagName();
if (ObjOrErr) {

View File

@ -873,7 +873,7 @@ bool TreePredicateFn::hasPredCode() const {
}
std::string TreePredicateFn::getPredCode() const {
std::string Code = "";
std::string Code;
if (!isLoad() && !isStore() && !isAtomic()) {
Record *MemoryVT = getMemoryVT();

View File

@ -472,7 +472,7 @@ HasOneImplicitDefWithKnownVT(const CodeGenTarget &TargetInfo) const {
/// include text from the specified variant, returning the new string.
std::string CodeGenInstruction::
FlattenAsmStringVariants(StringRef Cur, unsigned Variant) {
std::string Res = "";
std::string Res;
for (;;) {
// Find the start of the next variant string.

View File

@ -374,7 +374,7 @@ unsigned MapTableEmitter::emitBinSearchTable(raw_ostream &OS) {
for (unsigned i = 0; i < TotalNumInstr; i++) {
Record *CurInstr = NumberedInstructions[i]->TheDef;
std::vector<Record*> ColInstrs = MapTable[CurInstr];
std::string OutStr("");
std::string OutStr;
unsigned RelExists = 0;
if (!ColInstrs.empty()) {
for (unsigned j = 0; j < NumCol; j++) {

View File

@ -201,7 +201,7 @@ static Optional<LLTCodeGen> MVTToLLT(MVT::SimpleValueType SVT) {
}
static std::string explainPredicates(const TreePatternNode *N) {
std::string Explanation = "";
std::string Explanation;
StringRef Separator = "";
for (const TreePredicateCall &Call : N->getPredicateCalls()) {
const TreePredicateFn &P = Call.Fn;
@ -305,8 +305,8 @@ static Error failedImport(const Twine &Reason) {
}
static Error isTrivialOperatorNode(const TreePatternNode *N) {
std::string Explanation = "";
std::string Separator = "";
std::string Explanation;
std::string Separator;
bool HasUnsupportedPredicate = false;
for (const TreePredicateCall &Call : N->getPredicateCalls()) {

View File

@ -635,10 +635,10 @@ void RISCVCompressInstEmitter::emitCompressInstEmitter(raw_ostream &o,
return;
}
std::string CaseString("");
std::string CaseString;
raw_string_ostream CaseStream(CaseString);
std::string PrevOp("");
std::string CurOp("");
std::string PrevOp;
std::string CurOp;
CaseStream << " switch (MI.getOpcode()) {\n";
CaseStream << " default: return false;\n";