This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGb76c7c6faf06: [clang][driver] NFC: Expose InputInfo in Job instead of plain filenames (authored by jansvoboda11).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106788/new/ https://reviews.llvm.org/D106788 Files: clang/include/clang/Driver/Job.h clang/lib/Driver/Job.cpp clang/unittests/Driver/ToolChainTest.cpp Index: clang/unittests/Driver/ToolChainTest.cpp =================================================================== --- clang/unittests/Driver/ToolChainTest.cpp +++ clang/unittests/Driver/ToolChainTest.cpp @@ -321,13 +321,13 @@ const JobList &Jobs = CC->getJobs(); const auto &CmdCompile = Jobs.getJobs().front(); - const auto &InFile = CmdCompile->getInputFilenames().front(); + const auto &InFile = CmdCompile->getInputInfos().front().getFilename(); EXPECT_STREQ(InFile, "foo.cpp"); auto ObjFile = CmdCompile->getOutputFilenames().front(); EXPECT_TRUE(StringRef(ObjFile).endswith(".o")); const auto &CmdLink = Jobs.getJobs().back(); - const auto LinkInFile = CmdLink->getInputFilenames().front(); + const auto LinkInFile = CmdLink->getInputInfos().front().getFilename(); EXPECT_EQ(ObjFile, LinkInFile); auto ExeFile = CmdLink->getOutputFilenames().front(); EXPECT_EQ("a.out", ExeFile); Index: clang/lib/Driver/Job.cpp =================================================================== --- clang/lib/Driver/Job.cpp +++ clang/lib/Driver/Job.cpp @@ -43,7 +43,7 @@ Executable(Executable), Arguments(Arguments) { for (const auto &II : Inputs) if (II.isFilename()) - InputFilenames.push_back(II.getFilename()); + InputInfoList.push_back(II); for (const auto &II : Outputs) if (II.isFilename()) OutputFilenames.push_back(II.getFilename()); @@ -237,9 +237,10 @@ } } - auto Found = llvm::find_if(InputFilenames, - [&Arg](StringRef IF) { return IF == Arg; }); - if (Found != InputFilenames.end() && + auto Found = llvm::find_if(InputInfoList, [&Arg](const InputInfo &II) { + return II.getFilename() == Arg; + }); + if (Found != InputInfoList.end() && (i == 0 || StringRef(Args[i - 1]) != "-main-file-name")) { // Replace the input file name with the crashinfo's file name. OS << ' '; @@ -302,8 +303,8 @@ void Command::PrintFileNames() const { if (PrintInputFilenames) { - for (const char *Arg : InputFilenames) - llvm::outs() << llvm::sys::path::filename(Arg) << "\n"; + for (const auto &Arg : InputInfoList) + llvm::outs() << llvm::sys::path::filename(Arg.getFilename()) << "\n"; llvm::outs().flush(); } } Index: clang/include/clang/Driver/Job.h =================================================================== --- clang/include/clang/Driver/Job.h +++ clang/include/clang/Driver/Job.h @@ -10,6 +10,7 @@ #define LLVM_CLANG_DRIVER_JOB_H #include "clang/Basic/LLVM.h" +#include "clang/Driver/InputInfo.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" @@ -119,8 +120,8 @@ /// argument, which will be the executable). llvm::opt::ArgStringList Arguments; - /// The list of program arguments which are inputs. - llvm::opt::ArgStringList InputFilenames; + /// The list of program inputs. + std::vector<InputInfo> InputInfoList; /// The list of program arguments which are outputs. May be empty. std::vector<std::string> OutputFilenames; @@ -207,9 +208,7 @@ const llvm::opt::ArgStringList &getArguments() const { return Arguments; } - const llvm::opt::ArgStringList &getInputFilenames() const { - return InputFilenames; - } + const std::vector<InputInfo> &getInputInfos() const { return InputInfoList; } const std::vector<std::string> &getOutputFilenames() const { return OutputFilenames;
Index: clang/unittests/Driver/ToolChainTest.cpp =================================================================== --- clang/unittests/Driver/ToolChainTest.cpp +++ clang/unittests/Driver/ToolChainTest.cpp @@ -321,13 +321,13 @@ const JobList &Jobs = CC->getJobs(); const auto &CmdCompile = Jobs.getJobs().front(); - const auto &InFile = CmdCompile->getInputFilenames().front(); + const auto &InFile = CmdCompile->getInputInfos().front().getFilename(); EXPECT_STREQ(InFile, "foo.cpp"); auto ObjFile = CmdCompile->getOutputFilenames().front(); EXPECT_TRUE(StringRef(ObjFile).endswith(".o")); const auto &CmdLink = Jobs.getJobs().back(); - const auto LinkInFile = CmdLink->getInputFilenames().front(); + const auto LinkInFile = CmdLink->getInputInfos().front().getFilename(); EXPECT_EQ(ObjFile, LinkInFile); auto ExeFile = CmdLink->getOutputFilenames().front(); EXPECT_EQ("a.out", ExeFile); Index: clang/lib/Driver/Job.cpp =================================================================== --- clang/lib/Driver/Job.cpp +++ clang/lib/Driver/Job.cpp @@ -43,7 +43,7 @@ Executable(Executable), Arguments(Arguments) { for (const auto &II : Inputs) if (II.isFilename()) - InputFilenames.push_back(II.getFilename()); + InputInfoList.push_back(II); for (const auto &II : Outputs) if (II.isFilename()) OutputFilenames.push_back(II.getFilename()); @@ -237,9 +237,10 @@ } } - auto Found = llvm::find_if(InputFilenames, - [&Arg](StringRef IF) { return IF == Arg; }); - if (Found != InputFilenames.end() && + auto Found = llvm::find_if(InputInfoList, [&Arg](const InputInfo &II) { + return II.getFilename() == Arg; + }); + if (Found != InputInfoList.end() && (i == 0 || StringRef(Args[i - 1]) != "-main-file-name")) { // Replace the input file name with the crashinfo's file name. OS << ' '; @@ -302,8 +303,8 @@ void Command::PrintFileNames() const { if (PrintInputFilenames) { - for (const char *Arg : InputFilenames) - llvm::outs() << llvm::sys::path::filename(Arg) << "\n"; + for (const auto &Arg : InputInfoList) + llvm::outs() << llvm::sys::path::filename(Arg.getFilename()) << "\n"; llvm::outs().flush(); } } Index: clang/include/clang/Driver/Job.h =================================================================== --- clang/include/clang/Driver/Job.h +++ clang/include/clang/Driver/Job.h @@ -10,6 +10,7 @@ #define LLVM_CLANG_DRIVER_JOB_H #include "clang/Basic/LLVM.h" +#include "clang/Driver/InputInfo.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" @@ -119,8 +120,8 @@ /// argument, which will be the executable). llvm::opt::ArgStringList Arguments; - /// The list of program arguments which are inputs. - llvm::opt::ArgStringList InputFilenames; + /// The list of program inputs. + std::vector<InputInfo> InputInfoList; /// The list of program arguments which are outputs. May be empty. std::vector<std::string> OutputFilenames; @@ -207,9 +208,7 @@ const llvm::opt::ArgStringList &getArguments() const { return Arguments; } - const llvm::opt::ArgStringList &getInputFilenames() const { - return InputFilenames; - } + const std::vector<InputInfo> &getInputInfos() const { return InputInfoList; } const std::vector<std::string> &getOutputFilenames() const { return OutputFilenames;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits