Skip to content

Commit 0102c52

Browse files
committed
Remove OutputFileMap's Knowledge of Range Dependencies
1 parent 1c93feb commit 0102c52

File tree

4 files changed

+14
-44
lines changed

4 files changed

+14
-44
lines changed

include/swift/Basic/OutputFileMap.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ class OutputFileMap {
4646
/// Loads an OutputFileMap from the given \p Path into the receiver, if
4747
/// possible.
4848
static llvm::Expected<OutputFileMap>
49-
loadFromPath(StringRef Path, StringRef workingDirectory,
50-
bool addEntriesForSourceRangeDependencies);
49+
loadFromPath(StringRef Path, StringRef workingDirector);
5150

5251
static llvm::Expected<OutputFileMap>
53-
loadFromBuffer(StringRef Data, StringRef workingDirectory,
54-
bool addEntriesForSourceRangeDependencies);
52+
loadFromBuffer(StringRef Data, StringRef workingDirectory);
5553

5654
/// Loads an OutputFileMap from the given \p Buffer, taking ownership
5755
/// of the buffer in the process.
@@ -60,8 +58,7 @@ class OutputFileMap {
6058
/// the output file map.
6159
static llvm::Expected<OutputFileMap>
6260
loadFromBuffer(std::unique_ptr<llvm::MemoryBuffer> Buffer,
63-
StringRef workingDirectory,
64-
bool addEntriesForSourceRangeDependencies);
61+
StringRef workingDirectory);
6562

6663
/// Get the map of outputs for the given \p Input, if present in the
6764
/// OutputFileMap. (If not present, returns nullptr.)
@@ -90,8 +87,7 @@ class OutputFileMap {
9087
/// Parses the given \p Buffer and returns either an OutputFileMap or
9188
/// error, taking ownership of \p Buffer in the process.
9289
static llvm::Expected<OutputFileMap>
93-
parse(std::unique_ptr<llvm::MemoryBuffer> Buffer, StringRef workingDirectory,
94-
bool addEntriesForSourceRangeDependencies);
90+
parse(std::unique_ptr<llvm::MemoryBuffer> Buffer, StringRef workingDirectory);
9591
};
9692

9793
} // end namespace swift

lib/Basic/OutputFileMap.cpp

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,26 @@
2121
using namespace swift;
2222

