aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Driver/Driver.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Driver/Driver.h')
-rw-r--r--include/clang/Driver/Driver.h93
1 files changed, 68 insertions, 25 deletions
diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h
index a3662872a953..017248c3690f 100644
--- a/include/clang/Driver/Driver.h
+++ b/include/clang/Driver/Driver.h
@@ -19,6 +19,8 @@
#include "clang/Driver/Util.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/StringSaver.h"
#include <list>
#include <map>
@@ -26,14 +28,6 @@
namespace llvm {
class Triple;
-
-namespace opt {
- class Arg;
- class ArgList;
- class DerivedArgList;
- class InputArgList;
- class OptTable;
-}
}
namespace clang {
@@ -138,6 +132,12 @@ public:
/// The path to the compiler resource directory.
std::string ResourceDir;
+ /// System directory for config files.
+ std::string SystemConfigDir;
+
+ /// User directory for config files.
+ std::string UserConfigDir;
+
/// A prefix directory used to emulate a limited subset of GCC's '-Bprefix'
/// functionality.
/// FIXME: This type of customization should be removed in favor of the
@@ -202,12 +202,27 @@ public:
unsigned CCGenDiagnostics : 1;
private:
- /// Default target triple.
- std::string DefaultTargetTriple;
+ /// Raw target triple.
+ std::string TargetTriple;
/// Name to use when invoking gcc/g++.
std::string CCCGenericGCCName;
+ /// Name of configuration file if used.
+ std::string ConfigFile;
+
+ /// Allocator for string saver.
+ llvm::BumpPtrAllocator Alloc;
+
+ /// Object that stores strings read from configuration file.
+ llvm::StringSaver Saver;
+
+ /// Arguments originated from configuration file.
+ std::unique_ptr<llvm::opt::InputArgList> CfgOptions;
+
+ /// Arguments originated from command line.
+ std::unique_ptr<llvm::opt::InputArgList> CLOptions;
+
/// Whether to check that input files exist when constructing compilation
/// jobs.
unsigned CheckInputsExist : 1;
@@ -228,7 +243,7 @@ private:
std::list<std::string> TempFiles;
std::list<std::string> ResultFiles;
- /// \brief Cache of all the ToolChains in use by the driver.
+ /// Cache of all the ToolChains in use by the driver.
///
/// This maps from the string representation of a triple to a ToolChain
/// created targeting that triple. The driver owns all the ToolChain objects
@@ -252,7 +267,7 @@ private:
void generatePrefixedToolNames(StringRef Tool, const ToolChain &TC,
SmallVectorImpl<std::string> &Names) const;
- /// \brief Find the appropriate .crash diagonostic file for the child crash
+ /// Find the appropriate .crash diagonostic file for the child crash
/// under this driver and copy it out to a temporary destination with the
/// other reproducer related files (.sh, .cache, etc). If not found, suggest a
/// directory for the user to look at.
@@ -267,7 +282,7 @@ private:
SmallString<128> &CrashDiagDir);
public:
- Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
+ Driver(StringRef ClangExecutable, StringRef TargetTriple,
DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
@@ -277,6 +292,8 @@ public:
/// Name to use when invoking gcc/g++.
const std::string &getCCCGenericGCCName() const { return CCCGenericGCCName; }
+ const std::string &getConfigFile() const { return ConfigFile; }
+
const llvm::opt::OptTable &getOpts() const { return *Opts; }
const DiagnosticsEngine &getDiags() const { return Diags; }
@@ -292,12 +309,14 @@ public:
const std::string &getTitle() { return DriverTitle; }
void setTitle(std::string Value) { DriverTitle = std::move(Value); }
- /// \brief Get the path to the main clang executable.
+ std::string getTargetTriple() const { return TargetTriple; }
+
+ /// Get the path to the main clang executable.
const char *getClangProgramPath() const {
return ClangExecutable.c_str();
}
- /// \brief Get the path to where the clang executable was installed.
+ /// Get the path to where the clang executable was installed.
const char *getInstalledDir() const {
if (!InstalledDir.empty())
return InstalledDir.c_str();
@@ -388,11 +407,19 @@ public:
int ExecuteCompilation(Compilation &C,
SmallVectorImpl< std::pair<int, const Command *> > &FailingCommands);
- /// generateCompilationDiagnostics - Generate diagnostics information
+ /// Contains the files in the compilation diagnostic report generated by
+ /// generateCompilationDiagnostics.
+ struct CompilationDiagnosticReport {
+ llvm::SmallVector<std::string, 4> TemporaryFiles;
+ };
+
+ /// generateCompilationDiagnostics - Generate diagnostics information
/// including preprocessed source file(s).
- ///
- void generateCompilationDiagnostics(Compilation &C,
- const Command &FailingCommand);
+ ///
+ void generateCompilationDiagnostics(
+ Compilation &C, const Command &FailingCommand,
+ StringRef AdditionalInformation = "",
+ CompilationDiagnosticReport *GeneratedReport = nullptr);
/// @}
/// @name Helper Methods
@@ -425,9 +452,9 @@ public:
// FIXME: This should be in CompilationInfo.
std::string GetProgramPath(StringRef Name, const ToolChain &TC) const;
- /// handleAutocompletions - Handle --autocomplete by searching and printing
+ /// HandleAutocompletions - Handle --autocomplete by searching and printing
/// possible flags, descriptions, and its arguments.
- void handleAutocompletions(StringRef PassedFlags) const;
+ void HandleAutocompletions(StringRef PassedFlags) const;
/// HandleImmediateArgs - Handle any arguments which should be
/// treated before building actions or binding tools.
@@ -439,8 +466,10 @@ public:
/// ConstructAction - Construct the appropriate action to do for
/// \p Phase on the \p Input, taking in to account arguments
/// like -fsyntax-only or --analyze.
- Action *ConstructPhaseAction(Compilation &C, const llvm::opt::ArgList &Args,
- phases::ID Phase, Action *Input) const;
+ Action *ConstructPhaseAction(
+ Compilation &C, const llvm::opt::ArgList &Args, phases::ID Phase,
+ Action *Input,
+ Action::OffloadKind TargetDeviceOffloadKind = Action::OFK_None) const;
/// BuildJobsForAction - Construct the jobs to perform for the action \p A and
/// return an InputInfo for the result of running \p A. Will only construct
@@ -493,6 +522,18 @@ public:
LTOKind getLTOMode() const { return LTOMode; }
private:
+
+ /// Tries to load options from configuration file.
+ ///
+ /// \returns true if error occurred.
+ bool loadConfigFile();
+
+ /// Read options from the specified file.
+ ///
+ /// \param [in] FileName File to read.
+ /// \returns true, if error occurred while reading.
+ bool readConfigFile(StringRef FileName);
+
/// Set the driver mode (cl, gcc, etc) from an option string of the form
/// --driver-mode=<mode>.
void setDriverModeFromOption(StringRef Opt);
@@ -501,7 +542,7 @@ private:
/// compilation based on which -f(no-)?lto(=.*)? option occurs last.
void setLTOMode(const llvm::opt::ArgList &Args);
- /// \brief Retrieves a ToolChain for a particular \p Target triple.
+ /// Retrieves a ToolChain for a particular \p Target triple.
///
/// Will cache ToolChains for the life of the driver object, and create them
/// on-demand.
@@ -510,7 +551,7 @@ private:
/// @}
- /// \brief Get bitmasks for which option flags to include and exclude based on
+ /// Get bitmasks for which option flags to include and exclude based on
/// the driver mode.
std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks() const;
@@ -543,6 +584,8 @@ public:
/// no extra characters remaining at the end.
static bool GetReleaseVersion(StringRef Str,
MutableArrayRef<unsigned> Digits);
+ /// Compute the default -fmodule-cache-path.
+ static void getDefaultModuleCachePath(SmallVectorImpl<char> &Result);
};
/// \return True if the last defined optimization level is -Ofast.