This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lib/Parse/ParseExpr.cpp | |
/// #function | |
/// #dsohandle | |
/// #dogcow | |
NO CHANGES TO SNAKE CASE DEPRECATION: | |
``` | |
case tok::kw___FILE__: | |
case tok::kw___LINE__: | |
case tok::kw___COLUMN__: | |
case tok::kw___FUNCTION__: | |
case tok::kw___DSO_HANDLE__: { | |
StringRef replacement = ""; | |
switch (Tok.getKind()) { | |
default: llvm_unreachable("can't get here"); | |
case tok::kw___FILE__: replacement = "#file"; break; | |
case tok::kw___LINE__: replacement = "#line"; break; | |
case tok::kw___COLUMN__: replacement = "#column"; break; | |
case tok::kw___FUNCTION__: replacement = "#function"; break; | |
case tok::kw___DSO_HANDLE__: replacement = "#dsohandle"; break; | |
} | |
``` | |
case tok::pound_dogcow: | |
return MagicIdentifierLiteralExpr::Kind::DogCow; | |
case tok::pound_dsohandle: | |
case tok::pound_dogcow: { | |
case tok::pound_dogcow: SKind = SyntaxKind::PoundDogCowExpr; break; | |
default: break; | |
--- | |
lib/Parse/ParseExpr.cpp: case tok::pound_file: | |
lib/Parse/ParseExpr.cpp: case tok::pound_file: | |
lib/Parse/ParseExpr.cpp: case tok::pound_file: SKind = SyntaxKind::PoundFileExpr; break; | |
lib/Parse/ParseExpr.cpp: case tok::pound_file: SKind = SyntaxKind::PoundFileExpr; break; | |
lib/Parse/ParseExpr.cpp:/// MagicIdentifierLiteralExpr kind. | |
lib/Parse/ParseExpr.cpp:static MagicIdentifierLiteralExpr::Kind | |
lib/Parse/ParseExpr.cpp: return MagicIdentifierLiteralExpr::Kind::Column; | |
lib/Parse/ParseExpr.cpp: return MagicIdentifierLiteralExpr::Kind::File; | |
lib/Parse/ParseExpr.cpp: return MagicIdentifierLiteralExpr::Kind::Function; | |
lib/Parse/ParseExpr.cpp: return MagicIdentifierLiteralExpr::Kind::Line; | |
lib/Parse/ParseExpr.cpp: return MagicIdentifierLiteralExpr::Kind::DSOHandle; | |
lib/Parse/ParseExpr.cpp: return makeParserResult(new (Context) MagicIdentifierLiteralExpr( | |
--- | |
lib/Parse/ParsePattern.cpp | |
case MagicIdentifierLiteralExpr::DSOHandle: | |
return DefaultArgumentKind::DSOHandle; | |
case MagicIdentifierLiteralExpr::DogCow: | |
return DefaultArgumentKind::DogCow; | |
--- | |
lib/Parse/ParsePattern.cpp: auto magic = dyn_cast<MagicIdentifierLiteralExpr>(init); | |
lib/Parse/ParsePattern.cpp: case MagicIdentifierLiteralExpr::Column: | |
lib/Parse/ParsePattern.cpp: case MagicIdentifierLiteralExpr::File: | |
lib/Parse/ParsePattern.cpp: case MagicIdentifierLiteralExpr::Line: | |
lib/Parse/ParsePattern.cpp: case MagicIdentifierLiteralExpr::Function: | |
lib/Parse/ParsePattern.cpp: case MagicIdentifierLiteralExpr::DSOHandle: | |
lib/Parse/ParsePattern.cpp: llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch."); | |
--- | |
lib/Sema/CSApply.cpp | |
case MagicIdentifierLiteralExpr::File: | |
case MagicIdentifierLiteralExpr::Function: | |
case MagicIdentifierLiteralExpr::DogCow: | |
return handleStringLiteralExpr(expr); | |
case DefaultArgumentKind::File: | |
init = new (tc.Context) MagicIdentifierLiteralExpr( | |
MagicIdentifierLiteralExpr::File, loc, | |
/*implicit=*/true); | |
break; | |
case DefaultArgumentKind::DogCow: | |
init = new (tc.Context) MagicIdentifierLiteralExpr( | |
MagicIdentifierLiteralExpr::DogCow, loc, | |
/*implicit=*/true); | |
break; | |
--- | |
lib/Sema/CSApply.cpp: auto magicLiteral = dyn_cast<MagicIdentifierLiteralExpr>(expr); | |
lib/Sema/CSApply.cpp: Expr *visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *expr) { | |
lib/Sema/CSApply.cpp: case MagicIdentifierLiteralExpr::File: | |
lib/Sema/CSApply.cpp: case MagicIdentifierLiteralExpr::Function: | |
lib/Sema/CSApply.cpp: case MagicIdentifierLiteralExpr::Line: | |
lib/Sema/CSApply.cpp: case MagicIdentifierLiteralExpr::Column: | |
lib/Sema/CSApply.cpp: case MagicIdentifierLiteralExpr::DSOHandle: | |
lib/Sema/CSApply.cpp: llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch."); | |
lib/Sema/CSApply.cpp: init = new (tc.Context) MagicIdentifierLiteralExpr( | |
lib/Sema/CSApply.cpp: MagicIdentifierLiteralExpr::Column, loc, | |
lib/Sema/CSApply.cpp: init = new (tc.Context) MagicIdentifierLiteralExpr( | |
lib/Sema/CSApply.cpp: MagicIdentifierLiteralExpr::File, loc, | |
lib/Sema/CSApply.cpp: init = new (tc.Context) MagicIdentifierLiteralExpr( | |
lib/Sema/CSApply.cpp: MagicIdentifierLiteralExpr::Line, loc, | |
lib/Sema/CSApply.cpp: init = new (tc.Context) MagicIdentifierLiteralExpr( | |
lib/Sema/CSApply.cpp: MagicIdentifierLiteralExpr::Function, loc, | |
lib/Sema/CSApply.cpp: init = new (tc.Context) MagicIdentifierLiteralExpr( | |
lib/Sema/CSApply.cpp: MagicIdentifierLiteralExpr::DSOHandle, loc, | |
lib/Sema/CSApply.cpp: cast<MagicIdentifierLiteralExpr>(literal) | |
lib/Sema/CSApply.cpp: cast<MagicIdentifierLiteralExpr>(literal)->setInitializer(ref); | |
--- | |
lib/Sema/CSGen.cpp | |
case MagicIdentifierLiteralExpr::Function: | |
case MagicIdentifierLiteralExpr::Line: | |
case MagicIdentifierLiteralExpr::DogCow: | |
return visitLiteralExpr(expr); | |
--- | |
lib/Sema/CSGen.cpp: Type visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *expr) { | |
lib/Sema/CSGen.cpp: case MagicIdentifierLiteralExpr::Column: | |
lib/Sema/CSGen.cpp: case MagicIdentifierLiteralExpr::File: | |
lib/Sema/CSGen.cpp: case MagicIdentifierLiteralExpr::Function: | |
lib/Sema/CSGen.cpp: case MagicIdentifierLiteralExpr::Line: | |
lib/Sema/CSGen.cpp: case MagicIdentifierLiteralExpr::DSOHandle: { | |
lib/Sema/CSGen.cpp: llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch."); | |
--- | |
lib/Sema/TypeChecker.cpp | |
case MagicIdentifierLiteralExpr::File: | |
case MagicIdentifierLiteralExpr::Function: | |
case MagicIdentifierLiteralExpr::DogCow: | |
return getProtocol(expr->getLoc(), | |
KnownProtocolKind::ExpressibleByStringLiteral); | |
--- | |
lib/Sema/TypeChecker.cpp: if (auto E = dyn_cast<MagicIdentifierLiteralExpr>(expr)) { | |
lib/Sema/TypeChecker.cpp: case MagicIdentifierLiteralExpr::File: | |
lib/Sema/TypeChecker.cpp: case MagicIdentifierLiteralExpr::Function: | |
lib/Sema/TypeChecker.cpp: case MagicIdentifierLiteralExpr::Line: | |
lib/Sema/TypeChecker.cpp: case MagicIdentifierLiteralExpr::Column: | |
lib/Sema/TypeChecker.cpp: case MagicIdentifierLiteralExpr::DSOHandle: | |
--- | |
lib/Serialization/Deserialization.cpp | |
case serialization::DefaultArgumentKind::DSOHandle: | |
return swift::DefaultArgumentKind::DSOHandle; | |
case serialization::DefaultArgumentKind::DogCow: | |
return swift::DefaultArgumentKind::DogCow; | |
--- | |
lib/Serialization/Deserialization.cpp: case serialization::DefaultArgumentKind::DSOHandle: | |
lib/Serialization/Deserialization.cpp: return swift::DefaultArgumentKind::DSOHandle; | |
--- | |
lib/Serialization/Serialization.cpp | |
CASE(Function) | |
CASE(DSOHandle) | |
CASE(DogCow) | |
--- | |
lib/Serialization/Serialization.cpp: CASE(DSOHandle) | |
--- | |
lib/SILGen/SILGen.cpp | |
case DefaultArgumentKind::Function: | |
case DefaultArgumentKind::DSOHandle: | |
case DefaultArgumentKind::DogCow: | |
--- | |
lib/SILGen/SILGen.cpp: case DefaultArgumentKind::DSOHandle: | |
--- | |
lib/Sema/TypeCheckStmt.cpp | |
case MagicIdentifierLiteralExpr::Kind::DSOHandle: return "#dsohandle"; | |
case MagicIdentifierLiteralExpr::Kind::DogCow: return "#dogcow"; | |
--- | |
lib/Sema/TypeCheckStmt.cpp: switch (cast<MagicIdentifierLiteralExpr>(LE)->getKind()) { | |
lib/Sema/TypeCheckStmt.cpp: case MagicIdentifierLiteralExpr::Kind::File: return "#file"; | |
lib/Sema/TypeCheckStmt.cpp: case MagicIdentifierLiteralExpr::Kind::Line: return "#line"; | |
lib/Sema/TypeCheckStmt.cpp: case MagicIdentifierLiteralExpr::Kind::Column: return "#column"; | |
lib/Sema/TypeCheckStmt.cpp: case MagicIdentifierLiteralExpr::Kind::Function: return "#function"; | |
lib/Sema/TypeCheckStmt.cpp: case MagicIdentifierLiteralExpr::Kind::DSOHandle: return "#dsohandle"; | |
--- | |
lib/SILGen/SILGenApply.cpp | |
case MagicIdentifierLiteralExpr::Function: { | |
StringRef value = ""; | |
if (loc.isValid()) | |
value = getMagicFunctionString(*this); | |
builtinLiteralArgs = emitStringLiteral(*this, literal, value, C, | |
magicLiteral->getStringEncoding()); | |
builtinInit = magicLiteral->getBuiltinInitializer(); | |
init = magicLiteral->getInitializer(); | |
break; | |
} | |
case MagicIdentifierLiteralExpr::DogCow: { | |
StringRef value = "🐶🐮"; | |
builtinLiteralArgs = emitStringLiteral(*this, literal, value, C, magicLiteral->getStringEncoding()); | |
builtinInit = magicLiteral->getBuiltinInitializer(); | |
init = magicLiteral->getInitializer(); | |
break; | |
} | |
### | |
35: error: expected ';' at end of declaration | |
StringRef value = "🐶🐮" | |
7: error: use of undeclared identifier 'builtinLiteraArgs'; did you mean 'builtinLiteralArgs'? | |
builtinLiteraArgs = emitStringLiteral(*this, literal, value, C, magicLiteral->getStringEncoding()); | |
^~~~~~~~~~~~~~~~~ | |
builtinLiteralArgs | |
### | |
### | |
--- | |
lib/SILGen/SILGenApply.cpp: auto magicLiteral = cast<MagicIdentifierLiteralExpr>(literal); | |
lib/SILGen/SILGenApply.cpp: case MagicIdentifierLiteralExpr::File: { | |
lib/SILGen/SILGenApply.cpp: case MagicIdentifierLiteralExpr::Function: { | |
lib/SILGen/SILGenApply.cpp: case MagicIdentifierLiteralExpr::Line: | |
lib/SILGen/SILGenApply.cpp: case MagicIdentifierLiteralExpr::Column: | |
lib/SILGen/SILGenApply.cpp: case MagicIdentifierLiteralExpr::DSOHandle: | |
--- | |
lib/SILGen/SILGenExpr.cpp | |
case MagicIdentifierLiteralExpr::File: | |
case MagicIdentifierLiteralExpr::Function: | |
case MagicIdentifierLiteralExpr::DogCow: | |
return SGF.emitLiteral(E, C); | |
--- | |
lib/SILGen/SILGenExpr.cpp: RValue visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E, | |
lib/SILGen/SILGenExpr.cpp:visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E, SGFContext C) { | |
lib/SILGen/SILGenExpr.cpp: case MagicIdentifierLiteralExpr::File: | |
lib/SILGen/SILGenExpr.cpp: case MagicIdentifierLiteralExpr::Function: | |
lib/SILGen/SILGenExpr.cpp: case MagicIdentifierLiteralExpr::Line: { | |
lib/SILGen/SILGenExpr.cpp: case MagicIdentifierLiteralExpr::Column: { | |
lib/SILGen/SILGenExpr.cpp: case MagicIdentifierLiteralExpr::DSOHandle: { | |
lib/SILGen/SILGenExpr.cpp: llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch."); | |
lib/SILGen/SILGenExpr.cpp: case MagicIdentifierLiteralExpr::DSOHandle: { | |
lib/SILGen/SILGenExpr.cpp: auto DSOGlobal = SGF.SGM.M.lookUpGlobalVariable("__dso_handle"); | |
lib/SILGen/SILGenExpr.cpp: if (!DSOGlobal) | |
lib/SILGen/SILGenExpr.cpp: DSOGlobal = SILGlobalVariable::create(SGF.SGM.M, | |
lib/SILGen/SILGenExpr.cpp: IsNotSerialized, "__dso_handle", | |
lib/SILGen/SILGenExpr.cpp: auto DSOAddr = SGF.B.createGlobalAddr(SILLoc, DSOGlobal); | |
lib/SILGen/SILGenExpr.cpp: auto DSOPointer = SGF.B.createAddressToPointer(SILLoc, DSOAddr, | |
lib/SILGen/SILGenExpr.cpp: { DSOPointer }); | |
--- | |
test/Syntax/Outputs/round_trip_parse_gen.swift.withkinds | |
FunctionCallArgument>)</ObjectLiteralExpr><PoundColumnExpr> | |
#column</PoundColumnExpr><PoundFileExpr> | |
#file</PoundFileExpr><PoundFunctionExpr> | |
#function</PoundFunctionExpr><PoundDsohandleExpr> | |
#dsohandle</PoundDsohandleExpr><PoundDogCowExpr> | |
#dogcow</PoundDogCowExpr> | |
}</CodeBlock></FunctionDecl><EnumDecl> | |
--- | |
test/Syntax/Outputs/round_trip_parse_gen.swift.withkinds: #column</PoundColumnExpr><PoundFileExpr> | |
test/Syntax/Outputs/round_trip_parse_gen.swift.withkinds: #file</PoundFileExpr><PoundFunctionExpr> | |
--- | |
utils/gyb_syntax_support/ExprNodes.py | |
# A #dsohandle expression. | |
Node('PoundDsohandleExpr', kind='Expr', | |
children=[ | |
Child('PoundDsohandle', kind='PoundDsohandleToken'), | |
]), | |
# A #dogcow expression. | |
Node('PoundDogCowExpr', kind='Expr', | |
children=[ | |
Child('PoundDogCow', kind='PoundDogcowToken'), | |
]), | |
--- | |
utils/gyb_syntax_support/ExprNodes.py: Node('PoundFileExpr', kind='Expr', | |
utils/gyb_syntax_support/ExprNodes.py: Child('PoundFile', kind='PoundFileToken'), | |
utils/gyb_syntax_support/ExprNodes.py: 'PoundFileLiteralToken', | |
Binary file utils/gyb_syntax_support/ExprNodes.pyc matches | |
utils/gyb_syntax_support/ExprNodes.py: # A #dsohandle expression. | |
utils/gyb_syntax_support/ExprNodes.py: Node('PoundDsohandleExpr', kind='Expr', | |
utils/gyb_syntax_support/ExprNodes.py: Child('PoundDsohandle', kind='PoundDsohandleToken'), | |
--- | |
utils/gyb_syntax_support/Token.py | |
Token('PoundDsohandle', 'pound_dsohandle', text='#dsohandle', | |
is_keyword=True), | |
Token('PoundDogCow', 'pound_dogcow', text='#dogcow', | |
is_keyword=True), | |
--- | |
utils/gyb_syntax_support/Token.py: Keyword('__DSO_HANDLE__', '__DSO_HANDLE__'), | |
utils/gyb_syntax_support/Token.py: Token('PoundSourceLocation', 'pound_sourceLocation', | |
utils/gyb_syntax_support/Token.py: Token('PoundDsohandle', 'pound_dsohandle', text='#dsohandle', | |
utils/gyb_syntax_support/Token.py: Token('PoundFile', 'pound_file', text='#file', | |
utils/gyb_syntax_support/Token.py: Token('PoundFileLiteral', 'pound_fileLiteral', text='#fileLiteral', | |
Binary file utils/gyb_syntax_support/Token.pyc matches | |
utils/gyb_syntax_support/Token.py: Token('PoundFile', 'pound_file', text='#file', | |
utils/gyb_syntax_support/Token.py: Token('PoundFileLiteral', 'pound_fileLiteral', text='#fileLiteral', | |
Binary file utils/gyb_syntax_support/Token.pyc matches | |
--- | |
lib/IDE/CodeCompletion.cpp | |
AddKeyword("#dsohandle", "UnsafeMutableRawPointer", CodeCompletionKeywordKind::pound_dsohandle); | |
AddKeyword("#dogcow", "String", CodeCompletionKeywordKind::pound_dogcow); | |
--- | |
lib/IDE/CodeCompletion.cpp: AddKeyword("#file", "String", CodeCompletionKeywordKind::pound_file); | |
--- | |
lib/AST/ASTPrinter.cpp | |
case DefaultArgumentKind::Function: | |
case DefaultArgumentKind::DSOHandle: | |
case DefaultArgumentKind::DogCow: | |
Printer.printKeyword(defaultArgStr); | |
--- | |
lib/AST/ASTPrinter.cpp: case DefaultArgumentKind::DSOHandle: | |
--- | |
lib/AST/ASTDumper.cpp | |
case DefaultArgumentKind::DogCow: return "#dogcow"; | |
case DefaultArgumentKind::DSOHandle: return "#dsohandle"; | |
case MagicIdentifierLiteralExpr::Column: return "#column"; | |
case MagicIdentifierLiteralExpr::DogCow: return "#dogcow"; | |
case MagicIdentifierLiteralExpr::DSOHandle: return "#dsohandle"; | |
--- | |
lib/AST/ASTDumper.cpp:getMagicIdentifierLiteralExprKindString(MagicIdentifierLiteralExpr::Kind value) { | |
lib/AST/ASTDumper.cpp: case MagicIdentifierLiteralExpr::File: return "#file"; | |
lib/AST/ASTDumper.cpp: case MagicIdentifierLiteralExpr::Function: return "#function"; | |
lib/AST/ASTDumper.cpp: case MagicIdentifierLiteralExpr::Line: return "#line"; | |
lib/AST/ASTDumper.cpp: case MagicIdentifierLiteralExpr::Column: return "#column"; | |
lib/AST/ASTDumper.cpp: case MagicIdentifierLiteralExpr::DSOHandle: return "#dsohandle"; | |
lib/AST/ASTDumper.cpp: llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch."); | |
lib/AST/ASTDumper.cpp: void visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E) { | |
lib/AST/ASTDumper.cpp: << " kind=" << getMagicIdentifierLiteralExprKindString(E->getKind()); | |
--- | |
include/swift/AST/Decl.h | |
/// The #function default argument, which is expanded at the call site. | |
Function, | |
/// The #dogcow default argument, which is expanded at the call site. | |
DogCow, | |
--- | |
% open include/swift/AST/Decl.h | |
% open include/swift/AST/DefaultArgumentKind.h | |
See error | |
### | |
/Users/ericasadun/github/Apple/appleswift/swift/lib/AST/ASTDumper.cpp:281:31: error: no member named 'DogCow' in 'swift::DefaultArgumentKind' | |
### | |
10:45 - hardest bug to date because both .h and .cpp seem to have it there. compiling again. Adding to include/swift/Syntax/TokenKinds.def | |
--- | |
include/swift/Syntax/TokenKinds.def | |
POUND_KEYWORD(function) | |
POUND_KEYWORD(dsohandle) | |
POUND_KEYWORD(dogcow) | |
--- | |
include/swift/Syntax/TokenKinds.def:KEYWORD(__DSO_HANDLE__) | |
include/swift/Syntax/TokenKinds.def:POUND_KEYWORD(dsohandle) | |
### | |
/Users/ericasadun/github/Apple/appleswift/swift/lib/IDE/CodeCompletion.cpp:4920:62: error: no member named 'pound_dogcow' in 'swift::ide::CodeCompletionKeywordKind' | |
AddKeyword("#dogcow", "String", CodeCompletionKeywordKind::pound_dogcow); | |
### | |
10:57: Looking through a search for dso for other sites | |
--- | |
lib/AST/DefaultArgumentKind.cpp | |
case DefaultArgumentKind::Column: return "#column"; | |
case DefaultArgumentKind::Function: return "#function"; | |
case DefaultArgumentKind::DogCow: return "#dogcow"; | |
case DefaultArgumentKind::DSOHandle: return "#dsohandle"; | |
--- | |
### | |
/Users/ericasadun/github/Apple/appleswift/swift/lib/AST/DefaultArgumentKind.cpp:23:11: error: enumeration value 'DogCow' not handled in switch [-Werror,-Wswitch] | |
switch (kind) { | |
^ | |
/Users/ericasadun/github/Apple/appleswift/swift/lib/AST/DefaultArgumentKind.cpp:23:11: note: add missing switch cases | |
switch (kind) { | |
### | |
--- | |
lib/IDE/CodeCompletion.cpp | |
case DefaultArgumentKind::Function: | |
case DefaultArgumentKind::DSOHandle: | |
case DefaultArgumentKind::DogCow: | |
AddKeyword("#dsohandle", "UnsafeMutableRawPointer", CodeCompletionKeywordKind::pound_dsohandle); | |
AddKeyword("#dogcow", "String", CodeCompletionKeywordKind::pound_dogcow); | |
--- | |
### | |
/Users/ericasadun/github/Apple/appleswift/swift/lib/IDE/CodeCompletion.cpp:2239:35: error: enumeration value 'DogCow' not handled in switch [-Werror,-Wswitch] | |
switch (BodyParams->get(i)->getDefaultArgumentKind()) { | |
^ | |
/Users/ericasadun/github/Apple/appleswift/swift/lib/IDE/CodeCompletion.cpp:2239:35: note: add missing switch cases | |
switch (BodyParams->get(i)->getDefaultArgumentKind()) { | |
^ | |
/Users/ericasadun/github/Apple/appleswift/swift/lib/IDE/CodeCompletion.cpp:4919:62: error: no member named 'pound_dogcow' in 'swift::ide::CodeCompletionKeywordKind' | |
AddKeyword("#dogcow", "String", CodeCompletionKeywordKind::pound_dogcow); | |
### | |
Note: CodeCompletionKeywordKind from | |
% grep -R "class CodeCompletionKeywordKind" * | |
include/swift/IDE/CodeCompletion.h:enum class CodeCompletionKeywordKind { | |
enum class CodeCompletionKeywordKind { | |
None, | |
#define KEYWORD(X) kw_##X, | |
#define POUND_KEYWORD(X) pound_##X, | |
#include "swift/Syntax/TokenKinds.def" | |
}; | |
--- | |
include/swift/Serialization/ModuleFormat.h | |
enum class DefaultArgumentKind : uint8_t { | |
None = 0, | |
Normal, | |
File, | |
Line, | |
Column, | |
Function, | |
DogCow, | |
--- | |
include/swift/Serialization/ModuleFormat.h: DSOHandle, | |
--- | |
include/swift/AST/Expr.h | |
class MagicIdentifierLiteralExpr : public LiteralExpr { | |
public: | |
enum Kind : unsigned { | |
File, Line, Column, Function, DSOHandle, DogCow | |
}; | |
bool isString() const { | |
switch (getKind()) { | |
case File: | |
case Function: | |
case DogCow: // it's a string! | |
return true; | |
case Line: | |
case Column: | |
case DSOHandle: | |
return false; | |
} | |
llvm_unreachable("bad Kind"); | |
} | |
### | |
This was actually a stupid mistake and an actual bug. It took forever to track down. Notice I have DogCow returning true here. I accidentally swapped the two lines so it was originally returning false, falling into the Line/Column/DSOHandle case. | |
Although Swift compiled, it failed at runtime because of the type mismatch in code like this: | |
``` | |
// String interpolation and default argument | |
func hello(x: String = #dogcow) { | |
print("Hello \(x)") | |
} | |
``` | |
Ouch. | |
For the longest time I was convinced (wrongly) that because I was using Unicode, that I had somehow screwed up the string encoding. | |
### | |
--- | |
include/swift/AST/Expr.h: SWIFT_INLINE_BITFIELD(MagicIdentifierLiteralExpr, LiteralExpr, 3+1, | |
include/swift/AST/Expr.h:/// MagicIdentifierLiteralExpr - A magic identifier like #file which expands | |
include/swift/AST/Expr.h:class MagicIdentifierLiteralExpr : public LiteralExpr { | |
include/swift/AST/Expr.h: MagicIdentifierLiteralExpr(Kind kind, SourceLoc loc, bool implicit = false) | |
include/swift/AST/Expr.h: Bits.MagicIdentifierLiteralExpr.Kind = static_cast<unsigned>(kind); | |
include/swift/AST/Expr.h: Bits.MagicIdentifierLiteralExpr.StringEncoding | |
include/swift/AST/Expr.h: return static_cast<Kind>(Bits.MagicIdentifierLiteralExpr.Kind); | |
include/swift/AST/Expr.h: Bits.MagicIdentifierLiteralExpr.StringEncoding); | |
include/swift/AST/Expr.h: Bits.MagicIdentifierLiteralExpr.StringEncoding | |
--- | |
lib/AST/Expr.cpp | |
NO CHANGES | |
--- | |
lib/AST/Expr.cpp:shallowCloneImpl(const MagicIdentifierLiteralExpr *E, ASTContext &Ctx, | |
lib/AST/Expr.cpp: auto res = new (Ctx) MagicIdentifierLiteralExpr(E->getKind(), | |
--- | |
--- | |
--- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment