clang 10.0.0git

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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 "clang/Lex/MacroInfo.h"`

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

## 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. More...
const MacroDirective * | getPrevious () const
| Get previous definition of the macro with the same name. More...
MacroDirective * | getPrevious ()
| Get previous definition of the macro with the same name. More...
bool | isFromPCH () const
| Return true if the macro directive was loaded from a PCH file. More...
void | setIsFromPCH ()
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. More...
const DefInfo | getDefinition () const
bool | isDefined () const
const MacroInfo * | getMacroInfo () const
MacroInfo * | getMacroInfo ()
const DefInfo | findDirectiveAtLoc (SourceLocation L, const SourceManager &SM) const
| Find macro definition active in the specified source location. More...
void | dump () const

## Static Public Member Functions
static bool | classof (const MacroDirective *)

## Protected Member Functions
| MacroDirective (Kind K, SourceLocation Loc)

## Protected Attributes
MacroDirective * | Previous = nullptr
| Previous macro directive for the same identifier, or nullptr. More...
SourceLocation | Loc
unsigned | MDKind: 2
| MacroDirective kind. More...
unsigned | IsFromPCH: 1
| True if the macro directive was loaded from a PCH file. More...
unsigned | IsPublic: 1
| Whether the macro has public visibility (when described in a module). More...

## 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 #pragma push_macro / pop_macro can create additional DefMacroDirectives for the same MacroInfo.

Definition at line 290 of file MacroInfo.h.

## Member Enumeration Documentation

## ◆ Kind

enum clang::MacroDirective::Kind

Enumerator
MD_Define |
MD_Undefine |
MD_Visibility |

Definition at line 292 of file MacroInfo.h.

## Constructor & Destructor Documentation

## ◆ MacroDirective()

clang::MacroDirective::MacroDirective | ( | Kind | K,
|  | SourceLocation | Loc
| ) |  |
| inline protected

Definition at line 316 of file MacroInfo.h.

## Member Function Documentation

## ◆ classof()

static bool clang::MacroDirective::classof | ( | const MacroDirective * |  | ) |
| inline static

Definition at line 402 of file MacroInfo.h.

## ◆ dump()

LLVM_DUMP_METHOD void MacroDirective::dump | ( |  | ) | const

Definition at line 215 of file MacroInfo.cpp.

References getKind().

## ◆ findDirectiveAtLoc()

const MacroDirective::DefInfo MacroDirective::findDirectiveAtLoc | ( | SourceLocation | L,
|  | const SourceManager & | SM
| ) |  | const

Find macro definition active in the specified source location.

If this macro was not defined there, return NULL.

Definition at line 202 of file MacroInfo.cpp.

References getDefinition(), clang::SourceManager::isBeforeInTranslationUnit(), and clang::SourceLocation::isValid().

## ◆ getDefinition() [1/2]

MacroDirective::DefInfo MacroDirective::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.

Definition at line 178 of file MacroInfo.cpp.

References getPrevious(), and clang::VisibilityMacroDirective::isPublic().

Referenced by clang::Preprocessor::getLocalMacroDirective().

## ◆ getDefinition() [2/2]

const DefInfo clang::MacroDirective::getDefinition | ( |  | ) | const
| inline

Definition at line 380 of file MacroInfo.h.

References getDefinition().

## ◆ getKind()

Kind clang::MacroDirective::getKind | ( |  | ) | const
| inline

Definition at line 320 of file MacroInfo.h.

Referenced by clang::DefMacroDirective::classof(), clang::UndefMacroDirective::classof(), and clang::VisibilityMacroDirective::classof().

## ◆ getLocation()

SourceLocation clang::MacroDirective::getLocation | ( |  | ) | const
| inline

Definition at line 322 of file MacroInfo.h.

Referenced by shouldIgnoreMacro().

## ◆ getMacroInfo() [1/2]

const MacroInfo* clang::MacroDirective::getMacroInfo | ( |  | ) | const
| inline

Definition at line 390 of file MacroInfo.h.

References getDefinition().

Referenced by clang::PreprocessingRecord::findMacroDefinition(), clang::Preprocessor::getMacroInfo(), and shouldIgnoreMacro().

## ◆ getMacroInfo() [2/2]

MacroInfo* clang::MacroDirective::getMacroInfo | ( |  | ) |
| inline

Definition at line 393 of file MacroInfo.h.

References clang::MacroInfo::dump(), getDefinition(), and SM.

## ◆ getPrevious() [1/2]

const MacroDirective* clang::MacroDirective::getPrevious | ( |  | ) | const
| inline

Get previous definition of the macro with the same name.

Definition at line 328 of file MacroInfo.h.

References Previous.

Referenced by clang::Preprocessor::appendMacroDirective(), getDefinition(), and clang::Preprocessor::LeaveSubmodule().

## ◆ getPrevious() [2/2]

MacroDirective* clang::MacroDirective::getPrevious | ( |  | ) |
| inline

Get previous definition of the macro with the same name.

Definition at line 331 of file MacroInfo.h.

References Previous.

## ◆ isDefined()

bool clang::MacroDirective::isDefined | ( |  | ) | const
| inline

Definition at line 384 of file MacroInfo.h.

References getDefinition().

Referenced by clang::Preprocessor::appendMacroDirective(), clang::Preprocessor::isMacroDefinedInLocalModule(), and clang::Preprocessor::setLoadedMacroDirective().

## ◆ isFromPCH()

bool clang::MacroDirective::isFromPCH | ( |  | ) | const
| inline

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

Definition at line 334 of file MacroInfo.h.

## ◆ setIsFromPCH()

void clang::MacroDirective::setIsFromPCH | ( |  | ) |
| inline

Definition at line 336 of file MacroInfo.h.

## ◆ setPrevious()

void clang::MacroDirective::setPrevious | ( | MacroDirective * | Prev | ) |
| inline

Set previous definition of the macro with the same name.

Definition at line 325 of file MacroInfo.h.

Referenced by clang::Preprocessor::appendMacroDirective(), clang::ASTReader::resolvePendingMacro(), and clang::Preprocessor::setLoadedMacroDirective().

## Member Data Documentation

## ◆ IsFromPCH

unsigned clang::MacroDirective::IsFromPCH
| protected

True if the macro directive was loaded from a PCH file.

Definition at line 308 of file MacroInfo.h.

## ◆ IsPublic

unsigned clang::MacroDirective::IsPublic
| protected

Whether the macro has public visibility (when described in a module).

Definition at line 314 of file MacroInfo.h.

## ◆ Loc

SourceLocation clang::MacroDirective::Loc
| protected

Definition at line 302 of file MacroInfo.h.

## ◆ MDKind

unsigned clang::MacroDirective::MDKind
| protected

MacroDirective kind.

Definition at line 305 of file MacroInfo.h.

## ◆ Previous

MacroDirective* clang::MacroDirective::Previous = nullptr
| protected

Previous macro directive for the same identifier, or nullptr.

Definition at line 300 of file MacroInfo.h.

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

- include/clang/Lex/MacroInfo.h
- lib/Lex/MacroInfo.cpp