Skip to content

Commit f5838cc

Browse files
committed
[clang-tools-extra] Don't flush llvm::raw_string_ostream (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. ( 65b1361 for further reference )
1 parent dc2d0d5 commit f5838cc

File tree

12 files changed

+0
-20
lines changed

12 files changed

+0
-20
lines changed

clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ static std::string getNameOfNamespace(const CXXRecordDecl *Decl) {
107107
std::string Ns;
108108
llvm::raw_string_ostream OStream(Ns);
109109
NsDecl->printQualifiedName(OStream);
110-
OStream.flush();
111110
return Ns.empty() ? "(global)" : Ns;
112111
}
113112

clang-tools-extra/clangd/AST.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ std::string printQualifiedName(const NamedDecl &ND) {
187187
// In clangd, context is usually available and paths are mostly noise.
188188
Policy.AnonymousTagLocations = false;
189189
ND.printQualifiedName(OS, Policy);
190-
OS.flush();
191190
assert(!StringRef(QName).starts_with("::"));
192191
return QName;
193192
}
@@ -270,7 +269,6 @@ std::string printTemplateSpecializationArgs(const NamedDecl &ND) {
270269
// location information.
271270
printTemplateArgumentList(OS, Cls->getTemplateArgs().asArray(), Policy);
272271
}
273-
OS.flush();
274272
return TemplateArgs;
275273
}
276274

@@ -303,7 +301,6 @@ std::string printObjCMethod(const ObjCMethodDecl &Method) {
303301
OS << ", ...";
304302

305303
OS << ']';
306-
OS.flush();
307304
return Name;
308305
}
309306

@@ -314,15 +311,13 @@ std::string printObjCContainer(const ObjCContainerDecl &C) {
314311
const ObjCInterfaceDecl *Class = Category->getClassInterface();
315312
OS << getNameOrErrForObjCInterface(Class) << '(' << Category->getName()
316313
<< ')';
317-
OS.flush();
318314
return Name;
319315
}
320316
if (const ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(&C)) {
321317
std::string Name;
322318
llvm::raw_string_ostream OS(Name);
323319
const ObjCInterfaceDecl *Class = CID->getClassInterface();
324320
OS << getNameOrErrForObjCInterface(Class) << '(' << CID->getName() << ')';
325-
OS.flush();
326321
return Name;
327322
}
328323
return C.getNameAsString();

clang-tools-extra/clangd/Diagnostics.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ std::string mainMessage(const Diag &D, const ClangdDiagnosticOptions &Opts) {
319319
OS << "\n\n";
320320
printDiag(OS, Note);
321321
}
322-
OS.flush();
323322
return capitalize(std::move(Result));
324323
}
325324

@@ -335,7 +334,6 @@ std::string noteMessage(const Diag &Main, const DiagBase &Note,
335334
OS << "\n\n";
336335
printDiag(OS, Main);
337336
}
338-
OS.flush();
339337
return capitalize(std::move(Result));
340338
}
341339

clang-tools-extra/clangd/FindSymbols.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ std::string getSymbolName(ASTContext &Ctx, const NamedDecl &ND) {
182182
OS << (Method->isInstanceMethod() ? '-' : '+');
183183
Method->getSelector().print(OS);
184184

185-
OS.flush();
186185
return Name;
187186
}
188187
return printName(Ctx, ND);

clang-tools-extra/clangd/Hover.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ std::string printDefinition(const Decl *D, PrintingPolicy PP,
150150
std::string Definition;
151151
llvm::raw_string_ostream OS(Definition);
152152
D->print(OS, PP);
153-
OS.flush();
154153
return Definition;
155154
}
156155

@@ -179,7 +178,6 @@ HoverInfo::PrintedType printType(QualType QT, ASTContext &ASTCtx,
179178
OS << TT->getDecl()->getKindName() << " ";
180179
}
181180
QT.print(OS, PP);
182-
OS.flush();
183181

184182
const Config &Cfg = Config::current();
185183
if (!QT.isNull() && Cfg.Hover.ShowAKA) {
@@ -229,7 +227,6 @@ HoverInfo::PrintedType printType(const TemplateTemplateParmDecl *TTP,
229227
// FIXME: TemplateTemplateParameter doesn't store the info on whether this
230228
// param was a "typename" or "class".
231229
OS << "> class";
232-
OS.flush();
233230
return Result;
234231
}
235232

@@ -821,7 +818,6 @@ std::string typeAsDefinition(const HoverInfo::PrintedType &PType) {
821818
OS << PType.Type;
822819
if (PType.AKA)
823820
OS << " // aka: " << *PType.AKA;
824-
OS.flush();
825821
return Result;
826822
}
827823

clang-tools-extra/clangd/Preamble.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,6 @@ PreamblePatch PreamblePatch::create(llvm::StringRef FileName,
913913
PP.PatchedMarks = std::move(ModifiedScan->Marks);
914914
PP.PatchedMacros = std::move(ModifiedScan->Macros);
915915
dlog("Created preamble patch: {0}", Patch.str());
916-
Patch.flush();
917916
return PP;
918917
}
919918

clang-tools-extra/clangd/Quality.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,6 @@ std::string sortText(float Score, llvm::StringRef Name) {
554554
llvm::write_hex(OS, encodeFloat(-Score), llvm::HexPrintStyle::Lower,
555555
/*Width=*/2 * sizeof(Score));
556556
OS << Name;
557-
OS.flush();
558557
return S;
559558
}
560559

clang-tools-extra/clangd/SystemIncludeExtractor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ std::string convertGlobToRegex(llvm::StringRef Glob) {
483483
}
484484
}
485485
RegStream << '$';
486-
RegStream.flush();
487486
return RegText;
488487
}
489488

clang-tools-extra/clangd/index/StdLib.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ std::string buildUmbrella(llvm::StringLiteral Mandatory,
8787
"#endif\n",
8888
Header);
8989
}
90-
OS.flush();
9190
return Result;
9291
}
9392

clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ const NamedDecl &findDeclWithTemplateArgs(ParsedAST &AST,
242242
// Use getNameForDiagnostic() which includes the template
243243
// arguments in the printed name.
244244
ND.getNameForDiagnostic(OS, Policy, /*Qualified=*/true);
245-
OS.flush();
246245
return QName == Query;
247246
});
248247
}

clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ TEST_F(PragmaIncludeTest, IWYUExportBlock) {
546546
for (auto &FE : FEs) {
547547
OS << FE.getName() << " ";
548548
}
549-
OS.flush();
550549
return Result;
551550
};
552551
auto Exporters = PI.getExporters(FM.getFile("private1.h").get(), FM);

clang-tools-extra/modularize/Modularize.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,6 @@ class CollectEntitiesVisitor
621621
std::string Name;
622622
llvm::raw_string_ostream OS(Name);
623623
ND->printQualifiedName(OS);
624-
OS.flush();
625624
if (Name.empty())
626625
return true;
627626

0 commit comments

Comments
 (0)