Skip to content

Commit aa46954

Browse files
committed
ParseTestSpecification: handle multi-line strings
We need this for specifications that involve multiple components and long instruction lists.
1 parent 747d8a3 commit aa46954

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3638,7 +3638,9 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
36383638
return true;
36393639
}
36403640
// Drop the double quotes.
3641-
auto ArgumentsSpecification = P.Tok.getText().drop_front().drop_back();
3641+
unsigned numQuotes = P.Tok.isMultilineString() ? 4 : 1;
3642+
auto ArgumentsSpecification =
3643+
P.Tok.getText().drop_front(numQuotes).drop_back(numQuotes).trim();
36423644
P.consumeToken(tok::string_literal);
36433645
ResultVal = B.createTestSpecificationInst(InstLoc, ArgumentsSpecification);
36443646
break;

lib/SILOptimizer/UtilityPasses/ParseTestSpecification.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,10 @@ class ParseTestSpecification {
568568
specificationString.split(components, " ");
569569
for (unsigned long index = 0, size = components.size(); index < size;
570570
++index) {
571-
auto componentString = components[index];
571+
auto componentString = components[index].trim();
572+
if (componentString.empty())
573+
continue;
574+
572575
ParseArgumentSpecification parser(*this, componentString,
573576
specification.context);
574577
auto argument = parser.parse();

lib/SILOptimizer/UtilityPasses/UnitTestRunner.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ class UnitTestRunner : public SILFunctionTransform {
124124
<< name << " with: ";
125125
for (unsigned long index = 0, size = components.size(); index < size;
126126
++index) {
127-
llvm::errs() << components[index];
127+
auto componentString = components[index].trim();
128+
if (componentString.empty())
129+
continue;
130+
131+
llvm::errs() << componentString;
128132
if (index != size - 1) {
129133
llvm::errs() << ", ";
130134
}

0 commit comments

Comments
 (0)