[cte][NFC] Remove all references to stdlib stream headers.

Inclusion of iostream is frobidden and using other stream classes from standard library is discouraged as per https://llvm.org/docs/CodingStandards.html#include-iostream-is-forbidden

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D97771
This commit is contained in:
Nathan James 2021-03-02 21:57:16 +00:00
parent a7cad6680b
commit 00c7d6699a
No known key found for this signature in database
GPG Key ID: CC007AFCDA90AA5F
7 changed files with 22 additions and 26 deletions

View File

@ -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 @@ static cl::opt<std::string> PreloadFile(
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))

View File

@ -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 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
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

View File

@ -12,7 +12,6 @@
#include <algorithm>
#include <functional>
#include <sstream>
using namespace clang::ast_matchers;

View File

@ -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 @@ std::unique_ptr<SymbolIndex> buildDex() {
// 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);

View File

@ -16,7 +16,6 @@
#include "ClangdServer.h"
#include "support/ThreadsafeFS.h"
#include <cstdio>
#include <sstream>
using namespace clang::clangd;

View File

@ -39,7 +39,6 @@
#include "llvm/Support/raw_ostream.h"
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <mutex>
#include <string>

View File

@ -247,7 +247,6 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include <algorithm>
#include <fstream>
#include <iterator>
#include <string>
#include <vector>