PPCallbacks.h revision ba9eee326434ba62b180271d3cc2999d94ee0de4
1//===--- PPCallbacks.h - Callbacks for Preprocessor actions -----*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the PPCallbacks interface. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_LEX_PPCALLBACKS_H 15#define LLVM_CLANG_LEX_PPCALLBACKS_H 16 17#include "clang/Lex/DirectoryLookup.h" 18#include "clang/Basic/SourceLocation.h" 19#include <string> 20 21namespace clang { 22 class SourceLocation; 23 class IdentifierInfo; 24 class MacroInfo; 25 26/// PPCallbacks - This interface provides a way to observe the actions of the 27/// preprocessor as it does its thing. Clients can define their hooks here to 28/// implement preprocessor level tools. 29class PPCallbacks { 30public: 31 virtual ~PPCallbacks(); 32 33 enum FileChangeReason { 34 EnterFile, ExitFile, SystemHeaderPragma, RenameFile 35 }; 36 37 /// FileChanged - This callback is invoked whenever a source file is 38 /// entered or exited. The SourceLocation indicates the new location, and 39 /// EnteringFile indicates whether this is because we are entering a new 40 /// #include'd file (when true) or whether we're exiting one because we ran 41 /// off the end (when false). 42 virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason, 43 SrcMgr::CharacteristicKind FileType) { 44 } 45 46 /// Ident - This callback is invoked when a #ident or #sccs directive is read. 47 /// 48 virtual void Ident(SourceLocation Loc, const std::string &str) { 49 } 50 51 /// PragmaComment - This callback is invoked when a #pragma comment directive 52 /// is read. 53 /// 54 virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, 55 const std::string &Str) { 56 } 57 58 /// MacroExpands - This is called Preprocessor::HandleMacroExpandedIdentifier 59 /// when a macro invocation is found. 60 virtual void MacroExpands(const Token &Id, const MacroInfo* MI) { 61 } 62}; 63 64} // end namespace clang 65 66#endif 67