2323
llvm::Expected<OutputFileMap>
24-
OutputFileMap::loadFromPath(StringRef Path, StringRef workingDirectory,
25-
const bool addEntriesForSourceRangeDependencies) {
24+
OutputFileMap::loadFromPath(StringRef Path, StringRef workingDirectory) {
2625
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
2726
llvm::MemoryBuffer::getFile(Path);
2827
if (!FileBufOrErr) {
2928
return llvm::errorCodeToError(FileBufOrErr.getError());
3029
}
31-
return loadFromBuffer(std::move(FileBufOrErr.get()), workingDirectory,
32-
addEntriesForSourceRangeDependencies);
30+
return loadFromBuffer(std::move(FileBufOrErr.get()), workingDirectory);
3331
}
3432

3533
llvm::Expected<OutputFileMap>
36-
OutputFileMap::loadFromBuffer(StringRef Data, StringRef workingDirectory,
37-
bool addEntriesForSourceRangeDependencies) {
34+
OutputFileMap::loadFromBuffer(StringRef Data, StringRef workingDirectory) {
3835
std::unique_ptr<llvm::MemoryBuffer> Buffer{
3936
llvm::MemoryBuffer::getMemBuffer(Data)};
40-
return loadFromBuffer(std::move(Buffer), workingDirectory,
41-
addEntriesForSourceRangeDependencies);
37+
return loadFromBuffer(std::move(Buffer), workingDirectory);
4238
}
4339

4440
llvm::Expected<OutputFileMap>
4541
OutputFileMap::loadFromBuffer(std::unique_ptr<llvm::MemoryBuffer> Buffer,
46-
StringRef workingDirectory,
47-
bool addEntriesForSourceRangeDependencies) {
48-
return parse(std::move(Buffer), workingDirectory,
49-
addEntriesForSourceRangeDependencies);
42+
StringRef workingDirectory) {
43+
return parse(std::move(Buffer), workingDirectory);
5044
}
5145

5246
const TypeToPathMap *OutputFileMap::getOutputMapForInput(StringRef Input) const{
@@ -143,8 +137,7 @@ void OutputFileMap::write(llvm::raw_ostream &os,
143137

144138
llvm::Expected<OutputFileMap>
145139
OutputFileMap::parse(std::unique_ptr<llvm::MemoryBuffer> Buffer,
146-
StringRef workingDirectory,
147-
const bool addEntriesForSourceRangeDependencies) {
140+
StringRef workingDirectory) {
148141
auto constructError =
149142
[](const char *errorString) -> llvm::Expected<OutputFileMap> {
150143
return llvm::make_error<llvm::StringError>(errorString,
@@ -233,25 +226,6 @@ OutputFileMap::parse(std::unique_ptr<llvm::MemoryBuffer> Buffer,
233226
llvm::SmallString<128> PathStorage;
234227
OutputMap.insert(std::pair<file_types::ID, std::string>(
235228
Kind, resolvePath(Path, PathStorage).str()));
236-
237-
// HACK: fake up an SwiftRanges & CompiledSource output filenames
238-
if (addEntriesForSourceRangeDependencies &&
239-
Kind == file_types::TY_SwiftDeps) {
240-
// Not for the master-swiftdeps
241-
llvm::SmallString<128> Storage;
242-
if (!InputPath->getValue(Storage).empty()) {
243-
std::string baseName = OutputMap[Kind];
244-
baseName.resize(baseName.size() -
245-
getExtension(file_types::TY_SwiftDeps).size());
246-
auto insertFilename = [&](file_types::ID type) {
247-
std::string s = baseName;
248-
s += getExtension(type);
249-
OutputMap.insert({type, s});
250-
};
251-
insertFilename(file_types::TY_SwiftRanges);
252-
insertFilename(file_types::TY_CompiledSource);
253-
}
254-
}
255229
}
256230

257231
llvm::SmallString<128> InputStorage;

lib/Driver/Compilation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ namespace driver {
686686
// might have been blocked.
687687
markFinished(FinishedCmd);
688688

689-
noteBuildingJobs(DependentsInEffect, useRangesForScheduling,
689+
noteBuildingJobs(DependentsInEffect,
690690
"because of dependencies discovered later");
691691

692692
scheduleCommandsInSortedOrder(DependentsInEffect);
@@ -875,7 +875,7 @@ namespace driver {
875875
/// Figure out the best strategy and return those jobs. May return
876876
/// duplicates.
877877
CommandSet computeFirstRoundCompileJobsForIncrementalCompilation() {
878-
return computeDependenciesAndGetNeededCompileJobs(/*useRanges=*/false);
878+
return computeDependenciesAndGetNeededCompileJobs();
879879
}
880880

881881
/// Return jobs to run if using dependencies, may include duplicates.

lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,7 @@ Driver::buildOutputFileMap(const llvm::opt::DerivedArgList &Args,
23562356

23572357
// TODO: perform some preflight checks to ensure the file exists.
23582358
llvm::Expected<OutputFileMap> OFM = OutputFileMap::loadFromPath(
2359-
A->getValue(), workingDirectory, addEntriesForSourceFileDependencies);
2359+
A->getValue(), workingDirectory);
23602360
if (auto Err = OFM.takeError()) {
23612361
Diags.diagnose(SourceLoc(), diag::error_unable_to_load_output_file_map,
23622362
llvm::toString(std::move(Err)), A->getValue());

0 commit comments

Comments
 (0)