diff options
Diffstat (limited to 'include/clang/Lex/PPCallbacks.h')
-rw-r--r-- | include/clang/Lex/PPCallbacks.h | 139 |
1 files changed, 125 insertions, 14 deletions
diff --git a/include/clang/Lex/PPCallbacks.h b/include/clang/Lex/PPCallbacks.h index 782f2d5..b2a80a6 100644 --- a/include/clang/Lex/PPCallbacks.h +++ b/include/clang/Lex/PPCallbacks.h @@ -54,12 +54,43 @@ public: SrcMgr::CharacteristicKind FileType) { } + /// \brief This callback is invoked whenever an inclusion directive of + /// any kind (\c #include, \c #import, etc.) has been processed, regardless + /// of whether the inclusion will actually result in an inclusion. + /// + /// \param HashLoc The location of the '#' that starts the inclusion + /// directive. + /// + /// \param IncludeTok The token that indicates the kind of inclusion + /// directive, e.g., 'include' or 'import'. + /// + /// \param FileName The name of the file being included, as written in the + /// source code. + /// + /// \param IsAngled Whether the file name was enclosed in angle brackets; + /// otherwise, it was enclosed in quotes. + /// + /// \param File The actual file that may be included by this inclusion + /// directive. + /// + /// \param EndLoc The location of the last token within the inclusion + /// directive. + virtual void InclusionDirective(SourceLocation HashLoc, + const Token &IncludeTok, + llvm::StringRef FileName, + bool IsAngled, + const FileEntry *File, + SourceLocation EndLoc) { + } + /// EndOfMainFile - This callback is invoked when the end of the main file is /// reach, no subsequent callbacks will be made. virtual void EndOfMainFile() { } /// Ident - This callback is invoked when a #ident or #sccs directive is read. + /// \param Loc The location of the directive. + /// \param str The text of the directive. /// virtual void Ident(SourceLocation Loc, const std::string &str) { } @@ -73,6 +104,8 @@ public: /// PragmaMessage - This callback is invoked when a #pragma message directive /// is read. + /// \param Loc The location of the message directive. + /// \param str The text of the message directive. /// virtual void PragmaMessage(SourceLocation Loc, llvm::StringRef Str) { } @@ -80,17 +113,48 @@ public: /// MacroExpands - This is called by /// Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is /// found. - virtual void MacroExpands(const Token &Id, const MacroInfo* MI) { + virtual void MacroExpands(const Token &MacroNameTok, const MacroInfo* MI) { } /// MacroDefined - This hook is called whenever a macro definition is seen. - virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI) { + virtual void MacroDefined(const Token &MacroNameTok, const MacroInfo *MI) { } /// MacroUndefined - This hook is called whenever a macro #undef is seen. /// MI is released immediately following this callback. - virtual void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II, - const MacroInfo *MI) { + virtual void MacroUndefined(const Token &MacroNameTok, const MacroInfo *MI) { + } + + /// If -- This hook is called whenever an #if is seen. + /// \param Range The SourceRange of the expression being tested. + // FIXME: better to pass in a list (or tree!) of Tokens. + virtual void If(SourceRange Range) { + } + + /// Elif -- This hook is called whenever an #elif is seen. + /// \param Range The SourceRange of the expression being tested. + // FIXME: better to pass in a list (or tree!) of Tokens. + virtual void Elif(SourceRange Range) { + } + + /// Ifdef -- This hook is called whenever an #ifdef is seen. + /// \param Loc The location of the token being tested. + /// \param II Information on the token being tested. + virtual void Ifdef(const Token &MacroNameTok) { + } + + /// Ifndef -- This hook is called whenever an #ifndef is seen. + /// \param Loc The location of the token being tested. + /// \param II Information on the token being tested. + virtual void Ifndef(const Token &MacroNameTok) { + } + + /// Else -- This hook is called whenever an #else is seen. + virtual void Else() { + } + + /// Endif -- This hook is called whenever an #endif is seen. + virtual void Endif() { } }; @@ -119,6 +183,18 @@ public: Second->FileSkipped(ParentFile, FilenameTok, FileType); } + virtual void InclusionDirective(SourceLocation HashLoc, + const Token &IncludeTok, + llvm::StringRef FileName, + bool IsAngled, + const FileEntry *File, + SourceLocation EndLoc) { + First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, File, + EndLoc); + Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, File, + EndLoc); + } + virtual void EndOfMainFile() { First->EndOfMainFile(); Second->EndOfMainFile(); @@ -140,20 +216,55 @@ public: Second->PragmaMessage(Loc, Str); } - virtual void MacroExpands(const Token &Id, const MacroInfo* MI) { - First->MacroExpands(Id, MI); - Second->MacroExpands(Id, MI); + virtual void MacroExpands(const Token &MacroNameTok, const MacroInfo* MI) { + First->MacroExpands(MacroNameTok, MI); + Second->MacroExpands(MacroNameTok, MI); + } + + virtual void MacroDefined(const Token &MacroNameTok, const MacroInfo *MI) { + First->MacroDefined(MacroNameTok, MI); + Second->MacroDefined(MacroNameTok, MI); + } + + virtual void MacroUndefined(const Token &MacroNameTok, const MacroInfo *MI) { + First->MacroUndefined(MacroNameTok, MI); + Second->MacroUndefined(MacroNameTok, MI); + } + + /// If -- This hook is called whenever an #if is seen. + virtual void If(SourceRange Range) { + First->If(Range); + Second->If(Range); + } + + /// Elif -- This hook is called whenever an #if is seen. + virtual void Elif(SourceRange Range) { + First->Elif(Range); + Second->Elif(Range); + } + + /// Ifdef -- This hook is called whenever an #ifdef is seen. + virtual void Ifdef(const Token &MacroNameTok) { + First->Ifdef(MacroNameTok); + Second->Ifdef(MacroNameTok); + } + + /// Ifndef -- This hook is called whenever an #ifndef is seen. + virtual void Ifndef(const Token &MacroNameTok) { + First->Ifndef(MacroNameTok); + Second->Ifndef(MacroNameTok); } - virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI) { - First->MacroDefined(II, MI); - Second->MacroDefined(II, MI); + /// Else -- This hook is called whenever an #else is seen. + virtual void Else() { + First->Else(); + Second->Else(); } - virtual void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II, - const MacroInfo *MI) { - First->MacroUndefined(Loc, II, MI); - Second->MacroUndefined(Loc, II, MI); + /// Endif -- This hook is called whenever an #endif is seen. + virtual void Endif() { + First->Endif(); + Second->Endif(); } }; |