clang API Documentation

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
clang::MacroDirective Class Reference

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>

Inheritance diagram for clang::MacroDirective:
Inheritance graph
[legend]
Collaboration diagram for clang::MacroDirective:
Collaboration graph
[legend]

List of all members.

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 MacroDirectivegetPrevious () const
 Get previous definition of the macro with the same name.
MacroDirectivegetPrevious ()
 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< unsignedgetOverriddenModules () 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 MacroInfogetMacroInfo () const
MacroInfogetMacroInfo ()
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

unsignedgetModuleDataStart ()
const unsignedgetModuleDataStart () const
 MacroDirective (Kind K, SourceLocation Loc, unsigned ImportedFromModuleID=0, ArrayRef< unsigned > Overrides=None)

Protected Attributes

MacroDirectivePrevious
 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.

Detailed Description

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.


Member Enumeration Documentation

Enumerator:
MD_Define 
MD_Undefine 
MD_Visibility 

Definition at line 316 of file MacroInfo.h.


Constructor & Destructor Documentation

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.


Member Function Documentation

static bool clang::MacroDirective::classof ( const MacroDirective ) [inline, static]
void MacroDirective::dump ( ) 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().

Definition at line 459 of file MacroInfo.h.

References getDefinition().

Definition at line 379 of file MacroInfo.h.

References Loc.

Referenced by clang::MacroDirective::DefInfo::getLocation(), and shouldIgnoreMacro().

Definition at line 472 of file MacroInfo.h.

References getDefinition(), and clang::MacroDirective::DefInfo::getMacroInfo().

const unsigned* clang::MacroDirective::getModuleDataStart ( ) const [inline, protected]

Definition at line 356 of file MacroInfo.h.

References getModuleDataStart().

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.

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().

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().

Get previous definition of the macro with the same name.

Definition at line 390 of file MacroInfo.h.

References Previous.

Return true if the macro directive was loaded from a PCH file.

Definition at line 393 of file MacroInfo.h.

References IsFromPCH.

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().

Definition at line 395 of file MacroInfo.h.

References IsFromPCH.

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().


Member Data Documentation

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().

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().

True if this macro was imported from a module.

Definition at line 349 of file MacroInfo.h.

Referenced by dump(), getOverriddenModules(), isImported(), and MacroDirective().

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().

Definition at line 326 of file MacroInfo.h.

Referenced by getLocation().

MacroDirective kind.

Definition at line 329 of file MacroInfo.h.

Referenced by getKind().

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().

Previous macro directive for the same identifier, or NULL.

Definition at line 324 of file MacroInfo.h.

Referenced by getPrevious(), and setPrevious().


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