9 #ifndef LLVM_CLANG_DRIVER_JOB_H
10 #define LLVM_CLANG_DRIVER_JOB_H
14 #include "llvm/ADT/ArrayRef.h"
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/ADT/iterator.h"
19 #include "llvm/Option/Option.h"
20 #include "llvm/Support/Program.h"
80 return {
RF_None, llvm::sys::WEM_UTF8,
nullptr};
87 return {
RF_Full, llvm::sys::WEM_UTF8,
"@"};
94 return {
RF_Full, llvm::sys::WEM_CurrentCodePage,
"@"};
101 return {
RF_Full, llvm::sys::WEM_UTF16,
"@"};
123 const char *Executable;
143 const char *PrependArg;
147 llvm::opt::ArgStringList Arguments;
153 std::vector<std::string> OutputFilenames;
157 const char *ResponseFile =
nullptr;
161 llvm::opt::ArgStringList InputFileList;
165 std::string ResponseFileFlag;
168 std::vector<const char *> Environment;
171 std::vector<std::optional<std::string>> RedirectFiles;
174 mutable std::optional<llvm::sys::ProcessStatistics> ProcStat;
186 void writeResponseFile(raw_ostream &OS)
const;
199 const char *PrependArg =
nullptr);
205 virtual void Print(llvm::raw_ostream &OS,
const char *Terminator,
bool Quote,
209 std::string *ErrMsg,
bool *ExecutionFailed)
const;
236 return ResponseSupport;
245 InputFileList = std::move(List);
258 Arguments = std::move(List);
265 const llvm::opt::ArgStringList &
getArguments()
const {
return Arguments; }
270 return OutputFilenames;
287 const llvm::opt::ArgStringList &Arguments,
290 const char *PrependArg =
nullptr);
292 void Print(llvm::raw_ostream &OS,
const char *Terminator,
bool Quote,
295 int Execute(
ArrayRef<std::optional<StringRef>> Redirects, std::string *ErrMsg,
296 bool *ExecutionFailed)
const override;
306 using iterator = llvm::pointee_iterator<list_type::iterator>;
313 void Print(llvm::raw_ostream &OS,
const char *Terminator,
317 void addJob(std::unique_ptr<Command> J) { Jobs.push_back(std::move(J)); }
326 bool empty()
const {
return Jobs.empty(); }
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Action - Represent an abstract compilation step to perform.
Use the CC1 tool callback when available, to avoid creating a new process.
void setEnvironment(llvm::ArrayRef< const char * > NewEnvironment) override
Sets the environment to be used by the new process.
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo=nullptr) const override
int Execute(ArrayRef< std::optional< StringRef >> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const override
CC1Command(const Action &Source, const Tool &Creator, ResponseFileSupport ResponseSupport, const char *Executable, const llvm::opt::ArgStringList &Arguments, ArrayRef< InputInfo > Inputs, ArrayRef< InputInfo > Outputs=std::nullopt, const char *PrependArg=nullptr)
Command - An executable path/name and argument vector to execute.
llvm::DenseMap< int, std::string > ErrorCodeDiagMapTy
const char * getExecutable() const
const ResponseFileSupport & getResponseFileSupport()
Returns the kind of response file supported by the current invocation.
const Tool & getCreator() const
getCreator - Return the Tool which caused the creation of this job.
void addDiagForErrorCode(int ErrorCode, StringRef CustomDiag)
Store a custom driver diagnostic message upon a particular error code returned by the command.
virtual ~Command()=default
void setResponseFile(const char *FileName)
Set to pass arguments via a response file when launching the command.
Command(const Command &)=default
StringRef getDiagForErrorCode(int ErrorCode) const
Get the custom driver diagnostic message for a particular error code if such was stored.
void replaceExecutable(const char *Exe)
void setInputFileList(llvm::opt::ArgStringList List)
Set an input file list, necessary if you specified an RF_FileList response file support.
void addExitForErrorCode(int ErrorCode, bool Exit)
Store if the compilation should exit upon a particular error code returned by the command.
bool PrintInputFilenames
Whether to print the input filenames when executing.
const std::vector< std::string > & getOutputFilenames() const
virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo=nullptr) const
bool getWillExitForErrorCode(int ErrorCode) const
Will the tool exit when a particular error code is encountered.
bool InProcess
Whether the command will be executed in this process or not.
virtual int Execute(ArrayRef< std::optional< StringRef >> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const
std::optional< llvm::sys::ProcessStatistics > getProcessStatistics() const
virtual void setEnvironment(llvm::ArrayRef< const char * > NewEnvironment)
Sets the environment to be used by the new process.
Command(const Action &Source, const Tool &Creator, ResponseFileSupport ResponseSupport, const char *Executable, const llvm::opt::ArgStringList &Arguments, ArrayRef< InputInfo > Inputs, ArrayRef< InputInfo > Outputs=std::nullopt, const char *PrependArg=nullptr)
const std::vector< InputInfo > & getInputInfos() const
const llvm::opt::ArgStringList & getArguments() const
const Action & getSource() const
getSource - Return the Action which caused the creation of this job.
llvm::DenseMap< int, bool > ErrorCodeExitMapTy
void setRedirectFiles(const std::vector< std::optional< std::string >> &Redirects)
void replaceArguments(llvm::opt::ArgStringList List)
void PrintFileNames() const
Optionally print the filenames to be compiled.
JobList - A sequence of jobs to perform.
list_type & getJobsForOverride()
Return a mutable list of Jobs for llvm-foreach wrapping.
list_type::size_type size_type
void clear()
Clear the job list.
const_iterator begin() const
const list_type & getJobs() const
void addJob(std::unique_ptr< Command > J)
Add a job to the list (taking ownership).
const_iterator end() const
llvm::pointee_iterator< list_type::iterator > iterator
llvm::pointee_iterator< list_type::const_iterator > const_iterator
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo=nullptr) const
The JSON file list parser is used to communicate input to InstallAPI.
CrashReportInfo(StringRef Filename, StringRef VFSPath)
ResponseFileKind ResponseKind
The level of support for response files.
llvm::sys::WindowsEncodingMethod ResponseEncoding
The encoding to use when writing response files on Windows.
static constexpr ResponseFileSupport None()
Returns a ResponseFileSupport indicating that response files are not supported.
static constexpr ResponseFileSupport AtFileUTF8()
const char * ResponseFlag
What prefix to use for the command-line argument when passing a response file.
static constexpr ResponseFileSupport AtFileCurCP()
static constexpr ResponseFileSupport AtFileUTF16()