azhan92 updated this revision to Diff 535389. azhan92 added a comment. Herald added subscribers: JDevlieghere, jdoerfert.
Remove unrelated changes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151567/new/ https://reviews.llvm.org/D151567 Files: llvm/lib/Support/CommandLine.cpp llvm/unittests/Support/CommandLineTest.cpp Index: llvm/unittests/Support/CommandLineTest.cpp =================================================================== --- llvm/unittests/Support/CommandLineTest.cpp +++ llvm/unittests/Support/CommandLineTest.cpp @@ -1060,7 +1060,6 @@ ASSERT_STREQ(Argv[0], "clang"); ASSERT_STREQ(Argv[1], AFileExp.c_str()); -#if !defined(_AIX) && !defined(__MVS__) std::string ADirExp = std::string("@") + std::string(ADir.path()); Argv = {"clang", ADirExp.c_str()}; Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv); @@ -1068,7 +1067,6 @@ ASSERT_EQ(2U, Argv.size()); ASSERT_STREQ(Argv[0], "clang"); ASSERT_STREQ(Argv[1], ADirExp.c_str()); -#endif } TEST(CommandLineTest, SetDefaultValue) { Index: llvm/lib/Support/CommandLine.cpp =================================================================== --- llvm/lib/Support/CommandLine.cpp +++ llvm/lib/Support/CommandLine.cpp @@ -1289,8 +1289,9 @@ } ErrorOr<llvm::vfs::Status> Res = FS->status(FName); + std::error_code EC; if (!Res || !Res->exists()) { - std::error_code EC = Res.getError(); + EC = Res.getError(); if (!InConfigFile) { // If the specified file does not exist, leave '@file' unexpanded, as // libiberty does. @@ -1305,6 +1306,11 @@ "': " + EC.message()); } const llvm::vfs::Status &FileStatus = Res.get(); + if (FileStatus.isDirectory()) { + EC = std::make_error_code(std::errc::is_a_directory); + return createStringError(EC, Twine("cannot not open file '") + FName + + "': " + EC.message()); + } auto IsEquivalent = [FileStatus, this](const ResponseFileRecord &RFile) -> ErrorOr<bool> {
Index: llvm/unittests/Support/CommandLineTest.cpp =================================================================== --- llvm/unittests/Support/CommandLineTest.cpp +++ llvm/unittests/Support/CommandLineTest.cpp @@ -1060,7 +1060,6 @@ ASSERT_STREQ(Argv[0], "clang"); ASSERT_STREQ(Argv[1], AFileExp.c_str()); -#if !defined(_AIX) && !defined(__MVS__) std::string ADirExp = std::string("@") + std::string(ADir.path()); Argv = {"clang", ADirExp.c_str()}; Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv); @@ -1068,7 +1067,6 @@ ASSERT_EQ(2U, Argv.size()); ASSERT_STREQ(Argv[0], "clang"); ASSERT_STREQ(Argv[1], ADirExp.c_str()); -#endif } TEST(CommandLineTest, SetDefaultValue) { Index: llvm/lib/Support/CommandLine.cpp =================================================================== --- llvm/lib/Support/CommandLine.cpp +++ llvm/lib/Support/CommandLine.cpp @@ -1289,8 +1289,9 @@ } ErrorOr<llvm::vfs::Status> Res = FS->status(FName); + std::error_code EC; if (!Res || !Res->exists()) { - std::error_code EC = Res.getError(); + EC = Res.getError(); if (!InConfigFile) { // If the specified file does not exist, leave '@file' unexpanded, as // libiberty does. @@ -1305,6 +1306,11 @@ "': " + EC.message()); } const llvm::vfs::Status &FileStatus = Res.get(); + if (FileStatus.isDirectory()) { + EC = std::make_error_code(std::errc::is_a_directory); + return createStringError(EC, Twine("cannot not open file '") + FName + + "': " + EC.message()); + } auto IsEquivalent = [FileStatus, this](const ResponseFileRecord &RFile) -> ErrorOr<bool> {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits