clang  14.0.0git
Classes | Public Member Functions | Public Attributes | List of all members
clang::PreprocessorOptions Class Reference

PreprocessorOptions - This class is used for passing the various options used in preprocessor initialization to InitializePreprocessor(). More...

#include "clang/Lex/PreprocessorOptions.h"

Collaboration diagram for clang::PreprocessorOptions:
Collaboration graph
[legend]

Classes

class  FailedModulesSet
 Records the set of modules. More...
 

Public Member Functions

 PreprocessorOptions ()
 
void addMacroDef (StringRef Name)
 
void addMacroUndef (StringRef Name)
 
void addRemappedFile (StringRef From, StringRef To)
 
void addRemappedFile (StringRef From, llvm::MemoryBuffer *To)
 
void clearRemappedFiles ()
 
void resetNonModularOptions ()
 Reset any options that are not considered when building a module. More...
 

Public Attributes

std::vector< std::pair< std::string, bool > > Macros
 
std::vector< std::stringIncludes
 
std::vector< std::stringMacroIncludes
 
bool UsePredefines = true
 Initialize the preprocessor with the compiler and target specific predefines. More...
 
bool DetailedRecord = false
 Whether we should maintain a detailed record of all macro definitions and expansions. More...
 
bool PCHWithHdrStop = false
 When true, we are creating or using a PCH where a #pragma hdrstop is expected to indicate the beginning or end of the PCH. More...
 
bool PCHWithHdrStopCreate = false
 When true, we are creating a PCH or creating the PCH object while expecting a #pragma hdrstop to separate the two. More...
 
std::string PCHThroughHeader
 If non-empty, the filename used in an include directive in the primary source file (or command-line preinclude) that is used to implement MSVC-style precompiled headers. More...
 
std::string ImplicitPCHInclude
 The implicit PCH included at the start of the translation unit, or empty. More...
 
std::vector< std::stringChainedIncludes
 Headers that will be converted to chained PCHs in memory. More...
 
DisableValidationForModuleKind DisablePCHOrModuleValidation
 Whether to disable most of the normal validation performed on precompiled headers and module files. More...
 
bool AllowPCHWithCompilerErrors = false
 When true, a PCH with compiler errors will not be rejected. More...
 
bool AllowPCHWithDifferentModulesCachePath = false
 When true, a PCH with modules cache path different to the current compilation will not be rejected. More...
 
bool DumpDeserializedPCHDecls = false
 Dump declarations that are deserialized from PCH, for testing. More...
 
std::set< std::stringDeserializedPCHDeclsToErrorOn
 This is a set of names for decls that we do not want to be deserialized, and we emit an error if they are; for testing purposes. More...
 
std::pair< unsigned, boolPrecompiledPreambleBytes
 If non-zero, the implicit PCH include is actually a precompiled preamble that covers this number of bytes in the main source file. More...
 
bool GeneratePreamble = false
 True indicates that a preamble is being generated. More...
 
bool WriteCommentListToPCH = true
 Whether to write comment locations into the PCH when building it. More...
 
bool SingleFileParseMode = false
 When enabled, preprocessor is in a mode for parsing a single file only. More...
 
bool LexEditorPlaceholders = true
 When enabled, the preprocessor will construct editor placeholder tokens. More...
 
bool RemappedFilesKeepOriginalName = true
 True if the SourceManager should report the original file name for contents of files that were remapped to other files. More...
 
std::vector< std::pair< std::string, std::string > > RemappedFiles
 The set of file remappings, which take existing files on the system (the first part of each pair) and gives them the contents of other files on the system (the second part of each pair). More...
 
std::vector< std::pair< std::string, llvm::MemoryBuffer * > > RemappedFileBuffers
 The set of file-to-buffer remappings, which take existing files on the system (the first part of each pair) and gives them the contents of the specified memory buffer (the second part of each pair). More...
 
bool RetainRemappedFileBuffers = false
 Whether the compiler instance should retain (i.e., not free) the buffers associated with remapped files. More...
 
bool RetainExcludedConditionalBlocks = false
 When enabled, excluded conditional blocks retain in the main file. More...
 
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary = ARCXX_nolib
 The Objective-C++ ARC standard library that we should support, by providing appropriate definitions to retrofit the standard library with support for lifetime-qualified pointers. More...
 
std::shared_ptr< FailedModulesSetFailedModules
 The set of modules that failed to build. More...
 
