clang API Documentation
Encapsulates the data about a macro definition (e.g. its tokens). More...
#include <MacroInfo.h>
Public Types | |
typedef IdentifierInfo *const * | arg_iterator |
typedef SmallVectorImpl< Token > ::const_iterator | tokens_iterator |
Public Member Functions | |
SourceLocation | getDefinitionLoc () const |
Return the location that the macro was defined at. | |
void | setDefinitionEndLoc (SourceLocation EndLoc) |
Set the location of the last token in the macro. | |
SourceLocation | getDefinitionEndLoc () const |
Return the location of the last token in the macro. | |
unsigned | getDefinitionLength (SourceManager &SM) const |
Get length in characters of the macro definition. | |
bool | isIdenticalTo (const MacroInfo &Other, Preprocessor &PP, bool Syntactically) const |
Return true if the specified macro definition is equal to this macro in spelling, arguments, and whitespace. | |
void | setIsBuiltinMacro (bool Val=true) |
Set or clear the isBuiltinMacro flag. | |
void | setIsUsed (bool Val) |
Set the value of the IsUsed flag. | |
void | setIsAllowRedefinitionsWithoutWarning (bool Val) |
Set the value of the IsAllowRedefinitionsWithoutWarning flag. | |
void | setIsWarnIfUnused (bool val) |
Set the value of the IsWarnIfUnused flag. | |
void | setArgumentList (IdentifierInfo *const *List, unsigned NumArgs, llvm::BumpPtrAllocator &PPAllocator) |
Set the specified list of identifiers as the argument list for this macro. | |
bool | arg_empty () const |
arg_iterator | arg_begin () const |
arg_iterator | arg_end () const |
unsigned | getNumArgs () const |
int | getArgumentNum (IdentifierInfo *Arg) const |
Return the argument number of the specified identifier, or -1 if the identifier is not a formal argument identifier. | |
void | setIsFunctionLike () |
bool | isFunctionLike () const |
bool | isObjectLike () const |
void | setIsC99Varargs () |
Varargs querying methods. This can only be set for function-like macros. | |
void | setIsGNUVarargs () |
bool | isC99Varargs () const |
bool | isGNUVarargs () const |
bool | isVariadic () const |
bool | isBuiltinMacro () const |
Return true if this macro requires processing before expansion. | |
bool | hasCommaPasting () const |
void | setHasCommaPasting () |
bool | isUsed () const |
Return false if this macro is defined in the main file and has not yet been used. | |
bool | isAllowRedefinitionsWithoutWarning () const |
Return true if this macro can be redefined without warning. | |
bool | isWarnIfUnused () const |
Return true if we should emit a warning if the macro is unused. | |
unsigned | getNumTokens () const |
Return the number of tokens that this macro expands to. | |
const Token & | getReplacementToken (unsigned Tok) const |
tokens_iterator | tokens_begin () const |
tokens_iterator | tokens_end () const |
bool | tokens_empty () const |
void | AddTokenToBody (const Token &Tok) |
Add the specified token to the replacement text for the macro. | |
bool | isEnabled () const |
Return true if this macro is enabled. | |
void | EnableMacro () |
void | DisableMacro () |
bool | isFromASTFile () const |
Determine whether this macro info came from an AST file (such as a precompiled header or module) rather than having been parsed. | |
bool | isUsedForHeaderGuard () const |
Determine whether this macro was used for a header guard. | |
void | setUsedForHeaderGuard (bool Val) |
unsigned | getOwningModuleID () const |
Retrieve the global ID of the module that owns this particular macro info. | |
void | dump () const |
Friends | |
class | Preprocessor |
Encapsulates the data about a macro definition (e.g. its tokens).
There's an instance of this class for every #define.
Definition at line 30 of file MacroInfo.h.
typedef IdentifierInfo* const* clang::MacroInfo::arg_iterator |
Arguments - The list of arguments for a function-like macro. This can be empty, for, e.g. "#define X()".
Definition at line 177 of file MacroInfo.h.
typedef SmallVectorImpl<Token>::const_iterator clang::MacroInfo::tokens_iterator |
Definition at line 240 of file MacroInfo.h.
void clang::MacroInfo::AddTokenToBody | ( | const Token & | Tok | ) | [inline] |
Add the specified token to the replacement text for the macro.
Definition at line 246 of file MacroInfo.h.
Referenced by clang::ASTReader::ReadMacroRecord().
arg_iterator clang::MacroInfo::arg_begin | ( | ) | const [inline] |
Definition at line 179 of file MacroInfo.h.
Referenced by clang::CodeCompletionResult::CreateCodeCompletionString(), getArgumentNum(), isIdenticalTo(), isTrivialSingleTokenExpansion(), and PrintMacroDefinition().
bool clang::MacroInfo::arg_empty | ( | ) | const [inline] |
Definition at line 178 of file MacroInfo.h.
Referenced by PrintMacroDefinition().
arg_iterator clang::MacroInfo::arg_end | ( | ) | const [inline] |
Definition at line 180 of file MacroInfo.h.
Referenced by clang::CodeCompletionResult::CreateCodeCompletionString(), getArgumentNum(), isIdenticalTo(), isTrivialSingleTokenExpansion(), and PrintMacroDefinition().
void clang::MacroInfo::DisableMacro | ( | ) | [inline] |
Definition at line 262 of file MacroInfo.h.
Referenced by clang::TokenLexer::Init().
void MacroInfo::dump | ( | ) | const |
Definition at line 129 of file MacroInfo.cpp.
References clang::tok::getKeywordSpelling(), clang::IdentifierInfo::getName(), and clang::tok::getPunctuatorSpelling().
void clang::MacroInfo::EnableMacro | ( | ) | [inline] |
Definition at line 257 of file MacroInfo.h.
Referenced by clang::TokenLexer::Lex().
int clang::MacroInfo::getArgumentNum | ( | IdentifierInfo * | Arg | ) | const [inline] |
Return the argument number of the specified identifier, or -1 if the identifier is not a formal argument identifier.
Definition at line 185 of file MacroInfo.h.
References arg_begin(), and arg_end().
Referenced by isIdenticalTo().
SourceLocation clang::MacroInfo::getDefinitionEndLoc | ( | ) | const [inline] |
Return the location of the last token in the macro.
Definition at line 122 of file MacroInfo.h.
unsigned clang::MacroInfo::getDefinitionLength | ( | SourceManager & | SM | ) | const [inline] |
Get length in characters of the macro definition.
Definition at line 125 of file MacroInfo.h.
Referenced by clang::TokenLexer::Init().
SourceLocation clang::MacroInfo::getDefinitionLoc | ( | ) | const [inline] |
Return the location that the macro was defined at.
Definition at line 116 of file MacroInfo.h.
Referenced by clang::Preprocessor::appendDefMacroDirective(), areDefinedInSystemModules(), clang::Preprocessor::HandlePragmaPopMacro(), and clang::Preprocessor::markMacroAsUsed().
unsigned clang::MacroInfo::getNumArgs | ( | ) | const [inline] |
Definition at line 181 of file MacroInfo.h.
Referenced by clang::MacroArgs::getPreExpArgument(), clang::TokenLexer::Init(), and isIdenticalTo().
unsigned clang::MacroInfo::getNumTokens | ( | ) | const [inline] |
Return the number of tokens that this macro expands to.
Definition at line 231 of file MacroInfo.h.
Referenced by clang::Preprocessor::DumpMacro(), and MacroDefinitionEquals().
unsigned clang::MacroInfo::getOwningModuleID | ( | ) | const [inline] |
Retrieve the global ID of the module that owns this particular macro info.
Definition at line 278 of file MacroInfo.h.
References isFromASTFile().
Referenced by areDefinedInSystemModules(), and clang::ASTReader::getModuleMacro().
const Token& clang::MacroInfo::getReplacementToken | ( | unsigned | Tok | ) | const [inline] |
Definition at line 235 of file MacroInfo.h.
Referenced by clang::Preprocessor::DumpMacro(), and isTrivialSingleTokenExpansion().
bool clang::MacroInfo::hasCommaPasting | ( | ) | const [inline] |
Definition at line 212 of file MacroInfo.h.
bool clang::MacroInfo::isAllowRedefinitionsWithoutWarning | ( | ) | const [inline] |
Return true if this macro can be redefined without warning.
Definition at line 220 of file MacroInfo.h.
bool clang::MacroInfo::isBuiltinMacro | ( | ) | const [inline] |
Return true if this macro requires processing before expansion.
This is true only for builtin macro, such as , whose values are not given by fixed textual expansions. Regular predefined macros from the "<built-in>" buffer are not reported as builtins by this function.
Definition at line 210 of file MacroInfo.h.
Referenced by clang::Preprocessor::CheckMacroName(), DoPrintMacros(), clang::ASTWriter::getMacroID(), and clang::ASTWriter::getMacroRef().
bool clang::MacroInfo::isC99Varargs | ( | ) | const [inline] |
Definition at line 200 of file MacroInfo.h.
Referenced by clang::CodeCompletionResult::CreateCodeCompletionString(), and isIdenticalTo().
bool clang::MacroInfo::isEnabled | ( | ) | const [inline] |
Return true if this macro is enabled.
In other words, that we are not currently in an expansion of this macro.
Definition at line 255 of file MacroInfo.h.
Referenced by clang::MacroArgs::ArgNeedsPreexpansion(), clang::Preprocessor::HandleIdentifier(), and isTrivialSingleTokenExpansion().
bool clang::MacroInfo::isFromASTFile | ( | ) | const [inline] |
Determine whether this macro info came from an AST file (such as a precompiled header or module) rather than having been parsed.
Definition at line 269 of file MacroInfo.h.
Referenced by getOwningModuleID().
bool clang::MacroInfo::isFunctionLike | ( | ) | const [inline] |
Definition at line 194 of file MacroInfo.h.
Referenced by clang::MacroArgs::create(), clang::CodeCompletionResult::CreateCodeCompletionString(), clang::Preprocessor::HandleIdentifier(), clang::TokenLexer::Init(), isIdenticalTo(), and PrintMacroDefinition().
bool clang::MacroInfo::isGNUVarargs | ( | ) | const [inline] |
Definition at line 201 of file MacroInfo.h.
Referenced by isIdenticalTo(), and PrintMacroDefinition().
bool MacroInfo::isIdenticalTo | ( | const MacroInfo & | Other, |
Preprocessor & | PP, | ||
bool | Syntactically | ||
) | const |
Return true if the specified macro definition is equal to this macro in spelling, arguments, and whitespace.
Syntactically | if true, the macro definitions can be identical even if they use different identifiers for the function macro parameters. Otherwise the comparison is lexical and this implements the rules in C99 6.10.3. |
Definition at line 72 of file MacroInfo.cpp.
References arg_begin(), arg_end(), getArgumentNum(), clang::Token::getIdentifierInfo(), clang::Token::getKind(), getNumArgs(), clang::Preprocessor::getSpelling(), clang::Token::hasLeadingSpace(), clang::Token::isAtStartOfLine(), isC99Varargs(), isFunctionLike(), and isGNUVarargs().
Referenced by checkConfigMacro(), and clang::ASTReader::installImportedMacro().
bool clang::MacroInfo::isObjectLike | ( | ) | const [inline] |
Definition at line 195 of file MacroInfo.h.
Referenced by clang::Preprocessor::HandleIdentifier(), and isTrivialSingleTokenExpansion().
bool clang::MacroInfo::isUsed | ( | ) | const [inline] |
Return false if this macro is defined in the main file and has not yet been used.
Definition at line 217 of file MacroInfo.h.
Referenced by clang::Preprocessor::markMacroAsUsed().
bool clang::MacroInfo::isUsedForHeaderGuard | ( | ) | const [inline] |
Determine whether this macro was used for a header guard.
Definition at line 272 of file MacroInfo.h.
bool clang::MacroInfo::isVariadic | ( | ) | const [inline] |
Definition at line 202 of file MacroInfo.h.
Referenced by clang::CodeCompletionResult::CreateCodeCompletionString().
bool clang::MacroInfo::isWarnIfUnused | ( | ) | const [inline] |
Return true if we should emit a warning if the macro is unused.
Definition at line 225 of file MacroInfo.h.
Referenced by clang::Preprocessor::HandlePragmaPopMacro(), and clang::Preprocessor::markMacroAsUsed().
void clang::MacroInfo::setArgumentList | ( | IdentifierInfo *const * | List, |
unsigned | NumArgs, | ||
llvm::BumpPtrAllocator & | PPAllocator | ||
) | [inline] |
Set the specified list of identifiers as the argument list for this macro.
Definition at line 163 of file MacroInfo.h.
Referenced by clang::ASTReader::ReadMacroRecord().
void clang::MacroInfo::setDefinitionEndLoc | ( | SourceLocation | EndLoc | ) | [inline] |
Set the location of the last token in the macro.
Definition at line 119 of file MacroInfo.h.
Referenced by clang::ASTReader::ReadMacroRecord().
void clang::MacroInfo::setHasCommaPasting | ( | ) | [inline] |
Definition at line 213 of file MacroInfo.h.
Referenced by clang::ASTReader::ReadMacroRecord().
void clang::MacroInfo::setIsAllowRedefinitionsWithoutWarning | ( | bool | Val | ) | [inline] |
Set the value of the IsAllowRedefinitionsWithoutWarning flag.
Definition at line 152 of file MacroInfo.h.
Referenced by clang::Preprocessor::HandlePragmaPushMacro().
void clang::MacroInfo::setIsBuiltinMacro | ( | bool | Val = true | ) | [inline] |
Set or clear the isBuiltinMacro flag.
Definition at line 142 of file MacroInfo.h.
Referenced by RegisterBuiltinMacro().
void clang::MacroInfo::setIsC99Varargs | ( | ) | [inline] |
Varargs querying methods. This can only be set for function-like macros.
Definition at line 198 of file MacroInfo.h.
Referenced by clang::ASTReader::ReadMacroRecord().
void clang::MacroInfo::setIsFunctionLike | ( | ) | [inline] |
Function/Object-likeness. Keep track of whether this macro has formal parameters.
Definition at line 193 of file MacroInfo.h.
Referenced by clang::ASTReader::ReadMacroRecord().
void clang::MacroInfo::setIsGNUVarargs | ( | ) | [inline] |
Definition at line 199 of file MacroInfo.h.
Referenced by clang::ASTReader::ReadMacroRecord().
void clang::MacroInfo::setIsUsed | ( | bool | Val | ) | [inline] |
Set the value of the IsUsed flag.
Definition at line 147 of file MacroInfo.h.
Referenced by clang::Preprocessor::markMacroAsUsed(), and clang::ASTReader::ReadMacroRecord().
void clang::MacroInfo::setIsWarnIfUnused | ( | bool | val | ) | [inline] |
Set the value of the IsWarnIfUnused flag.
Definition at line 157 of file MacroInfo.h.
void clang::MacroInfo::setUsedForHeaderGuard | ( | bool | Val | ) | [inline] |
Definition at line 274 of file MacroInfo.h.
Referenced by clang::ASTReader::ReadMacroRecord().
tokens_iterator clang::MacroInfo::tokens_begin | ( | ) | const [inline] |
Definition at line 241 of file MacroInfo.h.
Referenced by clang::TokenLexer::Init(), MacroDefinitionEquals(), and PrintMacroDefinition().
bool clang::MacroInfo::tokens_empty | ( | ) | const [inline] |
Definition at line 243 of file MacroInfo.h.
Referenced by PrintMacroDefinition().
tokens_iterator clang::MacroInfo::tokens_end | ( | ) | const [inline] |
Definition at line 242 of file MacroInfo.h.
Referenced by clang::TokenLexer::Init(), and PrintMacroDefinition().
friend class Preprocessor [friend] |
Definition at line 295 of file MacroInfo.h.