9#ifndef LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H
10#define LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H
23#include "llvm/ADT/IntrusiveRefCntPtr.h"
24#include "llvm/ADT/ArrayRef.h"
48class DiagnosticsEngine;
49class HeaderSearchOptions;
50class PreprocessorOptions;
55std::unique_ptr<DiagnosticOptions>
67 bool DefaultDiagColor =
true);
85 std::shared_ptr<HeaderSearchOptions>
HSOpts;
88 std::shared_ptr<PreprocessorOptions>
PPOpts;
99 std::shared_ptr<FileSystemOptions>
FSOpts;
160 Args.push_back(Arg.isSingleStringLiteral()
161 ? Arg.getSingleStringRef().data()
183 bool DefaultDiagColor);
186 static void GenerateLangArgs(
const LangOptions &Opts,
193 const llvm::Triple &T,
194 const std::string &OutputFile,
283 const char *Argv0 =
nullptr);
308 const char *Argv0 =
nullptr);
324 static bool ParseLangArgs(
LangOptions &Opts, llvm::opt::ArgList &Args,
326 std::vector<std::string> &Includes,
330 static bool ParseCodeGenArgs(
CodeGenOptions &Opts, llvm::opt::ArgList &Args,
332 const llvm::Triple &T,
333 const std::string &OutputFile,
379IntrusiveRefCntPtr<llvm::vfs::FileSystem>
381 DiagnosticsEngine &Diags);
384 const CompilerInvocation &CI, DiagnosticsEngine &Diags,
385 IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);
387IntrusiveRefCntPtr<llvm::vfs::FileSystem>
389 DiagnosticsEngine &Diags,
390 IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);
Defines the clang::FileSystemOptions interface.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
Stores options for the analyzer from the command line.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
The base class of CompilerInvocation.
~CompilerInvocationBase()=default
std::shared_ptr< MigratorOptions > MigratorOpts
std::shared_ptr< PreprocessorOutputOptions > PreprocessorOutputOpts
Options controlling preprocessed output.
std::shared_ptr< TargetOptions > TargetOpts
Options controlling the target.
const FrontendOptions & getFrontendOpts() const
const CodeGenOptions & getCodeGenOpts() const
CompilerInvocationBase(CompilerInvocationBase &&X)=default
llvm::function_ref< const char *(const Twine &)> StringAllocator
Command line generation.
const FileSystemOptions & getFileSystemOpts() const
std::shared_ptr< PreprocessorOptions > PPOpts
Options controlling the preprocessor (aside from #include handling).
const PreprocessorOutputOptions & getPreprocessorOutputOpts() const
std::vector< std::string > getCC1CommandLine() const
Generate cc1-compatible command line arguments from this instance, wrapping the result as a std::vect...
CompilerInvocationBase(EmptyConstructor)
std::shared_ptr< FileSystemOptions > FSOpts
Options controlling file system operations.
const AnalyzerOptions & getAnalyzerOpts() const
const MigratorOptions & getMigratorOpts() const
void generateCC1CommandLine(llvm::SmallVectorImpl< const char * > &Args, StringAllocator SA) const
Generate cc1-compatible command line arguments from this instance.
CompilerInvocationBase & deep_copy_assign(const CompilerInvocationBase &X)
const DependencyOutputOptions & getDependencyOutputOpts() const
AnalyzerOptionsRef AnalyzerOpts
Options controlling the static analyzer.
IntrusiveRefCntPtr< DiagnosticOptions > DiagnosticOpts
Options controlling the diagnostic engine.
CompilerInvocationBase & shallow_copy_assign(const CompilerInvocationBase &X)
CompilerInvocationBase(const CompilerInvocationBase &X)=delete
const TargetOptions & getTargetOpts() const
CompilerInvocationBase & operator=(CompilerInvocationBase &&X)=default
std::shared_ptr< CodeGenOptions > CodeGenOpts
Options controlling IRgen and the backend.
CompilerInvocationBase & operator=(const CompilerInvocationBase &X)=delete
std::shared_ptr< LangOptions > LangOpts
Options controlling the language variant.
const HeaderSearchOptions & getHeaderSearchOpts() const
std::shared_ptr< HeaderSearchOptions > HSOpts
Options controlling the #include directive.
const PreprocessorOptions & getPreprocessorOpts() const
const DiagnosticOptions & getDiagnosticOpts() const
const LangOptions & getLangOpts() const
Const getters.
std::shared_ptr< FrontendOptions > FrontendOpts
Options controlling the frontend itself.
llvm::function_ref< void(const Twine &)> ArgumentConsumer
std::shared_ptr< DependencyOutputOptions > DependencyOutputOpts
Options controlling dependency output.
Helper class for holding the data necessary to invoke the compiler.
PreprocessorOptions & getPreprocessorOpts()
void clearImplicitModuleBuildOptions()
Disable implicit modules and canonicalize options that are only used by implicit modules.
MigratorOptions & getMigratorOpts()
AnalyzerOptions & getAnalyzerOpts()
static std::string GetResourcesPath(const char *Argv0, void *MainAddr)
Get the directory where the compiler headers reside, relative to the compiler binary (found by the pa...
static bool CreateFromArgs(CompilerInvocation &Res, ArrayRef< const char * > CommandLineArgs, DiagnosticsEngine &Diags, const char *Argv0=nullptr)
Create a compiler invocation from a list of input options.
std::shared_ptr< TargetOptions > TargetOpts
Options controlling the target.
std::shared_ptr< HeaderSearchOptions > getHeaderSearchOptsPtr()
LangOptions & getLangOpts()
Mutable getters.
static bool checkCC1RoundTrip(ArrayRef< const char * > Args, DiagnosticsEngine &Diags, const char *Argv0=nullptr)
Check that Args can be parsed and re-serialized without change, emiting diagnostics for any differenc...
DependencyOutputOptions & getDependencyOutputOpts()
CompilerInvocation()=default
void resetNonModularOptions()
Reset all of the options that are not considered when building a module.
FrontendOptions & getFrontendOpts()
std::string getModuleHash() const
Retrieve a module hash string that is suitable for uniquely identifying the conditions under which th...
CompilerInvocation(const CompilerInvocation &X)
FileSystemOptions & getFileSystemOpts()
IntrusiveRefCntPtr< DiagnosticOptions > DiagnosticOpts
Options controlling the diagnostic engine.
CompilerInvocation(CompilerInvocation &&)=default
CompilerInvocation & operator=(const CompilerInvocation &X)
CodeGenOptions & getCodeGenOpts()
std::shared_ptr< LangOptions > LangOpts
Base class internals.
TargetOptions & getTargetOpts()
HeaderSearchOptions & getHeaderSearchOpts()
DiagnosticOptions & getDiagnosticOpts()
PreprocessorOutputOptions & getPreprocessorOutputOpts()
~CompilerInvocation()=default
std::shared_ptr< PreprocessorOptions > getPreprocessorOptsPtr()
Same as CompilerInvocation, but with copy-on-write optimization.
FrontendOptions & getMutFrontendOpts()
LangOptions & getMutLangOpts()
Mutable getters.
~CowCompilerInvocation()=default
HeaderSearchOptions & getMutHeaderSearchOpts()
MigratorOptions & getMutMigratorOpts()
CowCompilerInvocation(CowCompilerInvocation &&)=default
PreprocessorOptions & getMutPreprocessorOpts()
PreprocessorOutputOptions & getMutPreprocessorOutputOpts()
CodeGenOptions & getMutCodeGenOpts()
TargetOptions & getMutTargetOpts()
FileSystemOptions & getMutFileSystemOpts()
AnalyzerOptions & getMutAnalyzerOpts()
CowCompilerInvocation(const CompilerInvocation &X)
DiagnosticOptions & getMutDiagnosticOpts()
CowCompilerInvocation(const CowCompilerInvocation &X)
DependencyOutputOptions & getMutDependencyOutputOpts()
CowCompilerInvocation()=default
CowCompilerInvocation & operator=(const CowCompilerInvocation &X)
CowCompilerInvocation(CompilerInvocation &&X)
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
Options for controlling the compiler diagnostics engine.
Concrete class used by the front-end to report problems and issues.
Keeps track of options that affect how file operations are performed.
FrontendOptions - Options for controlling the behavior of the frontend.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
PreprocessorOutputOptions - Options for controlling the C preprocessor output (e.g....
Options for controlling the target.
IntrusiveRefCntPtr< llvm::vfs::FileSystem > createVFSFromOverlayFiles(ArrayRef< std::string > VFSOverlayFiles, DiagnosticsEngine &Diags, IntrusiveRefCntPtr< llvm::vfs::FileSystem > BaseFS)
std::unique_ptr< DiagnosticOptions > CreateAndPopulateDiagOpts(ArrayRef< const char * > Argv)
IntrusiveRefCntPtr< llvm::vfs::FileSystem > createVFSFromCompilerInvocation(const CompilerInvocation &CI, DiagnosticsEngine &Diags)
bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args, DiagnosticsEngine *Diags=nullptr, bool DefaultDiagColor=true)
Fill out Opts based on the options given in Args.
YAML serialization mapping.
Dummy tag type whose instance can be passed into the constructor to prevent creation of the reference...