1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | #ifndef LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_ |
10 | #define LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_ |
11 | |
12 | #include "clang/AST/ASTConsumer.h" |
13 | #include "clang/Basic/Diagnostic.h" |
14 | #include "clang/Basic/SourceManager.h" |
15 | #include "clang/Frontend/CompilerInvocation.h" |
16 | #include "clang/Frontend/PCHContainerOperations.h" |
17 | #include "clang/Frontend/Utils.h" |
18 | #include "clang/Lex/HeaderSearchOptions.h" |
19 | #include "clang/Lex/ModuleLoader.h" |
20 | #include "llvm/ADT/ArrayRef.h" |
21 | #include "llvm/ADT/DenseMap.h" |
22 | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
23 | #include "llvm/ADT/StringRef.h" |
24 | #include "llvm/Support/BuryPointer.h" |
25 | #include <cassert> |
26 | #include <list> |
27 | #include <memory> |
28 | #include <string> |
29 | #include <utility> |
30 | |
31 | namespace llvm { |
32 | class raw_fd_ostream; |
33 | class Timer; |
34 | class TimerGroup; |
35 | } |
36 | |
37 | namespace clang { |
38 | class ASTContext; |
39 | class ASTReader; |
40 | class CodeCompleteConsumer; |
41 | class DiagnosticsEngine; |
42 | class DiagnosticConsumer; |
43 | class ExternalASTSource; |
44 | class FileEntry; |
45 | class FileManager; |
46 | class FrontendAction; |
47 | class InMemoryModuleCache; |
48 | class Module; |
49 | class Preprocessor; |
50 | class Sema; |
51 | class SourceManager; |
52 | class TargetInfo; |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | |
65 | |
66 | |
67 | |
68 | |
69 | |
70 | |
71 | |
72 | class CompilerInstance : public ModuleLoader { |
73 | |
74 | std::shared_ptr<CompilerInvocation> Invocation; |
75 | |
76 | |
77 | IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics; |
78 | |
79 | |
80 | IntrusiveRefCntPtr<TargetInfo> Target; |
81 | |
82 | |
83 | IntrusiveRefCntPtr<TargetInfo> AuxTarget; |
84 | |
85 | |
86 | IntrusiveRefCntPtr<FileManager> FileMgr; |
87 | |
88 | |
89 | IntrusiveRefCntPtr<SourceManager> SourceMgr; |
90 | |
91 | |
92 | IntrusiveRefCntPtr<InMemoryModuleCache> ModuleCache; |
93 | |
94 | |
95 | std::shared_ptr<Preprocessor> PP; |
96 | |
97 | |
98 | IntrusiveRefCntPtr<ASTContext> Context; |
99 | |
100 | |
101 | IntrusiveRefCntPtr<ExternalSemaSource> ExternalSemaSrc; |
102 | |
103 | |
104 | std::unique_ptr<ASTConsumer> Consumer; |
105 | |
106 | |
107 | std::unique_ptr<CodeCompleteConsumer> CompletionConsumer; |
108 | |
109 | |
110 | std::unique_ptr<Sema> TheSema; |
111 | |
112 | |
113 | std::unique_ptr<llvm::TimerGroup> FrontendTimerGroup; |
114 | |
115 | |
116 | std::unique_ptr<llvm::Timer> FrontendTimer; |
117 | |
118 | |
119 | IntrusiveRefCntPtr<ASTReader> ModuleManager; |
120 | |
121 | |
122 | std::shared_ptr<ModuleDependencyCollector> ModuleDepCollector; |
123 | |
124 | |
125 | std::shared_ptr<PCHContainerOperations> ThePCHContainerOperations; |
126 | |
127 | |
128 | std::unique_ptr<DependencyFileGenerator> TheDependencyFileGenerator; |
129 | |
130 | std::vector<std::shared_ptr<DependencyCollector>> DependencyCollectors; |
131 | |
132 | |
133 | |
134 | llvm::DenseMap<const IdentifierInfo *, Module *> KnownModules; |
135 | |
136 | |
137 | |
138 | std::map<std::string, std::string> BuiltModules; |
139 | |
140 | |
141 | bool DeleteBuiltModules = true; |
142 | |
143 | |
144 | |
145 | SourceLocation LastModuleImportLoc; |
146 | |
147 | |
148 | |
149 | ModuleLoadResult LastModuleImportResult; |
150 | |
151 | |
152 | |
153 | bool BuildGlobalModuleIndex = false; |
154 | |
155 | |
156 | bool HaveFullGlobalModuleIndex = false; |
157 | |
158 | |
159 | bool ModuleBuildFailed = false; |
160 | |
161 | |
162 | |
163 | |
164 | |
165 | |
166 | struct OutputFile { |
167 | std::string Filename; |
168 | std::string TempFilename; |
169 | |
170 | OutputFile(std::string filename, std::string tempFilename) |
171 | : Filename(std::move(filename)), TempFilename(std::move(tempFilename)) { |
172 | } |
173 | }; |
174 | |
175 | |
176 | |
177 | |
178 | std::unique_ptr<llvm::raw_fd_ostream> NonSeekStream; |
179 | |
180 | |
181 | std::list<OutputFile> OutputFiles; |
182 | |
183 | |
184 | std::unique_ptr<llvm::raw_pwrite_stream> OutputStream; |
185 | |
186 | CompilerInstance(const CompilerInstance &) = delete; |
187 | void operator=(const CompilerInstance &) = delete; |
188 | public: |
189 | explicit CompilerInstance( |
190 | std::shared_ptr<PCHContainerOperations> PCHContainerOps = |
191 | std::make_shared<PCHContainerOperations>(), |
192 | InMemoryModuleCache *SharedModuleCache = nullptr); |
193 | ~CompilerInstance() override; |
194 | |
195 | |
196 | |
197 | |
198 | |
199 | |
200 | |
201 | |
202 | |
203 | |
204 | |
205 | |
206 | |
207 | |
208 | |
209 | |
210 | |
211 | |
212 | |
213 | |
214 | |
215 | |
216 | |
217 | |
218 | |
219 | |
220 | |
221 | |
222 | |
223 | |
224 | |
225 | |
226 | |
227 | |
228 | bool ExecuteAction(FrontendAction &Act); |
229 | |
230 | |
231 | |
232 | |
233 | |
234 | bool hasInvocation() const { return Invocation != nullptr; } |
235 | |
236 | CompilerInvocation &getInvocation() { |
237 | (0) . __assert_fail ("Invocation && \"Compiler instance has no invocation!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 237, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Invocation && "Compiler instance has no invocation!"); |
238 | return *Invocation; |
239 | } |
240 | |
241 | |
242 | void setInvocation(std::shared_ptr<CompilerInvocation> Value); |
243 | |
244 | |
245 | bool shouldBuildGlobalModuleIndex() const; |
246 | |
247 | |
248 | |
249 | void setBuildGlobalModuleIndex(bool Build) { |
250 | BuildGlobalModuleIndex = Build; |
251 | } |
252 | |
253 | |
254 | |
255 | |
256 | |
257 | AnalyzerOptionsRef getAnalyzerOpts() { |
258 | return Invocation->getAnalyzerOpts(); |
259 | } |
260 | |
261 | CodeGenOptions &getCodeGenOpts() { |
262 | return Invocation->getCodeGenOpts(); |
263 | } |
264 | const CodeGenOptions &getCodeGenOpts() const { |
265 | return Invocation->getCodeGenOpts(); |
266 | } |
267 | |
268 | DependencyOutputOptions &getDependencyOutputOpts() { |
269 | return Invocation->getDependencyOutputOpts(); |
270 | } |
271 | const DependencyOutputOptions &getDependencyOutputOpts() const { |
272 | return Invocation->getDependencyOutputOpts(); |
273 | } |
274 | |
275 | DiagnosticOptions &getDiagnosticOpts() { |
276 | return Invocation->getDiagnosticOpts(); |
277 | } |
278 | const DiagnosticOptions &getDiagnosticOpts() const { |
279 | return Invocation->getDiagnosticOpts(); |
280 | } |
281 | |
282 | FileSystemOptions &getFileSystemOpts() { |
283 | return Invocation->getFileSystemOpts(); |
284 | } |
285 | const FileSystemOptions &getFileSystemOpts() const { |
286 | return Invocation->getFileSystemOpts(); |
287 | } |
288 | |
289 | FrontendOptions &getFrontendOpts() { |
290 | return Invocation->getFrontendOpts(); |
291 | } |
292 | const FrontendOptions &getFrontendOpts() const { |
293 | return Invocation->getFrontendOpts(); |
294 | } |
295 | |
296 | HeaderSearchOptions &() { |
297 | return Invocation->getHeaderSearchOpts(); |
298 | } |
299 | const HeaderSearchOptions &() const { |
300 | return Invocation->getHeaderSearchOpts(); |
301 | } |
302 | std::shared_ptr<HeaderSearchOptions> () const { |
303 | return Invocation->getHeaderSearchOptsPtr(); |
304 | } |
305 | |
306 | LangOptions &getLangOpts() { |
307 | return *Invocation->getLangOpts(); |
308 | } |
309 | const LangOptions &getLangOpts() const { |
310 | return *Invocation->getLangOpts(); |
311 | } |
312 | |
313 | PreprocessorOptions &getPreprocessorOpts() { |
314 | return Invocation->getPreprocessorOpts(); |
315 | } |
316 | const PreprocessorOptions &getPreprocessorOpts() const { |
317 | return Invocation->getPreprocessorOpts(); |
318 | } |
319 | |
320 | PreprocessorOutputOptions &getPreprocessorOutputOpts() { |
321 | return Invocation->getPreprocessorOutputOpts(); |
322 | } |
323 | const PreprocessorOutputOptions &getPreprocessorOutputOpts() const { |
324 | return Invocation->getPreprocessorOutputOpts(); |
325 | } |
326 | |
327 | TargetOptions &getTargetOpts() { |
328 | return Invocation->getTargetOpts(); |
329 | } |
330 | const TargetOptions &getTargetOpts() const { |
331 | return Invocation->getTargetOpts(); |
332 | } |
333 | |
334 | |
335 | |
336 | |
337 | |
338 | bool hasDiagnostics() const { return Diagnostics != nullptr; } |
339 | |
340 | |
341 | DiagnosticsEngine &getDiagnostics() const { |
342 | (0) . __assert_fail ("Diagnostics && \"Compiler instance has no diagnostics!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 342, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Diagnostics && "Compiler instance has no diagnostics!"); |
343 | return *Diagnostics; |
344 | } |
345 | |
346 | |
347 | void setDiagnostics(DiagnosticsEngine *Value); |
348 | |
349 | DiagnosticConsumer &getDiagnosticClient() const { |
350 | (0) . __assert_fail ("Diagnostics && Diagnostics->getClient() && \"Compiler instance has no diagnostic client!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 351, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Diagnostics && Diagnostics->getClient() && |
351 | (0) . __assert_fail ("Diagnostics && Diagnostics->getClient() && \"Compiler instance has no diagnostic client!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 351, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "Compiler instance has no diagnostic client!"); |
352 | return *Diagnostics->getClient(); |
353 | } |
354 | |
355 | |
356 | |
357 | |
358 | |
359 | bool hasTarget() const { return Target != nullptr; } |
360 | |
361 | TargetInfo &getTarget() const { |
362 | (0) . __assert_fail ("Target && \"Compiler instance has no target!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 362, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Target && "Compiler instance has no target!"); |
363 | return *Target; |
364 | } |
365 | |
366 | |
367 | void setTarget(TargetInfo *Value); |
368 | |
369 | |
370 | |
371 | |
372 | |
373 | TargetInfo *getAuxTarget() const { return AuxTarget.get(); } |
374 | |
375 | |
376 | void setAuxTarget(TargetInfo *Value); |
377 | |
378 | |
379 | |
380 | |
381 | |
382 | llvm::vfs::FileSystem &getVirtualFileSystem() const { |
383 | return getFileManager().getVirtualFileSystem(); |
384 | } |
385 | |
386 | |
387 | |
388 | |
389 | |
390 | bool hasFileManager() const { return FileMgr != nullptr; } |
391 | |
392 | |
393 | FileManager &getFileManager() const { |
394 | (0) . __assert_fail ("FileMgr && \"Compiler instance has no file manager!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 394, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(FileMgr && "Compiler instance has no file manager!"); |
395 | return *FileMgr; |
396 | } |
397 | |
398 | void resetAndLeakFileManager() { |
399 | llvm::BuryPointer(FileMgr.get()); |
400 | FileMgr.resetWithoutRelease(); |
401 | } |
402 | |
403 | |
404 | void setFileManager(FileManager *Value); |
405 | |
406 | |
407 | |
408 | |
409 | |
410 | bool hasSourceManager() const { return SourceMgr != nullptr; } |
411 | |
412 | |
413 | SourceManager &getSourceManager() const { |
414 | (0) . __assert_fail ("SourceMgr && \"Compiler instance has no source manager!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 414, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(SourceMgr && "Compiler instance has no source manager!"); |
415 | return *SourceMgr; |
416 | } |
417 | |
418 | void resetAndLeakSourceManager() { |
419 | llvm::BuryPointer(SourceMgr.get()); |
420 | SourceMgr.resetWithoutRelease(); |
421 | } |
422 | |
423 | |
424 | void setSourceManager(SourceManager *Value); |
425 | |
426 | |
427 | |
428 | |
429 | |
430 | bool hasPreprocessor() const { return PP != nullptr; } |
431 | |
432 | |
433 | Preprocessor &getPreprocessor() const { |
434 | (0) . __assert_fail ("PP && \"Compiler instance has no preprocessor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 434, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(PP && "Compiler instance has no preprocessor!"); |
435 | return *PP; |
436 | } |
437 | |
438 | std::shared_ptr<Preprocessor> getPreprocessorPtr() { return PP; } |
439 | |
440 | void resetAndLeakPreprocessor() { |
441 | llvm::BuryPointer(new std::shared_ptr<Preprocessor>(PP)); |
442 | } |
443 | |
444 | |
445 | void setPreprocessor(std::shared_ptr<Preprocessor> Value); |
446 | |
447 | |
448 | |
449 | |
450 | |
451 | bool hasASTContext() const { return Context != nullptr; } |
452 | |
453 | ASTContext &getASTContext() const { |
454 | (0) . __assert_fail ("Context && \"Compiler instance has no AST context!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 454, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Context && "Compiler instance has no AST context!"); |
455 | return *Context; |
456 | } |
457 | |
458 | void resetAndLeakASTContext() { |
459 | llvm::BuryPointer(Context.get()); |
460 | Context.resetWithoutRelease(); |
461 | } |
462 | |
463 | |
464 | void setASTContext(ASTContext *Value); |
465 | |
466 | |
467 | |
468 | void setSema(Sema *S); |
469 | |
470 | |
471 | |
472 | |
473 | |
474 | bool hasASTConsumer() const { return (bool)Consumer; } |
475 | |
476 | ASTConsumer &getASTConsumer() const { |
477 | (0) . __assert_fail ("Consumer && \"Compiler instance has no AST consumer!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 477, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Consumer && "Compiler instance has no AST consumer!"); |
478 | return *Consumer; |
479 | } |
480 | |
481 | |
482 | |
483 | std::unique_ptr<ASTConsumer> takeASTConsumer() { return std::move(Consumer); } |
484 | |
485 | |
486 | |
487 | void setASTConsumer(std::unique_ptr<ASTConsumer> Value); |
488 | |
489 | |
490 | |
491 | |
492 | bool hasSema() const { return (bool)TheSema; } |
493 | |
494 | Sema &getSema() const { |
495 | (0) . __assert_fail ("TheSema && \"Compiler instance has no Sema object!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 495, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(TheSema && "Compiler instance has no Sema object!"); |
496 | return *TheSema; |
497 | } |
498 | |
499 | std::unique_ptr<Sema> takeSema(); |
500 | void resetAndLeakSema(); |
501 | |
502 | |
503 | |
504 | |
505 | |
506 | IntrusiveRefCntPtr<ASTReader> getModuleManager() const; |
507 | void setModuleManager(IntrusiveRefCntPtr<ASTReader> Reader); |
508 | |
509 | std::shared_ptr<ModuleDependencyCollector> getModuleDepCollector() const; |
510 | void setModuleDepCollector( |
511 | std::shared_ptr<ModuleDependencyCollector> Collector); |
512 | |
513 | std::shared_ptr<PCHContainerOperations> getPCHContainerOperations() const { |
514 | return ThePCHContainerOperations; |
515 | } |
516 | |
517 | |
518 | |
519 | const PCHContainerWriter &getPCHContainerWriter() const { |
520 | (0) . __assert_fail ("Invocation && \"cannot determine module format without invocation\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 520, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Invocation && "cannot determine module format without invocation"); |
521 | StringRef Format = getHeaderSearchOpts().ModuleFormat; |
522 | auto *Writer = ThePCHContainerOperations->getWriterOrNull(Format); |
523 | if (!Writer) { |
524 | if (Diagnostics) |
525 | Diagnostics->Report(diag::err_module_format_unhandled) << Format; |
526 | llvm::report_fatal_error("unknown module format"); |
527 | } |
528 | return *Writer; |
529 | } |
530 | |
531 | |
532 | |
533 | const PCHContainerReader &getPCHContainerReader() const { |
534 | (0) . __assert_fail ("Invocation && \"cannot determine module format without invocation\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 534, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Invocation && "cannot determine module format without invocation"); |
535 | StringRef Format = getHeaderSearchOpts().ModuleFormat; |
536 | auto *Reader = ThePCHContainerOperations->getReaderOrNull(Format); |
537 | if (!Reader) { |
538 | if (Diagnostics) |
539 | Diagnostics->Report(diag::err_module_format_unhandled) << Format; |
540 | llvm::report_fatal_error("unknown module format"); |
541 | } |
542 | return *Reader; |
543 | } |
544 | |
545 | |
546 | |
547 | |
548 | |
549 | bool hasCodeCompletionConsumer() const { return (bool)CompletionConsumer; } |
550 | |
551 | CodeCompleteConsumer &getCodeCompletionConsumer() const { |
552 | (0) . __assert_fail ("CompletionConsumer && \"Compiler instance has no code completion consumer!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 553, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(CompletionConsumer && |
553 | (0) . __assert_fail ("CompletionConsumer && \"Compiler instance has no code completion consumer!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 553, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "Compiler instance has no code completion consumer!"); |
554 | return *CompletionConsumer; |
555 | } |
556 | |
557 | |
558 | |
559 | void setCodeCompletionConsumer(CodeCompleteConsumer *Value); |
560 | |
561 | |
562 | |
563 | |
564 | |
565 | bool hasFrontendTimer() const { return (bool)FrontendTimer; } |
566 | |
567 | llvm::Timer &getFrontendTimer() const { |
568 | (0) . __assert_fail ("FrontendTimer && \"Compiler instance has no frontend timer!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Frontend/CompilerInstance.h", 568, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(FrontendTimer && "Compiler instance has no frontend timer!"); |
569 | return *FrontendTimer; |
570 | } |
571 | |
572 | |
573 | |
574 | |
575 | |
576 | |
577 | |
578 | |
579 | void addOutputFile(OutputFile &&OutFile); |
580 | |
581 | |
582 | |
583 | |
584 | |
585 | void clearOutputFiles(bool EraseFiles); |
586 | |
587 | |
588 | |
589 | |
590 | |
591 | |
592 | |
593 | |
594 | |
595 | |
596 | |
597 | |
598 | |
599 | |
600 | |
601 | |
602 | |
603 | void createDiagnostics(DiagnosticConsumer *Client = nullptr, |
604 | bool ShouldOwnClient = true); |
605 | |
606 | |
607 | |
608 | |
609 | |
610 | |
611 | |
612 | |
613 | |
614 | |
615 | |
616 | |
617 | |
618 | |
619 | |
620 | |
621 | |
622 | |
623 | |
624 | static IntrusiveRefCntPtr<DiagnosticsEngine> |
625 | createDiagnostics(DiagnosticOptions *Opts, |
626 | DiagnosticConsumer *Client = nullptr, |
627 | bool ShouldOwnClient = true, |
628 | const CodeGenOptions *CodeGenOpts = nullptr); |
629 | |
630 | |
631 | |
632 | |
633 | FileManager * |
634 | createFileManager(IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr); |
635 | |
636 | |
637 | void createSourceManager(FileManager &FileMgr); |
638 | |
639 | |
640 | |
641 | void createPreprocessor(TranslationUnitKind TUKind); |
642 | |
643 | std::string getSpecificModuleCachePath(); |
644 | |
645 | |
646 | void createASTContext(); |
647 | |
648 | |
649 | |
650 | void createPCHExternalASTSource(StringRef Path, bool DisablePCHValidation, |
651 | bool AllowPCHWithCompilerErrors, |
652 | void *DeserializationListener, |
653 | bool OwnDeserializationListener); |
654 | |
655 | |
656 | |
657 | |
658 | static IntrusiveRefCntPtr<ASTReader> createPCHExternalASTSource( |
659 | StringRef Path, StringRef Sysroot, bool DisablePCHValidation, |
660 | bool AllowPCHWithCompilerErrors, Preprocessor &PP, |
661 | InMemoryModuleCache &ModuleCache, ASTContext &Context, |
662 | const PCHContainerReader &PCHContainerRdr, |
663 | ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions, |
664 | DependencyFileGenerator *DependencyFile, |
665 | ArrayRef<std::shared_ptr<DependencyCollector>> DependencyCollectors, |
666 | void *DeserializationListener, bool OwnDeserializationListener, |
667 | bool Preamble, bool UseGlobalModuleIndex); |
668 | |
669 | |
670 | |
671 | |
672 | void createCodeCompletionConsumer(); |
673 | |
674 | |
675 | |
676 | static CodeCompleteConsumer *createCodeCompletionConsumer( |
677 | Preprocessor &PP, StringRef Filename, unsigned Line, unsigned Column, |
678 | const CodeCompleteOptions &Opts, raw_ostream &OS); |
679 | |
680 | |
681 | void createSema(TranslationUnitKind TUKind, |
682 | CodeCompleteConsumer *CompletionConsumer); |
683 | |
684 | |
685 | void createFrontendTimer(); |
686 | |
687 | |
688 | |
689 | |
690 | |
691 | |
692 | |
693 | |
694 | |
695 | std::unique_ptr<raw_pwrite_stream> |
696 | createDefaultOutputFile(bool Binary = true, StringRef BaseInput = "", |
697 | StringRef Extension = ""); |
698 | |
699 | |
700 | |
701 | |
702 | |
703 | std::unique_ptr<raw_pwrite_stream> |
704 | createOutputFile(StringRef OutputPath, bool Binary, bool RemoveFileOnSignal, |
705 | StringRef BaseInput, StringRef Extension, bool UseTemporary, |
706 | bool CreateMissingDirectories = false); |
707 | |
708 | |
709 | |
710 | |
711 | |
712 | |
713 | |
714 | |
715 | |
716 | |
717 | |
718 | |
719 | |
720 | |
721 | |
722 | |
723 | |
724 | |
725 | |
726 | |
727 | |
728 | |
729 | |
730 | |
731 | |
732 | |
733 | std::unique_ptr<raw_pwrite_stream> |
734 | createOutputFile(StringRef OutputPath, std::error_code &Error, bool Binary, |
735 | bool RemoveFileOnSignal, StringRef BaseInput, |
736 | StringRef Extension, bool UseTemporary, |
737 | bool CreateMissingDirectories, std::string *ResultPathName, |
738 | std::string *TempPathName); |
739 | |
740 | std::unique_ptr<raw_pwrite_stream> createNullOutputFile(); |
741 | |
742 | |
743 | |
744 | |
745 | |
746 | |
747 | |
748 | |
749 | |
750 | bool InitializeSourceManager(const FrontendInputFile &Input); |
751 | |
752 | |
753 | |
754 | |
755 | |
756 | static bool (const FrontendInputFile &Input, |
757 | DiagnosticsEngine &Diags, |
758 | FileManager &FileMgr, |
759 | SourceManager &SourceMgr, |
760 | HeaderSearch *HS, |
761 | DependencyOutputOptions &DepOpts, |
762 | const FrontendOptions &Opts); |
763 | |
764 | |
765 | |
766 | void setOutputStream(std::unique_ptr<llvm::raw_pwrite_stream> OutStream) { |
767 | OutputStream = std::move(OutStream); |
768 | } |
769 | |
770 | std::unique_ptr<llvm::raw_pwrite_stream> takeOutputStream() { |
771 | return std::move(OutputStream); |
772 | } |
773 | |
774 | |
775 | void createModuleManager(); |
776 | |
777 | bool loadModuleFile(StringRef FileName); |
778 | |
779 | ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, |
780 | Module::NameVisibilityKind Visibility, |
781 | bool IsInclusionDirective) override; |
782 | |
783 | void loadModuleFromSource(SourceLocation ImportLoc, StringRef ModuleName, |
784 | StringRef Source) override; |
785 | |
786 | void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, |
787 | SourceLocation ImportLoc) override; |
788 | |
789 | bool hadModuleLoaderFatalFailure() const { |
790 | return ModuleLoader::HadFatalFailure; |
791 | } |
792 | |
793 | GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override; |
794 | |
795 | bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override; |
796 | |
797 | void addDependencyCollector(std::shared_ptr<DependencyCollector> Listener) { |
798 | DependencyCollectors.push_back(std::move(Listener)); |
799 | } |
800 | |
801 | void setExternalSemaSource(IntrusiveRefCntPtr<ExternalSemaSource> ESS); |
802 | |
803 | InMemoryModuleCache &getModuleCache() const { return *ModuleCache; } |
804 | }; |
805 | |
806 | } |
807 | |
808 | #endif |
809 | |