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