Skip to content

Commit 448d9df

Browse files
author
David Ungar
authored
Merge pull request #28444 from davidungar/WIP-custom-diff
Fix memory violation when build record is bad.
2 parents 84c7b63 + 08cfe80 commit 448d9df

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

include/swift/Driver/Compilation.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ using CommandSet = llvm::SmallPtrSet<const Job *, 16>;
7979
class Compilation {
8080
public:
8181
class IncrementalSchemeComparator {
82+
const bool EnableIncrementalBuildWhenConstructed;
8283
const bool &EnableIncrementalBuild;
8384
const bool EnableSourceRangeDependencies;
8485
const bool &UseSourceRangeDependencies;
@@ -108,7 +109,8 @@ class Compilation {
108109
const StringRef CompareIncrementalSchemesPath,
109110
unsigned SwiftInputCount,
110111
DiagnosticEngine &Diags)
111-
: EnableIncrementalBuild(EnableIncrementalBuild),
112+
: EnableIncrementalBuildWhenConstructed(EnableIncrementalBuild),
113+
EnableIncrementalBuild(EnableIncrementalBuild),
112114
EnableSourceRangeDependencies(EnableSourceRangeDependencies),
113115
UseSourceRangeDependencies(UseSourceRangeDependencies),
114116
CompareIncrementalSchemesPath(CompareIncrementalSchemesPath),

lib/Driver/Compilation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,6 +2025,10 @@ void Compilation::IncrementalSchemeComparator::outputComparison() const {
20252025

20262026
void Compilation::IncrementalSchemeComparator::outputComparison(
20272027
llvm::raw_ostream &out) const {
2028+
if (!EnableIncrementalBuildWhenConstructed) {
2029+
out << "*** Incremental build was not enabled in the command line ***\n";
2030+
return;
2031+
}
20282032
if (!EnableIncrementalBuild) {
20292033
// No stats will have been gathered
20302034
assert(!WhyIncrementalWasDisabled.empty() && "Must be a reason");

lib/Driver/Driver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static bool getCompilationRecordPath(std::string &buildRecordPath,
375375
return false;
376376
}
377377

378-
static StringRef failedToReadOutOfDateMap(bool ShowIncrementalBuildDecisions,
378+
static std::string failedToReadOutOfDateMap(bool ShowIncrementalBuildDecisions,
379379
StringRef buildRecordPath,
380380
StringRef reason = "") {
381381
std::string why = "malformed build record file";
@@ -398,7 +398,7 @@ static void dealWithRemovedInputs(ArrayRef<StringRef> removedInputs,
398398
bool ShowIncrementalBuildDecisions);
399399

400400
/// Returns why ignore incrementality
401-
static StringRef
401+
static std::string
402402
populateOutOfDateMap(InputInfoMap &map, llvm::sys::TimePoint<> &LastBuildTime,
403403
StringRef argsHashStr, const InputFileList &inputs,
404404
StringRef buildRecordPath,
@@ -893,7 +893,7 @@ Driver::buildCompilation(const ToolChain &TC,
893893
computeArgsHash(ArgsHash, *TranslatedArgList);
894894
llvm::sys::TimePoint<> LastBuildTime = llvm::sys::TimePoint<>::min();
895895
InputInfoMap outOfDateMap;
896-
StringRef whyIgnoreIncrementallity =
896+
std::string whyIgnoreIncrementallity =
897897
!Incremental
898898
? ""
899899
: buildRecordPath.empty()
@@ -1027,7 +1027,7 @@ Driver::buildCompilation(const ToolChain &TC,
10271027
// This has to happen after building jobs, because otherwise we won't even
10281028
// emit .swiftdeps files for the next build.
10291029
if (!whyIgnoreIncrementallity.empty())
1030-
C->disableIncrementalBuild(whyIgnoreIncrementallity.str());
1030+
C->disableIncrementalBuild(whyIgnoreIncrementallity);
10311031

10321032
if (Diags.hadAnyError())
10331033
return nullptr;

0 commit comments

Comments
 (0)