|
14 | 14 | //
|
15 | 15 | //===----------------------------------------------------------------------===//
|
16 | 16 | #include "swift/ClangImporter/ClangImporter.h"
|
17 |
| -#include "swift/ClangImporter/ClangModule.h" |
| 17 | +#include "ClangDiagnosticConsumer.h" |
18 | 18 | #include "IAMInference.h"
|
19 | 19 | #include "ImporterImpl.h"
|
20 |
| -#include "ClangDiagnosticConsumer.h" |
21 |
| -#include "swift/Subsystems.h" |
22 | 20 | #include "swift/AST/ASTContext.h"
|
23 | 21 | #include "swift/AST/DiagnosticEngine.h"
|
24 | 22 | #include "swift/AST/DiagnosticsClangImporter.h"
|
|
34 | 32 | #include "swift/Basic/Version.h"
|
35 | 33 | #include "swift/ClangImporter/ClangImporterOptions.h"
|
36 | 34 | #include "swift/Demangling/Demangle.h"
|
| 35 | +#include "swift/ClangImporter/ClangModule.h" |
| 36 | +#include "swift/Config.h" |
37 | 37 | #include "swift/Parse/Lexer.h"
|
38 | 38 | #include "swift/Parse/Parser.h"
|
39 |
| -#include "swift/Config.h" |
| 39 | +#include "swift/Subsystems.h" |
40 | 40 | #include "clang/AST/ASTContext.h"
|
41 | 41 | #include "clang/AST/Mangle.h"
|
42 | 42 | #include "clang/Basic/CharInfo.h"
|
|
48 | 48 | #include "clang/Frontend/FrontendActions.h"
|
49 | 49 | #include "clang/Frontend/Utils.h"
|
50 | 50 | #include "clang/Index/IndexingAction.h"
|
51 |
| -#include "clang/Serialization/ASTReader.h" |
52 |
| -#include "clang/Serialization/ASTWriter.h" |
53 | 51 | #include "clang/Lex/Preprocessor.h"
|
54 | 52 | #include "clang/Lex/PreprocessorOptions.h"
|
55 | 53 | #include "clang/Parse/Parser.h"
|
56 | 54 | #include "clang/Rewrite/Frontend/FrontendActions.h"
|
57 | 55 | #include "clang/Rewrite/Frontend/Rewriters.h"
|
58 | 56 | #include "clang/Sema/Lookup.h"
|
59 | 57 | #include "clang/Sema/Sema.h"
|
| 58 | +#include "clang/Serialization/ASTReader.h" |
| 59 | +#include "clang/Serialization/ASTWriter.h" |
60 | 60 | #include "llvm/ADT/STLExtras.h"
|
61 | 61 | #include "llvm/ADT/StringExtras.h"
|
62 | 62 | #include "llvm/Support/CrashRecoveryContext.h"
|
| 63 | +#include "llvm/Support/FileCollector.h" |
63 | 64 | #include "llvm/Support/Memory.h"
|
64 | 65 | #include "llvm/Support/Path.h"
|
65 | 66 | #include <algorithm>
|
@@ -320,11 +321,13 @@ class BridgingPPTracker : public clang::PPCallbacks {
|
320 | 321 | class ClangImporterDependencyCollector : public clang::DependencyCollector
|
321 | 322 | {
|
322 | 323 | llvm::StringSet<> ExcludedPaths;
|
| 324 | + std::shared_ptr<llvm::FileCollector> FileCollector; |
323 | 325 | const bool TrackSystemDeps;
|
324 | 326 |
|
325 | 327 | public:
|
326 |
| - ClangImporterDependencyCollector(bool TrackSystemDeps) |
327 |
| - : TrackSystemDeps(TrackSystemDeps) {} |
| 328 | + ClangImporterDependencyCollector( |
| 329 | + bool TrackSystemDeps, std::shared_ptr<llvm::FileCollector> FileCollector) |
| 330 | + : FileCollector(FileCollector), TrackSystemDeps(TrackSystemDeps) {} |
328 | 331 |
|
329 | 332 | void excludePath(StringRef filename) {
|
330 | 333 | ExcludedPaths.insert(filename);
|
@@ -353,13 +356,22 @@ class ClangImporterDependencyCollector : public clang::DependencyCollector
|
353 | 356 | return false;
|
354 | 357 | return true;
|
355 | 358 | }
|
| 359 | + |
| 360 | + void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem, |
| 361 | + bool IsModuleFile, bool IsMissing) override { |
| 362 | + if (FileCollector) |
| 363 | + FileCollector->addFile(Filename); |
| 364 | + clang::DependencyCollector::maybeAddDependency( |
| 365 | + Filename, FromModule, IsSystem, IsModuleFile, IsMissing); |
| 366 | + } |
356 | 367 | };
|
357 | 368 | } // end anonymous namespace
|
358 | 369 |
|
359 | 370 | std::shared_ptr<clang::DependencyCollector>
|
360 |
| -ClangImporter::createDependencyCollector(bool TrackSystemDeps) |
361 |
| -{ |
362 |
| - return std::make_shared<ClangImporterDependencyCollector>(TrackSystemDeps); |
| 371 | +ClangImporter::createDependencyCollector( |
| 372 | + bool TrackSystemDeps, std::shared_ptr<llvm::FileCollector> FileCollector) { |
| 373 | + return std::make_shared<ClangImporterDependencyCollector>(TrackSystemDeps, |
| 374 | + FileCollector); |
363 | 375 | }
|
364 | 376 |
|
365 | 377 | void ClangImporter::Implementation::addBridgeHeaderTopLevelDecls(
|
|
0 commit comments