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