-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMultiTuProcessor.hpp
More file actions
92 lines (63 loc) · 2.09 KB
/
Copy pathMultiTuProcessor.hpp
File metadata and controls
92 lines (63 loc) · 2.09 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef SYNTH_MULTI_TU_PROCESSOR_HPP_INCLUDED
#define SYNTH_MULTI_TU_PROCESSOR_HPP_INCLUDED
#include "FileIdSupport.hpp"
#include "output.hpp"
#include <boost/filesystem/path.hpp>
#include <clang-c/Index.h>
#include <atomic>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
namespace synth {
class SimpleTemplate;
namespace fs = boost::filesystem;
struct MissingDef {
HighlightedFile* hlFile;
std::size_t markupIdx;
};
struct FileEntry {
std::atomic_flag processed;
HighlightedFile hlFile;
};
using PathMap = std::vector<std::pair<fs::path, fs::path>>;
class MultiTuProcessor {
public:
explicit MultiTuProcessor(PathMap const& rootdir_);
bool isFileIncluded(fs::path const& p) const;
// Returns nullptr if f should be ignored.
HighlightedFile const* referenceFilename(CXFile f);
HighlightedFile* prepareToProcess(CXFile f);
void registerDef(std::string&& usr, SourceLocation&& def)
{
std::lock_guard<std::mutex> lock(m_mut);
m_defs.insert({std::move(usr), std::move(def)});
}
void registerMissingDefLink(
HighlightedFile& file,
std::size_t markupIdx,
std::string&& dstUsr)
{
std::lock_guard<std::mutex> lock(m_mut);
m_missingDefs[std::move(dstUsr)].push_back({&file, markupIdx});
}
void resolveMissingRefs();
void writeOutput(SimpleTemplate const& tpl);
private:
using FileEntryMap = std::unordered_map<CXFileUniqueID, FileEntry>;
Markup& markupFromMissingDef(MissingDef const& def);
// Returns nullptr if f should be ignored.
FileEntry* obtainFileEntry(CXFile f);
PathMap::value_type const* getFileMapping(fs::path const& p) const;
FileEntryMap m_processedFiles;
PathMap m_dirs;
// Maps from USRs to source location
std::unordered_map<std::string, SourceLocation> m_defs;
// Maps from USRs to missing definitions
std::unordered_map<std::string, std::vector<MissingDef>> m_missingDefs;
// Common prefix of all keys in m_dirs
fs::path m_rootInDir;
mutable std::mutex m_mut;
};
} // namespace synth
#endif