Prefix error_code with std.

llvm-svn: 210840
This commit is contained in:
Rafael Espindola 2014-06-12 22:08:48 +00:00
parent bd14dc519c
commit c7f0d23f56
6 changed files with 45 additions and 48 deletions

View File

@ -29,7 +29,6 @@
using namespace llvm;
using namespace clang;
using std::error_code;
static void eatDiagnostics(const SMDiagnostic &, void *) {}
@ -45,7 +44,7 @@ collectReplacementsFromDirectory(const llvm::StringRef Directory,
using namespace llvm::sys::fs;
using namespace llvm::sys::path;
error_code ErrorCode;
std::error_code ErrorCode;
for (recursive_directory_iterator I(Directory, ErrorCode), E;
I != E && !ErrorCode; I.increment(ErrorCode)) {
@ -61,7 +60,7 @@ collectReplacementsFromDirectory(const llvm::StringRef Directory,
TURFiles.push_back(I->path());
std::unique_ptr<MemoryBuffer> Out;
error_code BufferError = MemoryBuffer::getFile(I->path(), Out);
std::error_code BufferError = MemoryBuffer::getFile(I->path(), Out);
if (BufferError) {
errs() << "Error reading " << I->path() << ": " << BufferError.message()
<< "\n";
@ -264,7 +263,7 @@ bool deleteReplacementFiles(const TUReplacementFiles &Files,
bool Success = true;
for (TUReplacementFiles::const_iterator I = Files.begin(), E = Files.end();
I != E; ++I) {
error_code Error = llvm::sys::fs::remove(*I);
std::error_code Error = llvm::sys::fs::remove(*I);
if (Error) {
Success = false;
// FIXME: Use Diagnostics for outputting errors.

View File

@ -27,7 +27,6 @@
using namespace llvm;
using namespace clang;
using namespace clang::replace;
using std::error_code;
static cl::opt<std::string> Directory(cl::Positional, cl::Required,
cl::desc("<Search Root Directory>"));
@ -223,7 +222,7 @@ int main(int argc, char **argv) {
TUReplacements TUs;
TUReplacementFiles TURFiles;
error_code ErrorCode =
std::error_code ErrorCode =
collectReplacementsFromDirectory(Directory, TUs, TURFiles, Diagnostics);
if (ErrorCode) {

View File

@ -21,7 +21,6 @@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
using std::error_code;
/// A string type to represent paths.
typedef SmallString<64> PathString;
@ -83,8 +82,8 @@ std::string removeRelativeOperators(StringRef Path) {
/// \brief Helper function to tokenize a string of paths and populate
/// the vector.
error_code parseCLInput(StringRef Line, std::vector<std::string> &List,
StringRef Separator) {
std::error_code parseCLInput(StringRef Line, std::vector<std::string> &List,
StringRef Separator) {
SmallVector<StringRef, 32> Tokens;
Line.split(Tokens, Separator, /*MaxSplit=*/ -1, /*KeepEmpty=*/ false);
for (SmallVectorImpl<StringRef>::iterator I = Tokens.begin(),
@ -92,7 +91,7 @@ error_code parseCLInput(StringRef Line, std::vector<std::string> &List,
I != E; ++I) {
// Convert each path to its absolute path.
PathString Path = I->rtrim();
if (error_code Err = sys::fs::make_absolute(Path))
if (std::error_code Err = sys::fs::make_absolute(Path))
return Err;
// Remove relative operators from the path.
std::string AbsPath = removeRelativeOperators(Path);
@ -104,44 +103,46 @@ error_code parseCLInput(StringRef Line, std::vector<std::string> &List,
llvm::errs() << "Parse: " <<List.back() << "\n";
}
return error_code();
return std::error_code();
}
} // end anonymous namespace
error_code IncludeExcludeInfo::readListFromString(StringRef IncludeString,
StringRef ExcludeString) {
if (error_code Err = parseCLInput(IncludeString, IncludeList,
/*Separator=*/ ","))
std::error_code
IncludeExcludeInfo::readListFromString(StringRef IncludeString,
StringRef ExcludeString) {
if (std::error_code Err = parseCLInput(IncludeString, IncludeList,
/*Separator=*/","))
return Err;
if (error_code Err = parseCLInput(ExcludeString, ExcludeList,
/*Separator=*/ ","))
if (std::error_code Err = parseCLInput(ExcludeString, ExcludeList,
/*Separator=*/","))
return Err;
return error_code();
return std::error_code();
}
error_code IncludeExcludeInfo::readListFromFile(StringRef IncludeListFile,
StringRef ExcludeListFile) {
std::error_code
IncludeExcludeInfo::readListFromFile(StringRef IncludeListFile,
StringRef ExcludeListFile) {
if (!IncludeListFile.empty()) {
std::unique_ptr<MemoryBuffer> FileBuf;
if (error_code Err = MemoryBuffer::getFile(IncludeListFile, FileBuf)) {
if (std::error_code Err = MemoryBuffer::getFile(IncludeListFile, FileBuf)) {
errs() << "Unable to read from include file.\n";
return Err;
}
if (error_code Err = parseCLInput(FileBuf->getBuffer(), IncludeList,
/*Separator=*/ "\n"))
if (std::error_code Err = parseCLInput(FileBuf->getBuffer(), IncludeList,
/*Separator=*/"\n"))
return Err;
}
if (!ExcludeListFile.empty()) {
std::unique_ptr<MemoryBuffer> FileBuf;
if (error_code Err = MemoryBuffer::getFile(ExcludeListFile, FileBuf)) {
if (std::error_code Err = MemoryBuffer::getFile(ExcludeListFile, FileBuf)) {
errs() << "Unable to read from exclude file.\n";
return Err;
}
if (error_code Err = parseCLInput(FileBuf->getBuffer(), ExcludeList,
/*Separator=*/ "\n"))
if (std::error_code Err = parseCLInput(FileBuf->getBuffer(), ExcludeList,
/*Separator=*/"\n"))
return Err;
}
return error_code();
return std::error_code();
}
bool IncludeExcludeInfo::isFileIncluded(StringRef FilePath) const {

View File

@ -23,7 +23,6 @@
using namespace llvm;
using namespace llvm::sys;
using namespace clang::tooling;
using std::error_code;
bool ReplacementHandling::findClangApplyReplacements(const char *Argv0) {
CARPath = FindProgramByName("clang-apply-replacements");
@ -145,7 +144,7 @@ bool ReplacementHandling::generateReplacementsFileName(
Error.clear();
SmallString<128> Prefix = DestinationDir;
path::append(Prefix, path::filename(MainSourceFile));
if (error_code EC =
if (std::error_code EC =
fs::createUniqueFile(Prefix + "_%%_%%_%%_%%_%%_%%.yaml", Result)) {
const std::string &Msg = EC.message();
Error.append(Msg.begin(), Msg.end());

View File

@ -175,7 +175,6 @@ using namespace clang::tooling;
using namespace llvm;
using namespace llvm::opt;
using namespace Modularize;
using std::error_code;
// Option to specify a file name for a list of header files to check.
cl::opt<std::string>
@ -216,9 +215,10 @@ std::string CommandLine;
// Read the header list file and collect the header file names and
// optional dependencies.
error_code getHeaderFileNames(SmallVectorImpl<std::string> &HeaderFileNames,
DependencyMap &Dependencies,
StringRef ListFileName, StringRef HeaderPrefix) {
std::error_code
getHeaderFileNames(SmallVectorImpl<std::string> &HeaderFileNames,
DependencyMap &Dependencies, StringRef ListFileName,
StringRef HeaderPrefix) {
// By default, use the path component of the list file name.
SmallString<256> HeaderDirectory(ListFileName);
sys::path::remove_filename(HeaderDirectory);
@ -231,7 +231,7 @@ error_code getHeaderFileNames(SmallVectorImpl<std::string> &HeaderFileNames,
// Read the header list file into a buffer.
std::unique_ptr<MemoryBuffer> listBuffer;
if (error_code ec = MemoryBuffer::getFile(ListFileName, listBuffer)) {
if (std::error_code ec = MemoryBuffer::getFile(ListFileName, listBuffer)) {
return ec;
}
@ -284,7 +284,7 @@ error_code getHeaderFileNames(SmallVectorImpl<std::string> &HeaderFileNames,
Dependencies[HeaderFileName.str()] = Dependents;
}
return error_code();
return std::error_code();
}
// Helper function for finding the input file in an arguments list.
@ -706,8 +706,8 @@ int main(int Argc, const char **Argv) {
// Get header file names and dependencies.
SmallVector<std::string, 32> Headers;
DependencyMap Dependencies;
if (error_code EC = getHeaderFileNames(Headers, Dependencies, ListFileName,
HeaderPrefix)) {
if (std::error_code EC = getHeaderFileNames(Headers, Dependencies,
ListFileName, HeaderPrefix)) {
errs() << Argv[0] << ": error: Unable to get header list '" << ListFileName
<< "': " << EC.message() << '\n';
return 1;

View File

@ -97,7 +97,6 @@ using namespace clang::tooling;
using namespace llvm;
using namespace llvm::opt;
using namespace llvm::sys;
using std::error_code;
// Option for include paths.
static cl::list<std::string>
@ -133,11 +132,11 @@ int main(int Argc, const char **Argv) {
// Do the checks. The return value is the program return code,
// 0 for okay, 1 for module map warnings produced, 2 for any other error.
error_code ReturnCode = Checker->doChecks();
std::error_code ReturnCode = Checker->doChecks();
if (ReturnCode == error_code(1, std::generic_category()))
if (ReturnCode == std::error_code(1, std::generic_category()))
return 1; // Module map warnings were issued.
else if (ReturnCode == error_code(2, std::generic_category()))
else if (ReturnCode == std::error_code(2, std::generic_category()))
return 2; // Some other error occurred.
else
return 0; // No errors or warnings.
@ -244,26 +243,26 @@ ModuleMapChecker *ModuleMapChecker::createModuleMapChecker(
// Returns error_code of 0 if there were no errors or warnings, 1 if there
// were warnings, 2 if any other problem, such as if a bad
// module map path argument was specified.
error_code ModuleMapChecker::doChecks() {
error_code returnValue;
std::error_code ModuleMapChecker::doChecks() {
std::error_code returnValue;
// Load the module map.
if (!loadModuleMap())
return error_code(2, std::generic_category());
return std::error_code(2, std::generic_category());
// Collect the headers referenced in the modules.
collectModuleHeaders();
// Collect the file system headers.
if (!collectFileSystemHeaders())
return error_code(2, std::generic_category());
return std::error_code(2, std::generic_category());
// Do the checks. These save the problematic file names.
findUnaccountedForHeaders();
// Check for warnings.
if (UnaccountedForHeaders.size())
returnValue = error_code(1, std::generic_category());
returnValue = std::error_code(1, std::generic_category());
// Dump module map if requested.
if (DumpModuleMap) {
@ -364,7 +363,7 @@ bool ModuleMapChecker::collectUmbrellaHeaders(StringRef UmbrellaDirName) {
if (Directory.size() == 0)
Directory = ".";
// Walk the directory.
error_code EC;
std::error_code EC;
fs::file_status Status;
for (fs::directory_iterator I(Directory.str(), EC), E; I != E;
I.increment(EC)) {
@ -481,7 +480,7 @@ bool ModuleMapChecker::collectFileSystemHeaders(StringRef IncludePath) {
}
// Recursively walk the directory tree.
error_code EC;
std::error_code EC;
fs::file_status Status;
int Count = 0;
for (fs::recursive_directory_iterator I(Directory.str(), EC), E; I != E;