mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-21 14:56:57 +00:00
[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. ( 65b13610a5226b84889b923bae884ba395ad084d for further reference )
This commit is contained in:
parent
dc2d0d5e1a
commit
f5838cc17f
clang-tools-extra
clang-tidy/bugprone
clangd
AST.cppDiagnostics.cppFindSymbols.cppHover.cppPreamble.cppQuality.cppSystemIncludeExtractor.cpp
index
unittests
include-cleaner/unittests
modularize
@ -107,7 +107,6 @@ static std::string getNameOfNamespace(const CXXRecordDecl *Decl) {
|
||||
std::string Ns;
|
||||
llvm::raw_string_ostream OStream(Ns);
|
||||
NsDecl->printQualifiedName(OStream);
|
||||
OStream.flush();
|
||||
return Ns.empty() ? "(global)" : Ns;
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,6 @@ std::string printQualifiedName(const NamedDecl &ND) {
|
||||
// In clangd, context is usually available and paths are mostly noise.
|
||||
Policy.AnonymousTagLocations = false;
|
||||
ND.printQualifiedName(OS, Policy);
|
||||
OS.flush();
|
||||
assert(!StringRef(QName).starts_with("::"));
|
||||
return QName;
|
||||
}
|
||||
@ -270,7 +269,6 @@ std::string printTemplateSpecializationArgs(const NamedDecl &ND) {
|
||||
// location information.
|
||||
printTemplateArgumentList(OS, Cls->getTemplateArgs().asArray(), Policy);
|
||||
}
|
||||
OS.flush();
|
||||
return TemplateArgs;
|
||||
}
|
||||
|
||||
@ -303,7 +301,6 @@ std::string printObjCMethod(const ObjCMethodDecl &Method) {
|
||||
OS << ", ...";
|
||||
|
||||
OS << ']';
|
||||
OS.flush();
|
||||
return Name;
|
||||
}
|
||||
|
||||
@ -314,7 +311,6 @@ std::string printObjCContainer(const ObjCContainerDecl &C) {
|
||||
const ObjCInterfaceDecl *Class = Category->getClassInterface();
|
||||
OS << getNameOrErrForObjCInterface(Class) << '(' << Category->getName()
|
||||
<< ')';
|
||||
OS.flush();
|
||||
return Name;
|
||||
}
|
||||
if (const ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(&C)) {
|
||||
@ -322,7 +318,6 @@ std::string printObjCContainer(const ObjCContainerDecl &C) {
|
||||
llvm::raw_string_ostream OS(Name);
|
||||
const ObjCInterfaceDecl *Class = CID->getClassInterface();
|
||||
OS << getNameOrErrForObjCInterface(Class) << '(' << CID->getName() << ')';
|
||||
OS.flush();
|
||||
return Name;
|
||||
}
|
||||
return C.getNameAsString();
|
||||
|
@ -319,7 +319,6 @@ std::string mainMessage(const Diag &D, const ClangdDiagnosticOptions &Opts) {
|
||||
OS << "\n\n";
|
||||
printDiag(OS, Note);
|
||||
}
|
||||
OS.flush();
|
||||
return capitalize(std::move(Result));
|
||||
}
|
||||
|
||||
@ -335,7 +334,6 @@ std::string noteMessage(const Diag &Main, const DiagBase &Note,
|
||||
OS << "\n\n";
|
||||
printDiag(OS, Main);
|
||||
}
|
||||
OS.flush();
|
||||
return capitalize(std::move(Result));
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,6 @@ std::string getSymbolName(ASTContext &Ctx, const NamedDecl &ND) {
|
||||
OS << (Method->isInstanceMethod() ? '-' : '+');
|
||||
Method->getSelector().print(OS);
|
||||
|
||||
OS.flush();
|
||||
return Name;
|
||||
}
|
||||
return printName(Ctx, ND);
|
||||
|
@ -150,7 +150,6 @@ std::string printDefinition(const Decl *D, PrintingPolicy PP,
|
||||
std::string Definition;
|
||||
llvm::raw_string_ostream OS(Definition);
|
||||
D->print(OS, PP);
|
||||
OS.flush();
|
||||
return Definition;
|
||||
}
|
||||
|
||||
@ -179,7 +178,6 @@ HoverInfo::PrintedType printType(QualType QT, ASTContext &ASTCtx,
|
||||
OS << TT->getDecl()->getKindName() << " ";
|
||||
}
|
||||
QT.print(OS, PP);
|
||||
OS.flush();
|
||||
|
||||
const Config &Cfg = Config::current();
|
||||
if (!QT.isNull() && Cfg.Hover.ShowAKA) {
|
||||
@ -229,7 +227,6 @@ HoverInfo::PrintedType printType(const TemplateTemplateParmDecl *TTP,
|
||||
// FIXME: TemplateTemplateParameter doesn't store the info on whether this
|
||||
// param was a "typename" or "class".
|
||||
OS << "> class";
|
||||
OS.flush();
|
||||
return Result;
|
||||
}
|
||||
|
||||
@ -821,7 +818,6 @@ std::string typeAsDefinition(const HoverInfo::PrintedType &PType) {
|
||||
OS << PType.Type;
|
||||
if (PType.AKA)
|
||||
OS << " // aka: " << *PType.AKA;
|
||||
OS.flush();
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
@ -913,7 +913,6 @@ PreamblePatch PreamblePatch::create(llvm::StringRef FileName,
|
||||
PP.PatchedMarks = std::move(ModifiedScan->Marks);
|
||||
PP.PatchedMacros = std::move(ModifiedScan->Macros);
|
||||
dlog("Created preamble patch: {0}", Patch.str());
|
||||
Patch.flush();
|
||||
return PP;
|
||||
}
|
||||
|
||||
|
@ -554,7 +554,6 @@ std::string sortText(float Score, llvm::StringRef Name) {
|
||||
llvm::write_hex(OS, encodeFloat(-Score), llvm::HexPrintStyle::Lower,
|
||||
/*Width=*/2 * sizeof(Score));
|
||||
OS << Name;
|
||||
OS.flush();
|
||||
return S;
|
||||
}
|
||||
|
||||
|
@ -483,7 +483,6 @@ std::string convertGlobToRegex(llvm::StringRef Glob) {
|
||||
}
|
||||
}
|
||||
RegStream << '$';
|
||||
RegStream.flush();
|
||||
return RegText;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,6 @@ std::string buildUmbrella(llvm::StringLiteral Mandatory,
|
||||
"#endif\n",
|
||||
Header);
|
||||
}
|
||||
OS.flush();
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,6 @@ const NamedDecl &findDeclWithTemplateArgs(ParsedAST &AST,
|
||||
// Use getNameForDiagnostic() which includes the template
|
||||
// arguments in the printed name.
|
||||
ND.getNameForDiagnostic(OS, Policy, /*Qualified=*/true);
|
||||
OS.flush();
|
||||
return QName == Query;
|
||||
});
|
||||
}
|
||||
|
@ -546,7 +546,6 @@ TEST_F(PragmaIncludeTest, IWYUExportBlock) {
|
||||
for (auto &FE : FEs) {
|
||||
OS << FE.getName() << " ";
|
||||
}
|
||||
OS.flush();
|
||||
return Result;
|
||||
};
|
||||
auto Exporters = PI.getExporters(FM.getFile("private1.h").get(), FM);
|
||||
|
@ -621,7 +621,6 @@ public:
|
||||
std::string Name;
|
||||
llvm::raw_string_ostream OS(Name);
|
||||
ND->printQualifiedName(OS);
|
||||
OS.flush();
|
||||
if (Name.empty())
|
||||
return true;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user