[clang] 7db641a - [clang] Don't call raw_string_ostream::flush() (NFC)
Youngsuk Kim via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 19 15:18:41 PDT 2024
Author: Youngsuk Kim
Date: 2024-09-19T17:18:10-05:00
New Revision: 7db641af13670aa1f1ecd3106eda3ce447afd752
URL: https://github.com/llvm/llvm-project/commit/7db641af13670aa1f1ecd3106eda3ce447afd752
DIFF: https://github.com/llvm/llvm-project/commit/7db641af13670aa1f1ecd3106eda3ce447afd752.diff
LOG: [clang] Don't call raw_string_ostream::flush() (NFC)
Don't call raw_string_ostream::flush(), which is essentially a no-op.
As specified in the docs, raw_string_ostream is always unbuffered
Added:
Modified:
clang/include/clang/AST/StmtDataCollectors.td
clang/lib/AST/DataCollection.cpp
clang/lib/AST/TemplateName.cpp
clang/lib/Basic/Module.cpp
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CodeGenPGO.cpp
clang/lib/Driver/Job.cpp
clang/lib/Driver/ToolChains/HIPUtility.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
clang/lib/Tooling/CommonOptionsParser.cpp
clang/lib/Tooling/Core/Replacement.cpp
clang/lib/Tooling/Refactoring/AtomicChange.cpp
clang/lib/Tooling/Transformer/Stencil.cpp
clang/unittests/Basic/SarifTest.cpp
clang/unittests/Frontend/TextDiagnosticTest.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/StmtDataCollectors.td b/clang/include/clang/AST/StmtDataCollectors.td
index 922dd2a20d59c2..abf4b5f34d3491 100644
--- a/clang/include/clang/AST/StmtDataCollectors.td
+++ b/clang/include/clang/AST/StmtDataCollectors.td
@@ -55,7 +55,6 @@ class CallExpr {
// Add a padding character so that 'foo<X, XX>()' != 'foo<XX, X>()'.
OS << '\n';
}
- OS.flush();
addData(ArgString);
}
diff --git a/clang/lib/AST/DataCollection.cpp b/clang/lib/AST/DataCollection.cpp
index d3f2c22e9cc3a8..786821ded98c39 100644
--- a/clang/lib/AST/DataCollection.cpp
+++ b/clang/lib/AST/DataCollection.cpp
@@ -41,7 +41,6 @@ std::string getMacroStack(SourceLocation Loc, ASTContext &Context) {
printMacroName(MacroStackStream, Context, Loc);
Loc = SM.getImmediateMacroCallerLoc(Loc);
}
- MacroStackStream.flush();
return MacroStack;
}
diff --git a/clang/lib/AST/TemplateName.cpp b/clang/lib/AST/TemplateName.cpp
index 044a1a92469aca..c27b07ad6c6f87 100644
--- a/clang/lib/AST/TemplateName.cpp
+++ b/clang/lib/AST/TemplateName.cpp
@@ -439,6 +439,5 @@ const StreamingDiagnostic &clang::operator<<(const StreamingDiagnostic &DB,
OS << '\'';
N.print(OS, PrintingPolicy(LO));
OS << '\'';
- OS.flush();
return DB << NameStr;
}
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 90b7b0d24bb6a0..fee372bce3a367 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -252,7 +252,6 @@ std::string Module::getFullModuleName(bool AllowStringLiterals) const {
llvm::raw_string_ostream Out(Result);
printModuleId(Out, Names.rbegin(), Names.rend(), AllowStringLiterals);
- Out.flush();
return Result;
}
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 8492e5ab73e183..fa49763e312f13 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -352,7 +352,6 @@ static std::string flattenClangCommandLine(ArrayRef<std::string> Args,
llvm::sys::printArg(OS, Arg, /*Quote=*/true);
PrintedOneArg = true;
}
- OS.flush();
return FlatCmdLine;
}
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 2bc0fe909efd14..b745ad37fc96b1 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -1134,7 +1134,6 @@ void CodeGenPGO::emitCounterRegionMapping(const Decl *D) {
*CGM.getCoverageMapping(), CGM.getContext().getSourceManager(),
CGM.getLangOpts(), RegionCounterMap.get(), RegionMCDCState.get());
MappingGen.emitCounterMapping(D, OS);
- OS.flush();
if (CoverageMapping.empty())
return;
@@ -1155,7 +1154,6 @@ CodeGenPGO::emitEmptyCounterMapping(const Decl *D, StringRef Name,
CGM.getContext().getSourceManager(),
CGM.getLangOpts());
MappingGen.emitEmptyMapping(D, OS);
- OS.flush();
if (CoverageMapping.empty())
return;
diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index a6c1581be79626..fe2f7242b04a51 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -343,7 +343,6 @@ int Command::Execute(ArrayRef<std::optional<StringRef>> Redirects,
writeResponseFile(SS);
buildArgvForResponseFile(Argv);
Argv.push_back(nullptr);
- SS.flush();
// Save the response file in the appropriate encoding
if (std::error_code EC = writeFileWithEncoding(
diff --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index 1b707376dea819..b3adfe65402ff3 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -446,7 +446,6 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
}
if (HostTriple.isOSLinux() && HostTriple.isOSBinFormatELF())
ObjStream << " .section .note.GNU-stack, \"\", @progbits\n";
- ObjStream.flush();
// Dump the contents of the temp object file gen if the user requested that.
// We support this option to enable testing of behavior with -###.
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 69d72412471809..6d7a57d7b5a41a 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -125,7 +125,6 @@ IdentifierInfo *Sema::InventAbbreviatedTemplateParameterTypeName(
else
OS << ParamName->getName() << ":auto";
- OS.flush();
return &Context.Idents.get(OS.str());
}
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index d2570119c3432d..af1dc21594da8a 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6559,7 +6559,6 @@ CheckFormatHandler::HandleInvalidConversionSpecifier(unsigned argIndex,
OS << "\\u" << llvm::format("%04x", CodePoint);
else
OS << "\\U" << llvm::format("%08x", CodePoint);
- OS.flush();
Specifier = CodePointStr;
}
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index d3d4bf27ae7283..76bfbdebdbbfff 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -4880,7 +4880,6 @@ void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
SmallVector<const IdentifierInfo *, 4> NewNameSpecifierIdentifiers;
getNestedNameSpecifierIdentifiers(NNS, NewNameSpecifierIdentifiers);
NNS->print(SpecifierOStream, Context.getPrintingPolicy());
- SpecifierOStream.flush();
SameNameSpecifier = NewNameSpecifier == CurNameSpecifier;
}
if (SameNameSpecifier || llvm::is_contained(CurContextIdentifiers, Name)) {
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 7d83b86a007337..cc095ae67ac400 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5128,7 +5128,6 @@ static bool CheckDeducedPlaceholderConstraints(Sema &S, const AutoType &Type,
Type.getTypeConstraintConcept()->getTemplateParameters());
}
OS << "'";
- OS.flush();
S.Diag(TypeLoc.getConceptNameLoc(),
diag::err_placeholder_constraints_not_satisfied)
<< Deduced << Buf << TypeLoc.getLocalSourceRange();
diff --git a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
index 524a4c43abf243..ef617f5715c370 100644
--- a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -669,7 +669,6 @@ void CheckerManager::runCheckersForEvalCall(ExplodedNodeSet &Dst,
std::string Buf;
llvm::raw_string_ostream OS(Buf);
Call.dump(OS);
- OS.flush();
return Buf;
};
std::string AssertionMessage = llvm::formatv(
diff --git a/clang/lib/Tooling/CommonOptionsParser.cpp b/clang/lib/Tooling/CommonOptionsParser.cpp
index 59ef47cc0166ef..c8c3ca98323e2a 100644
--- a/clang/lib/Tooling/CommonOptionsParser.cpp
+++ b/clang/lib/Tooling/CommonOptionsParser.cpp
@@ -114,7 +114,6 @@ llvm::Error CommonOptionsParser::init(
llvm::raw_string_ostream OS(ErrorMessage);
// Stop initializing if command-line option parsing failed.
if (!cl::ParseCommandLineOptions(argc, argv, Overview, &OS)) {
- OS.flush();
return llvm::make_error<llvm::StringError>(ErrorMessage,
llvm::inconvertibleErrorCode());
}
diff --git a/clang/lib/Tooling/Core/Replacement.cpp b/clang/lib/Tooling/Core/Replacement.cpp
index 9acf00263b5a8c..89a5b152442740 100644
--- a/clang/lib/Tooling/Core/Replacement.cpp
+++ b/clang/lib/Tooling/Core/Replacement.cpp
@@ -605,7 +605,6 @@ llvm::Expected<std::string> applyAllReplacements(StringRef Code,
std::string Result;
llvm::raw_string_ostream OS(Result);
Rewrite.getEditBuffer(ID).write(OS);
- OS.flush();
return Result;
}
diff --git a/clang/lib/Tooling/Refactoring/AtomicChange.cpp b/clang/lib/Tooling/Refactoring/AtomicChange.cpp
index 5bafe43aa92d6f..116f2a757a807c 100644
--- a/clang/lib/Tooling/Refactoring/AtomicChange.cpp
+++ b/clang/lib/Tooling/Refactoring/AtomicChange.cpp
@@ -235,7 +235,6 @@ std::string AtomicChange::toYAMLString() {
llvm::yaml::Output YAML(YamlContentStream);
YAML << *this;
- YamlContentStream.flush();
return YamlContent;
}
diff --git a/clang/lib/Tooling/Transformer/Stencil.cpp b/clang/lib/Tooling/Transformer/Stencil.cpp
index 223fb5a7689751..c39a71b5983fc3 100644
--- a/clang/lib/Tooling/Transformer/Stencil.cpp
+++ b/clang/lib/Tooling/Transformer/Stencil.cpp
@@ -75,7 +75,6 @@ class RawTextStencil : public StencilInterface {
OS << "\"";
OS.write_escaped(Text);
OS << "\"";
- OS.flush();
return Result;
}
diff --git a/clang/unittests/Basic/SarifTest.cpp b/clang/unittests/Basic/SarifTest.cpp
index e87f4fa47aab26..febfbabe8695e1 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -35,7 +35,6 @@ static std::string serializeSarifDocument(llvm::json::Object &&Doc) {
llvm::json::Value Value(std::move(Doc));
llvm::raw_string_ostream OS{Output};
OS << llvm::formatv("{0}", Value);
- OS.flush();
return Output;
}
diff --git a/clang/unittests/Frontend/TextDiagnosticTest.cpp b/clang/unittests/Frontend/TextDiagnosticTest.cpp
index 3acd89a985ab80..fef5726f053f15 100644
--- a/clang/unittests/Frontend/TextDiagnosticTest.cpp
+++ b/clang/unittests/Frontend/TextDiagnosticTest.cpp
@@ -30,7 +30,6 @@ static std::string PrintDiag(const DiagnosticOptions &Opts, FullSourceLoc Loc) {
// Emit a dummy diagnostic that is just 'message'.
Diag.emitDiagnostic(Loc, DiagnosticsEngine::Level::Warning, "message",
/*Ranges=*/{}, /*FixItHints=*/{});
- OS.flush();
return Out;
}
More information about the cfe-commits
mailing list