/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Tooling/Tooling.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- Tooling.h - Framework for standalone Clang tools ---------*- C++ -*-===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | // |
9 | | // This file implements functions to run clang tools standalone instead |
10 | | // of running them as a plugin. |
11 | | // |
12 | | // A ClangTool is initialized with a CompilationDatabase and a set of files |
13 | | // to run over. The tool will then run a user-specified FrontendAction over |
14 | | // all TUs in which the given files are compiled. |
15 | | // |
16 | | // It is also possible to run a FrontendAction over a snippet of code by |
17 | | // calling runToolOnCode, which is useful for unit testing. |
18 | | // |
19 | | // Applications that need more fine grained control over how to run |
20 | | // multiple FrontendActions over code can use ToolInvocation. |
21 | | // |
22 | | // Example tools: |
23 | | // - running clang -fsyntax-only over source code from an editor to get |
24 | | // fast syntax checks |
25 | | // - running match/replace tools over C++ code |
26 | | // |
27 | | //===----------------------------------------------------------------------===// |
28 | | |
29 | | #ifndef LLVM_CLANG_TOOLING_TOOLING_H |
30 | | #define LLVM_CLANG_TOOLING_TOOLING_H |
31 | | |
32 | | #include "clang/AST/ASTConsumer.h" |
33 | | #include "clang/Basic/FileManager.h" |
34 | | #include "clang/Basic/LLVM.h" |
35 | | #include "clang/Frontend/FrontendAction.h" |
36 | | #include "clang/Frontend/PCHContainerOperations.h" |
37 | | #include "clang/Tooling/ArgumentsAdjusters.h" |
38 | | #include "llvm/ADT/ArrayRef.h" |
39 | | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
40 | | #include "llvm/ADT/StringMap.h" |
41 | | #include "llvm/ADT/StringRef.h" |
42 | | #include "llvm/ADT/StringSet.h" |
43 | | #include "llvm/ADT/Twine.h" |
44 | | #include "llvm/Option/Option.h" |
45 | | #include "llvm/Support/VirtualFileSystem.h" |
46 | | #include <memory> |
47 | | #include <string> |
48 | | #include <utility> |
49 | | #include <vector> |
50 | | |
51 | | namespace clang { |
52 | | |
53 | | class CompilerInstance; |
54 | | class CompilerInvocation; |
55 | | class DiagnosticConsumer; |
56 | | class DiagnosticsEngine; |
57 | | class SourceManager; |
58 | | |
59 | | namespace driver { |
60 | | |
61 | | class Compilation; |
62 | | |
63 | | } // namespace driver |
64 | | |
65 | | namespace tooling { |
66 | | |
67 | | class CompilationDatabase; |
68 | | |
69 | | /// Interface to process a clang::CompilerInvocation. |
70 | | /// |
71 | | /// If your tool is based on FrontendAction, you should be deriving from |
72 | | /// FrontendActionFactory instead. |
73 | | class ToolAction { |
74 | | public: |
75 | | virtual ~ToolAction(); |
76 | | |
77 | | /// Perform an action for an invocation. |
78 | | virtual bool |
79 | | runInvocation(std::shared_ptr<CompilerInvocation> Invocation, |
80 | | FileManager *Files, |
81 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps, |
82 | | DiagnosticConsumer *DiagConsumer) = 0; |
83 | | }; |
84 | | |
85 | | /// Interface to generate clang::FrontendActions. |
86 | | /// |
87 | | /// Having a factory interface allows, for example, a new FrontendAction to be |
88 | | /// created for each translation unit processed by ClangTool. This class is |
89 | | /// also a ToolAction which uses the FrontendActions created by create() to |
90 | | /// process each translation unit. |
91 | | class FrontendActionFactory : public ToolAction { |
92 | | public: |
93 | | ~FrontendActionFactory() override; |
94 | | |
95 | | /// Invokes the compiler with a FrontendAction created by create(). |
96 | | bool runInvocation(std::shared_ptr<CompilerInvocation> Invocation, |
97 | | FileManager *Files, |
98 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps, |
99 | | DiagnosticConsumer *DiagConsumer) override; |
100 | | |
101 | | /// Returns a new clang::FrontendAction. |
102 | | virtual std::unique_ptr<FrontendAction> create() = 0; |
103 | | }; |
104 | | |
105 | | /// Returns a new FrontendActionFactory for a given type. |
106 | | /// |
107 | | /// T must derive from clang::FrontendAction. |
108 | | /// |
109 | | /// Example: |
110 | | /// FrontendActionFactory *Factory = |
111 | | /// newFrontendActionFactory<clang::SyntaxOnlyAction>(); |
112 | | template <typename T> |
113 | | std::unique_ptr<FrontendActionFactory> newFrontendActionFactory(); |
114 | | |
115 | | /// Callbacks called before and after each source file processed by a |
116 | | /// FrontendAction created by the FrontedActionFactory returned by \c |
117 | | /// newFrontendActionFactory. |
118 | | class SourceFileCallbacks { |
119 | | public: |
120 | | virtual ~SourceFileCallbacks() = default; |
121 | | |
122 | | /// Called before a source file is processed by a FrontEndAction. |
123 | | /// \see clang::FrontendAction::BeginSourceFileAction |
124 | 0 | virtual bool handleBeginSource(CompilerInstance &CI) { |
125 | 0 | return true; |
126 | 0 | } |
127 | | |
128 | | /// Called after a source file is processed by a FrontendAction. |
129 | | /// \see clang::FrontendAction::EndSourceFileAction |
130 | 0 | virtual void handleEndSource() {} |
131 | | }; |
132 | | |
133 | | /// Returns a new FrontendActionFactory for any type that provides an |
134 | | /// implementation of newASTConsumer(). |
135 | | /// |
136 | | /// FactoryT must implement: ASTConsumer *newASTConsumer(). |
137 | | /// |
138 | | /// Example: |
139 | | /// struct ProvidesASTConsumers { |
140 | | /// clang::ASTConsumer *newASTConsumer(); |
141 | | /// } Factory; |
142 | | /// std::unique_ptr<FrontendActionFactory> FactoryAdapter( |
143 | | /// newFrontendActionFactory(&Factory)); |
144 | | template <typename FactoryT> |
145 | | inline std::unique_ptr<FrontendActionFactory> newFrontendActionFactory( |
146 | | FactoryT *ConsumerFactory, SourceFileCallbacks *Callbacks = nullptr); |
147 | | |
148 | | /// Runs (and deletes) the tool on 'Code' with the -fsyntax-only flag. |
149 | | /// |
150 | | /// \param ToolAction The action to run over the code. |
151 | | /// \param Code C++ code. |
152 | | /// \param FileName The file name which 'Code' will be mapped as. |
153 | | /// \param PCHContainerOps The PCHContainerOperations for loading and creating |
154 | | /// clang modules. |
155 | | /// |
156 | | /// \return - True if 'ToolAction' was successfully executed. |
157 | | bool runToolOnCode(std::unique_ptr<FrontendAction> ToolAction, const Twine &Code, |
158 | | const Twine &FileName = "input.cc", |
159 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps = |
160 | | std::make_shared<PCHContainerOperations>()); |
161 | | |
162 | | /// The first part of the pair is the filename, the second part the |
163 | | /// file-content. |
164 | | using FileContentMappings = std::vector<std::pair<std::string, std::string>>; |
165 | | |
166 | | /// Runs (and deletes) the tool on 'Code' with the -fsyntax-only flag and |
167 | | /// with additional other flags. |
168 | | /// |
169 | | /// \param ToolAction The action to run over the code. |
170 | | /// \param Code C++ code. |
171 | | /// \param Args Additional flags to pass on. |
172 | | /// \param FileName The file name which 'Code' will be mapped as. |
173 | | /// \param ToolName The name of the binary running the tool. Standard library |
174 | | /// header paths will be resolved relative to this. |
175 | | /// \param PCHContainerOps The PCHContainerOperations for loading and creating |
176 | | /// clang modules. |
177 | | /// |
178 | | /// \return - True if 'ToolAction' was successfully executed. |
179 | | bool runToolOnCodeWithArgs( |
180 | | std::unique_ptr<FrontendAction> ToolAction, const Twine &Code, |
181 | | const std::vector<std::string> &Args, const Twine &FileName = "input.cc", |
182 | | const Twine &ToolName = "clang-tool", |
183 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps = |
184 | | std::make_shared<PCHContainerOperations>(), |
185 | | const FileContentMappings &VirtualMappedFiles = FileContentMappings()); |
186 | | |
187 | | // Similar to the overload except this takes a VFS. |
188 | | bool runToolOnCodeWithArgs( |
189 | | std::unique_ptr<FrontendAction> ToolAction, const Twine &Code, |
190 | | llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, |
191 | | const std::vector<std::string> &Args, const Twine &FileName = "input.cc", |
192 | | const Twine &ToolName = "clang-tool", |
193 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps = |
194 | | std::make_shared<PCHContainerOperations>()); |
195 | | |
196 | | /// Builds an AST for 'Code'. |
197 | | /// |
198 | | /// \param Code C++ code. |
199 | | /// \param FileName The file name which 'Code' will be mapped as. |
200 | | /// \param PCHContainerOps The PCHContainerOperations for loading and creating |
201 | | /// clang modules. |
202 | | /// |
203 | | /// \return The resulting AST or null if an error occurred. |
204 | | std::unique_ptr<ASTUnit> |
205 | | buildASTFromCode(StringRef Code, StringRef FileName = "input.cc", |
206 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps = |
207 | | std::make_shared<PCHContainerOperations>()); |
208 | | |
209 | | /// Builds an AST for 'Code' with additional flags. |
210 | | /// |
211 | | /// \param Code C++ code. |
212 | | /// \param Args Additional flags to pass on. |
213 | | /// \param FileName The file name which 'Code' will be mapped as. |
214 | | /// \param ToolName The name of the binary running the tool. Standard library |
215 | | /// header paths will be resolved relative to this. |
216 | | /// \param PCHContainerOps The PCHContainerOperations for loading and creating |
217 | | /// clang modules. |
218 | | /// |
219 | | /// \param Adjuster A function to filter the command line arguments as specified. |
220 | | /// |
221 | | /// \return The resulting AST or null if an error occurred. |
222 | | std::unique_ptr<ASTUnit> buildASTFromCodeWithArgs( |
223 | | StringRef Code, const std::vector<std::string> &Args, |
224 | | StringRef FileName = "input.cc", StringRef ToolName = "clang-tool", |
225 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps = |
226 | | std::make_shared<PCHContainerOperations>(), |
227 | | ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster(), |
228 | | const FileContentMappings &VirtualMappedFiles = FileContentMappings(), |
229 | | DiagnosticConsumer *DiagConsumer = nullptr); |
230 | | |
231 | | /// Utility to run a FrontendAction in a single clang invocation. |
232 | | class ToolInvocation { |
233 | | public: |
234 | | /// Create a tool invocation. |
235 | | /// |
236 | | /// \param CommandLine The command line arguments to clang. Note that clang |
237 | | /// uses its binary name (CommandLine[0]) to locate its builtin headers. |
238 | | /// Callers have to ensure that they are installed in a compatible location |
239 | | /// (see clang driver implementation) or mapped in via mapVirtualFile. |
240 | | /// \param FAction The action to be executed. |
241 | | /// \param Files The FileManager used for the execution. Class does not take |
242 | | /// ownership. |
243 | | /// \param PCHContainerOps The PCHContainerOperations for loading and creating |
244 | | /// clang modules. |
245 | | ToolInvocation(std::vector<std::string> CommandLine, |
246 | | std::unique_ptr<FrontendAction> FAction, FileManager *Files, |
247 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps = |
248 | | std::make_shared<PCHContainerOperations>()); |
249 | | |
250 | | /// Create a tool invocation. |
251 | | /// |
252 | | /// \param CommandLine The command line arguments to clang. |
253 | | /// \param Action The action to be executed. |
254 | | /// \param Files The FileManager used for the execution. |
255 | | /// \param PCHContainerOps The PCHContainerOperations for loading and creating |
256 | | /// clang modules. |
257 | | ToolInvocation(std::vector<std::string> CommandLine, ToolAction *Action, |
258 | | FileManager *Files, |
259 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps); |
260 | | |
261 | | ~ToolInvocation(); |
262 | | |
263 | | /// Set a \c DiagnosticConsumer to use during parsing. |
264 | 6.44k | void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) { |
265 | 6.44k | this->DiagConsumer = DiagConsumer; |
266 | 6.44k | } |
267 | | |
268 | | /// Run the clang invocation. |
269 | | /// |
270 | | /// \returns True if there were no errors during execution. |
271 | | bool run(); |
272 | | |
273 | | private: |
274 | | bool runInvocation(const char *BinaryName, |
275 | | driver::Compilation *Compilation, |
276 | | std::shared_ptr<CompilerInvocation> Invocation, |
277 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps); |
278 | | |
279 | | std::vector<std::string> CommandLine; |
280 | | ToolAction *Action; |
281 | | bool OwnsAction; |
282 | | FileManager *Files; |
283 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps; |
284 | | DiagnosticConsumer *DiagConsumer = nullptr; |
285 | | }; |
286 | | |
287 | | /// Utility to run a FrontendAction over a set of files. |
288 | | /// |
289 | | /// This class is written to be usable for command line utilities. |
290 | | /// By default the class uses ClangSyntaxOnlyAdjuster to modify |
291 | | /// command line arguments before the arguments are used to run |
292 | | /// a frontend action. One could install an additional command line |
293 | | /// arguments adjuster by calling the appendArgumentsAdjuster() method. |
294 | | class ClangTool { |
295 | | public: |
296 | | /// Constructs a clang tool to run over a list of files. |
297 | | /// |
298 | | /// \param Compilations The CompilationDatabase which contains the compile |
299 | | /// command lines for the given source paths. |
300 | | /// \param SourcePaths The source files to run over. If a source files is |
301 | | /// not found in Compilations, it is skipped. |
302 | | /// \param PCHContainerOps The PCHContainerOperations for loading and creating |
303 | | /// clang modules. |
304 | | /// \param BaseFS VFS used for all underlying file accesses when running the |
305 | | /// tool. |
306 | | /// \param Files The file manager to use for underlying file operations when |
307 | | /// running the tool. |
308 | | ClangTool(const CompilationDatabase &Compilations, |
309 | | ArrayRef<std::string> SourcePaths, |
310 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps = |
311 | | std::make_shared<PCHContainerOperations>(), |
312 | | IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS = |
313 | | llvm::vfs::getRealFileSystem(), |
314 | | IntrusiveRefCntPtr<FileManager> Files = nullptr); |
315 | | |
316 | | ~ClangTool(); |
317 | | |
318 | | /// Set a \c DiagnosticConsumer to use during parsing. |
319 | 77 | void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) { |
320 | 77 | this->DiagConsumer = DiagConsumer; |
321 | 77 | } |
322 | | |
323 | | /// Map a virtual file to be used while running the tool. |
324 | | /// |
325 | | /// \param FilePath The path at which the content will be mapped. |
326 | | /// \param Content A null terminated buffer of the file's content. |
327 | | void mapVirtualFile(StringRef FilePath, StringRef Content); |
328 | | |
329 | | /// Append a command line arguments adjuster to the adjuster chain. |
330 | | /// |
331 | | /// \param Adjuster An argument adjuster, which will be run on the output of |
332 | | /// previous argument adjusters. |
333 | | void appendArgumentsAdjuster(ArgumentsAdjuster Adjuster); |
334 | | |
335 | | /// Clear the command line arguments adjuster chain. |
336 | | void clearArgumentsAdjusters(); |
337 | | |
338 | | /// Runs an action over all files specified in the command line. |
339 | | /// |
340 | | /// \param Action Tool action. |
341 | | /// |
342 | | /// \returns 0 on success; 1 if any error occurred; 2 if there is no error but |
343 | | /// some files are skipped due to missing compile commands. |
344 | | int run(ToolAction *Action); |
345 | | |
346 | | /// Create an AST for each file specified in the command line and |
347 | | /// append them to ASTs. |
348 | | int buildASTs(std::vector<std::unique_ptr<ASTUnit>> &ASTs); |
349 | | |
350 | | /// Sets whether working directory should be restored after calling run(). By |
351 | | /// default, working directory is restored. However, it could be useful to |
352 | | /// turn this off when running on multiple threads to avoid the raciness. |
353 | | void setRestoreWorkingDir(bool RestoreCWD); |
354 | | |
355 | | /// Sets whether an error message should be printed out if an action fails. By |
356 | | /// default, if an action fails, a message is printed out to stderr. |
357 | | void setPrintErrorMessage(bool PrintErrorMessage); |
358 | | |
359 | | /// Returns the file manager used in the tool. |
360 | | /// |
361 | | /// The file manager is shared between all translation units. |
362 | 70 | FileManager &getFiles() { return *Files; } |
363 | | |
364 | 0 | llvm::ArrayRef<std::string> getSourcePaths() const { return SourcePaths; } |
365 | | |
366 | | private: |
367 | | const CompilationDatabase &Compilations; |
368 | | std::vector<std::string> SourcePaths; |
369 | | std::shared_ptr<PCHContainerOperations> PCHContainerOps; |
370 | | |
371 | | llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem; |
372 | | llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem; |
373 | | llvm::IntrusiveRefCntPtr<FileManager> Files; |
374 | | |
375 | | // Contains a list of pairs (<file name>, <file content>). |
376 | | std::vector<std::pair<StringRef, StringRef>> MappedFileContents; |
377 | | |
378 | | llvm::StringSet<> SeenWorkingDirectories; |
379 | | |
380 | | ArgumentsAdjuster ArgsAdjuster; |
381 | | |
382 | | DiagnosticConsumer *DiagConsumer = nullptr; |
383 | | |
384 | | bool RestoreCWD = true; |
385 | | bool PrintErrorMessage = true; |
386 | | }; |
387 | | |
388 | | template <typename T> |
389 | 9 | std::unique_ptr<FrontendActionFactory> newFrontendActionFactory() { |
390 | 9 | class SimpleFrontendActionFactory : public FrontendActionFactory { |
391 | 9 | public: |
392 | 9 | std::unique_ptr<FrontendAction> create() override { |
393 | 9 | return std::make_unique<T>(); |
394 | 9 | } std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::ento::AnalysisAction>()::SimpleFrontendActionFactory::create() Line | Count | Source | 392 | 4 | std::unique_ptr<FrontendAction> create() override { | 393 | 4 | return std::make_unique<T>(); | 394 | 4 | } |
ClangCheck.cpp:std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckFixItAction>()::SimpleFrontendActionFactory::create() Line | Count | Source | 392 | 4 | std::unique_ptr<FrontendAction> create() override { | 393 | 4 | return std::make_unique<T>(); | 394 | 4 | } |
std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<MapExtDefNamesAction>()::SimpleFrontendActionFactory::create() Line | Count | Source | 392 | 1 | std::unique_ptr<FrontendAction> create() override { | 393 | 1 | return std::make_unique<T>(); | 394 | 1 | } |
Unexecuted instantiation: std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<SBAction>()::SimpleFrontendActionFactory::create() Unexecuted instantiation: std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::EmitObjAction>()::SimpleFrontendActionFactory::create() |
395 | 9 | }; |
396 | | |
397 | 9 | return std::unique_ptr<FrontendActionFactory>( |
398 | 9 | new SimpleFrontendActionFactory); |
399 | 9 | } std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::ento::AnalysisAction>() Line | Count | Source | 389 | 4 | std::unique_ptr<FrontendActionFactory> newFrontendActionFactory() { | 390 | 4 | class SimpleFrontendActionFactory : public FrontendActionFactory { | 391 | 4 | public: | 392 | 4 | std::unique_ptr<FrontendAction> create() override { | 393 | 4 | return std::make_unique<T>(); | 394 | 4 | } | 395 | 4 | }; | 396 | | | 397 | 4 | return std::unique_ptr<FrontendActionFactory>( | 398 | 4 | new SimpleFrontendActionFactory); | 399 | 4 | } |
ClangCheck.cpp:std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckFixItAction>() Line | Count | Source | 389 | 4 | std::unique_ptr<FrontendActionFactory> newFrontendActionFactory() { | 390 | 4 | class SimpleFrontendActionFactory : public FrontendActionFactory { | 391 | 4 | public: | 392 | 4 | std::unique_ptr<FrontendAction> create() override { | 393 | 4 | return std::make_unique<T>(); | 394 | 4 | } | 395 | 4 | }; | 396 | | | 397 | 4 | return std::unique_ptr<FrontendActionFactory>( | 398 | 4 | new SimpleFrontendActionFactory); | 399 | 4 | } |
std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<MapExtDefNamesAction>() Line | Count | Source | 389 | 1 | std::unique_ptr<FrontendActionFactory> newFrontendActionFactory() { | 390 | 1 | class SimpleFrontendActionFactory : public FrontendActionFactory { | 391 | 1 | public: | 392 | 1 | std::unique_ptr<FrontendAction> create() override { | 393 | 1 | return std::make_unique<T>(); | 394 | 1 | } | 395 | 1 | }; | 396 | | | 397 | 1 | return std::unique_ptr<FrontendActionFactory>( | 398 | 1 | new SimpleFrontendActionFactory); | 399 | 1 | } |
Unexecuted instantiation: std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<SBAction>() Unexecuted instantiation: std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::EmitObjAction>() |
400 | | |
401 | | template <typename FactoryT> |
402 | | inline std::unique_ptr<FrontendActionFactory> newFrontendActionFactory( |
403 | 427 | FactoryT *ConsumerFactory, SourceFileCallbacks *Callbacks) { |
404 | 427 | class FrontendActionFactoryAdapter : public FrontendActionFactory { |
405 | 427 | public: |
406 | 427 | explicit FrontendActionFactoryAdapter(FactoryT *ConsumerFactory, |
407 | 427 | SourceFileCallbacks *Callbacks) |
408 | 427 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::USRFindingAction>(clang::tooling::USRFindingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::FrontendActionFactoryAdapter(clang::tooling::USRFindingAction*, clang::tooling::SourceFileCallbacks*) Line | Count | Source | 408 | 329 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} |
std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::RenamingAction>(clang::tooling::RenamingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::FrontendActionFactoryAdapter(clang::tooling::RenamingAction*, clang::tooling::SourceFileCallbacks*) Line | Count | Source | 408 | 69 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} |
ClangCheck.cpp:std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::FrontendActionFactoryAdapter((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*) Line | Count | Source | 408 | 29 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} |
|
409 | | |
410 | 428 | std::unique_ptr<FrontendAction> create() override { |
411 | 428 | return std::make_unique<ConsumerFactoryAdaptor>(ConsumerFactory, |
412 | 428 | Callbacks); |
413 | 428 | } std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::USRFindingAction>(clang::tooling::USRFindingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::create() Line | Count | Source | 410 | 329 | std::unique_ptr<FrontendAction> create() override { | 411 | 329 | return std::make_unique<ConsumerFactoryAdaptor>(ConsumerFactory, | 412 | 329 | Callbacks); | 413 | 329 | } |
std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::RenamingAction>(clang::tooling::RenamingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::create() Line | Count | Source | 410 | 69 | std::unique_ptr<FrontendAction> create() override { | 411 | 69 | return std::make_unique<ConsumerFactoryAdaptor>(ConsumerFactory, | 412 | 69 | Callbacks); | 413 | 69 | } |
ClangCheck.cpp:std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::create() Line | Count | Source | 410 | 30 | std::unique_ptr<FrontendAction> create() override { | 411 | 30 | return std::make_unique<ConsumerFactoryAdaptor>(ConsumerFactory, | 412 | 30 | Callbacks); | 413 | 30 | } |
|
414 | | |
415 | 427 | private: |
416 | 427 | class ConsumerFactoryAdaptor : public ASTFrontendAction { |
417 | 427 | public: |
418 | 427 | ConsumerFactoryAdaptor(FactoryT *ConsumerFactory, |
419 | 427 | SourceFileCallbacks *Callbacks) |
420 | 428 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::USRFindingAction>(clang::tooling::USRFindingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::ConsumerFactoryAdaptor(clang::tooling::USRFindingAction*, clang::tooling::SourceFileCallbacks*) Line | Count | Source | 420 | 329 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} |
std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::RenamingAction>(clang::tooling::RenamingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::ConsumerFactoryAdaptor(clang::tooling::RenamingAction*, clang::tooling::SourceFileCallbacks*) Line | Count | Source | 420 | 69 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} |
ClangCheck.cpp:std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::ConsumerFactoryAdaptor((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*) Line | Count | Source | 420 | 30 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} |
|
421 | | |
422 | 427 | std::unique_ptr<ASTConsumer> |
423 | 428 | CreateASTConsumer(CompilerInstance &, StringRef) override { |
424 | 428 | return ConsumerFactory->newASTConsumer(); |
425 | 428 | } std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::USRFindingAction>(clang::tooling::USRFindingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef) Line | Count | Source | 423 | 329 | CreateASTConsumer(CompilerInstance &, StringRef) override { | 424 | 329 | return ConsumerFactory->newASTConsumer(); | 425 | 329 | } |
std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::RenamingAction>(clang::tooling::RenamingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef) Line | Count | Source | 423 | 69 | CreateASTConsumer(CompilerInstance &, StringRef) override { | 424 | 69 | return ConsumerFactory->newASTConsumer(); | 425 | 69 | } |
ClangCheck.cpp:std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef) Line | Count | Source | 423 | 30 | CreateASTConsumer(CompilerInstance &, StringRef) override { | 424 | 30 | return ConsumerFactory->newASTConsumer(); | 425 | 30 | } |
|
426 | | |
427 | 427 | protected: |
428 | 428 | bool BeginSourceFileAction(CompilerInstance &CI) override { |
429 | 428 | if (!ASTFrontendAction::BeginSourceFileAction(CI)) |
430 | 0 | return false; |
431 | 428 | if (Callbacks) |
432 | 0 | return Callbacks->handleBeginSource(CI); |
433 | 428 | return true; |
434 | 428 | } std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::USRFindingAction>(clang::tooling::USRFindingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::BeginSourceFileAction(clang::CompilerInstance&) Line | Count | Source | 428 | 329 | bool BeginSourceFileAction(CompilerInstance &CI) override { | 429 | 329 | if (!ASTFrontendAction::BeginSourceFileAction(CI)) | 430 | 0 | return false; | 431 | 329 | if (Callbacks) | 432 | 0 | return Callbacks->handleBeginSource(CI); | 433 | 329 | return true; | 434 | 329 | } |
std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::RenamingAction>(clang::tooling::RenamingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::BeginSourceFileAction(clang::CompilerInstance&) Line | Count | Source | 428 | 69 | bool BeginSourceFileAction(CompilerInstance &CI) override { | 429 | 69 | if (!ASTFrontendAction::BeginSourceFileAction(CI)) | 430 | 0 | return false; | 431 | 69 | if (Callbacks) | 432 | 0 | return Callbacks->handleBeginSource(CI); | 433 | 69 | return true; | 434 | 69 | } |
ClangCheck.cpp:std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::BeginSourceFileAction(clang::CompilerInstance&) Line | Count | Source | 428 | 30 | bool BeginSourceFileAction(CompilerInstance &CI) override { | 429 | 30 | if (!ASTFrontendAction::BeginSourceFileAction(CI)) | 430 | 0 | return false; | 431 | 30 | if (Callbacks) | 432 | 0 | return Callbacks->handleBeginSource(CI); | 433 | 30 | return true; | 434 | 30 | } |
|
435 | | |
436 | 428 | void EndSourceFileAction() override { |
437 | 428 | if (Callbacks) |
438 | 0 | Callbacks->handleEndSource(); |
439 | 428 | ASTFrontendAction::EndSourceFileAction(); |
440 | 428 | } std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::USRFindingAction>(clang::tooling::USRFindingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::EndSourceFileAction() Line | Count | Source | 436 | 329 | void EndSourceFileAction() override { | 437 | 329 | if (Callbacks) | 438 | 0 | Callbacks->handleEndSource(); | 439 | 329 | ASTFrontendAction::EndSourceFileAction(); | 440 | 329 | } |
std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::RenamingAction>(clang::tooling::RenamingAction*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::EndSourceFileAction() Line | Count | Source | 436 | 69 | void EndSourceFileAction() override { | 437 | 69 | if (Callbacks) | 438 | 0 | Callbacks->handleEndSource(); | 439 | 69 | ASTFrontendAction::EndSourceFileAction(); | 440 | 69 | } |
ClangCheck.cpp:std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*)::FrontendActionFactoryAdapter::ConsumerFactoryAdaptor::EndSourceFileAction() Line | Count | Source | 436 | 30 | void EndSourceFileAction() override { | 437 | 30 | if (Callbacks) | 438 | 0 | Callbacks->handleEndSource(); | 439 | 30 | ASTFrontendAction::EndSourceFileAction(); | 440 | 30 | } |
|
441 | | |
442 | 427 | private: |
443 | 427 | FactoryT *ConsumerFactory; |
444 | 427 | SourceFileCallbacks *Callbacks; |
445 | 427 | }; |
446 | 427 | FactoryT *ConsumerFactory; |
447 | 427 | SourceFileCallbacks *Callbacks; |
448 | 427 | }; |
449 | | |
450 | 427 | return std::unique_ptr<FrontendActionFactory>( |
451 | 427 | new FrontendActionFactoryAdapter(ConsumerFactory, Callbacks)); |
452 | 427 | } std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::USRFindingAction>(clang::tooling::USRFindingAction*, clang::tooling::SourceFileCallbacks*) Line | Count | Source | 403 | 329 | FactoryT *ConsumerFactory, SourceFileCallbacks *Callbacks) { | 404 | 329 | class FrontendActionFactoryAdapter : public FrontendActionFactory { | 405 | 329 | public: | 406 | 329 | explicit FrontendActionFactoryAdapter(FactoryT *ConsumerFactory, | 407 | 329 | SourceFileCallbacks *Callbacks) | 408 | 329 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} | 409 | | | 410 | 329 | std::unique_ptr<FrontendAction> create() override { | 411 | 329 | return std::make_unique<ConsumerFactoryAdaptor>(ConsumerFactory, | 412 | 329 | Callbacks); | 413 | 329 | } | 414 | | | 415 | 329 | private: | 416 | 329 | class ConsumerFactoryAdaptor : public ASTFrontendAction { | 417 | 329 | public: | 418 | 329 | ConsumerFactoryAdaptor(FactoryT *ConsumerFactory, | 419 | 329 | SourceFileCallbacks *Callbacks) | 420 | 329 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} | 421 | | | 422 | 329 | std::unique_ptr<ASTConsumer> | 423 | 329 | CreateASTConsumer(CompilerInstance &, StringRef) override { | 424 | 329 | return ConsumerFactory->newASTConsumer(); | 425 | 329 | } | 426 | | | 427 | 329 | protected: | 428 | 329 | bool BeginSourceFileAction(CompilerInstance &CI) override { | 429 | 329 | if (!ASTFrontendAction::BeginSourceFileAction(CI)) | 430 | 329 | return false; | 431 | 329 | if (Callbacks) | 432 | 329 | return Callbacks->handleBeginSource(CI); | 433 | 329 | return true; | 434 | 329 | } | 435 | | | 436 | 329 | void EndSourceFileAction() override { | 437 | 329 | if (Callbacks) | 438 | 329 | Callbacks->handleEndSource(); | 439 | 329 | ASTFrontendAction::EndSourceFileAction(); | 440 | 329 | } | 441 | | | 442 | 329 | private: | 443 | 329 | FactoryT *ConsumerFactory; | 444 | 329 | SourceFileCallbacks *Callbacks; | 445 | 329 | }; | 446 | 329 | FactoryT *ConsumerFactory; | 447 | 329 | SourceFileCallbacks *Callbacks; | 448 | 329 | }; | 449 | | | 450 | 329 | return std::unique_ptr<FrontendActionFactory>( | 451 | 329 | new FrontendActionFactoryAdapter(ConsumerFactory, Callbacks)); | 452 | 329 | } |
std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<clang::tooling::RenamingAction>(clang::tooling::RenamingAction*, clang::tooling::SourceFileCallbacks*) Line | Count | Source | 403 | 69 | FactoryT *ConsumerFactory, SourceFileCallbacks *Callbacks) { | 404 | 69 | class FrontendActionFactoryAdapter : public FrontendActionFactory { | 405 | 69 | public: | 406 | 69 | explicit FrontendActionFactoryAdapter(FactoryT *ConsumerFactory, | 407 | 69 | SourceFileCallbacks *Callbacks) | 408 | 69 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} | 409 | | | 410 | 69 | std::unique_ptr<FrontendAction> create() override { | 411 | 69 | return std::make_unique<ConsumerFactoryAdaptor>(ConsumerFactory, | 412 | 69 | Callbacks); | 413 | 69 | } | 414 | | | 415 | 69 | private: | 416 | 69 | class ConsumerFactoryAdaptor : public ASTFrontendAction { | 417 | 69 | public: | 418 | 69 | ConsumerFactoryAdaptor(FactoryT *ConsumerFactory, | 419 | 69 | SourceFileCallbacks *Callbacks) | 420 | 69 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} | 421 | | | 422 | 69 | std::unique_ptr<ASTConsumer> | 423 | 69 | CreateASTConsumer(CompilerInstance &, StringRef) override { | 424 | 69 | return ConsumerFactory->newASTConsumer(); | 425 | 69 | } | 426 | | | 427 | 69 | protected: | 428 | 69 | bool BeginSourceFileAction(CompilerInstance &CI) override { | 429 | 69 | if (!ASTFrontendAction::BeginSourceFileAction(CI)) | 430 | 69 | return false; | 431 | 69 | if (Callbacks) | 432 | 69 | return Callbacks->handleBeginSource(CI); | 433 | 69 | return true; | 434 | 69 | } | 435 | | | 436 | 69 | void EndSourceFileAction() override { | 437 | 69 | if (Callbacks) | 438 | 69 | Callbacks->handleEndSource(); | 439 | 69 | ASTFrontendAction::EndSourceFileAction(); | 440 | 69 | } | 441 | | | 442 | 69 | private: | 443 | 69 | FactoryT *ConsumerFactory; | 444 | 69 | SourceFileCallbacks *Callbacks; | 445 | 69 | }; | 446 | 69 | FactoryT *ConsumerFactory; | 447 | 69 | SourceFileCallbacks *Callbacks; | 448 | 69 | }; | 449 | | | 450 | 69 | return std::unique_ptr<FrontendActionFactory>( | 451 | 69 | new FrontendActionFactoryAdapter(ConsumerFactory, Callbacks)); | 452 | 69 | } |
ClangCheck.cpp:std::__1::unique_ptr<clang::tooling::FrontendActionFactory, std::__1::default_delete<clang::tooling::FrontendActionFactory> > clang::tooling::newFrontendActionFactory<(anonymous namespace)::ClangCheckActionFactory>((anonymous namespace)::ClangCheckActionFactory*, clang::tooling::SourceFileCallbacks*) Line | Count | Source | 403 | 29 | FactoryT *ConsumerFactory, SourceFileCallbacks *Callbacks) { | 404 | 29 | class FrontendActionFactoryAdapter : public FrontendActionFactory { | 405 | 29 | public: | 406 | 29 | explicit FrontendActionFactoryAdapter(FactoryT *ConsumerFactory, | 407 | 29 | SourceFileCallbacks *Callbacks) | 408 | 29 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} | 409 | | | 410 | 29 | std::unique_ptr<FrontendAction> create() override { | 411 | 29 | return std::make_unique<ConsumerFactoryAdaptor>(ConsumerFactory, | 412 | 29 | Callbacks); | 413 | 29 | } | 414 | | | 415 | 29 | private: | 416 | 29 | class ConsumerFactoryAdaptor : public ASTFrontendAction { | 417 | 29 | public: | 418 | 29 | ConsumerFactoryAdaptor(FactoryT *ConsumerFactory, | 419 | 29 | SourceFileCallbacks *Callbacks) | 420 | 29 | : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {} | 421 | | | 422 | 29 | std::unique_ptr<ASTConsumer> | 423 | 29 | CreateASTConsumer(CompilerInstance &, StringRef) override { | 424 | 29 | return ConsumerFactory->newASTConsumer(); | 425 | 29 | } | 426 | | | 427 | 29 | protected: | 428 | 29 | bool BeginSourceFileAction(CompilerInstance &CI) override { | 429 | 29 | if (!ASTFrontendAction::BeginSourceFileAction(CI)) | 430 | 29 | return false; | 431 | 29 | if (Callbacks) | 432 | 29 | return Callbacks->handleBeginSource(CI); | 433 | 29 | return true; | 434 | 29 | } | 435 | | | 436 | 29 | void EndSourceFileAction() override { | 437 | 29 | if (Callbacks) | 438 | 29 | Callbacks->handleEndSource(); | 439 | 29 | ASTFrontendAction::EndSourceFileAction(); | 440 | 29 | } | 441 | | | 442 | 29 | private: | 443 | 29 | FactoryT *ConsumerFactory; | 444 | 29 | SourceFileCallbacks *Callbacks; | 445 | 29 | }; | 446 | 29 | FactoryT *ConsumerFactory; | 447 | 29 | SourceFileCallbacks *Callbacks; | 448 | 29 | }; | 449 | | | 450 | 29 | return std::unique_ptr<FrontendActionFactory>( | 451 | 29 | new FrontendActionFactoryAdapter(ConsumerFactory, Callbacks)); | 452 | 29 | } |
|
453 | | |
454 | | /// Returns the absolute path of \c File, by prepending it with |
455 | | /// the current directory if \c File is not absolute. |
456 | | /// |
457 | | /// Otherwise returns \c File. |
458 | | /// If 'File' starts with "./", the returned path will not contain the "./". |
459 | | /// Otherwise, the returned path will contain the literal path-concatenation of |
460 | | /// the current directory and \c File. |
461 | | /// |
462 | | /// The difference to llvm::sys::fs::make_absolute is the canonicalization this |
463 | | /// does by removing "./" and computing native paths. |
464 | | /// |
465 | | /// \param File Either an absolute or relative path. |
466 | | std::string getAbsolutePath(StringRef File); |
467 | | |
468 | | /// An overload of getAbsolutePath that works over the provided \p FS. |
469 | | llvm::Expected<std::string> getAbsolutePath(llvm::vfs::FileSystem &FS, |
470 | | StringRef File); |
471 | | |
472 | | /// Changes CommandLine to contain implicit flags that would have been |
473 | | /// defined had the compiler driver been invoked through the path InvokedAs. |
474 | | /// |
475 | | /// For example, when called with \c InvokedAs set to `i686-linux-android-g++`, |
476 | | /// the arguments '-target', 'i686-linux-android`, `--driver-mode=g++` will |
477 | | /// be inserted after the first argument in \c CommandLine. |
478 | | /// |
479 | | /// This function will not add new `-target` or `--driver-mode` flags if they |
480 | | /// are already present in `CommandLine` (even if they have different settings |
481 | | /// than would have been inserted). |
482 | | /// |
483 | | /// \pre `llvm::InitializeAllTargets()` has been called. |
484 | | /// |
485 | | /// \param CommandLine the command line used to invoke the compiler driver or |
486 | | /// Clang tool, including the path to the executable as \c CommandLine[0]. |
487 | | /// \param InvokedAs the path to the driver used to infer implicit flags. |
488 | | /// |
489 | | /// \note This will not set \c CommandLine[0] to \c InvokedAs. The tooling |
490 | | /// infrastructure expects that CommandLine[0] is a tool path relative to which |
491 | | /// the builtin headers can be found. |
492 | | void addTargetAndModeForProgramName(std::vector<std::string> &CommandLine, |
493 | | StringRef InvokedAs); |
494 | | |
495 | | /// Creates a \c CompilerInvocation. |
496 | | CompilerInvocation *newInvocation(DiagnosticsEngine *Diagnostics, |
497 | | const llvm::opt::ArgStringList &CC1Args, |
498 | | const char *const BinaryName); |
499 | | |
500 | | } // namespace tooling |
501 | | |
502 | | } // namespace clang |
503 | | |
504 | | #endif // LLVM_CLANG_TOOLING_TOOLING_H |