From 96b033006d9959b2e944779ea8836f2c81cc7e2b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 11 Jun 2014 19:05:55 +0000 Subject: [PATCH] Use std::error_code instead of llvm::error_code. This is an update for a llvm api change. llvm-svn: 210688 --- clang/lib/Basic/VirtualFileSystem.cpp | 24 +++++++++---------- clang/lib/Format/Format.cpp | 10 ++++---- clang/lib/Frontend/CompilerInstance.cpp | 2 +- .../unittests/Basic/VirtualFileSystemTest.cpp | 11 +++++---- clang/unittests/Format/FormatTest.cpp | 12 +++++----- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index 3bca96449dbd..3515bf1c031a 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -198,10 +198,10 @@ ErrorOr OverlayFileSystem::status(const Twine &Path) { // FIXME: handle symlinks that cross file systems for (iterator I = overlays_begin(), E = overlays_end(); I != E; ++I) { ErrorOr Status = (*I)->status(Path); - if (Status || Status.getError() != errc::no_such_file_or_directory) + if (Status || Status.getError() != std::errc::no_such_file_or_directory) return Status; } - return make_error_code(errc::no_such_file_or_directory); + return make_error_code(std::errc::no_such_file_or_directory); } error_code OverlayFileSystem::openFileForRead(const llvm::Twine &Path, @@ -209,10 +209,10 @@ error_code OverlayFileSystem::openFileForRead(const llvm::Twine &Path, // 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); - if (!EC || EC != errc::no_such_file_or_directory) + if (!EC || EC != std::errc::no_such_file_or_directory) return EC; } - return make_error_code(errc::no_such_file_or_directory); + return make_error_code(std::errc::no_such_file_or_directory); } //===-----------------------------------------------------------------------===/ @@ -744,17 +744,17 @@ ErrorOr VFSFromYAML::lookupPath(const Twine &Path_) { return EC; if (Path.empty()) - return make_error_code(errc::invalid_argument); + return make_error_code(std::errc::invalid_argument); sys::path::const_iterator Start = sys::path::begin(Path); sys::path::const_iterator End = sys::path::end(Path); for (std::vector::iterator I = Roots.begin(), E = Roots.end(); I != E; ++I) { ErrorOr Result = lookupPath(Start, End, *I); - if (Result || Result.getError() != errc::no_such_file_or_directory) + if (Result || Result.getError() != std::errc::no_such_file_or_directory) return Result; } - return make_error_code(errc::no_such_file_or_directory); + return make_error_code(std::errc::no_such_file_or_directory); } ErrorOr VFSFromYAML::lookupPath(sys::path::const_iterator Start, @@ -767,7 +767,7 @@ ErrorOr VFSFromYAML::lookupPath(sys::path::const_iterator Start, if (CaseSensitive ? !Start->equals(From->getName()) : !Start->equals_lower(From->getName())) // failure to match - return make_error_code(errc::no_such_file_or_directory); + return make_error_code(std::errc::no_such_file_or_directory); ++Start; @@ -778,16 +778,16 @@ ErrorOr VFSFromYAML::lookupPath(sys::path::const_iterator Start, DirectoryEntry *DE = dyn_cast(From); if (!DE) - return make_error_code(errc::not_a_directory); + return make_error_code(std::errc::not_a_directory); for (DirectoryEntry::iterator I = DE->contents_begin(), E = DE->contents_end(); I != E; ++I) { ErrorOr Result = lookupPath(Start, End, *I); - if (Result || Result.getError() != errc::no_such_file_or_directory) + if (Result || Result.getError() != std::errc::no_such_file_or_directory) return Result; } - return make_error_code(errc::no_such_file_or_directory); + return make_error_code(std::errc::no_such_file_or_directory); } ErrorOr VFSFromYAML::status(const Twine &Path) { @@ -820,7 +820,7 @@ error_code VFSFromYAML::openFileForRead(const Twine &Path, FileEntry *F = dyn_cast(*E); if (!F) // FIXME: errc::not_a_file? - return make_error_code(errc::invalid_argument); + return make_error_code(std::errc::invalid_argument); if (error_code EC = ExternalFS->openFileForRead(F->getExternalContentsPath(), Result)) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index f497126950d0..e3378d144603 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -447,7 +447,7 @@ llvm::error_code parseConfiguration(StringRef Text, FormatStyle *Style) { FormatStyle::LanguageKind Language = Style->Language; assert(Language != FormatStyle::LK_None); if (Text.trim().empty()) - return llvm::make_error_code(llvm::errc::invalid_argument); + return llvm::make_error_code(std::errc::invalid_argument); std::vector Styles; llvm::yaml::Input Input(Text); @@ -463,14 +463,14 @@ llvm::error_code parseConfiguration(StringRef Text, FormatStyle *Style) { for (unsigned i = 0; i < Styles.size(); ++i) { // Ensures that only the first configuration can skip the Language option. if (Styles[i].Language == FormatStyle::LK_None && i != 0) - return llvm::make_error_code(llvm::errc::invalid_argument); + return llvm::make_error_code(std::errc::invalid_argument); // Ensure that each language is configured at most once. for (unsigned j = 0; j < i; ++j) { if (Styles[i].Language == Styles[j].Language) { DEBUG(llvm::dbgs() << "Duplicate languages in the config file on positions " << j << " and " << i << "\n"); - return llvm::make_error_code(llvm::errc::invalid_argument); + return llvm::make_error_code(std::errc::invalid_argument); } } } @@ -485,7 +485,7 @@ llvm::error_code parseConfiguration(StringRef Text, FormatStyle *Style) { return llvm::error_code(); } } - return llvm::make_error_code(llvm::errc::not_supported); + return llvm::make_error_code(std::errc::not_supported); } std::string configurationAsText(const FormatStyle &Style) { @@ -2049,7 +2049,7 @@ FormatStyle getStyle(StringRef StyleName, StringRef FileName, break; } if (llvm::error_code ec = parseConfiguration(Text->getBuffer(), &Style)) { - if (ec == llvm::errc::not_supported) { + if (ec == std::errc::not_supported) { if (!UnsuitableConfigFiles.empty()) UnsuitableConfigFiles.append(", "); UnsuitableConfigFiles.append(ConfigFile); diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index f5e2749a718d..bbcb71f3f1f9 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -572,7 +572,7 @@ CompilerInstance::createOutputFile(StringRef OutputPath, llvm::sys::fs::createUniqueFile(TempPath.str(), fd, TempPath); if (CreateMissingDirectories && - EC == llvm::errc::no_such_file_or_directory) { + EC == std::errc::no_such_file_or_directory) { StringRef Parent = llvm::sys::path::parent_path(OutputPath); EC = llvm::sys::fs::create_directories(Parent); if (!EC) { diff --git a/clang/unittests/Basic/VirtualFileSystemTest.cpp b/clang/unittests/Basic/VirtualFileSystemTest.cpp index 22e095a7708e..27d5e4cd0529 100644 --- a/clang/unittests/Basic/VirtualFileSystemTest.cpp +++ b/clang/unittests/Basic/VirtualFileSystemTest.cpp @@ -35,7 +35,7 @@ public: std::map::iterator I = FilesAndDirs.find(Path.str()); if (I == FilesAndDirs.end()) - return make_error_code(errc::no_such_file_or_directory); + return make_error_code(std::errc::no_such_file_or_directory); return I->second; } error_code openFileForRead(const Twine &Path, @@ -306,7 +306,8 @@ TEST_F(VFSFromYAMLTest, MappedFiles) { EXPECT_TRUE(S->equivalent(*O->status("//root/"))); // non-volatile UniqueID // broken mapping - EXPECT_EQ(errc::no_such_file_or_directory, O->status("//root/file2").getError()); + EXPECT_EQ(std::errc::no_such_file_or_directory, + O->status("//root/file2").getError()); EXPECT_EQ(0, NumDiagnostics); } @@ -370,11 +371,11 @@ TEST_F(VFSFromYAMLTest, CaseSensitive) { O->pushOverlay(FS); ErrorOr SS = O->status("//root/xx"); - EXPECT_EQ(errc::no_such_file_or_directory, SS.getError()); + EXPECT_EQ(std::errc::no_such_file_or_directory, SS.getError()); SS = O->status("//root/xX"); - EXPECT_EQ(errc::no_such_file_or_directory, SS.getError()); + EXPECT_EQ(std::errc::no_such_file_or_directory, SS.getError()); SS = O->status("//root/Xx"); - EXPECT_EQ(errc::no_such_file_or_directory, SS.getError()); + EXPECT_EQ(std::errc::no_such_file_or_directory, SS.getError()); EXPECT_EQ(0, NumDiagnostics); } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index f474c42144d5..f8bf85bdbabe 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -8181,7 +8181,7 @@ TEST_F(FormatTest, ParsesConfigurationWithLanguages) { CHECK_PARSE("Language: Cpp\n" "IndentWidth: 12", IndentWidth, 12u); - EXPECT_EQ(llvm::errc::not_supported, + EXPECT_EQ(std::errc::not_supported, parseConfiguration("Language: JavaScript\n" "IndentWidth: 34", &Style)); @@ -8194,9 +8194,9 @@ TEST_F(FormatTest, ParsesConfigurationWithLanguages) { "IndentWidth: 12", IndentWidth, 12u); CHECK_PARSE("IndentWidth: 23", IndentWidth, 23u); - EXPECT_EQ(llvm::errc::not_supported, parseConfiguration("Language: Cpp\n" - "IndentWidth: 34", - &Style)); + EXPECT_EQ(std::errc::not_supported, parseConfiguration("Language: Cpp\n" + "IndentWidth: 34", + &Style)); EXPECT_EQ(23u, Style.IndentWidth); CHECK_PARSE("IndentWidth: 56", IndentWidth, 56u); EXPECT_EQ(FormatStyle::LK_JavaScript, Style.Language); @@ -8254,7 +8254,7 @@ TEST_F(FormatTest, ParsesConfigurationWithLanguages) { EXPECT_EQ(789u, Style.TabWidth); - EXPECT_EQ(llvm::errc::invalid_argument, + EXPECT_EQ(std::errc::invalid_argument, parseConfiguration("---\n" "Language: JavaScript\n" "IndentWidth: 56\n" @@ -8262,7 +8262,7 @@ TEST_F(FormatTest, ParsesConfigurationWithLanguages) { "IndentWidth: 78\n" "...\n", &Style)); - EXPECT_EQ(llvm::errc::invalid_argument, + EXPECT_EQ(std::errc::invalid_argument, parseConfiguration("---\n" "Language: JavaScript\n" "IndentWidth: 56\n"