1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CINDEXER_H |
15 | #define LLVM_CLANG_TOOLS_LIBCLANG_CINDEXER_H |
16 | |
17 | #include "clang-c/Index.h" |
18 | #include "clang/Frontend/PCHContainerOperations.h" |
19 | #include "llvm/ADT/STLExtras.h" |
20 | #include "llvm/Support/Mutex.h" |
21 | #include <utility> |
22 | |
23 | namespace llvm { |
24 | class CrashRecoveryContext; |
25 | } |
26 | |
27 | namespace clang { |
28 | class ASTUnit; |
29 | class MacroInfo; |
30 | class MacroDefinitionRecord; |
31 | class SourceLocation; |
32 | class Token; |
33 | class IdentifierInfo; |
34 | |
35 | class CIndexer { |
36 | bool OnlyLocalDecls; |
37 | bool DisplayDiagnostics; |
38 | unsigned Options; |
39 | |
40 | std::string ResourcesPath; |
41 | std::shared_ptr<PCHContainerOperations> PCHContainerOps; |
42 | |
43 | std::string ToolchainPath; |
44 | |
45 | std::string InvocationEmissionPath; |
46 | |
47 | public: |
48 | CIndexer(std::shared_ptr<PCHContainerOperations> PCHContainerOps = |
49 | std::make_shared<PCHContainerOperations>()) |
50 | : OnlyLocalDecls(false), DisplayDiagnostics(false), |
51 | Options(CXGlobalOpt_None), PCHContainerOps(std::move(PCHContainerOps)) { |
52 | } |
53 | |
54 | |
55 | |
56 | |
57 | bool getOnlyLocalDecls() const { return OnlyLocalDecls; } |
58 | void setOnlyLocalDecls(bool Local = true) { OnlyLocalDecls = Local; } |
59 | |
60 | bool getDisplayDiagnostics() const { return DisplayDiagnostics; } |
61 | void setDisplayDiagnostics(bool Display = true) { |
62 | DisplayDiagnostics = Display; |
63 | } |
64 | |
65 | std::shared_ptr<PCHContainerOperations> getPCHContainerOperations() const { |
66 | return PCHContainerOps; |
67 | } |
68 | |
69 | unsigned getCXGlobalOptFlags() const { return Options; } |
70 | void setCXGlobalOptFlags(unsigned options) { Options = options; } |
71 | |
72 | bool isOptEnabled(CXGlobalOptFlags opt) const { |
73 | return Options & opt; |
74 | } |
75 | |
76 | |
77 | const std::string &getClangResourcesPath(); |
78 | |
79 | StringRef getClangToolchainPath(); |
80 | |
81 | void setInvocationEmissionPath(StringRef Str) { |
82 | InvocationEmissionPath = Str; |
83 | } |
84 | |
85 | StringRef getInvocationEmissionPath() const { return InvocationEmissionPath; } |
86 | }; |
87 | |
88 | |
89 | |
90 | class LibclangInvocationReporter { |
91 | public: |
92 | enum class OperationKind { ParseOperation, CompletionOperation }; |
93 | |
94 | LibclangInvocationReporter(CIndexer &Idx, OperationKind Op, |
95 | unsigned ParseOptions, |
96 | llvm::ArrayRef<const char *> Args, |
97 | llvm::ArrayRef<std::string> InvocationArgs, |
98 | llvm::ArrayRef<CXUnsavedFile> UnsavedFiles); |
99 | ~LibclangInvocationReporter(); |
100 | |
101 | private: |
102 | std::string File; |
103 | }; |
104 | |
105 | |
106 | unsigned GetSafetyThreadStackSize(); |
107 | |
108 | |
109 | |
110 | void SetSafetyThreadStackSize(unsigned Value); |
111 | |
112 | |
113 | |
114 | |
115 | |
116 | bool RunSafely(llvm::CrashRecoveryContext &CRC, llvm::function_ref<void()> Fn, |
117 | unsigned Size = 0); |
118 | |
119 | |
120 | |
121 | void setThreadBackgroundPriority(); |
122 | |
123 | |
124 | void PrintLibclangResourceUsage(CXTranslationUnit TU); |
125 | |
126 | namespace cxindex { |
127 | void printDiagsToStderr(ASTUnit *Unit); |
128 | |
129 | |
130 | |
131 | MacroInfo *getMacroInfo(const IdentifierInfo &II, |
132 | SourceLocation MacroDefLoc, CXTranslationUnit TU); |
133 | |
134 | |
135 | const MacroInfo *getMacroInfo(const MacroDefinitionRecord *MacroDef, |
136 | CXTranslationUnit TU); |
137 | |
138 | |
139 | |
140 | |
141 | MacroDefinitionRecord *checkForMacroInMacroDefinition(const MacroInfo *MI, |
142 | SourceLocation Loc, |
143 | CXTranslationUnit TU); |
144 | |
145 | |
146 | |
147 | |
148 | MacroDefinitionRecord *checkForMacroInMacroDefinition(const MacroInfo *MI, |
149 | const Token &Tok, |
150 | CXTranslationUnit TU); |
151 | } |
152 | } |
153 | |
154 | #endif |
155 | |