clang 22.0.0git
clang::CompilerInvocationBase Class Reference

The base class of CompilerInvocation. More...

#include "clang/Frontend/CompilerInvocation.h"

Inheritance diagram for clang::CompilerInvocationBase:
[legend]

Classes

struct  EmptyConstructor
 Dummy tag type whose instance can be passed into the constructor to prevent creation of the reference-counted option objects. More...

Public Member Functions

const LangOptionsgetLangOpts () const
 Const getters.
const TargetOptionsgetTargetOpts () const
const DiagnosticOptionsgetDiagnosticOpts () const
const HeaderSearchOptionsgetHeaderSearchOpts () const
const PreprocessorOptionsgetPreprocessorOpts () const
const AnalyzerOptionsgetAnalyzerOpts () const
const MigratorOptionsgetMigratorOpts () const
const APINotesOptionsgetAPINotesOpts () const
const CodeGenOptionsgetCodeGenOpts () const
const FileSystemOptionsgetFileSystemOpts () const
const FrontendOptionsgetFrontendOpts () const
const DependencyOutputOptionsgetDependencyOutputOpts () const
const PreprocessorOutputOptionsgetPreprocessorOutputOpts () const
void visitPaths (llvm::function_ref< bool(StringRef)> Callback) const
 Visitation.

Protected Member Functions

 CompilerInvocationBase ()
 CompilerInvocationBase (EmptyConstructor)
 CompilerInvocationBase (const CompilerInvocationBase &X)=delete
 CompilerInvocationBase (CompilerInvocationBase &&X)=default
CompilerInvocationBaseoperator= (const CompilerInvocationBase &X)=delete
CompilerInvocationBasedeep_copy_assign (const CompilerInvocationBase &X)
CompilerInvocationBaseshallow_copy_assign (const CompilerInvocationBase &X)
CompilerInvocationBaseoperator= (CompilerInvocationBase &&X)=default
 ~CompilerInvocationBase ()=default

Protected Attributes

std::shared_ptr< LangOptionsLangOpts
 Options controlling the language variant.
std::shared_ptr< TargetOptionsTargetOpts
 Options controlling the target.
std::shared_ptr< DiagnosticOptionsDiagnosticOpts
 Options controlling the diagnostic engine.
std::shared_ptr< HeaderSearchOptionsHSOpts
 Options controlling the #include directive.