ExcludedPreprocessorDirectiveSkipMappingExcludedConditionalDirectiveSkipMappings = nullptr
 Contains the currently active skipped range mappings for skipping excluded conditional directives. More...
 
bool SetUpStaticAnalyzer = false
 Set up preprocessor for RunAnalysis action. More...
 
bool DisablePragmaDebugCrash = false
 Prevents intended crashes when using #pragma clang __debug. For testing. More...
 

Detailed Description

PreprocessorOptions - This class is used for passing the various options used in preprocessor initialization to InitializePreprocessor().

Definition at line 64 of file PreprocessorOptions.h.

Constructor & Destructor Documentation

◆ PreprocessorOptions()

clang::PreprocessorOptions::PreprocessorOptions ( )
inline

Definition at line 217 of file PreprocessorOptions.h.

Member Function Documentation

◆ addMacroDef()

void clang::PreprocessorOptions::addMacroDef ( StringRef  Name)
inline

Definition at line 219 of file PreprocessorOptions.h.

◆ addMacroUndef()

void clang::PreprocessorOptions::addMacroUndef ( StringRef  Name)
inline

Definition at line 222 of file PreprocessorOptions.h.

◆ addRemappedFile() [1/2]

void clang::PreprocessorOptions::addRemappedFile ( StringRef  From,
llvm::MemoryBuffer *  To 
)
inline

Definition at line 230 of file PreprocessorOptions.h.

References RemappedFileBuffers, and string().

◆ addRemappedFile() [2/2]

void clang::PreprocessorOptions::addRemappedFile ( StringRef  From,
StringRef  To 
)
inline

◆ clearRemappedFiles()

void clang::PreprocessorOptions::clearRemappedFiles ( )
inline

Definition at line 234 of file PreprocessorOptions.h.

References RemappedFileBuffers, and RemappedFiles.

Referenced by clang::ASTUnit::CodeComplete().

◆ resetNonModularOptions()

void clang::PreprocessorOptions::resetNonModularOptions ( )
inline

Member Data Documentation

◆ AllowPCHWithCompilerErrors

bool clang::PreprocessorOptions::AllowPCHWithCompilerErrors = false

When true, a PCH with compiler errors will not be rejected.

Definition at line 107 of file PreprocessorOptions.h.

Referenced by clang::GeneratePCHAction::CreateASTConsumer(), and clang::ASTUnit::LoadFromCommandLine().

◆ AllowPCHWithDifferentModulesCachePath

bool clang::PreprocessorOptions::AllowPCHWithDifferentModulesCachePath = false

When true, a PCH with modules cache path different to the current compilation will not be rejected.

Definition at line 111 of file PreprocessorOptions.h.

Referenced by checkHeaderSearchOptions().

◆ ChainedIncludes

std::vector<std::string> clang::PreprocessorOptions::ChainedIncludes

Headers that will be converted to chained PCHs in memory.

Definition at line 99 of file PreprocessorOptions.h.

Referenced by clang::createChainedIncludesSource(), GeneratePreprocessorArgs(), and resetNonModularOptions().

◆ DeserializedPCHDeclsToErrorOn

std::set<std::string> clang::PreprocessorOptions::DeserializedPCHDeclsToErrorOn

This is a set of names for decls that we do not want to be deserialized, and we emit an error if they are; for testing purposes.

Definition at line 118 of file PreprocessorOptions.h.

Referenced by GeneratePreprocessorArgs(), and ParsePreprocessorArgs().

◆ DetailedRecord

bool clang::PreprocessorOptions::DetailedRecord = false

Whether we should maintain a detailed record of all macro definitions and expansions.

Definition at line 76 of file PreprocessorOptions.h.

Referenced by checkPreprocessorOptions(), clang::CompilerInstance::createPreprocessor(), and clang::CompilerInvocation::getModuleHash().

◆ DisablePCHOrModuleValidation

DisableValidationForModuleKind clang::PreprocessorOptions::DisablePCHOrModuleValidation
Initial value:

Whether to disable most of the normal validation performed on precompiled headers and module files.

Definition at line 103 of file PreprocessorOptions.h.

Referenced by clang::CompilerInstance::createASTReader().

◆ DisablePragmaDebugCrash

bool clang::PreprocessorOptions::DisablePragmaDebugCrash = false

Prevents intended crashes when using #pragma clang __debug. For testing.

