forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModuleLoader.cpp
55 lines (48 loc) · 2.04 KB
/
ModuleLoader.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//===--- ModuleLoader.cpp - Swift Language Module Implementation ----------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file implements the ModuleLoader class and/or any helpers.
//
//===----------------------------------------------------------------------===//
#include "swift/AST/ModuleLoader.h"
#include "clang/Frontend/Utils.h"
#include "swift/ClangImporter/ClangImporter.h"
namespace swift {
DependencyTracker::DependencyTracker()
// NB: The ClangImporter believes it's responsible for the construction of
// this instance, and it static_cast<>s the instance pointer to its own
// subclass based on that belief. If you change this to be some other
// instance, you will need to change ClangImporter's code to handle the
// difference.
: clangCollector(ClangImporter::createDependencyCollector())
{
}
void
DependencyTracker::addDependency(StringRef File, bool IsSystem) {
// DependencyTracker exposes an interface that (intentionally) does not talk
// about clang at all, nor about missing deps. It does expose an IsSystem
// dimension, though it is presently always false, we accept it and pass it
// along to the clang DependencyCollector in case Swift callers start setting
// it to true someday.
clangCollector->maybeAddDependency(File, /*FromModule=*/false,
IsSystem, /*IsModuleFile=*/false,
/*IsMissing=*/false);
}
ArrayRef<std::string>
DependencyTracker::getDependencies() const {
return clangCollector->getDependencies();
}
std::shared_ptr<clang::DependencyCollector>
DependencyTracker::getClangCollector() {
return clangCollector;
}
} // namespace swift