clang 19.0.0git
Public Member Functions | Public Attributes | List of all members
clang::format::MacroExpansion Struct Reference

Contains information on the token's role in a macro expansion. More...

#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/Format/FormatToken.h"

Public Member Functions

 MacroExpansion (MacroRole Role)
 

Public Attributes

MacroRole Role
 The token's role in the macro expansion.
 
llvm::SmallVector< FormatToken *, 1 > ExpandedFrom
 The stack of macro call identifier tokens this token was expanded from.
 
unsigned StartOfExpansion = 0
 The number of expansions of which this macro is the first entry.
 
unsigned EndOfExpansion = 0
 The number of currently open expansions in ExpandedFrom this macro is the last token in.
 

Detailed Description

Contains information on the token's role in a macro expansion.

Given the following definitions: A(X) = [ X ] B(X) = < X > C(X) = X

Consider the macro call: A({B(C(C(x)))}) -> [{<x>}]

In this case, the tokens of the unexpanded macro call will have the following relevant entries in their macro context (note that formatting the unexpanded macro call happens after formatting the expanded macro call): A( { B( C( C(x) ) ) } ) Role: NN U NN NN NNUN N N U N (N=None, U=UnexpandedArg)

              [  { <       x    > } ]

Role: H E H E H E H (H=Hidden, E=ExpandedArg) ExpandedFrom[0]: A A A A A A A ExpandedFrom[1]: B B B ExpandedFrom[2]: C ExpandedFrom[3]: C StartOfExpansion: 1 0 1 2 0 0 0 EndOfExpansion: 0 0 0 2 1 0 1

Definition at line 258 of file FormatToken.h.

Constructor & Destructor Documentation

◆ MacroExpansion()

clang::format::MacroExpansion::MacroExpansion ( MacroRole  Role)
inline

Definition at line 259 of file FormatToken.h.

References Role.

Member Data Documentation

◆ EndOfExpansion

unsigned clang::format::MacroExpansion::EndOfExpansion = 0

The number of currently open expansions in ExpandedFrom this macro is the last token in.

Definition at line 277 of file FormatToken.h.

◆ ExpandedFrom

llvm::SmallVector<FormatToken *, 1> clang::format::MacroExpansion::ExpandedFrom

The stack of macro call identifier tokens this token was expanded from.

Definition at line 270 of file FormatToken.h.

◆ Role

MacroRole clang::format::MacroExpansion::Role

The token's role in the macro expansion.

When formatting an expanded macro, all tokens that are part of macro arguments will be MR_ExpandedArg, while all tokens that are not visible in the macro call will be MR_Hidden. When formatting an unexpanded macro call, all tokens that are part of macro arguments will be MR_UnexpandedArg.

Definition at line 267 of file FormatToken.h.

Referenced by MacroExpansion().

◆ StartOfExpansion

unsigned clang::format::MacroExpansion::StartOfExpansion = 0

The number of expansions of which this macro is the first entry.

Definition at line 273 of file FormatToken.h.


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