Definition at line 214 of file PreprocessorOptions.h.

◆ DumpDeserializedPCHDecls

bool clang::PreprocessorOptions::DumpDeserializedPCHDecls = false

Dump declarations that are deserialized from PCH, for testing.

Definition at line 114 of file PreprocessorOptions.h.

Referenced by resetNonModularOptions().

◆ ExcludedConditionalDirectiveSkipMappings

ExcludedPreprocessorDirectiveSkipMapping* clang::PreprocessorOptions::ExcludedConditionalDirectiveSkipMappings = nullptr

Contains the currently active skipped range mappings for skipping excluded conditional directives.

The pointer is passed to the Preprocessor when it's constructed. The pointer is unowned, the client is responsible for its lifetime.

Definition at line 208 of file PreprocessorOptions.h.

◆ FailedModules

std::shared_ptr<FailedModulesSet> clang::PreprocessorOptions::FailedModules

The set of modules that failed to build.

This pointer will be shared among all of the compiler instances created to (re)build modules, so that once a module fails to build anywhere, other instances will see that the module has failed and won't try to build it again.

Definition at line 200 of file PreprocessorOptions.h.

◆ GeneratePreamble

bool clang::PreprocessorOptions::GeneratePreamble = false

True indicates that a preamble is being generated.

When the lexer is done, one of the things that need to be preserved is the conditional if stack, so the ASTWriter/ASTReader can save/restore it when processing the rest of the file.

Definition at line 132 of file PreprocessorOptions.h.

Referenced by clang::PrecompiledPreamble::Build().

◆ ImplicitPCHInclude

std::string clang::PreprocessorOptions::ImplicitPCHInclude

◆ Includes

std::vector<std::string> clang::PreprocessorOptions::Includes

◆ LexEditorPlaceholders

bool clang::PreprocessorOptions::LexEditorPlaceholders = true

When enabled, the preprocessor will construct editor placeholder tokens.

Definition at line 147 of file PreprocessorOptions.h.

Referenced by resetNonModularOptions().

◆ MacroIncludes

std::vector<std::string> clang::PreprocessorOptions::MacroIncludes

Definition at line 68 of file PreprocessorOptions.h.

Referenced by checkPreprocessorOptions(), and resetNonModularOptions().

◆ Macros

std::vector<std::pair<std::string, bool> > clang::PreprocessorOptions::Macros

Definition at line 66 of file PreprocessorOptions.h.

Referenced by collectMacroDefinitions(), and GeneratePreprocessorArgs().

◆ ObjCXXARCStandardLibrary

ObjCXXARCStandardLibraryKind clang::PreprocessorOptions::ObjCXXARCStandardLibrary = ARCXX_nolib

The Objective-C++ ARC standard library that we should support, by providing appropriate definitions to retrofit the standard library with support for lifetime-qualified pointers.

Definition at line 178 of file PreprocessorOptions.h.

◆ PCHThroughHeader

std::string clang::PreprocessorOptions::PCHThroughHeader

If non-empty, the filename used in an include directive in the primary source file (or command-line preinclude) that is used to implement MSVC-style precompiled headers.

When creating a PCH, after the include of this header, the PCH generation stops. When using a PCH, tokens are skipped until after an include of this header is seen.

Definition at line 93 of file PreprocessorOptions.h.

Referenced by checkPreprocessorOptions().

◆ PCHWithHdrStop

bool clang::PreprocessorOptions::PCHWithHdrStop = false

When true, we are creating or using a PCH where a #pragma hdrstop is expected to indicate the beginning or end of the PCH.

Definition at line 80 of file PreprocessorOptions.h.

Referenced by GeneratePreprocessorArgs(), and ParsePreprocessorArgs().

◆ PCHWithHdrStopCreate

bool clang::PreprocessorOptions::PCHWithHdrStopCreate = false

When true, we are creating a PCH or creating the PCH object while expecting a #pragma hdrstop to separate the two.

Allow for a missing #pragma hdrstop, which generates a PCH for the whole file, and creates an empty PCH object.

Definition at line 86 of file PreprocessorOptions.h.

Referenced by GeneratePreprocessorArgs().

◆ PrecompiledPreambleBytes

std::pair<unsigned, bool> clang::PreprocessorOptions::PrecompiledPreambleBytes

If non-zero, the implicit PCH include is actually a precompiled preamble that covers this number of bytes in the main source file.

