class MacroInfo
Declaration
class MacroInfo { /* full declaration omitted */ };
Description
Encapsulates the data about a macro definition (e.g. its tokens). There's an instance of this class for every #define.
Declared at: clang/include/clang/Lex/MacroInfo.h:39
Member Variables
- private clang::SourceLocation Location
- The location the macro is defined.
- private clang::SourceLocation EndLocation
- The location of the last token in the macro.
- private clang::IdentifierInfo** ParameterList = nullptr
- This can be empty, for, e.g. "#define X()". In a C99-style variadic macro, this includes the \c __VA_ARGS__ identifier on the list.
- private const clang::Token* ReplacementTokens = nullptr
- This is the list of tokens that the macro is defined to.
- private unsigned int NumParameters = 0
- private unsigned int NumReplacementTokens = 0
- private unsigned int DefinitionLength
- Length in characters of the macro definition.
- private bool IsDefinitionLengthCached
- private bool IsFunctionLike
- True if this macro is function-like, false if it is object-like.
- private bool IsC99Varargs
- The __VA_ARGS__ token should be replaced with the contents of "..." in an invocation.
- private bool IsGNUVarargs
- The "a" identifier in the replacement list will be replaced with all arguments of the macro starting with the specified one.
- private bool IsBuiltinMacro
- This is the case for builtin macros such as __LINE__, so long as they have not been redefined, but not for regular predefined macros from the "<built-in>" memory buffer (see Preprocessing::getPredefinesFileID).
- private bool HasCommaPasting
- Whether this macro contains the sequence ", ## __VA_ARGS__"
- private bool IsDisabled
- This disables recursive expansion, which would be quite bad for things like # define A A.
- private bool IsUsed
- This is used to emit -Wunused-macros diagnostics.
- private bool IsAllowRedefinitionsWithoutWarning
- True if this macro can be redefined without emitting a warning.
- private bool IsWarnIfUnused
- Must warn if the macro is unused at the end of translation unit.
- private bool UsedForHeaderGuard
- Whether this macro was used as header guard.
Method Overview
- public void DisableMacro()
- public void EnableMacro()
- private MacroInfo(clang::SourceLocation DefLoc)
- public llvm::MutableArrayRef<Token> allocateTokens(unsigned int NumTokens, llvm::BumpPtrAllocator & PPAllocator)
- public void dump() const
- public clang::SourceLocation getDefinitionEndLoc() const
- public unsigned int getDefinitionLength(const clang::SourceManager & SM) const
- private unsigned int getDefinitionLengthSlow(const clang::SourceManager & SM) const
- public clang::SourceLocation getDefinitionLoc() const
- public unsigned int getNumParams() const
- public unsigned int getNumTokens() const
- public int getParameterNum(const clang::IdentifierInfo * Arg) const
- public const clang::Token & getReplacementToken(unsigned int Tok) const
- public bool hasCommaPasting() const
- public bool isAllowRedefinitionsWithoutWarning() const
- public bool isBuiltinMacro() const
- public bool isC99Varargs() const
- public bool isEnabled() const
- public bool isFunctionLike() const
- public bool isGNUVarargs() const
- public bool isIdenticalTo(const clang::MacroInfo & Other, clang::Preprocessor & PP, bool Syntactically) const
- public bool isObjectLike() const
- public bool isUsed() const
- public bool isUsedForHeaderGuard() const
- public bool isVariadic() const
- public bool isWarnIfUnused() const
- public clang::MacroInfo::param_iterator param_begin() const
- public bool param_empty() const
- public clang::MacroInfo::param_iterator param_end() const
- public ArrayRef<const clang::IdentifierInfo *> params() const
- public void setDefinitionEndLoc(clang::SourceLocation EndLoc)
- public void setHasCommaPasting()
- public void setIsAllowRedefinitionsWithoutWarning(bool Val)
- public void setIsBuiltinMacro(bool Val = true)
- public void setIsC99Varargs()
- public void setIsFunctionLike()
- public void setIsGNUVarargs()
- public void setIsUsed(bool Val)
- public void setIsWarnIfUnused(bool val)
- public void setParameterList(ArrayRef<clang::IdentifierInfo *> List, llvm::BumpPtrAllocator & PPAllocator)
- public void setTokens(ArrayRef<clang::Token> Tokens, llvm::BumpPtrAllocator & PPAllocator)
- public void setUsedForHeaderGuard(bool Val)
- public ArrayRef<clang::Token> tokens() const
- public clang::MacroInfo::const_tokens_iterator tokens_begin() const
- public bool tokens_empty() const
- public clang::MacroInfo::const_tokens_iterator tokens_end() const
- private ~MacroInfo()
Methods
¶void DisableMacro()
void DisableMacro()
Declared at: clang/include/clang/Lex/MacroInfo.h:289
¶void EnableMacro()
void EnableMacro()
Declared at: clang/include/clang/Lex/MacroInfo.h:284
¶MacroInfo(clang::SourceLocation DefLoc)
MacroInfo(clang::SourceLocation DefLoc)
Declared at: clang/include/clang/Lex/MacroInfo.h:121
Parameters
- clang::SourceLocation DefLoc
¶llvm::MutableArrayRef<Token> allocateTokens(
unsigned int NumTokens,
llvm::BumpPtrAllocator& PPAllocator)
llvm::MutableArrayRef<Token> allocateTokens(
unsigned int NumTokens,
llvm::BumpPtrAllocator& PPAllocator)
Declared at: clang/include/clang/Lex/MacroInfo.h:255
Parameters
- unsigned int NumTokens
- llvm::BumpPtrAllocator& PPAllocator
¶void dump() const
void dump() const
Declared at: clang/include/clang/Lex/MacroInfo.h:299
¶clang::SourceLocation getDefinitionEndLoc() const
clang::SourceLocation getDefinitionEndLoc() const
Description
Return the location of the last token in the macro.
Declared at: clang/include/clang/Lex/MacroInfo.h:132
¶unsigned int getDefinitionLength(
const clang::SourceManager& SM) const
unsigned int getDefinitionLength(
const clang::SourceManager& SM) const
Description
Get length in characters of the macro definition.
Declared at: clang/include/clang/Lex/MacroInfo.h:135
Parameters
- const clang::SourceManager& SM
¶unsigned int getDefinitionLengthSlow(
const clang::SourceManager& SM) const
unsigned int getDefinitionLengthSlow(
const clang::SourceManager& SM) const
Declared at: clang/include/clang/Lex/MacroInfo.h:304
Parameters
- const clang::SourceManager& SM
¶clang::SourceLocation getDefinitionLoc() const
clang::SourceLocation getDefinitionLoc() const
Description
Return the location that the macro was defined at.
Declared at: clang/include/clang/Lex/MacroInfo.h:126
¶unsigned int getNumParams() const
unsigned int getNumParams() const
Declared at: clang/include/clang/Lex/MacroInfo.h:185
¶unsigned int getNumTokens() const
unsigned int getNumTokens() const
Description
Return the number of tokens that this macro expands to.
Declared at: clang/include/clang/Lex/MacroInfo.h:236
¶int getParameterNum(
const clang::IdentifierInfo* Arg) const
int getParameterNum(
const clang::IdentifierInfo* Arg) const
Description
Return the parameter number of the specified identifier, or -1 if the identifier is not a formal parameter identifier.
Declared at: clang/include/clang/Lex/MacroInfo.h:192
Parameters
- const clang::IdentifierInfo* Arg
¶const clang::Token& getReplacementToken(
unsigned int Tok) const
const clang::Token& getReplacementToken(
unsigned int Tok) const
Declared at: clang/include/clang/Lex/MacroInfo.h:238
Parameters
- unsigned int Tok
¶bool hasCommaPasting() const
bool hasCommaPasting() const
Declared at: clang/include/clang/Lex/MacroInfo.h:220
¶bool isAllowRedefinitionsWithoutWarning() const
bool isAllowRedefinitionsWithoutWarning() const
Description
Return true if this macro can be redefined without warning.
Declared at: clang/include/clang/Lex/MacroInfo.h:228
¶bool isBuiltinMacro() const
bool isBuiltinMacro() const
Description
Return true if this macro requires processing before expansion. This is true only for builtin macro, such as \ __LINE__, 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.
Declared at: clang/include/clang/Lex/MacroInfo.h:218
¶bool isC99Varargs() const
bool isC99Varargs() const
Declared at: clang/include/clang/Lex/MacroInfo.h:208
¶bool isEnabled() const
bool isEnabled() const
Description
Return true if this macro is enabled. In other words, that we are not currently in an expansion of this macro.
Declared at: clang/include/clang/Lex/MacroInfo.h:282
¶bool isFunctionLike() const
bool isFunctionLike() const
Declared at: clang/include/clang/Lex/MacroInfo.h:202
¶bool isGNUVarargs() const
bool isGNUVarargs() const
Declared at: clang/include/clang/Lex/MacroInfo.h:209
¶bool isIdenticalTo(const clang::MacroInfo& Other,
clang::Preprocessor& PP,
bool Syntactically) const
bool isIdenticalTo(const clang::MacroInfo& Other,
clang::Preprocessor& PP,
bool Syntactically) const
Description
Return true if the specified macro definition is equal to this macro in spelling, arguments, and whitespace.
Declared at: clang/include/clang/Lex/MacroInfo.h:148
Parameters
- const clang::MacroInfo& Other
- clang::Preprocessor& PP
- bool 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.
¶bool isObjectLike() const
bool isObjectLike() const
Declared at: clang/include/clang/Lex/MacroInfo.h:203
¶bool isUsed() const
bool isUsed() const
Description
Return false if this macro is defined in the main file and has not yet been used.
Declared at: clang/include/clang/Lex/MacroInfo.h:225
¶bool isUsedForHeaderGuard() const
bool isUsedForHeaderGuard() const
Description
Determine whether this macro was used for a header guard.
Declared at: clang/include/clang/Lex/MacroInfo.h:295
¶bool isVariadic() const
bool isVariadic() const
Declared at: clang/include/clang/Lex/MacroInfo.h:210
¶bool isWarnIfUnused() const
bool isWarnIfUnused() const
Description
Return true if we should emit a warning if the macro is unused.
Declared at: clang/include/clang/Lex/MacroInfo.h:233
¶clang::MacroInfo::param_iterator param_begin()
const
clang::MacroInfo::param_iterator param_begin()
const
Declared at: clang/include/clang/Lex/MacroInfo.h:183
¶bool param_empty() const
bool param_empty() const
Declared at: clang/include/clang/Lex/MacroInfo.h:182
¶clang::MacroInfo::param_iterator param_end() const
clang::MacroInfo::param_iterator param_end() const
Declared at: clang/include/clang/Lex/MacroInfo.h:184
¶ArrayRef<const clang::IdentifierInfo*> params()
const
ArrayRef<const clang::IdentifierInfo*> params()
const
Declared at: clang/include/clang/Lex/MacroInfo.h:186
¶void setDefinitionEndLoc(
clang::SourceLocation EndLoc)
void setDefinitionEndLoc(
clang::SourceLocation EndLoc)
Description
Set the location of the last token in the macro.
Declared at: clang/include/clang/Lex/MacroInfo.h:129
Parameters
- clang::SourceLocation EndLoc
¶void setHasCommaPasting()
void setHasCommaPasting()
Declared at: clang/include/clang/Lex/MacroInfo.h:221
¶void setIsAllowRedefinitionsWithoutWarning(
bool Val)
void setIsAllowRedefinitionsWithoutWarning(
bool Val)
Description
Set the value of the IsAllowRedefinitionsWithoutWarning flag.
Declared at: clang/include/clang/Lex/MacroInfo.h:158
Parameters
- bool Val
¶void setIsBuiltinMacro(bool Val = true)
void setIsBuiltinMacro(bool Val = true)
Description
Set or clear the isBuiltinMacro flag.
Declared at: clang/include/clang/Lex/MacroInfo.h:152
Parameters
- bool Val = true
¶void setIsC99Varargs()
void setIsC99Varargs()
Description
Varargs querying methods. This can only be set for function-like macros.
Declared at: clang/include/clang/Lex/MacroInfo.h:206
¶void setIsFunctionLike()
void setIsFunctionLike()
Description
Function/Object-likeness. Keep track of whether this macro has formal parameters.
Declared at: clang/include/clang/Lex/MacroInfo.h:201
¶void setIsGNUVarargs()
void setIsGNUVarargs()
Declared at: clang/include/clang/Lex/MacroInfo.h:207
¶void setIsUsed(bool Val)
void setIsUsed(bool Val)
Description
Set the value of the IsUsed flag.
Declared at: clang/include/clang/Lex/MacroInfo.h:155
Parameters
- bool Val
¶void setIsWarnIfUnused(bool val)
void setIsWarnIfUnused(bool val)
Description
Set the value of the IsWarnIfUnused flag.
Declared at: clang/include/clang/Lex/MacroInfo.h:163
Parameters
- bool val
¶void setParameterList(
ArrayRef<clang::IdentifierInfo*> List,
llvm::BumpPtrAllocator& PPAllocator)
void setParameterList(
ArrayRef<clang::IdentifierInfo*> List,
llvm::BumpPtrAllocator& PPAllocator)
Description
Set the specified list of identifiers as the parameter list for this macro.
Declared at: clang/include/clang/Lex/MacroInfo.h:167
Parameters
- ArrayRef<clang::IdentifierInfo*> List
- llvm::BumpPtrAllocator& PPAllocator
¶void setTokens(
ArrayRef<clang::Token> Tokens,
llvm::BumpPtrAllocator& PPAllocator)
void setTokens(
ArrayRef<clang::Token> Tokens,
llvm::BumpPtrAllocator& PPAllocator)
Declared at: clang/include/clang/Lex/MacroInfo.h:264
Parameters
- ArrayRef<clang::Token> Tokens
- llvm::BumpPtrAllocator& PPAllocator
¶void setUsedForHeaderGuard(bool Val)
void setUsedForHeaderGuard(bool Val)
Declared at: clang/include/clang/Lex/MacroInfo.h:297
Parameters
- bool Val
¶ArrayRef<clang::Token> tokens() const
ArrayRef<clang::Token> tokens() const
Declared at: clang/include/clang/Lex/MacroInfo.h:250
¶clang::MacroInfo::const_tokens_iterator
tokens_begin() const
clang::MacroInfo::const_tokens_iterator
tokens_begin() const
Declared at: clang/include/clang/Lex/MacroInfo.h:245
¶bool tokens_empty() const
bool tokens_empty() const
Declared at: clang/include/clang/Lex/MacroInfo.h:249
¶clang::MacroInfo::const_tokens_iterator
tokens_end() const
clang::MacroInfo::const_tokens_iterator
tokens_end() const
Declared at: clang/include/clang/Lex/MacroInfo.h:246
¶~MacroInfo()
~MacroInfo()
Declared at: clang/include/clang/Lex/MacroInfo.h:122