Skip to content

Commit 24cec30

Browse files
committed
Merge branch 'coverage-c-struct-constructor'
2 parents 0b4693d + a405755 commit 24cec30

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

lib/SIL/IR/SILDeclRef.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,14 @@ bool SILDeclRef::hasUserWrittenCode() const {
316316
// Never has user-written code, is just a forwarding initializer.
317317
return false;
318318
default:
319+
if (auto decl = getDecl()) {
320+
// Declarations synthesized by ClangImporter by definition don't have
321+
// user written code, but despite that they aren't always marked
322+
// implicit.
323+
auto moduleContext = decl->getDeclContext()->getModuleScopeContext();
324+
if (isa<ClangModuleUnit>(moduleContext))
325+
return false;
326+
}
319327
// TODO: This checking is currently conservative, we ought to
320328
// exhaustively handle all the cases here, and use emitOrDelayFunction
321329
// in more cases to take advantage of it.
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
// RUN: %target-swift-frontend -emit-ir -profile-generate -profile-coverage-mapping -Xcc -fprofile-instr-generate -Xcc -fcoverage-mapping -I %S/Inputs/issue-57483 %s | %FileCheck %s
1+
// 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
22

33
// https://github.com/apple/swift/issues/57483 (rdar://82820628)
4-
// Make sure we don't crash in IRGen attempting to emit the coverage map for the
5-
// implicit Clang getter for the member bitfield.
6-
7-
// CHECK: define {{.*}} @"$So7cstructV$member$getter"
4+
// Make sure we don't crash in IRGen attempting to emit the coverage map for any
5+
// implicit Clang decls.
86

97
import CModule
108

11-
func foo(_ x: UnsafePointer<cstruct>?) {
9+
func testStruct(_ x: UnsafePointer<cstruct>?) {
1210
_ = x?.pointee.member
11+
_ = cstruct()
12+
_ = cstruct(member: 5)
1313
}
14-
foo(nil)
14+
testStruct(nil)
15+
16+
// CHECK: define {{.*}} @"$So7cstructV$member$setter"
17+
// CHECK: define {{.*}} @"$So7cstructV$member$getter"

0 commit comments

Comments
 (0)