The boolean indicates whether the preamble ends at the start of a new line.

Definition at line 125 of file PreprocessorOptions.h.

Referenced by clang::PrecompiledPreamble::Build(), clang::CompilerInstance::createPCHExternalASTSource(), clang::VerifyPCHAction::ExecuteAction(), GeneratePreprocessorArgs(), ParsePreprocessorArgs(), and resetNonModularOptions().

◆ RemappedFileBuffers

std::vector<std::pair<std::string, llvm::MemoryBuffer *> > clang::PreprocessorOptions::RemappedFileBuffers

The set of file-to-buffer remappings, which take existing files on the system (the first part of each pair) and gives them the contents of the specified memory buffer (the second part of each pair).

Definition at line 162 of file PreprocessorOptions.h.

Referenced by addRemappedFile(), clearRemappedFiles(), InitializeFileRemapping(), clang::ASTUnit::Reparse(), and clang::ASTUnit::~ASTUnit().

◆ RemappedFiles

std::vector<std::pair<std::string, std::string> > clang::PreprocessorOptions::RemappedFiles

The set of file remappings, which take existing files on the system (the first part of each pair) and gives them the contents of other files on the system (the second part of each pair).

Definition at line 157 of file PreprocessorOptions.h.

Referenced by addRemappedFile(), clang::FixItRecompile::BeginInvocation(), clang::PrecompiledPreamble::CanReuse(), clearRemappedFiles(), GeneratePreprocessorArgs(), and InitializeFileRemapping().

◆ RemappedFilesKeepOriginalName

bool clang::PreprocessorOptions::RemappedFilesKeepOriginalName = true

True if the SourceManager should report the original file name for contents of files that were remapped to other files.

Defaults to true.

Definition at line 151 of file PreprocessorOptions.h.

Referenced by clang::FixItRecompile::BeginInvocation(), InitializeFileRemapping(), and clang::ASTUnit::LoadFromCommandLine().

◆ RetainExcludedConditionalBlocks

bool clang::PreprocessorOptions::RetainExcludedConditionalBlocks = false

When enabled, excluded conditional blocks retain in the main file.

Definition at line 173 of file PreprocessorOptions.h.

Referenced by clang::ASTUnit::LoadFromCommandLine(), and resetNonModularOptions().

◆ RetainRemappedFileBuffers

bool clang::PreprocessorOptions::RetainRemappedFileBuffers = false

Whether the compiler instance should retain (i.e., not free) the buffers associated with remapped files.

This flag defaults to false; it can be set true only through direct manipulation of the compiler invocation object, in cases where the compiler invocation and its buffers will be reused.

Definition at line 170 of file PreprocessorOptions.h.

Referenced by clang::arcmt::FileRemapper::applyMappings(), clang::PrecompiledPreamble::Build(), clang::ASTUnit::CodeComplete(), InitializeFileRemapping(), and resetNonModularOptions().

◆ SetUpStaticAnalyzer

bool clang::PreprocessorOptions::SetUpStaticAnalyzer = false

Set up preprocessor for RunAnalysis action.

Definition at line 211 of file PreprocessorOptions.h.

◆ SingleFileParseMode

bool clang::PreprocessorOptions::SingleFileParseMode = false

When enabled, preprocessor is in a mode for parsing a single file only.

Disables #includes of other files and if there are unresolved identifiers in preprocessor directive conditions it causes all blocks to be parsed so that the client can get the maximum amount of information from the parser.

Definition at line 144 of file PreprocessorOptions.h.

Referenced by clang::ASTUnit::LoadFromCommandLine(), and resetNonModularOptions().

◆ UsePredefines

bool clang::PreprocessorOptions::UsePredefines = true

Initialize the preprocessor with the compiler and target specific predefines.

Definition at line 72 of file PreprocessorOptions.h.

Referenced by checkPreprocessorOptions(), and clang::CompilerInvocation::getModuleHash().

◆ WriteCommentListToPCH

bool clang::PreprocessorOptions::WriteCommentListToPCH = true

Whether to write comment locations into the PCH when building it.

Reading the comments from the PCH can be a performance hit even if the clients don't use them.

Definition at line 137 of file PreprocessorOptions.h.


The documentation for this class was generated from the following file:
clang::DisableValidationForModuleKind::None
@ None
Perform validation, don't disable it.