mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Use file IDs in generated code
Such as force unwraps, as! casts, etc.
This commit is contained in:
@@ -144,8 +144,7 @@ auto SILGenFunction::emitSourceLocationArgs(SourceLoc sourceLoc,
|
|||||||
unsigned line = 0;
|
unsigned line = 0;
|
||||||
unsigned column = 0;
|
unsigned column = 0;
|
||||||
if (sourceLoc.isValid()) {
|
if (sourceLoc.isValid()) {
|
||||||
// FIXME: Should be getMagicFileIDString()
|
filename = getMagicFileIDString(sourceLoc);
|
||||||
filename = getMagicFilePathString(sourceLoc);
|
|
||||||
std::tie(line, column) =
|
std::tie(line, column) =
|
||||||
ctx.SourceMgr.getPresumedLineAndColumnForLoc(sourceLoc);
|
ctx.SourceMgr.getPresumedLineAndColumnForLoc(sourceLoc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ synthesizeStubBody(AbstractFunctionDecl *fn, void *) {
|
|||||||
initName->setBuiltinInitializer(staticStringInit);
|
initName->setBuiltinInitializer(staticStringInit);
|
||||||
|
|
||||||
auto *file = new (ctx) MagicIdentifierLiteralExpr(
|
auto *file = new (ctx) MagicIdentifierLiteralExpr(
|
||||||
MagicIdentifierLiteralExpr::File, loc, /*Implicit=*/true);
|
MagicIdentifierLiteralExpr::FileID, loc, /*Implicit=*/true);
|
||||||
file->setType(staticStringType);
|
file->setType(staticStringType);
|
||||||
file->setBuiltinInitializer(staticStringInit);
|
file->setBuiltinInitializer(staticStringInit);
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,13 @@ func indirectUse() {
|
|||||||
func forceUnwrap(_ x: ()?) {
|
func forceUnwrap(_ x: ()?) {
|
||||||
// BOTH-LABEL: sil {{.*}} @$s3Foo11forceUnwrapyyytSgF
|
// BOTH-LABEL: sil {{.*}} @$s3Foo11forceUnwrapyyytSgF
|
||||||
_ = x!
|
_ = x!
|
||||||
// ABSOLUTE: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_file.swift"
|
// BOTH: string_literal utf8 "Foo/magic_identifier_file.swift"
|
||||||
// CONCISE: string_literal utf8 "Foo/magic_identifier_file.swift"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func forceTry(_ fn: () throws -> ()) {
|
func forceTry(_ fn: () throws -> ()) {
|
||||||
// BOTH-LABEL: sil {{.*}} @$s3Foo8forceTryyyyyKXEF
|
// BOTH-LABEL: sil {{.*}} @$s3Foo8forceTryyyyyKXEF
|
||||||
try! fn()
|
try! fn()
|
||||||
// ABSOLUTE: string_literal utf8 "SOURCE_DIR/test/SILGen/magic_identifier_file.swift"
|
// BOTH: string_literal utf8 "Foo/magic_identifier_file.swift"
|
||||||
// CONCISE: string_literal utf8 "Foo/magic_identifier_file.swift"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CONCISE-LABEL: // Mappings from '#fileID' to '#filePath':
|
// CONCISE-LABEL: // Mappings from '#fileID' to '#filePath':
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ func crash_on_dealloc(_ dict : [Int : [Int]] = [:]) {
|
|||||||
func use_unwrapped(_: Int) {}
|
func use_unwrapped(_: Int) {}
|
||||||
|
|
||||||
// CHECK-LABEL: sil hidden [ossa] @$s8optional15explicit_unwrap{{[_0-9a-zA-Z]*}}F
|
// CHECK-LABEL: sil hidden [ossa] @$s8optional15explicit_unwrap{{[_0-9a-zA-Z]*}}F
|
||||||
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "{{.*}}optional.swift"
|
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "optional/optional.swift"
|
||||||
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
|
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
|
||||||
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
|
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
|
||||||
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word,
|
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word,
|
||||||
@@ -118,7 +118,7 @@ func explicit_unwrap(_ value: Int?) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CHECK-LABEL: sil hidden [ossa] @$s8optional19explicit_iuo_unwrap{{[_0-9a-zA-Z]*}}F
|
// CHECK-LABEL: sil hidden [ossa] @$s8optional19explicit_iuo_unwrap{{[_0-9a-zA-Z]*}}F
|
||||||
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "{{.*}}optional.swift"
|
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "optional/optional.swift"
|
||||||
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
|
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
|
||||||
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
|
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
|
||||||
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word,
|
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word,
|
||||||
@@ -131,7 +131,7 @@ func explicit_iuo_unwrap(_ value: Int!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CHECK-LABEL: sil hidden [ossa] @$s8optional19implicit_iuo_unwrap{{[_0-9a-zA-Z]*}}F
|
// CHECK-LABEL: sil hidden [ossa] @$s8optional19implicit_iuo_unwrap{{[_0-9a-zA-Z]*}}F
|
||||||
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "{{.*}}optional.swift"
|
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "optional/optional.swift"
|
||||||
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
|
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
|
||||||
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
|
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
|
||||||
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word,
|
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word,
|
||||||
@@ -144,7 +144,7 @@ func implicit_iuo_unwrap(_ value: Int!) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CHECK-LABEL: sil hidden [ossa] @$s8optional34implicit_iuo_unwrap_sourceLocation{{[_0-9a-zA-Z]*}}F
|
// CHECK-LABEL: sil hidden [ossa] @$s8optional34implicit_iuo_unwrap_sourceLocation{{[_0-9a-zA-Z]*}}F
|
||||||
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "custom.swuft"
|
// CHECK: [[FILESTR:%.*]] = string_literal utf8 "optional/custom.swuft"
|
||||||
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
|
// CHECK-NEXT: [[FILESIZ:%.*]] = integer_literal $Builtin.Word,
|
||||||
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
|
// CHECK-NEXT: [[FILEASC:%.*]] = integer_literal $Builtin.Int1,
|
||||||
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word, 2000
|
// CHECK-NEXT: [[LINE:%.*]] = integer_literal $Builtin.Word, 2000
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ ErrorTests.test("try!/location")
|
|||||||
.skip(.custom({ _isFastAssertConfiguration() },
|
.skip(.custom({ _isFastAssertConfiguration() },
|
||||||
reason: "trap is not guaranteed to happen in -Ounchecked"))
|
reason: "trap is not guaranteed to happen in -Ounchecked"))
|
||||||
.crashOutputMatches(_isDebugAssertConfiguration()
|
.crashOutputMatches(_isDebugAssertConfiguration()
|
||||||
? "test/stdlib/Error.swift, line 128"
|
? "main/Error.swift, line 128"
|
||||||
: "")
|
: "")
|
||||||
.code {
|
.code {
|
||||||
expectCrashLater()
|
expectCrashLater()
|
||||||
|
|||||||
Reference in New Issue
Block a user