File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,15 @@ class CommandOutput {
147
147
// / with the provided \p Input pair of Base and Primary inputs.
148
148
void addPrimaryOutput (CommandInputPair Input, StringRef PrimaryOutputFile);
149
149
150
+ // / Return true iff the set of additional output types in \c this is
151
+ // / identical to the set of additional output types in \p other.
152
+ bool hasSameAdditionalOutputTypes (CommandOutput const &other) const ;
153
+
154
+ // / Copy all the input pairs from \p other to \c this. Assumes (and asserts)
155
+ // / that \p other shares output file map and PrimaryOutputType with \c this
156
+ // / already, as well as AdditionalOutputTypes if \c this has any.
157
+ void addOutputs (CommandOutput const &other);
158
+
150
159
// / Assuming (and asserting) that there is only one input pair, return the
151
160
// / primary output file associated with it. Note that the returned StringRef
152
161
// / may be invalidated by subsequent mutations to the \c CommandOutput.
Original file line number Diff line number Diff line change @@ -52,6 +52,32 @@ void CommandOutput::ensureEntry(StringRef PrimaryInputFile,
52
52
}
53
53
}
54
54
55
+ bool CommandOutput::hasSameAdditionalOutputTypes (
56
+ CommandOutput const &other) const {
57
+ bool sameAdditionalOutputTypes = true ;
58
+ types::forAllTypes ([&](types::ID Type) {
59
+ bool a = AdditionalOutputTypes.count (Type) == 0 ;
60
+ bool b = other.AdditionalOutputTypes .count (Type) == 0 ;
61
+ if (a != b)
62
+ sameAdditionalOutputTypes = false ;
63
+ });
64
+ return sameAdditionalOutputTypes;
65
+ }
66
+
67
+ void CommandOutput::addOutputs (CommandOutput const &other) {
68
+ assert (PrimaryOutputType == other.PrimaryOutputType );
69
+ assert (&DerivedOutputMap == &other.DerivedOutputMap );
70
+ Inputs.append (other.Inputs .begin (),
71
+ other.Inputs .end ());
72
+ // Should only be called with an empty AdditionalOutputTypes
73
+ // or one populated with the same types as other.
74
+ if (AdditionalOutputTypes.empty ()) {
75
+ AdditionalOutputTypes = other.AdditionalOutputTypes ;
76
+ } else {
77
+ assert (hasSameAdditionalOutputTypes (other));
78
+ }
79
+ }
80
+
55
81
CommandOutput::CommandOutput (types::ID PrimaryOutputType,
56
82
OutputFileMap &Derived)
57
83
: PrimaryOutputType(PrimaryOutputType), DerivedOutputMap(Derived) {}
You can’t perform that action at this time.
0 commit comments