class MacroArgs

Declaration

class MacroArgs : private TrailingObjects { /* full declaration omitted */ };

Description

MacroArgs - An instance of this class captures information about the formal arguments specified to a function-like macro invocation.

Declared at: clang/include/clang/Lex/MacroArgs.h:29

Inherits from: TrailingObjects

Member Variables

private unsigned int NumUnexpArgTokens
NumUnexpArgTokens - The number of raw, unexpanded tokens for the arguments. All of the actual argument tokens are allocated immediately after the MacroArgs object in memory. This is all of the arguments concatenated together, with 'EOF' markers at the end of each argument.
private bool VarargsElided
VarargsElided - True if this is a C99 style varargs macro invocation and there was no argument specified for the "..." argument. If the argument was specified (even empty) or this isn't a C99 style varargs function, or if in strict mode and the C99 varargs macro had only a ... argument, this is false.
private std::vector<std::vector<Token>> PreExpArgTokens
PreExpArgTokens - Pre-expanded tokens for arguments that need them. Empty if not yet computed. This includes the EOF marker at the end of the stream.
private clang::MacroArgs* ArgCache
ArgCache - This is a linked list of MacroArgs objects that the Preprocessor owns which we use to avoid thrashing malloc/free.
private unsigned int NumMacroArgs
MacroArgs - The number of arguments the invoked macro expects.

Method Overview

  • public bool ArgNeedsPreexpansion(const clang::Token * ArgTok, clang::Preprocessor & PP) const
  • private MacroArgs(unsigned int NumToks, bool varargsElided, unsigned int MacroArgs)
  • public static clang::Token StringifyArgument(const clang::Token * ArgToks, clang::Preprocessor & PP, bool Charify, clang::SourceLocation ExpansionLocStart, clang::SourceLocation ExpansionLocEnd)
  • public static clang::MacroArgs * create(const clang::MacroInfo * MI, ArrayRef<clang::Token> UnexpArgTokens, bool VarargsElided, clang::Preprocessor & PP)
  • public clang::MacroArgs * deallocate()
  • public void destroy(clang::Preprocessor & PP)
  • public static unsigned int getArgLength(const clang::Token * ArgPtr)
  • public unsigned int getNumMacroArguments() const
  • public const std::vector<Token> & getPreExpArgument(unsigned int Arg, clang::Preprocessor & PP)
  • public const clang::Token * getUnexpArgument(unsigned int Arg) const
  • public bool invokedWithVariadicArgument(const clang::MacroInfo *const MI, clang::Preprocessor & PP)
  • public bool isVarargsElidedUse() const
  • private ~MacroArgs()

Methods

bool ArgNeedsPreexpansion(
    const clang::Token* ArgTok,
    clang::Preprocessor& PP) const

Description

ArgNeedsPreexpansion - If we can prove that the argument won't be affected by pre-expansion, return false. Otherwise, conservatively return true.

Declared at: clang/include/clang/Lex/MacroArgs.h:76

Parameters

const clang::Token* ArgTok
clang::Preprocessor& PP

MacroArgs(unsigned int NumToks,
          bool varargsElided,
          unsigned int MacroArgs)

Declared at: clang/include/clang/Lex/MacroArgs.h:58

Parameters

unsigned int NumToks
bool varargsElided
unsigned int MacroArgs

static clang::Token StringifyArgument(
    const clang::Token* ArgToks,
    clang::Preprocessor& PP,
    bool Charify,
    clang::SourceLocation ExpansionLocStart,
    clang::SourceLocation ExpansionLocEnd)

Description

StringifyArgument - Implement C99 6.10.3.2p2, converting a sequence of tokens into the literal string token that should be produced by the C # preprocessor operator. If Charify is true, then it should be turned into a character literal for the Microsoft charize (# @ ) extension.

Declared at: clang/include/clang/Lex/MacroArgs.h:124

Parameters

const clang::Token* ArgToks
clang::Preprocessor& PP
bool Charify
clang::SourceLocation ExpansionLocStart
clang::SourceLocation ExpansionLocEnd

static clang::MacroArgs* create(
    const clang::MacroInfo* MI,
    ArrayRef<clang::Token> UnexpArgTokens,
    bool VarargsElided,
    clang::Preprocessor& PP)

Description

MacroArgs ctor function - Create a new MacroArgs object with the specified macro and argument info.

Declared at: clang/include/clang/Lex/MacroArgs.h:66

Parameters

const clang::MacroInfo* MI
ArrayRef<clang::Token> UnexpArgTokens
bool VarargsElided
clang::Preprocessor& PP

clang::MacroArgs* deallocate()

Description

deallocate - This should only be called by the Preprocessor when managing its freelist.

Declared at: clang/include/clang/Lex/MacroArgs.h:132

void destroy(clang::Preprocessor& PP)

Description

destroy - Destroy and deallocate the memory for this object.

Declared at: clang/include/clang/Lex/MacroArgs.h:72

Parameters

clang::Preprocessor& PP

static unsigned int getArgLength(
    const clang::Token* ArgPtr)

Description

getArgLength - Given a pointer to an expanded or unexpanded argument, return the number of tokens, not counting the EOF, that make up the argument.

Declared at: clang/include/clang/Lex/MacroArgs.h:86

Parameters

const clang::Token* ArgPtr

unsigned int getNumMacroArguments() const

Description

getNumMacroArguments - Return the number of arguments the invoked macro expects.

Declared at: clang/include/clang/Lex/MacroArgs.h:95

const std::vector<Token>& getPreExpArgument(
    unsigned int Arg,
    clang::Preprocessor& PP)

Description

getPreExpArgument - Return the pre-expanded form of the specified argument.

Declared at: clang/include/clang/Lex/MacroArgs.h:91

Parameters

unsigned int Arg
clang::Preprocessor& PP

const clang::Token* getUnexpArgument(
    unsigned int Arg) const

Description

getUnexpArgument - Return a pointer to the first token of the unexpanded token list for the specified formal.

Declared at: clang/include/clang/Lex/MacroArgs.h:81

Parameters

unsigned int Arg

bool invokedWithVariadicArgument(
    const clang::MacroInfo* const MI,
    clang::Preprocessor& PP)

Description

Returns true if the macro was defined with a variadic (ellipsis) parameter AND was invoked with at least one token supplied as a variadic argument (after pre-expansion).

Declared at: clang/include/clang/Lex/MacroArgs.h:117

Parameters

const clang::MacroInfo* const MI
clang::Preprocessor& PP

bool isVarargsElidedUse() const

Description

isVarargsElidedUse - Return true if this is a C99 style varargs macro invocation and there was no argument specified for the "..." argument. If the argument was specified (even empty) or this isn't a C99 style varargs function, or if in strict mode and the C99 varargs macro had only a ... argument, this returns false.

Declared at: clang/include/clang/Lex/MacroArgs.h:102

~MacroArgs()

Declared at: clang/include/clang/Lex/MacroArgs.h:61