logan-5 updated this revision to Diff 393262. logan-5 added a comment. Removed `.flush()`es. Seems like this might be able to land without https://reviews.llvm.org/D115421?
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D115374/new/ https://reviews.llvm.org/D115374 Files: clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h clang/include/clang/Testing/TestClangConfig.h clang/lib/AST/ASTDiagnostic.cpp clang/lib/AST/AttrImpl.cpp clang/lib/AST/Decl.cpp clang/lib/AST/DeclarationName.cpp clang/lib/AST/OpenMPClause.cpp clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp clang/lib/Analysis/AnalysisDeclContext.cpp clang/lib/Basic/SourceLocation.cpp clang/lib/Basic/Version.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/TestModuleFileExtension.cpp clang/lib/Rewrite/HTMLRewrite.cpp clang/lib/Sema/CodeCompleteConsumer.cpp clang/lib/Sema/SemaAttr.cpp clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp clang/lib/StaticAnalyzer/Core/MemRegion.cpp clang/lib/Tooling/Syntax/Tokens.cpp clang/lib/Tooling/Syntax/Tree.cpp clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp clang/unittests/AST/ASTTraverserTest.cpp clang/unittests/Analysis/MacroExpansionContextTest.cpp clang/unittests/Tooling/Syntax/TreeTest.cpp
Index: clang/unittests/Tooling/Syntax/TreeTest.cpp =================================================================== --- clang/unittests/Tooling/Syntax/TreeTest.cpp +++ clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -203,7 +203,7 @@ OS << "]"; - return OS.str(); + return Storage; } std::string dumpNodes(ArrayRef<Node *> Nodes) { @@ -218,7 +218,7 @@ OS << "]"; - return OS.str(); + return Storage; } }; Index: clang/unittests/Analysis/MacroExpansionContextTest.cpp =================================================================== --- clang/unittests/Analysis/MacroExpansionContextTest.cpp +++ clang/unittests/Analysis/MacroExpansionContextTest.cpp @@ -95,14 +95,14 @@ std::string Buf; llvm::raw_string_ostream OS{Buf}; Ctx.dumpExpandedTextsToStream(OS); - return OS.str(); + return Buf; } static std::string dumpExpansionRanges(const MacroExpansionContext &Ctx) { std::string Buf; llvm::raw_string_ostream OS{Buf}; Ctx.dumpExpansionRangesToStream(OS); - return OS.str(); + return Buf; } }; Index: clang/unittests/AST/ASTTraverserTest.cpp =================================================================== --- clang/unittests/AST/ASTTraverserTest.cpp +++ clang/unittests/AST/ASTTraverserTest.cpp @@ -111,7 +111,7 @@ Dumper.Visit(std::forward<NodeType &&>(N)...); - return OS.str(); + return Buffer; } template <typename... NodeType> @@ -126,7 +126,7 @@ Dumper.Visit(std::forward<NodeType &&>(N)...); - return OS.str(); + return Buffer; } const FunctionDecl *getFunctionNode(clang::ASTUnit *AST, Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp =================================================================== --- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp +++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp @@ -139,7 +139,7 @@ Passes.run(*M); - return OS.str(); + return outString; } // Takes a function and runs it on a set of inputs Index: clang/lib/Tooling/Syntax/Tree.cpp =================================================================== --- clang/lib/Tooling/Syntax/Tree.cpp +++ clang/lib/Tooling/Syntax/Tree.cpp @@ -263,7 +263,7 @@ OS << " "; } }); - return OS.str(); + return Storage; } void syntax::Node::assertInvariants() const { Index: clang/lib/Tooling/Syntax/Tokens.cpp =================================================================== --- clang/lib/Tooling/Syntax/Tokens.cpp +++ clang/lib/Tooling/Syntax/Tokens.cpp @@ -927,5 +927,5 @@ M.EndExpanded); } } - return OS.str(); + return Dump; } Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/MemRegion.cpp +++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -444,7 +444,7 @@ std::string s; llvm::raw_string_ostream os(s); dumpToStream(os); - return os.str(); + return s; } void MemRegion::dumpToStream(raw_ostream &os) const { Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -437,7 +437,7 @@ for (auto BI : *Buf) os << BI; - return os.str(); + return file; } void HTMLDiagnostics::dumpCoverageData( @@ -534,7 +534,7 @@ </form> )<<<"; - return os.str(); + return s; } void HTMLDiagnostics::FinalizeHTML(const PathDiagnostic& D, Rewriter &R, @@ -1200,9 +1200,9 @@ std::string getSpanBeginForControl(const char *ClassName, unsigned Index) { std::string Result; - llvm::raw_string_ostream OS(Result); - OS << "<span id=\"" << ClassName << Index << "\">"; - return OS.str(); + llvm::raw_string_ostream(Result) + << "<span id=\"" << ClassName << Index << "\">"; + return Result; } std::string getSpanBeginForControlStart(unsigned Index) { Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp @@ -386,10 +386,10 @@ auto *PathBR = static_cast<PathSensitiveBugReport *>(&BR); if (auto IsInteresting = PathBR->getInterestingnessKind(RetSym)) { std::string SBuf; - llvm::raw_string_ostream OS(SBuf); - OS << "Function '" << FuncDecl->getDeclName() - << "' returns an open handle"; - return OS.str(); + llvm::raw_string_ostream(SBuf) + << "Function '" << FuncDecl->getDeclName() + << "' returns an open handle"; + return SBuf; } else return ""; }); @@ -402,10 +402,10 @@ auto *PathBR = static_cast<PathSensitiveBugReport *>(&BR); if (auto IsInteresting = PathBR->getInterestingnessKind(RetSym)) { std::string SBuf; - llvm::raw_string_ostream OS(SBuf); - OS << "Function '" << FuncDecl->getDeclName() - << "' returns an unowned handle"; - return OS.str(); + llvm::raw_string_ostream(SBuf) + << "Function '" << FuncDecl->getDeclName() + << "' returns an unowned handle"; + return SBuf; } else return ""; }); @@ -436,10 +436,10 @@ auto *PathBR = static_cast<PathSensitiveBugReport *>(&BR); if (auto IsInteresting = PathBR->getInterestingnessKind(Handle)) { std::string SBuf; - llvm::raw_string_ostream OS(SBuf); - OS << "Handle released through " << ParamDiagIdx - << llvm::getOrdinalSuffix(ParamDiagIdx) << " parameter"; - return OS.str(); + llvm::raw_string_ostream(SBuf) + << "Handle released through " << ParamDiagIdx + << llvm::getOrdinalSuffix(ParamDiagIdx) << " parameter"; + return SBuf; } else return ""; }); @@ -450,10 +450,10 @@ auto *PathBR = static_cast<PathSensitiveBugReport *>(&BR); if (auto IsInteresting = PathBR->getInterestingnessKind(Handle)) { std::string SBuf; - llvm::raw_string_ostream OS(SBuf); - OS << "Handle allocated through " << ParamDiagIdx - << llvm::getOrdinalSuffix(ParamDiagIdx) << " parameter"; - return OS.str(); + llvm::raw_string_ostream(SBuf) + << "Handle allocated through " << ParamDiagIdx + << llvm::getOrdinalSuffix(ParamDiagIdx) << " parameter"; + return SBuf; } else return ""; }); @@ -464,10 +464,10 @@ auto *PathBR = static_cast<PathSensitiveBugReport *>(&BR); if (auto IsInteresting = PathBR->getInterestingnessKind(Handle)) { std::string SBuf; - llvm::raw_string_ostream OS(SBuf); - OS << "Unowned handle allocated through " << ParamDiagIdx - << llvm::getOrdinalSuffix(ParamDiagIdx) << " parameter"; - return OS.str(); + llvm::raw_string_ostream(SBuf) + << "Unowned handle allocated through " << ParamDiagIdx + << llvm::getOrdinalSuffix(ParamDiagIdx) << " parameter"; + return SBuf; } else return ""; }); Index: clang/lib/Sema/SemaAttr.cpp =================================================================== --- clang/lib/Sema/SemaAttr.cpp +++ clang/lib/Sema/SemaAttr.cpp @@ -792,7 +792,7 @@ OS << (I.index() == Rules.size() - 1 ? ", and " : ", "); OS << "'" << attr::getSubjectMatchRuleSpelling(I.value()) << "'"; } - return OS.str(); + return Result; } } // end anonymous namespace Index: clang/lib/Sema/CodeCompleteConsumer.cpp =================================================================== --- clang/lib/Sema/CodeCompleteConsumer.cpp +++ clang/lib/Sema/CodeCompleteConsumer.cpp @@ -335,7 +335,7 @@ break; } } - return OS.str(); + return Result; } const char *CodeCompletionString::getTypedText() const { @@ -640,7 +640,7 @@ break; } } - return OS.str(); + return Result; } void PrintingCodeCompleteConsumer::ProcessOverloadCandidates( Index: clang/lib/Rewrite/HTMLRewrite.cpp =================================================================== --- clang/lib/Rewrite/HTMLRewrite.cpp +++ clang/lib/Rewrite/HTMLRewrite.cpp @@ -202,8 +202,7 @@ case '&': os << "&"; break; } } - - return os.str(); + return Str; } static void AddLineNumber(RewriteBuffer &RB, unsigned LineNo, Index: clang/lib/Frontend/TestModuleFileExtension.cpp =================================================================== --- clang/lib/Frontend/TestModuleFileExtension.cpp +++ clang/lib/Frontend/TestModuleFileExtension.cpp @@ -130,8 +130,8 @@ std::string TestModuleFileExtension::str() const { std::string Buffer; - llvm::raw_string_ostream OS(Buffer); - OS << BlockName << ":" << MajorVersion << ":" << MinorVersion << ":" << Hashed - << ":" << UserInfo; - return OS.str(); + llvm::raw_string_ostream(Buffer) + << BlockName << ":" << MajorVersion << ":" << MinorVersion << ":" + << Hashed << ":" << UserInfo; + return Buffer; } Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -1285,7 +1285,7 @@ std::string Buffer; llvm::raw_string_ostream OS(Buffer); llvm::interleave(BundleParts, OS, [&OS](StringRef Part) { OS << Part; }, ","); - return OS.str(); + return Buffer; } // Set the profile kind using fprofile-instrument-use-path. Index: clang/lib/Basic/Version.cpp =================================================================== --- clang/lib/Basic/Version.cpp +++ clang/lib/Basic/Version.cpp @@ -82,7 +82,7 @@ OS << LLVMRepo << ' '; OS << LLVMRev << ')'; } - return OS.str(); + return buf; } std::string getClangFullVersion() { @@ -102,7 +102,7 @@ OS << " " << repo; } - return OS.str(); + return buf; } std::string getClangFullCPPVersion() { @@ -120,7 +120,7 @@ OS << " " << repo; } - return OS.str(); + return buf; } } // end namespace clang Index: clang/lib/Basic/SourceLocation.cpp =================================================================== --- clang/lib/Basic/SourceLocation.cpp +++ clang/lib/Basic/SourceLocation.cpp @@ -90,7 +90,7 @@ std::string S; llvm::raw_string_ostream OS(S); print(OS, SM); - return OS.str(); + return S; } LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const { @@ -149,7 +149,7 @@ std::string S; llvm::raw_string_ostream OS(S); print(OS, SM); - return OS.str(); + return S; } //===----------------------------------------------------------------------===// Index: clang/lib/Analysis/AnalysisDeclContext.cpp =================================================================== --- clang/lib/Analysis/AnalysisDeclContext.cpp +++ clang/lib/Analysis/AnalysisDeclContext.cpp @@ -387,7 +387,7 @@ OS << ' ' << OMD->getSelector().getAsString() << ']'; } - return OS.str(); + return Str; } LocationContextManager &AnalysisDeclContext::getLocationContextManager() { Index: clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp =================================================================== --- clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp +++ clang/lib/ASTMatchers/Dynamic/Diagnostics.cpp @@ -204,7 +204,7 @@ std::string S; llvm::raw_string_ostream OS(S); printToStream(OS); - return OS.str(); + return S; } void Diagnostics::printToStreamFull(llvm::raw_ostream &OS) const { @@ -223,7 +223,7 @@ std::string S; llvm::raw_string_ostream OS(S); printToStreamFull(OS); - return OS.str(); + return S; } } // namespace dynamic Index: clang/lib/AST/OpenMPClause.cpp =================================================================== --- clang/lib/AST/OpenMPClause.cpp +++ clang/lib/AST/OpenMPClause.cpp @@ -2454,7 +2454,7 @@ Property.RawString); } } - return OS.str(); + return MangledName; } OMPTraitInfo::OMPTraitInfo(StringRef MangledName) { Index: clang/lib/AST/DeclarationName.cpp =================================================================== --- clang/lib/AST/DeclarationName.cpp +++ clang/lib/AST/DeclarationName.cpp @@ -234,9 +234,8 @@ std::string DeclarationName::getAsString() const { std::string Result; - llvm::raw_string_ostream OS(Result); - OS << *this; - return OS.str(); + llvm::raw_string_ostream(Result) << *this; + return Result; } void *DeclarationName::getFETokenInfoSlow() const { @@ -458,9 +457,8 @@ std::string DeclarationNameInfo::getAsString() const { std::string Result; - llvm::raw_string_ostream OS(Result); - OS << *this; - return OS.str(); + llvm::raw_string_ostream(Result) << *this; + return Result; } raw_ostream &clang::operator<<(raw_ostream &OS, DeclarationNameInfo DNInfo) { Index: clang/lib/AST/Decl.cpp =================================================================== --- clang/lib/AST/Decl.cpp +++ clang/lib/AST/Decl.cpp @@ -1589,7 +1589,7 @@ std::string QualName; llvm::raw_string_ostream OS(QualName); printQualifiedName(OS, getASTContext().getPrintingPolicy()); - return OS.str(); + return QualName; } void NamedDecl::printQualifiedName(raw_ostream &OS) const { Index: clang/lib/AST/AttrImpl.cpp =================================================================== --- clang/lib/AST/AttrImpl.cpp +++ clang/lib/AST/AttrImpl.cpp @@ -60,7 +60,7 @@ else OS << "disable"; OS << ")"; - return OS.str(); + return ValueName; } // Return a string suitable for identifying this attribute in diagnostics. Index: clang/lib/AST/ASTDiagnostic.cpp =================================================================== --- clang/lib/AST/ASTDiagnostic.cpp +++ clang/lib/AST/ASTDiagnostic.cpp @@ -307,12 +307,12 @@ // type and element count. if (const auto *VTy = Ty->getAs<VectorType>()) { std::string DecoratedString; - llvm::raw_string_ostream OS(DecoratedString); const char *Values = VTy->getNumElements() > 1 ? "values" : "value"; - OS << "'" << S << "' (vector of " << VTy->getNumElements() << " '" - << VTy->getElementType().getAsString(Context.getPrintingPolicy()) - << "' " << Values << ")"; - return OS.str(); + llvm::raw_string_ostream(DecoratedString) + << "'" << S << "' (vector of " << VTy->getNumElements() << " '" + << VTy->getElementType().getAsString(Context.getPrintingPolicy()) + << "' " << Values << ")"; + return DecoratedString; } } Index: clang/include/clang/Testing/TestClangConfig.h =================================================================== --- clang/include/clang/Testing/TestClangConfig.h +++ clang/include/clang/Testing/TestClangConfig.h @@ -71,9 +71,9 @@ std::string toString() const { std::string Result; - llvm::raw_string_ostream OS(Result); - OS << "{ Language=" << Language << ", Target=" << Target << " }"; - return OS.str(); + llvm::raw_string_ostream(Result) + << "{ Language=" << Language << ", Target=" << Target << " }"; + return Result; } friend std::ostream &operator<<(std::ostream &OS, Index: clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h =================================================================== --- clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h +++ clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h @@ -32,7 +32,7 @@ std::string Str; llvm::raw_string_ostream OS(Str); S->printPretty(OS, nullptr, PrintingPolicy(ACtx.getLangOpts())); - return OS.str(); + return Str; } bool isThisObject(const SymbolicRegion *R) { @@ -67,9 +67,8 @@ std::string VisitLocConcreteInt(loc::ConcreteInt V) { const llvm::APSInt &I = V.getValue(); std::string Str; - llvm::raw_string_ostream OS(Str); - OS << "concrete memory address '" << I << "'"; - return OS.str(); + llvm::raw_string_ostream(Str) << "concrete memory address '" << I << "'"; + return Str; } std::string VisitNonLocSymbolVal(nonloc::SymbolVal V) { @@ -79,10 +78,10 @@ std::string VisitNonLocConcreteInt(nonloc::ConcreteInt V) { const llvm::APSInt &I = V.getValue(); std::string Str; - llvm::raw_string_ostream OS(Str); - OS << (I.isSigned() ? "signed " : "unsigned ") << I.getBitWidth() - << "-bit integer '" << I << "'"; - return OS.str(); + llvm::raw_string_ostream(Str) + << (I.isSigned() ? "signed " : "unsigned ") << I.getBitWidth() + << "-bit integer '" << I << "'"; + return Str; } std::string VisitNonLocLazyCompoundVal(nonloc::LazyCompoundVal V) { @@ -119,11 +118,11 @@ std::string VisitSymIntExpr(const SymIntExpr *S) { std::string Str; - llvm::raw_string_ostream OS(Str); - OS << "(" << Visit(S->getLHS()) << ") " - << std::string(BinaryOperator::getOpcodeStr(S->getOpcode())) << " " - << S->getRHS(); - return OS.str(); + llvm::raw_string_ostream(Str) + << "(" << Visit(S->getLHS()) << ") " + << std::string(BinaryOperator::getOpcodeStr(S->getOpcode())) << " " + << S->getRHS(); + return Str; } // TODO: IntSymExpr doesn't appear in practice. @@ -177,7 +176,7 @@ else OS << "'" << Visit(R->getIndex()) << "'"; OS << " of " + Visit(R->getSuperRegion()); - return OS.str(); + return Str; } std::string VisitNonParamVarRegion(const NonParamVarRegion *R) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits