This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
njames93 marked an inline comment as done.
Closed by commit rG00c7d6699a39: [cte][NFC] Remove all references to stdlib 
stream headers. (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D97771?vs=327448&id=327581#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97771/new/

https://reviews.llvm.org/D97771

Files:
  clang-tools-extra/clang-query/tool/ClangQuery.cpp
  clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
  
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
  clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp
  clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/modularize/Modularize.cpp

Index: clang-tools-extra/modularize/Modularize.cpp
===================================================================
--- clang-tools-extra/modularize/Modularize.cpp
+++ clang-tools-extra/modularize/Modularize.cpp
@@ -247,7 +247,6 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include <algorithm>
-#include <fstream>
 #include <iterator>
 #include <string>
 #include <vector>
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===================================================================
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -39,7 +39,6 @@
 #include "llvm/Support/raw_ostream.h"
 #include <chrono>
 #include <cstdlib>
-#include <iostream>
 #include <memory>
 #include <mutex>
 #include <string>
Index: clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp
===================================================================
--- clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp
+++ clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp
@@ -16,7 +16,6 @@
 #include "ClangdServer.h"
 #include "support/ThreadsafeFS.h"
 #include <cstdio>
-#include <sstream>
 
 using namespace clang::clangd;
 
Index: clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp
===================================================================
--- clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp
+++ 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 <fstream>
-#include <streambuf>
 #include <string>
 
 const char *IndexFilename;
@@ -34,9 +32,15 @@
 
 // Reads JSON array of serialized FuzzyFindRequest's from user-provided file.
 std::vector<FuzzyFindRequest> extractQueriesFromLogs() {
-  std::ifstream InputStream(RequestsFilename);
-  std::string Log((std::istreambuf_iterator<char>(InputStream)),
-                  std::istreambuf_iterator<char>());
+
+  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<FuzzyFindRequest> Requests;
   auto JSONArray = llvm::json::parse(Log);
Index: clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
@@ -12,7 +12,6 @@
 
 #include <algorithm>
 #include <functional>
-#include <sstream>
 
 using namespace clang::ast_matchers;
 
Index: clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -11,7 +11,6 @@
 #include "clang/AST/RecordLayout.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include <math.h>
-#include <sstream>
 
 using namespace clang::ast_matchers;
 
@@ -109,15 +108,13 @@
   AlignedAttr *Attribute = Struct->getAttr<AlignedAttr>();
   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
Index: clang-tools-extra/clang-query/tool/ClangQuery.cpp
===================================================================
--- clang-tools-extra/clang-query/tool/ClangQuery.cpp
+++ 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 <fstream>
 #include <string>
 
 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<char>(Input)),
-                          std::istreambuf_iterator<char>());
+  StringRef FileContentRef(Buffer.get()->getBuffer());
 
-  StringRef FileContentRef(FileContent);
   while (!FileContentRef.empty()) {
     QueryRef Q = QueryParser::parse(FileContentRef, QS);
     if (!Q->run(llvm::outs(), QS))
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to