clang  8.0.0svn
Public Member Functions | Static Public Member Functions | List of all members
clang::SrcMgr::ExpansionInfo Class Reference

Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded, and the SpellingLoc - where the actual character data for the token came from. More...

#include "clang/Basic/SourceManager.h"

Public Member Functions

SourceLocation getSpellingLoc () const
 
SourceLocation getExpansionLocStart () const
 
SourceLocation getExpansionLocEnd () const
 
bool isExpansionTokenRange () const
 
CharSourceRange getExpansionLocRange () const
 
bool isMacroArgExpansion () const
 
bool isMacroBodyExpansion () const
 
bool isFunctionMacroExpansion () const
 

Static Public Member Functions

static ExpansionInfo create (SourceLocation SpellingLoc, SourceLocation Start, SourceLocation End, bool ExpansionIsTokenRange=true)
 Return a ExpansionInfo for an expansion. More...
 
static ExpansionInfo createForMacroArg (SourceLocation SpellingLoc, SourceLocation ExpansionLoc)
 Return a special ExpansionInfo for the expansion of a macro argument into a function-like macro's body. More...
 
static ExpansionInfo createForTokenSplit (SourceLocation SpellingLoc, SourceLocation Start, SourceLocation End)
 Return a special ExpansionInfo representing a token that ends prematurely. More...
 

Detailed Description

Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded, and the SpellingLoc - where the actual character data for the token came from.

Definition at line 306 of file SourceManager.h.

Member Function Documentation

◆ create()

static ExpansionInfo clang::SrcMgr::ExpansionInfo::create ( SourceLocation  SpellingLoc,
SourceLocation  Start,
SourceLocation  End,
bool  ExpansionIsTokenRange = true 
)
inlinestatic

Return a ExpansionInfo for an expansion.

Start and End specify the expansion range (where the macro is expanded), and SpellingLoc specifies the spelling location (where the characters from the token come from). All three can refer to normal File SLocs or expansion locations.

Definition at line 371 of file SourceManager.h.

References clang::SourceLocation::getRawEncoding(), and X.

◆ createForMacroArg()

static ExpansionInfo clang::SrcMgr::ExpansionInfo::createForMacroArg ( SourceLocation  SpellingLoc,
SourceLocation  ExpansionLoc 
)
inlinestatic

Return a special ExpansionInfo for the expansion of a macro argument into a function-like macro's body.

ExpansionLoc specifies the expansion location (where the macro is expanded). This doesn't need to be a range because a macro is always expanded at a macro parameter reference, and macro parameters are always exactly one token. SpellingLoc specifies the spelling location (where the characters from the token come from). ExpansionLoc and SpellingLoc can both refer to normal File SLocs or expansion locations.

Given the code:

#define F(x) f(x)
F(42);

When expanding 'F(42)', the 'x' would call this with an SpellingLoc pointing at '42' and an ExpansionLoc pointing at its location in the definition of 'F'.

Definition at line 401 of file SourceManager.h.

References clang::serialized_diags::create().

◆ createForTokenSplit()

static ExpansionInfo clang::SrcMgr::ExpansionInfo::createForTokenSplit ( SourceLocation  SpellingLoc,
SourceLocation  Start,
SourceLocation  End 
)
inlinestatic

Return a special ExpansionInfo representing a token that ends prematurely.

This is used to model a '>>' token that has been split into '>' tokens and similar cases. Unlike for the other forms of expansion, the expansion range in this case is a character range, not a token range.

Definition at line 414 of file SourceManager.h.

References clang::serialized_diags::create().

◆ getExpansionLocEnd()

SourceLocation clang::SrcMgr::ExpansionInfo::getExpansionLocEnd ( ) const
inline

◆ getExpansionLocRange()

CharSourceRange clang::SrcMgr::ExpansionInfo::getExpansionLocRange ( ) const
inline

Definition at line 343 of file SourceManager.h.

Referenced by clang::SourceManager::getImmediateExpansionRange().

◆ getExpansionLocStart()

SourceLocation clang::SrcMgr::ExpansionInfo::getExpansionLocStart ( ) const
inline

◆ getSpellingLoc()

SourceLocation clang::SrcMgr::ExpansionInfo::getSpellingLoc ( ) const
inline

◆ isExpansionTokenRange()

bool clang::SrcMgr::ExpansionInfo::isExpansionTokenRange ( ) const
inline

Definition at line 339 of file SourceManager.h.

Referenced by clang::ASTImporter::Import().

◆ isFunctionMacroExpansion()

bool clang::SrcMgr::ExpansionInfo::isFunctionMacroExpansion ( ) const
inline

Definition at line 360 of file SourceManager.h.

Referenced by isFunctionMacroExpansion().

◆ isMacroArgExpansion()

bool clang::SrcMgr::ExpansionInfo::isMacroArgExpansion ( ) const
inline

◆ isMacroBodyExpansion()

bool clang::SrcMgr::ExpansionInfo::isMacroBodyExpansion ( ) const
inline

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