std::shared_ptr< PreprocessorOptionsPPOpts
 Options controlling the preprocessor (aside from #include handling).
std::shared_ptr< AnalyzerOptionsAnalyzerOpts
 Options controlling the static analyzer.
std::shared_ptr< MigratorOptionsMigratorOpts
std::shared_ptr< APINotesOptionsAPINotesOpts
 Options controlling API notes.
std::shared_ptr< CodeGenOptionsCodeGenOpts
 Options controlling IRgen and the backend.
std::shared_ptr< FileSystemOptionsFSOpts
 Options controlling file system operations.
std::shared_ptr< FrontendOptionsFrontendOpts
 Options controlling the frontend itself.
std::shared_ptr< DependencyOutputOptionsDependencyOutputOpts
 Options controlling dependency output.
std::shared_ptr< PreprocessorOutputOptionsPreprocessorOutputOpts
 Options controlling preprocessed output.
using StringAllocator = llvm::function_ref<const char *(const Twine &)>
 Command line generation.
using ArgumentConsumer = llvm::function_ref<void(const Twine &)>
void visitPathsImpl (llvm::function_ref< bool(std::string &)> Predicate)
 Visits paths stored in the invocation.
void generateCC1CommandLine (llvm::SmallVectorImpl< const char * > &Args, StringAllocator SA) const
 Generate cc1-compatible command line arguments from this instance.
void generateCC1CommandLine (ArgumentConsumer Consumer) const
 Generate cc1-compatible command line arguments from this instance.
std::vector< std::string > getCC1CommandLine () const
 Generate cc1-compatible command line arguments from this instance, wrapping the result as a std::vector<std::string>.

Detailed Description

The base class of CompilerInvocation.

It keeps individual option objects behind reference-counted pointers, which is useful for clients that want to keep select option objects alive (even after CompilerInvocation gets destroyed) without making a copy.

Definition at line 79 of file CompilerInvocation.h.

Member Typedef Documentation

◆ ArgumentConsumer

using clang::CompilerInvocationBase::ArgumentConsumer = llvm::function_ref<void(const Twine &)>

Definition at line 183 of file CompilerInvocation.h.

◆ StringAllocator

using clang::CompilerInvocationBase::StringAllocator = llvm::function_ref<const char *(const Twine &)>

Command line generation.

Definition at line 164 of file CompilerInvocation.h.

Constructor & Destructor Documentation

◆ CompilerInvocationBase() [1/4]

◆ CompilerInvocationBase() [2/4]

clang::CompilerInvocationBase::CompilerInvocationBase ( EmptyConstructor )
inlineprotected

Definition at line 124 of file CompilerInvocation.h.

◆ CompilerInvocationBase() [3/4]

clang::CompilerInvocationBase::CompilerInvocationBase ( const CompilerInvocationBase & X)
protecteddelete

References CompilerInvocationBase(), and X.

◆ CompilerInvocationBase() [4/4]

clang::CompilerInvocationBase::CompilerInvocationBase ( CompilerInvocationBase && X)
protecteddefault

References CompilerInvocationBase(), and X.

◆ ~CompilerInvocationBase()

clang::CompilerInvocationBase::~CompilerInvocationBase ( )
protecteddefault

Member Function Documentation

◆ deep_copy_assign()

◆ generateCC1CommandLine() [1/2]

◆ generateCC1CommandLine() [2/2]

void clang::CompilerInvocationBase::generateCC1CommandLine ( llvm::SmallVectorImpl< const char * > & Args,
StringAllocator SA ) const
inline

Generate cc1-compatible command line arguments from this instance.

Parameters
[out]Args- The generated arguments. Note that the caller is responsible for inserting the path to the clang executable and "-cc1" if desired.
SA- A function that given a Twine can allocate storage for a given command line argument and return a pointer to the newly allocated string. The returned pointer is what gets appended to Args.

Definition at line 173 of file CompilerInvocation.h.

References generateCC1CommandLine().

Referenced by clang::CompilerInvocation::checkCC1RoundTrip(), clang::CompilerInvocation::CreateFromArgs(), generateCC1CommandLine(), getCC1CommandLine(), and getModuleContextHash().

◆ getAnalyzerOpts()

const AnalyzerOptions & clang::CompilerInvocationBase::getAnalyzerOpts ( ) const
inline

◆ getAPINotesOpts()

const APINotesOptions & clang::CompilerInvocationBase::getAPINotesOpts ( ) const
inline

◆ getCC1CommandLine()

std::vector< std::string > CompilerInvocationBase::getCC1CommandLine ( ) const

Generate cc1-compatible command line arguments from this instance, wrapping the result as a std::vector<std::string>.

This is a (less-efficient) wrapper over generateCC1CommandLine().

Definition at line 5387 of file CompilerInvocation.cpp.

References generateCC1CommandLine().

Referenced by clang::tooling::dependencies::CompilerInstanceWithContext::computeDependencies().

◆ getCodeGenOpts()

const CodeGenOptions & clang::CompilerInvocationBase::getCodeGenOpts ( ) const
inline

◆ getDependencyOutputOpts()

const DependencyOutputOptions & clang::CompilerInvocationBase::getDependencyOutputOpts ( ) const
inline

◆ getDiagnosticOpts()

const DiagnosticOptions & clang::CompilerInvocationBase::getDiagnosticOpts ( ) const
inline

◆ getFileSystemOpts()

const FileSystemOptions & clang::CompilerInvocationBase::getFileSystemOpts ( ) const
inline

◆ getFrontendOpts()

const FrontendOptions & clang::CompilerInvocationBase::getFrontendOpts ( ) const
inline

◆ getHeaderSearchOpts()

const HeaderSearchOptions & clang::CompilerInvocationBase::getHeaderSearchOpts ( ) const
inline

◆ getLangOpts()

const LangOptions & clang::CompilerInvocationBase::getLangOpts ( ) const
inline

Const getters.

Definition at line 136 of file CompilerInvocation.h.

References LangOpts.

Referenced by generateCC1CommandLine(), and clang::CompilerInvocation::~CompilerInvocation().

◆ getMigratorOpts()

const MigratorOptions & clang::CompilerInvocationBase::getMigratorOpts ( ) const
inline

◆ getPreprocessorOpts()

const PreprocessorOptions & clang::CompilerInvocationBase::getPreprocessorOpts ( ) const
inline

◆ getPreprocessorOutputOpts()

const PreprocessorOutputOptions & clang::CompilerInvocationBase::getPreprocessorOutputOpts ( ) const
inline

◆ getTargetOpts()

const TargetOptions & clang::CompilerInvocationBase::getTargetOpts ( ) const
inline

◆ operator=() [1/2]

CompilerInvocationBase & clang::CompilerInvocationBase::operator= ( CompilerInvocationBase && X)
protecteddefault

References CompilerInvocationBase(), and X.

◆ operator=() [2/2]

CompilerInvocationBase & clang::CompilerInvocationBase::operator= ( const CompilerInvocationBase & X)
protecteddelete

References CompilerInvocationBase(), and X.

◆ shallow_copy_assign()

◆ visitPaths()

void CompilerInvocationBase::visitPaths ( llvm::function_ref< bool(StringRef)> Callback) const

Visitation.

Visits paths stored in the invocation. The callback may return true to short-circuit the visitation, or return false to continue visiting.

Definition at line 5355 of file CompilerInvocation.cpp.

References CompilerInvocationBase(), and visitPathsImpl().

Referenced by isSafeToIgnoreCWD().

◆ visitPathsImpl()

void CompilerInvocationBase::visitPathsImpl ( llvm::function_ref< bool(std::string &)> Predicate)
protected

Visits paths stored in the invocation.

This is generally unsafe to call directly, and each sub-class need to ensure calling this doesn't violate its invariants.

Definition at line 5282 of file CompilerInvocation.cpp.

References CodeGenOpts, DependencyOutputOpts, clang::File, FrontendOpts, FSOpts, HSOpts, LangOpts, PPOpts, RETURN_IF, and RETURN_IF_MANY.

Referenced by visitPaths().

Member Data Documentation

◆ AnalyzerOpts

std::shared_ptr<AnalyzerOptions> clang::CompilerInvocationBase::AnalyzerOpts
protected

◆ APINotesOpts

◆ CodeGenOpts

std::shared_ptr<CodeGenOptions> clang::CompilerInvocationBase::CodeGenOpts
protected

◆ DependencyOutputOpts

std::shared_ptr<DependencyOutputOptions> clang::CompilerInvocationBase::DependencyOutputOpts
protected

◆ DiagnosticOpts

std::shared_ptr<DiagnosticOptions> clang::CompilerInvocationBase::DiagnosticOpts
protected

◆ FrontendOpts

std::shared_ptr<FrontendOptions> clang::CompilerInvocationBase::FrontendOpts
protected

◆ FSOpts

std::shared_ptr<FileSystemOptions> clang::CompilerInvocationBase::FSOpts
protected

◆ HSOpts

std::shared_ptr<HeaderSearchOptions> clang::CompilerInvocationBase::HSOpts
protected

◆ LangOpts

◆ MigratorOpts

◆ PPOpts

std::shared_ptr<PreprocessorOptions> clang::CompilerInvocationBase::PPOpts
protected

◆ PreprocessorOutputOpts

std::shared_ptr<PreprocessorOutputOptions> clang::CompilerInvocationBase::PreprocessorOutputOpts
protected

◆ TargetOpts

std::shared_ptr<TargetOptions> clang::CompilerInvocationBase::TargetOpts
protected

The documentation for this class was generated from the following files: