PPCallbacks.h revision a9d9145741ef77db45890911674705b81605b10b
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
25/// PPCallbacks - This interface provides a way to observe the actions of the
26/// preprocessor as it does its thing.  Clients can define their hooks here to
27/// implement preprocessor level tools.
28class PPCallbacks {
29public:
30  virtual ~PPCallbacks();
31
32  enum FileChangeReason {
33    EnterFile, ExitFile, SystemHeaderPragma, RenameFile
34  };
35
36  /// FileChanged - This callback is invoked whenever a source file is
37  /// entered or exited.  The SourceLocation indicates the new location, and
38  /// EnteringFile indicates whether this is because we are entering a new
39  /// #include'd file (when true) or whether we're exiting one because we ran
40  /// off the end (when false).
41  virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
42                           SrcMgr::CharacteristicKind FileType) {
43  }
44
45  /// Ident - This callback is invoked when a #ident or #sccs directive is read.
46  ///
47  virtual void Ident(SourceLocation Loc, const std::string &str) {
48  }
49
50  /// PragmaComment - This callback is invoked when a #pragma comment directive
51  /// is read.
52  ///
53  virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
54                             const std::string &Str) {
55  }
56
57};
58
59}  // end namespace clang
60
61#endif
62