Skip to content

[llvm] Avoid 'raw_string_ostream::str()' (NFC) #96995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/ADT/FloatingPointMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ struct DenormalMode {
std::string storage;
raw_string_ostream OS(storage);
print(OS);
return OS.str();
return storage;
}
};

Expand Down
10 changes: 4 additions & 6 deletions llvm/include/llvm/Analysis/CFGPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ std::string SimpleNodeLabelString(const BasicBlockT *Node) {
raw_string_ostream OS(Str);

Node->printAsOperand(OS, false);
return OS.str();
return Str;
}

template <typename BasicBlockT>
Expand All @@ -145,10 +145,9 @@ std::string CompleteNodeLabelString(
HandleComment) {

enum { MaxColumns = 80 };
std::string Str;
raw_string_ostream OS(Str);
std::string OutStr;
raw_string_ostream OS(OutStr);
HandleBasicBlock(OS, *Node);
std::string OutStr = OS.str();
// Remove "%" from BB name
if (OutStr[0] == '%') {
OutStr.erase(OutStr.begin());
Expand Down Expand Up @@ -247,7 +246,7 @@ struct DOTGraphTraits<DOTFuncInfo *> : public DefaultDOTGraphTraits {
raw_string_ostream OS(Str);
auto Case = *SwitchInst::ConstCaseIt::fromSuccessorIndex(SI, SuccNo);
OS << Case.getCaseValue()->getValue();
return OS.str();
return Str;
}
return "";
}
Expand All @@ -257,7 +256,6 @@ struct DOTGraphTraits<DOTFuncInfo *> : public DefaultDOTGraphTraits {
if (NodeName.empty()) {
raw_string_ostream NodeOS(NodeName);
Node->printAsOperand(NodeOS, false);
NodeName = NodeOS.str();
// Removing %
NodeName.erase(NodeName.begin());
}
Expand Down
8 changes: 4 additions & 4 deletions llvm/include/llvm/Analysis/DDG.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,16 @@ DependenceGraphInfo<NodeType>::getDependenceString(const NodeType &Src,
raw_string_ostream OS(Str);
DependenceList Deps;
if (!getDependencies(Src, Dst, Deps))
return OS.str();
return Str;
interleaveComma(Deps, OS, [&](const std::unique_ptr<Dependence> &D) {
D->dump(OS);
// Remove the extra new-line character printed by the dump
// method
if (OS.str().back() == '\n')
OS.str().pop_back();
if (Str.back() == '\n')
Str.pop_back();
});

return OS.str();
return Str;
}

//===--------------------------------------------------------------------===//
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/DebugInfo/LogicalView/Core/LVSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ inline std::string hexString(uint64_t Value, size_t Width = HEX_WIDTH) {
std::string String;
raw_string_ostream Stream(String);
Stream << hexValue(Value, Width, false);
return Stream.str();
return String;
}

// Get a hexadecimal string representation for the given value.
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/IR/ModuleSummaryIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ class FunctionSummary : public GlobalValueSummary {
OS << ", hasUnknownCall: " << this->HasUnknownCall;
OS << ", mustBeUnreachable: " << this->MustBeUnreachable;
OS << ")";
return OS.str();
return Output;
}
};

Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Object/MachO.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ class MachOObjectFile : public ObjectFile {
std::string ret;
raw_string_ostream ss(ret);
ss << format_hex(platform, 8, true);
return ss.str();
return ret;
}
}

Expand All @@ -814,7 +814,7 @@ class MachOObjectFile : public ObjectFile {
std::string ret;
raw_string_ostream ss(ret);
ss << format_hex(tools, 8, true);
return ss.str();
return ret;
}
}

Expand Down
Loading