18
18
#define SWIFT_SIL_PARSETESTSPECIFICATION
19
19
20
20
#include " swift/Basic/TaggedUnion.h"
21
+ #include " swift/SIL/SILInstruction.h"
21
22
#include " swift/SIL/SILValue.h"
22
23
#include " llvm/ADT/StringRef.h"
23
24
@@ -140,7 +141,13 @@ struct Arguments {
140
141
return cast<UIntArgument>(takeArgument ()).getValue ();
141
142
}
142
143
SILValue takeValue () {
143
- return cast<ValueArgument>(takeArgument ()).getValue ();
144
+ auto argument = takeArgument ();
145
+ if (isa<InstructionArgument>(argument)) {
146
+ auto *instruction = cast<InstructionArgument>(argument).getValue ();
147
+ auto *svi = cast<SingleValueInstruction>(instruction);
148
+ return svi;
149
+ }
150
+ return cast<ValueArgument>(argument).getValue ();
144
151
}
145
152
Operand *takeOperand () {
146
153
return cast<OperandArgument>(takeArgument ()).getValue ();
@@ -156,17 +163,32 @@ struct Arguments {
156
163
}
157
164
};
158
165
166
+ // / The specification for a test which has not yet been parsed.
167
+ struct UnparsedSpecification {
168
+ // / The string which specifies the test.
169
+ // /
170
+ // / Not a StringRef because the TestSpecificationInst whose payload is of
171
+ // / interest gets deleted.
172
+ std::string string;
173
+ // / The next non-debug instruction.
174
+ // /
175
+ // / Provides an "anchor" for the specification. Contextual arguments
176
+ // / (@instruction, @block, @function) can be parsed in terms of this anchor.
177
+ SILInstruction *context;
178
+ };
179
+
159
180
// / Finds and deletes each test_specification instruction in \p function and
160
181
// / appends its string payload to the provided vector.
161
- void getTestSpecifications (SILFunction *function,
162
- SmallVectorImpl<std::string> &specifications);
182
+ void getTestSpecifications (
183
+ SILFunction *function,
184
+ SmallVectorImpl<UnparsedSpecification> &specifications);
163
185
164
186
// / Given the string \p specification operand of a test_specification
165
187
// / instruction from \p function, parse the arguments which it refers to into
166
188
// / \p arguments and the component strings into \p argumentStrings.
167
189
void parseTestArgumentsFromSpecification (
168
- SILFunction *function, StringRef specification, Arguments &arguments ,
169
- SmallVectorImpl<StringRef> &argumentStrings);
190
+ SILFunction *function, UnparsedSpecification const &specification ,
191
+ Arguments &arguments, SmallVectorImpl<StringRef> &argumentStrings);
170
192
171
193
} // namespace test
172
194
} // namespace swift
0 commit comments