Files
swift-mirror/test/Profiler/coverage_clang_decls.swift
Allan Shortlidge a4057551ad SILGen: Avoid attempting to profile any ClangImporter synthesized function.
ClangImporter synthesized declarations inherently do not have user written
code. Unfortunately, despite that they are not always marked implicit as they
should be. This was causing a crash when attempting to generate profile
coverage maps for synthesized constructors for imported structs.

I tried marking the constructors implicit, but that had too many knock-on
effects in tests. This more targeted fix unblocks compatibility suite testing
without trying to grapple with the implications of that more fundamental fix.

Resolves rdar://139486938.
2024-11-11 16:28:02 -08:00

18 lines
607 B
Swift

// RUN: %target-swift-frontend -emit-ir -profile-generate -profile-coverage-mapping -Xcc -fprofile-instr-generate -Xcc -fcoverage-mapping -I %S/Inputs/CModule %s | %FileCheck %s
// https://github.com/apple/swift/issues/57483 (rdar://82820628)
// Make sure we don't crash in IRGen attempting to emit the coverage map for any
// implicit Clang decls.
import CModule
func testStruct(_ x: UnsafePointer<cstruct>?) {
_ = x?.pointee.member
_ = cstruct()
_ = cstruct(member: 5)
}
testStruct(nil)
// CHECK: define {{.*}} @"$So7cstructV$member$setter"
// CHECK: define {{.*}} @"$So7cstructV$member$getter"