-
Notifications
You must be signed in to change notification settings - Fork 1
/
callbacks.h
71 lines (58 loc) · 1.91 KB
/
callbacks.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright: 2014 Steven Lamerton
// License: MIT, see LICENSE
#ifndef CALLBACKS_H_
#define CALLBACKS_H_
#include <clang/AST/ASTConsumer.h>
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/FrontendActions.h>
#include <clang/Lex/Preprocessor.h>
#include <clang/Tooling/Tooling.h>
#include "map_generator.h"
class Callbacks : public clang::PPCallbacks {
public:
Callbacks(
clang::Preprocessor &pp,
std::shared_ptr<MapGenerator> map_generator)
: pp_(pp), map_generator_(map_generator) {}
void InclusionDirective(
clang::SourceLocation hash_loc,
const clang::Token &include_tok,
llvm::StringRef filename,
bool is_angled,
clang::CharSourceRange filename_range,
const clang::FileEntry *file,
llvm::StringRef search_path,
llvm::StringRef relative_path,
const clang::Module *imported) override;
void FileChanged(
clang::SourceLocation loc,
clang::PPCallbacks::FileChangeReason reason,
clang::SrcMgr::CharacteristicKind file_type,
clang::FileID prev_fid) override;
private:
const clang::Preprocessor& pp_;
std::shared_ptr<MapGenerator> map_generator_;
};
class Consumer : public clang::ASTConsumer {
public:
Consumer(clang::Preprocessor &pp, std::shared_ptr<MapGenerator> inclusions);
};
class Action : public clang::SyntaxOnlyAction {
public:
Action(std::shared_ptr<MapGenerator> map_generator)
: map_generator_(map_generator) {}
std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(
clang::CompilerInstance &ci,
llvm::StringRef in_file) override;
private:
std::shared_ptr<MapGenerator> map_generator_;
};
class FrontendActionFactory : public clang::tooling::FrontendActionFactory {
public:
FrontendActionFactory(std::shared_ptr<MapGenerator> map_generator)
: map_generator_(map_generator) {}
virtual Action *create();
private:
std::shared_ptr<MapGenerator> map_generator_;
};
#endif