diff --git a/clang-tools-extra/clang-query/tool/ClangQuery.cpp b/clang-tools-extra/clang-query/tool/ClangQuery.cpp --- a/clang-tools-extra/clang-query/tool/ClangQuery.cpp +++ b/clang-tools-extra/clang-query/tool/ClangQuery.cpp @@ -33,10 +33,10 @@ #include "clang/Tooling/Tooling.h" #include "llvm/LineEditor/LineEditor.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Error.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Signals.h" #include "llvm/Support/WithColor.h" -#include #include using namespace clang; @@ -73,16 +73,15 @@ bool runCommandsInFile(const char *ExeName, std::string const &FileName, QuerySession &QS) { - std::ifstream Input(FileName.c_str()); - if (!Input.is_open()) { - llvm::errs() << ExeName << ": cannot open " << FileName << "\n"; - return 1; + auto Buffer = llvm::MemoryBuffer::getFile(FileName); + if (!Buffer) { + llvm::errs() << ExeName << ": cannot open " << FileName << ": " + << Buffer.getError().message() << "\n"; + return true; } - std::string FileContent((std::istreambuf_iterator(Input)), - std::istreambuf_iterator()); + StringRef FileContentRef(Buffer.get()->getBuffer()); - StringRef FileContentRef(FileContent); while (!FileContentRef.empty()) { QueryRef Q = QueryParser::parse(FileContentRef, QS); if (!Q->run(llvm::outs(), QS)) diff --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp --- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp +++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp @@ -11,7 +11,6 @@ #include "clang/AST/RecordLayout.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include -#include using namespace clang::ast_matchers; @@ -109,15 +108,13 @@ AlignedAttr *Attribute = Struct->getAttr(); std::string NewAlignQuantity = std::to_string((int)NewAlign.getQuantity()); if (Attribute) { - std::ostringstream FixItString; - FixItString << "aligned(" << NewAlignQuantity << ")"; - FixIt = - FixItHint::CreateReplacement(Attribute->getRange(), FixItString.str()); + FixIt = FixItHint::CreateReplacement( + Attribute->getRange(), + (Twine("aligned(") + NewAlignQuantity + ")").str()); } else { - std::ostringstream FixItString; - FixItString << " __attribute__((aligned(" << NewAlignQuantity << ")))"; - FixIt = FixItHint::CreateInsertion(Struct->getEndLoc().getLocWithOffset(1), - FixItString.str()); + FixIt = FixItHint::CreateInsertion( + Struct->getEndLoc().getLocWithOffset(1), + (Twine(" __attribute__((aligned(") + NewAlignQuantity + ")))").str()); } // And suggest the minimum power-of-two alignment for the struct as a whole diff --git a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp --- a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp @@ -12,7 +12,6 @@ #include #include -#include using namespace clang::ast_matchers; diff --git a/clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp b/clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp --- a/clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp +++ b/clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp @@ -13,8 +13,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Path.h" #include "llvm/Support/Regex.h" -#include -#include #include const char *IndexFilename; @@ -34,9 +32,15 @@ // Reads JSON array of serialized FuzzyFindRequest's from user-provided file. std::vector extractQueriesFromLogs() { - std::ifstream InputStream(RequestsFilename); - std::string Log((std::istreambuf_iterator(InputStream)), - std::istreambuf_iterator()); + + auto Buffer = llvm::MemoryBuffer::getFile(RequestsFilename); + if (!Buffer) { + llvm::errs() << "Error cannot open JSON request file:" << RequestsFilename + << ": " << Buffer.getError().message() << "\n"; + exit(1); + } + + StringRef Log = Buffer.get()->getBuffer(); std::vector Requests; auto JSONArray = llvm::json::parse(Log); diff --git a/clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp b/clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp --- a/clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp +++ b/clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp @@ -16,7 +16,6 @@ #include "ClangdServer.h" #include "support/ThreadsafeFS.h" #include -#include using namespace clang::clangd; diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp --- a/clang-tools-extra/clangd/tool/ClangdMain.cpp +++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -39,7 +39,6 @@ #include "llvm/Support/raw_ostream.h" #include #include -#include #include #include #include diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp --- a/clang-tools-extra/modularize/Modularize.cpp +++ b/clang-tools-extra/modularize/Modularize.cpp @@ -247,7 +247,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include -#include #include #include #include