Skip to content

Commit d29dcf8

Browse files
committed
[NFC] Upgrade CompileJobAction::InputInfo::Status to an enum class
1 parent 83f5162 commit d29dcf8

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

include/swift/Driver/Action.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,28 @@ class JobAction : public Action {
130130
class IncrementalJobAction : public JobAction {
131131
public:
132132
struct InputInfo {
133-
enum Status {
133+
/// The status of an input known to the driver. These are used to affect
134+
/// the scheduling decisions made during an incremental build.
135+
///
136+
/// \Note The order of cases matters. They are ordered from least to
137+
/// greatest impact on the incremental build schedule.
138+
enum class Status {
139+
/// The input to this job is up to date.
134140
UpToDate,
141+
/// The input to this job has changed in a way that requires this job to
142+
/// be rerun, but not in such a way that it requires a cascading rebuild.
135143
NeedsNonCascadingBuild,
144+
/// The input to this job has changed in a way that requires this job to
145+
/// be rerun, and in such a way that all jobs dependent upon this one
146+
/// must be scheduled as well.
136147
NeedsCascadingBuild,
148+
/// The input to this job was not known to the driver when it was last
149+
/// run.
137150
NewlyAdded
138151
};
139152

140153
public:
141-
Status status = UpToDate;
154+
Status status = Status::UpToDate;
142155
llvm::sys::TimePoint<> previousModTime;
143156

144157
InputInfo() = default;

lib/Driver/Compilation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,8 +1608,8 @@ namespace driver {
16081608
CompileJobAction::InputInfo info;
16091609
info.previousModTime = entry.first->getInputModTime();
16101610
info.status = entry.second ?
1611-
CompileJobAction::InputInfo::NeedsCascadingBuild :
1612-
CompileJobAction::InputInfo::NeedsNonCascadingBuild;
1611+
CompileJobAction::InputInfo::Status::NeedsCascadingBuild :
1612+
CompileJobAction::InputInfo::Status::NeedsNonCascadingBuild;
16131613
inputs[&inputFile->getInputArg()] = info;
16141614
}
16151615
}
@@ -1626,7 +1626,7 @@ namespace driver {
16261626

16271627
CompileJobAction::InputInfo info;
16281628
info.previousModTime = entry->getInputModTime();
1629-
info.status = CompileJobAction::InputInfo::UpToDate;
1629+
info.status = CompileJobAction::InputInfo::Status::UpToDate;
16301630
inputs[&inputFile->getInputArg()] = info;
16311631
}
16321632
}

lib/Driver/Driver.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,6 +2755,7 @@ static void
27552755
handleCompileJobCondition(Job *J, CompileJobAction::InputInfo inputInfo,
27562756
StringRef input, bool alwaysRebuildDependents) {
27572757
if (inputInfo.status == CompileJobAction::InputInfo::NewlyAdded) {
2758+
using InputStatus = CompileJobAction::InputInfo::Status;
27582759
J->setCondition(Job::Condition::NewlyAdded);
27592760
return;
27602761
}
@@ -2769,24 +2770,24 @@ handleCompileJobCondition(Job *J, CompileJobAction::InputInfo inputInfo,
27692770
Job::Condition condition;
27702771
if (hasValidModTime && J->getInputModTime() == inputInfo.previousModTime) {
27712772
switch (inputInfo.status) {
2772-
case CompileJobAction::InputInfo::UpToDate:
2773-
if (llvm::sys::fs::exists(J->getOutput().getPrimaryOutputFilename()))
2773+
case InputStatus::UpToDate:
2774+
if (llvm::sys::fs::exists(output))
27742775
condition = Job::Condition::CheckDependencies;
27752776
else
27762777
condition = Job::Condition::RunWithoutCascading;
27772778
break;
2778-
case CompileJobAction::InputInfo::NeedsCascadingBuild:
2779+
case InputStatus::NeedsCascadingBuild:
27792780
condition = Job::Condition::Always;
27802781
break;
2781-
case CompileJobAction::InputInfo::NeedsNonCascadingBuild:
2782+
case InputStatus::NeedsNonCascadingBuild:
27822783
condition = Job::Condition::RunWithoutCascading;
27832784
break;
2784-
case CompileJobAction::InputInfo::NewlyAdded:
2785+
case InputStatus::NewlyAdded:
27852786
llvm_unreachable("handled above");
27862787
}
27872788
} else {
27882789
if (alwaysRebuildDependents ||
2789-
inputInfo.status == CompileJobAction::InputInfo::NeedsCascadingBuild) {
2790+
inputInfo.status == InputStatus::NeedsCascadingBuild) {
27902791
condition = Job::Condition::Always;
27912792
} else {
27922793
condition = Job::Condition::RunWithoutCascading;

0 commit comments

Comments
 (0)