From 8e650d7bf02a59aac5aa15b749769a4fea367a9f Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 12 Jun 2014 20:37:59 +0000 Subject: [PATCH] Refer to error_code with the std prefix. llvm-svn: 210817 --- clang/lib/AST/InheritViz.cpp | 2 +- clang/lib/Basic/VirtualFileSystem.cpp | 80 +++++++++++++------------ clang/lib/Frontend/FrontendActions.cpp | 2 +- clang/tools/clang-format/ClangFormat.cpp | 2 +- clang/tools/driver/cc1as_main.cpp | 3 +- clang/unittests/Basic/VirtualFileSystemTest.cpp | 27 +++++---- 6 files changed, 60 insertions(+), 56 deletions(-) diff --git a/clang/lib/AST/InheritViz.cpp b/clang/lib/AST/InheritViz.cpp index 84cc167..eb3020c 100644 --- a/clang/lib/AST/InheritViz.cpp +++ b/clang/lib/AST/InheritViz.cpp @@ -139,7 +139,7 @@ void CXXRecordDecl::viewInheritance(ASTContext& Context) const { int FD; SmallString<128> Filename; - error_code EC = + std::error_code EC = sys::fs::createTemporaryFile(Self.getAsString(), "dot", FD, Filename); if (EC) { llvm::errs() << "Error: " << EC.message() << "\n"; diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index edc8bbb..5389de7 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -65,17 +65,15 @@ File::~File() {} FileSystem::~FileSystem() {} -error_code FileSystem::getBufferForFile(const llvm::Twine &Name, - std::unique_ptr &Result, - int64_t FileSize, - bool RequiresNullTerminator, - bool IsVolatile) { +std::error_code FileSystem::getBufferForFile( + const llvm::Twine &Name, std::unique_ptr &Result, + int64_t FileSize, bool RequiresNullTerminator, bool IsVolatile) { std::unique_ptr F; - if (error_code EC = openFileForRead(Name, F)) + if (std::error_code EC = openFileForRead(Name, F)) return EC; - error_code EC = F->getBuffer(Name, Result, FileSize, RequiresNullTerminator, - IsVolatile); + std::error_code EC = + F->getBuffer(Name, Result, FileSize, RequiresNullTerminator, IsVolatile); return EC; } @@ -96,11 +94,12 @@ class RealFile : public File { public: ~RealFile(); ErrorOr status() override; - error_code getBuffer(const Twine &Name, std::unique_ptr &Result, - int64_t FileSize = -1, - bool RequiresNullTerminator = true, - bool IsVolatile = false) override; - error_code close() override; + std::error_code getBuffer(const Twine &Name, + std::unique_ptr &Result, + int64_t FileSize = -1, + bool RequiresNullTerminator = true, + bool IsVolatile = false) override; + std::error_code close() override; void setName(StringRef Name) override; }; } // end anonymous namespace @@ -110,7 +109,7 @@ ErrorOr RealFile::status() { assert(FD != -1 && "cannot stat closed file"); if (!S.isStatusKnown()) { file_status RealStatus; - if (error_code EC = sys::fs::status(FD, RealStatus)) + if (std::error_code EC = sys::fs::status(FD, RealStatus)) return EC; Status NewS(RealStatus); NewS.setName(S.getName()); @@ -119,10 +118,11 @@ ErrorOr RealFile::status() { return S; } -error_code RealFile::getBuffer(const Twine &Name, - std::unique_ptr &Result, - int64_t FileSize, bool RequiresNullTerminator, - bool IsVolatile) { +std::error_code RealFile::getBuffer(const Twine &Name, + std::unique_ptr &Result, + int64_t FileSize, + bool RequiresNullTerminator, + bool IsVolatile) { assert(FD != -1 && "cannot get buffer for closed file"); return MemoryBuffer::getOpenFile(FD, Name.str().c_str(), Result, FileSize, RequiresNullTerminator, IsVolatile); @@ -138,11 +138,11 @@ error_code RealFile::getBuffer(const Twine &Name, #define S_ISFIFO(x) (0) #endif #endif -error_code RealFile::close() { +std::error_code RealFile::close() { if (::close(FD)) - return error_code(errno, std::generic_category()); + return std::error_code(errno, std::generic_category()); FD = -1; - return error_code(); + return std::error_code(); } void RealFile::setName(StringRef Name) { @@ -154,28 +154,28 @@ namespace { class RealFileSystem : public FileSystem { public: ErrorOr status(const Twine &Path) override; - error_code openFileForRead(const Twine &Path, - std::unique_ptr &Result) override; + std::error_code openFileForRead(const Twine &Path, + std::unique_ptr &Result) override; }; } // end anonymous namespace ErrorOr RealFileSystem::status(const Twine &Path) { sys::fs::file_status RealStatus; - if (error_code EC = sys::fs::status(Path, RealStatus)) + if (std::error_code EC = sys::fs::status(Path, RealStatus)) return EC; Status Result(RealStatus); Result.setName(Path.str()); return Result; } -error_code RealFileSystem::openFileForRead(const Twine &Name, - std::unique_ptr &Result) { +std::error_code RealFileSystem::openFileForRead(const Twine &Name, + std::unique_ptr &Result) { int FD; - if (error_code EC = sys::fs::openFileForRead(Name, FD)) + if (std::error_code EC = sys::fs::openFileForRead(Name, FD)) return EC; Result.reset(new RealFile(FD)); Result->setName(Name.str()); - return error_code(); + return std::error_code(); } IntrusiveRefCntPtr vfs::getRealFileSystem() { @@ -204,11 +204,12 @@ ErrorOr OverlayFileSystem::status(const Twine &Path) { return std::make_error_code(std::errc::no_such_file_or_directory); } -error_code OverlayFileSystem::openFileForRead(const llvm::Twine &Path, - std::unique_ptr &Result) { +std::error_code +OverlayFileSystem::openFileForRead(const llvm::Twine &Path, + std::unique_ptr &Result) { // FIXME: handle symlinks that cross file systems for (iterator I = overlays_begin(), E = overlays_end(); I != E; ++I) { - error_code EC = (*I)->openFileForRead(Path, Result); + std::error_code EC = (*I)->openFileForRead(Path, Result); if (!EC || EC != std::errc::no_such_file_or_directory) return EC; } @@ -389,8 +390,8 @@ public: IntrusiveRefCntPtr ExternalFS); ErrorOr status(const Twine &Path) override; - error_code openFileForRead(const Twine &Path, - std::unique_ptr &Result) override; + std::error_code openFileForRead(const Twine &Path, + std::unique_ptr &Result) override; }; /// \brief A helper class to hold the common YAML parsing state. @@ -740,7 +741,7 @@ ErrorOr VFSFromYAML::lookupPath(const Twine &Path_) { Path_.toVector(Path); // Handle relative paths - if (error_code EC = sys::fs::make_absolute(Path)) + if (std::error_code EC = sys::fs::make_absolute(Path)) return EC; if (Path.empty()) @@ -812,8 +813,9 @@ ErrorOr VFSFromYAML::status(const Twine &Path) { } } -error_code VFSFromYAML::openFileForRead(const Twine &Path, - std::unique_ptr &Result) { +std::error_code +VFSFromYAML::openFileForRead(const Twine &Path, + std::unique_ptr &Result) { ErrorOr E = lookupPath(Path); if (!E) return E.getError(); @@ -822,14 +824,14 @@ error_code VFSFromYAML::openFileForRead(const Twine &Path, if (!F) // FIXME: errc::not_a_file? return std::make_error_code(std::errc::invalid_argument); - if (error_code EC = ExternalFS->openFileForRead(F->getExternalContentsPath(), - Result)) + if (std::error_code EC = + ExternalFS->openFileForRead(F->getExternalContentsPath(), Result)) return EC; if (!F->useExternalName(UseExternalNames)) Result->setName(Path.str()); - return error_code(); + return std::error_code(); } IntrusiveRefCntPtr diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 5147a8a..ef6bfec 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -310,7 +310,7 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI, // Collect the set of #includes we need to build the module. SmallString<256> HeaderContents; - std::error_code Err = llvm::error_code(); + std::error_code Err = std::error_code(); if (const FileEntry *UmbrellaHeader = Module->getUmbrellaHeader()) Err = addHeaderInclude(UmbrellaHeader, HeaderContents, CI.getLangOpts(), Module->IsExternC); diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 189a611..e023949 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -210,7 +210,7 @@ static bool format(StringRef FileName) { new DiagnosticOptions); SourceManager Sources(Diagnostics, Files); std::unique_ptr Code; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(FileName, Code)) { + if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(FileName, Code)) { llvm::errs() << ec.message() << "\n"; return true; } diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp index 5f02029..2b4e97d 100644 --- a/clang/tools/driver/cc1as_main.cpp +++ b/clang/tools/driver/cc1as_main.cpp @@ -282,7 +282,8 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, return Diags.Report(diag::err_target_unknown_triple) << Opts.Triple; std::unique_ptr Buffer; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(Opts.InputFile, Buffer)) { + if (std::error_code ec = + MemoryBuffer::getFileOrSTDIN(Opts.InputFile, Buffer)) { Error = ec.message(); return Diags.Report(diag::err_fe_error_reading) << Opts.InputFile; } diff --git a/clang/unittests/Basic/VirtualFileSystemTest.cpp b/clang/unittests/Basic/VirtualFileSystemTest.cpp index 6d05049..63d5336 100644 --- a/clang/unittests/Basic/VirtualFileSystemTest.cpp +++ b/clang/unittests/Basic/VirtualFileSystemTest.cpp @@ -38,14 +38,14 @@ public: return std::make_error_code(std::errc::no_such_file_or_directory); return I->second; } - error_code openFileForRead(const Twine &Path, - std::unique_ptr &Result) { + std::error_code openFileForRead(const Twine &Path, + std::unique_ptr &Result) { llvm_unreachable("unimplemented"); } - error_code getBufferForFile(const Twine &Name, - std::unique_ptr &Result, - int64_t FileSize = -1, - bool RequiresNullTerminator = true) { + std::error_code getBufferForFile(const Twine &Name, + std::unique_ptr &Result, + int64_t FileSize = -1, + bool RequiresNullTerminator = true) { llvm_unreachable("unimplemented"); } @@ -75,7 +75,7 @@ public: TEST(VirtualFileSystemTest, StatusQueries) { IntrusiveRefCntPtr D(new DummyFileSystem()); - ErrorOr Status((error_code())); + ErrorOr Status((std::error_code())); D->addRegularFile("/foo"); Status = D->status("/foo"); @@ -115,7 +115,7 @@ TEST(VirtualFileSystemTest, StatusQueries) { TEST(VirtualFileSystemTest, BaseOnlyOverlay) { IntrusiveRefCntPtr D(new DummyFileSystem()); - ErrorOr Status((error_code())); + ErrorOr Status((std::error_code())); EXPECT_FALSE(Status = D->status("/foo")); IntrusiveRefCntPtr O(new vfs::OverlayFileSystem(D)); @@ -125,7 +125,7 @@ TEST(VirtualFileSystemTest, BaseOnlyOverlay) { Status = D->status("/foo"); EXPECT_FALSE(Status.getError()); - ErrorOr Status2((error_code())); + ErrorOr Status2((std::error_code())); Status2 = O->status("/foo"); EXPECT_FALSE(Status2.getError()); EXPECT_TRUE(Status->equivalent(*Status2)); @@ -140,9 +140,10 @@ TEST(VirtualFileSystemTest, OverlayFiles) { O->pushOverlay(Middle); O->pushOverlay(Top); - ErrorOr Status1((error_code())), Status2((error_code())), - Status3((error_code())), StatusB((error_code())), StatusM((error_code())), - StatusT((error_code())); + ErrorOr Status1((std::error_code())), + Status2((std::error_code())), Status3((std::error_code())), + StatusB((std::error_code())), StatusM((std::error_code())), + StatusT((std::error_code())); Base->addRegularFile("/foo"); StatusB = Base->status("/foo"); @@ -201,7 +202,7 @@ TEST(VirtualFileSystemTest, MergedDirPermissions) { new vfs::OverlayFileSystem(Lower)); O->pushOverlay(Upper); - ErrorOr Status((error_code())); + ErrorOr Status((std::error_code())); Lower->addDirectory("/both", sys::fs::owner_read); Upper->addDirectory("/both", sys::fs::owner_all | sys::fs::group_read); Status = O->status("/both"); -- 2.7.4