Skip to content

Commit a680768

Browse files
committed
SIL: In textual SIL allow global SIL names starting with '$'.
For example: @$S1m3fooyyF It's needed to change the mangling prefix to $S. The parser change only affects SIL (and not swift). I didn't add test case because it will be fully tested when changing the mangling prefix.
1 parent fbea78a commit a680768

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/Parse/Lexer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,9 @@ void Lexer::lexDollarIdent() {
852852
const char *tokStart = CurPtr-1;
853853
assert(*tokStart == '$');
854854

855-
// In a SIL function body, '$' is a token by itself.
856-
if (InSILBody)
855+
// In a SIL function body, '$' is a token by itself, except it's a SIL global
856+
// name. SIL global identifiers may start with a '$', e.g. @$S1m3fooyyF.
857+
if (InSILBody && NextToken.getKind() != tok::at_sign)
857858
return formToken(tok::sil_dollar, tokStart);
858859

859860
bool isAllDigits = true;
@@ -881,7 +882,7 @@ void Lexer::lexDollarIdent() {
881882

882883
// We reserve $nonNumeric for persistent bindings in the debugger.
883884
if (!isAllDigits) {
884-
if (!LangOpts.EnableDollarIdentifiers)
885+
if (!LangOpts.EnableDollarIdentifiers && !InSILBody)
885886
diagnose(tokStart, diag::expected_dollar_numeric);
886887

887888
// Even if we diagnose, we go ahead and form an identifier token,

lib/ParseSIL/ParseSIL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ bool SILParser::parseSILIdentifier(Identifier &Result, SourceLoc &Loc,
433433
const Diagnostic &D) {
434434
switch (P.Tok.getKind()) {
435435
case tok::identifier:
436+
case tok::dollarident:
436437
Result = P.Context.getIdentifier(P.Tok.getText());
437438
break;
438439
case tok::string_literal: {

0 commit comments

Comments
 (0)