clang API Documentation
#include <MacroArgs.h>
Public Member Functions | |
| void | destroy (Preprocessor &PP) |
| bool | ArgNeedsPreexpansion (const Token *ArgTok, Preprocessor &PP) const |
| const Token * | getUnexpArgument (unsigned Arg) const |
| const std::vector< Token > & | getPreExpArgument (unsigned Arg, const MacroInfo *MI, Preprocessor &PP) |
| const Token & | getStringifiedArgument (unsigned ArgNo, Preprocessor &PP, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd) |
| unsigned | getNumArguments () const |
| bool | isVarargsElidedUse () const |
| MacroArgs * | deallocate () |
Static Public Member Functions | |
| static MacroArgs * | create (const MacroInfo *MI, ArrayRef< Token > UnexpArgTokens, bool VarargsElided, Preprocessor &PP) |
| MacroArgs ctor function - This destroys the vector passed in. | |
| static unsigned | getArgLength (const Token *ArgPtr) |
| static Token | StringifyArgument (const Token *ArgToks, Preprocessor &PP, bool Charify, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd) |
MacroArgs - An instance of this class captures information about the formal arguments specified to a function-like macro invocation.
Definition at line 29 of file MacroArgs.h.
| bool MacroArgs::ArgNeedsPreexpansion | ( | const Token * | ArgTok, |
| Preprocessor & | PP | ||
| ) | const |
ArgNeedsPreexpansion - If we can prove that the argument won't be affected by pre-expansion, return false. Otherwise, conservatively return true.
Definition at line 131 of file MacroArgs.cpp.
References clang::comments::tok::eof, clang::Token::getIdentifierInfo(), clang::Preprocessor::getMacroInfo(), clang::MacroInfo::isEnabled(), and clang::Token::isNot().
| MacroArgs * MacroArgs::create | ( | const MacroInfo * | MI, |
| ArrayRef< Token > | UnexpArgTokens, | ||
| bool | VarargsElided, | ||
| Preprocessor & | PP | ||
| ) | [static] |
MacroArgs ctor function - This destroys the vector passed in.
MacroArgs ctor function - Create a new MacroArgs object with the specified macro and argument info.
Definition at line 25 of file MacroArgs.cpp.
References getUnexpArgument(), clang::MacroInfo::isFunctionLike(), and Token.
deallocate - This should only be called by the Preprocessor when managing its freelist.
Definition at line 88 of file MacroArgs.cpp.
| void MacroArgs::destroy | ( | Preprocessor & | PP | ) |
destroy - Destroy and deallocate the memory for this object.
Definition at line 73 of file MacroArgs.cpp.
| unsigned MacroArgs::getArgLength | ( | const Token * | ArgPtr | ) | [static] |
getArgLength - Given a pointer to an expanded or unexpanded argument, return the number of tokens, not counting the EOF, that make up the argument.
Definition at line 103 of file MacroArgs.cpp.
References clang::comments::tok::eof, and clang::Token::isNot().
Referenced by getPreExpArgument().
| unsigned clang::MacroArgs::getNumArguments | ( | ) | const [inline] |
getNumArguments - Return the number of arguments passed into this macro invocation.
Definition at line 98 of file MacroArgs.h.
Referenced by getStringifiedArgument().
| const std::vector< Token > & MacroArgs::getPreExpArgument | ( | unsigned | Arg, |
| const MacroInfo * | MI, | ||
| Preprocessor & | PP | ||
| ) |
getPreExpArgument - Return the pre-expanded form of the specified argument.
Definition at line 148 of file MacroArgs.cpp.
References clang::Preprocessor::EnterTokenStream(), clang::comments::tok::eof, getArgLength(), clang::MacroInfo::getNumArgs(), getUnexpArgument(), clang::Preprocessor::Lex(), clang::Preprocessor::RemoveTopOfLexerStack(), and Token.
| const Token & MacroArgs::getStringifiedArgument | ( | unsigned | ArgNo, |
| Preprocessor & | PP, | ||
| SourceLocation | ExpansionLocStart, | ||
| SourceLocation | ExpansionLocEnd | ||
| ) |
getStringifiedArgument - Compute, cache, and return the specified argument that has been 'stringified' as required by the # operator.
Definition at line 298 of file MacroArgs.cpp.
References getNumArguments(), getUnexpArgument(), and StringifyArgument().
| const Token * MacroArgs::getUnexpArgument | ( | unsigned | Arg | ) | const |
getUnexpArgument - Return a pointer to the first token of the unexpanded token list for the specified formal.
getUnexpArgument - Return the unexpanded tokens for the specified formal.
Definition at line 113 of file MacroArgs.cpp.
References clang::comments::tok::eof, and clang::Token::is().
Referenced by create(), getPreExpArgument(), and getStringifiedArgument().
| bool clang::MacroArgs::isVarargsElidedUse | ( | ) | const [inline] |
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.
Definition at line 106 of file MacroArgs.h.
| Token MacroArgs::StringifyArgument | ( | const Token * | ArgToks, |
| Preprocessor & | PP, | ||
| bool | Charify, | ||
| SourceLocation | ExpansionLocStart, | ||
| SourceLocation | ExpansionLocEnd | ||
| ) | [static] |
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.
Definition at line 195 of file MacroArgs.cpp.
References clang::Preprocessor::CodeCompleteNaturalLanguage(), clang::Preprocessor::CreateString(), clang::Preprocessor::Diag(), clang::comments::tok::eof, clang::Token::getKind(), clang::Token::getLength(), clang::Preprocessor::getSpelling(), clang::Token::hasLeadingSpace(), clang::Token::is(), clang::Token::isAtStartOfLine(), clang::Token::isNot(), clang::tok::isStringLiteral(), clang::Token::setKind(), clang::Token::startToken(), and clang::Lexer::Stringify().
Referenced by getStringifiedArgument().