Skip to content

Commit e1139a6

Browse files
author
Mingsheng Hong
committed
Added a test for SIL parsing/printing round-tripping, and fixed a bug.
1 parent ba38bcb commit e1139a6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/ParseSIL/ParseSIL.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,6 +2380,10 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
23802380
// Drop the double quotes.
23812381
StringRef rawString = P.Tok.getText().drop_front().drop_back();
23822382

2383+
P.consumeToken(tok::string_literal);
2384+
if (parseSILDebugLocation(InstLoc, B))
2385+
return true;
2386+
23832387
// Ask the lexer to interpret the entire string as a literal segment.
23842388
SmallVector<char, 128> stringBuffer;
23852389

@@ -2407,9 +2411,6 @@ bool SILParser::parseSILInstruction(SILBuilder &B) {
24072411
}
24082412

24092413
StringRef string = P.L->getEncodedStringSegment(rawString, stringBuffer);
2410-
P.consumeToken(tok::string_literal);
2411-
if (parseSILDebugLocation(InstLoc, B))
2412-
return true;
24132414
ResultVal = B.createStringLiteral(InstLoc, string, encoding);
24142415
break;
24152416
}

test/SIL/Serialization/literals.sil

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ bb0:
1414
%2 = const_string_literal utf8 "\u{0B}"
1515
// CHECK: const_string_literal utf16 "\u{0B}"
1616
%3 = const_string_literal utf16 "\u{0B}"
17+
// CHECK: string_literal bytes "ABCD"
18+
%4 = string_literal bytes "ABCD"
1719
%6 = tuple ()
1820
return %6 : $()
1921
}

0 commit comments

Comments
 (0)