clang API Documentation
Encapsulates changes to the "macros namespace" (the location where the macro name became active, the location where it was undefined, etc.). More...
#include <MacroInfo.h>
Classes | |
class | DefInfo |
Public Types | |
enum | Kind { MD_Define, MD_Undefine, MD_Visibility } |
Public Member Functions | |
Kind | getKind () const |
SourceLocation | getLocation () const |
void | setPrevious (MacroDirective *Prev) |
Set previous definition of the macro with the same name. | |
const MacroDirective * | getPrevious () const |
Get previous definition of the macro with the same name. | |
MacroDirective * | getPrevious () |
Get previous definition of the macro with the same name. | |
bool | isFromPCH () const |
Return true if the macro directive was loaded from a PCH file. | |
void | setIsFromPCH () |
bool | isImported () const |
True if this macro was imported from a module. Note that this is never the case for a VisibilityMacroDirective. | |
unsigned | getOwningModuleID () const |
If this directive was imported from a module, get the submodule whose directive this is. Note that this may be different from the module that owns the MacroInfo for a DefMacroDirective due to #pragma pop_macro and similar effects. | |
ArrayRef< unsigned > | getOverriddenModules () const |
Get the module IDs of modules whose macros are overridden by this directive. Only valid if this is an imported directive. | |
DefInfo | getDefinition () |
Traverses the macro directives history and returns the next macro definition directive along with info about its undefined location (if there is one) and if it is public or private. | |
const DefInfo | getDefinition () const |
bool | isDefined () const |
const MacroInfo * | getMacroInfo () const |
MacroInfo * | getMacroInfo () |
const DefInfo | findDirectiveAtLoc (SourceLocation L, SourceManager &SM) const |
Find macro definition active in the specified source location. If this macro was not defined there, return NULL. | |
void | dump () const |
Static Public Member Functions | |
static bool | classof (const MacroDirective *) |
Protected Member Functions | |
unsigned * | getModuleDataStart () |
const unsigned * | getModuleDataStart () const |
MacroDirective (Kind K, SourceLocation Loc, unsigned ImportedFromModuleID=0, ArrayRef< unsigned > Overrides=None) | |
Protected Attributes | |
MacroDirective * | Previous |
Previous macro directive for the same identifier, or NULL. | |
SourceLocation | Loc |
unsigned | MDKind: 2 |
MacroDirective kind. | |
bool | IsFromPCH: 1 |
True if the macro directive was loaded from a PCH file. | |
bool | IsAmbiguous: 1 |
Whether the definition of this macro is ambiguous, due to multiple definitions coming in from multiple modules. | |
bool | IsPublic: 1 |
Whether the macro has public visibility (when described in a module). | |
bool | IsImported: 1 |
True if this macro was imported from a module. | |
unsigned | NumOverrides: 26 |
For an imported directive, the number of modules whose macros are overridden by this directive. Only used if IsImported. |
Encapsulates changes to the "macros namespace" (the location where the macro name became active, the location where it was undefined, etc.).
MacroDirectives, associated with an identifier, are used to model the macro history. Usually a macro definition (MacroInfo) is where a macro name becomes active (MacroDirective) but modules can have their own macro history, separate from the local (current translation unit) macro history.
For example, if "@import A;" imports macro FOO, there will be a new local MacroDirective created to indicate that "FOO" became active at the import location. Module "A" itself will contain another MacroDirective in its macro history (at the point of the definition of FOO) and both MacroDirectives will point to the same MacroInfo object.
Definition at line 314 of file MacroInfo.h.
Definition at line 316 of file MacroInfo.h.
clang::MacroDirective::MacroDirective | ( | Kind | K, |
SourceLocation | Loc, | ||
unsigned | ImportedFromModuleID = 0 , |
||
ArrayRef< unsigned > | Overrides = None |
||
) | [inline, protected] |
Definition at line 360 of file MacroInfo.h.
References getModuleDataStart(), IsImported, and NumOverrides.
static bool clang::MacroDirective::classof | ( | const MacroDirective * | ) | [inline, static] |
Reimplemented in clang::VisibilityMacroDirective, clang::UndefMacroDirective, and clang::DefMacroDirective.
Definition at line 482 of file MacroInfo.h.
void MacroDirective::dump | ( | ) | const |
Definition at line 208 of file MacroInfo.cpp.
References getKind(), getPrevious(), IsAmbiguous, IsFromPCH, IsImported, IsPublic, MD_Define, MD_Undefine, and MD_Visibility.
const MacroDirective::DefInfo MacroDirective::findDirectiveAtLoc | ( | SourceLocation | L, |
SourceManager & | SM | ||
) | const |
Find macro definition active in the specified source location. If this macro was not defined there, return NULL.
Definition at line 196 of file MacroInfo.cpp.
References getDefinition(), clang::MacroDirective::DefInfo::getPreviousDefinition(), clang::SourceManager::isBeforeInTranslationUnit(), and clang::SourceLocation::isValid().
Referenced by isMacroDefined().
Traverses the macro directives history and returns the next macro definition directive along with info about its undefined location (if there is one) and if it is public or private.
Definition at line 172 of file MacroInfo.cpp.
References getPrevious(), and clang::VisibilityMacroDirective::isPublic().
Referenced by checkConfigMacro(), findDirectiveAtLoc(), getDefinition(), getMacroInfo(), and isDefined().
const DefInfo clang::MacroDirective::getDefinition | ( | ) | const [inline] |
Definition at line 459 of file MacroInfo.h.
References getDefinition().
Kind clang::MacroDirective::getKind | ( | ) | const [inline] |
Definition at line 377 of file MacroInfo.h.
References MDKind.
Referenced by clang::DefMacroDirective::classof(), clang::UndefMacroDirective::classof(), clang::VisibilityMacroDirective::classof(), and dump().
SourceLocation clang::MacroDirective::getLocation | ( | ) | const [inline] |
Definition at line 379 of file MacroInfo.h.
References Loc.
Referenced by clang::MacroDirective::DefInfo::getLocation(), and shouldIgnoreMacro().
const MacroInfo* clang::MacroDirective::getMacroInfo | ( | ) | const [inline] |
Definition at line 469 of file MacroInfo.h.
References getDefinition(), and clang::MacroDirective::DefInfo::getMacroInfo().
Referenced by clang::CodeCompletionResult::CreateCodeCompletionString(), EvaluateDefined(), and shouldIgnoreMacro().
MacroInfo* clang::MacroDirective::getMacroInfo | ( | ) | [inline] |
Definition at line 472 of file MacroInfo.h.
References getDefinition(), and clang::MacroDirective::DefInfo::getMacroInfo().
unsigned * clang::MacroDirective::getModuleDataStart | ( | ) | [inline, protected] |
Definition at line 554 of file MacroInfo.h.
Referenced by getModuleDataStart(), getOverriddenModules(), getOwningModuleID(), and MacroDirective().
const unsigned* clang::MacroDirective::getModuleDataStart | ( | ) | const [inline, protected] |
Definition at line 356 of file MacroInfo.h.
References getModuleDataStart().
ArrayRef<unsigned> clang::MacroDirective::getOverriddenModules | ( | ) | const [inline] |
Get the module IDs of modules whose macros are overridden by this directive. Only valid if this is an imported directive.
Definition at line 413 of file MacroInfo.h.
References getModuleDataStart(), IsImported, and NumOverrides.
unsigned clang::MacroDirective::getOwningModuleID | ( | ) | const [inline] |
If this directive was imported from a module, get the submodule whose directive this is. Note that this may be different from the module that owns the MacroInfo for a DefMacroDirective due to #pragma pop_macro and similar effects.
Definition at line 405 of file MacroInfo.h.
References getModuleDataStart(), and isImported().
const MacroDirective* clang::MacroDirective::getPrevious | ( | ) | const [inline] |
Get previous definition of the macro with the same name.
Definition at line 387 of file MacroInfo.h.
References Previous.
Referenced by clang::Preprocessor::appendMacroDirective(), dump(), and getDefinition().
MacroDirective* clang::MacroDirective::getPrevious | ( | ) | [inline] |
Get previous definition of the macro with the same name.
Definition at line 390 of file MacroInfo.h.
References Previous.
bool clang::MacroDirective::isDefined | ( | ) | const [inline] |
Definition at line 463 of file MacroInfo.h.
References getDefinition().
Referenced by clang::Preprocessor::appendMacroDirective(), clang::CodeCompletionResult::CreateCodeCompletionString(), clang::Preprocessor::getMacroDirective(), and clang::Preprocessor::setLoadedMacroDirective().
bool clang::MacroDirective::isFromPCH | ( | ) | const [inline] |
Return true if the macro directive was loaded from a PCH file.
Definition at line 393 of file MacroInfo.h.
References IsFromPCH.
bool clang::MacroDirective::isImported | ( | ) | const [inline] |
True if this macro was imported from a module. Note that this is never the case for a VisibilityMacroDirective.
Definition at line 399 of file MacroInfo.h.
References IsImported.
Referenced by getOwningModuleID(), and shouldIgnoreMacro().
void clang::MacroDirective::setIsFromPCH | ( | ) | [inline] |
Definition at line 395 of file MacroInfo.h.
References IsFromPCH.
void clang::MacroDirective::setPrevious | ( | MacroDirective * | Prev | ) | [inline] |
Set previous definition of the macro with the same name.
Definition at line 382 of file MacroInfo.h.
References Previous.
Referenced by clang::Preprocessor::appendMacroDirective(), and clang::ASTReader::installPCHMacroDirectives().
bool clang::MacroDirective::IsAmbiguous [protected] |
Whether the definition of this macro is ambiguous, due to multiple definitions coming in from multiple modules.
Definition at line 338 of file MacroInfo.h.
Referenced by dump(), clang::DefMacroDirective::isAmbiguous(), and clang::DefMacroDirective::setAmbiguous().
bool clang::MacroDirective::IsFromPCH [protected] |
True if the macro directive was loaded from a PCH file.
Definition at line 332 of file MacroInfo.h.
Referenced by dump(), isFromPCH(), and setIsFromPCH().
bool clang::MacroDirective::IsImported [protected] |
True if this macro was imported from a module.
Definition at line 349 of file MacroInfo.h.
Referenced by dump(), getOverriddenModules(), isImported(), and MacroDirective().
bool clang::MacroDirective::IsPublic [protected] |
Whether the macro has public visibility (when described in a module).
Definition at line 344 of file MacroInfo.h.
Referenced by dump(), clang::VisibilityMacroDirective::isPublic(), and clang::VisibilityMacroDirective::VisibilityMacroDirective().
SourceLocation clang::MacroDirective::Loc [protected] |
Definition at line 326 of file MacroInfo.h.
Referenced by getLocation().
unsigned clang::MacroDirective::MDKind [protected] |
unsigned clang::MacroDirective::NumOverrides [protected] |
For an imported directive, the number of modules whose macros are overridden by this directive. Only used if IsImported.
Definition at line 353 of file MacroInfo.h.
Referenced by getOverriddenModules(), and MacroDirective().
MacroDirective* clang::MacroDirective::Previous [protected] |
Previous macro directive for the same identifier, or NULL.
Definition at line 324 of file MacroInfo.h.
Referenced by getPrevious(), and setPrevious().