forked from OSchip/llvm-project
add a callback for macro expansion, based on a patch by Paolo Bolzoni!
llvm-svn: 66799
This commit is contained in:
parent
b0a553b925
commit
cf35ce9d0d
|
@ -21,6 +21,7 @@
|
|||
namespace clang {
|
||||
class SourceLocation;
|
||||
class IdentifierInfo;
|
||||
class MacroInfo;
|
||||
|
||||
/// PPCallbacks - This interface provides a way to observe the actions of the
|
||||
/// preprocessor as it does its thing. Clients can define their hooks here to
|
||||
|
@ -54,6 +55,10 @@ public:
|
|||
const std::string &Str) {
|
||||
}
|
||||
|
||||
/// MacroExpands - This is called Preprocessor::HandleMacroExpandedIdentifier
|
||||
/// when a macro invocation is found.
|
||||
virtual void MacroExpands(const Token &Id, const MacroInfo* MI) {
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
|
|
|
@ -150,6 +150,8 @@ bool Preprocessor::isNextPPTokenLParen() {
|
|||
/// expanded as a macro, handle it and return the next token as 'Identifier'.
|
||||
bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
|
||||
MacroInfo *MI) {
|
||||
if (Callbacks) Callbacks->MacroExpands(Identifier, MI);
|
||||
|
||||
// If this is a macro exapnsion in the "#if !defined(x)" line for the file,
|
||||
// then the macro could expand to different things in other contexts, we need
|
||||
// to disable the optimization in this case.
|
||||
|
|
Loading…
Reference in New Issue