Skip to content

Commit fa3c951

Browse files
authored
Merge pull request #61203 from hamishknight/pop-and-loc
2 parents 5e65c5e + 0431bb2 commit fa3c951

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

lib/ClangImporter/SwiftDeclSynthesizer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ std::pair<FuncDecl *, FuncDecl *> SwiftDeclSynthesizer::makeBitFieldAccessors(
981981
Ctx, structDecl->getDeclContext(), clang::SourceLocation(),
982982
clang::SourceLocation(), cGetterName, cGetterType, cGetterTypeInfo,
983983
clang::SC_Static);
984+
cGetterDecl->setImplicit();
984985
cGetterDecl->setImplicitlyInline();
985986
assert(!cGetterDecl->isExternallyVisible());
986987

@@ -1002,6 +1003,7 @@ std::pair<FuncDecl *, FuncDecl *> SwiftDeclSynthesizer::makeBitFieldAccessors(
10021003
Ctx, structDecl->getDeclContext(), clang::SourceLocation(),
10031004
clang::SourceLocation(), cSetterName, cSetterType, cSetterTypeInfo,
10041005
clang::SC_Static);
1006+
cSetterDecl->setImplicit();
10051007
cSetterDecl->setImplicitlyInline();
10061008
assert(!cSetterDecl->isExternallyVisible());
10071009

@@ -1017,6 +1019,7 @@ std::pair<FuncDecl *, FuncDecl *> SwiftDeclSynthesizer::makeBitFieldAccessors(
10171019
auto cGetterSelf = clang::ParmVarDecl::Create(
10181020
Ctx, cGetterDecl, clang::SourceLocation(), clang::SourceLocation(),
10191021
cGetterSelfId, recordType, recordTypeInfo, clang::SC_None, nullptr);
1022+
cGetterSelf->setImplicit();
10201023
cGetterDecl->setParams(cGetterSelf);
10211024

10221025
auto cGetterSelfExpr = new (Ctx)
@@ -1040,13 +1043,15 @@ std::pair<FuncDecl *, FuncDecl *> SwiftDeclSynthesizer::makeBitFieldAccessors(
10401043
Ctx, cSetterDecl, clang::SourceLocation(), clang::SourceLocation(),
10411044
/* nameID? */ nullptr, fieldType, fieldTypeInfo, clang::SC_None,
10421045
nullptr);
1046+
cSetterValue->setImplicit();
10431047
cSetterParams.push_back(cSetterValue);
10441048
auto recordPointerTypeInfo =
10451049
Ctx.getTrivialTypeSourceInfo(recordPointerType);
10461050
auto cSetterSelf = clang::ParmVarDecl::Create(
10471051
Ctx, cSetterDecl, clang::SourceLocation(), clang::SourceLocation(),
10481052
/* nameID? */ nullptr, recordPointerType, recordPointerTypeInfo,
10491053
clang::SC_None, nullptr);
1054+
cSetterSelf->setImplicit();
10501055
cSetterParams.push_back(cSetterSelf);
10511056
cSetterDecl->setParams(cSetterParams);
10521057

lib/IRGen/IRGenModule.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
138138
CGO.TrapFuncName = Opts.TrapFuncName;
139139
}
140140

141+
// We don't need to perform coverage mapping for any Clang decls we've
142+
// synthesized, as they have no user-written code. This is also needed to
143+
// avoid a Clang crash when attempting to emit coverage for decls without
144+
// source locations (rdar://100172217).
145+
CGO.CoverageMapping = false;
146+
141147
auto &VFS = Importer->getClangInstance().getVirtualFileSystem();
142148
auto &HSI = Importer->getClangPreprocessor()
143149
.getHeaderSearchInfo()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct cstruct {
2+
int member : 16;
3+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module CModule {
2+
header "cmodule.h"
3+
}

test/Profiler/issue-57483.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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
2+
3+
// 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"
8+
9+
import CModule
10+
11+
func foo(_ x: UnsafePointer<cstruct>?) {
12+
_ = x?.pointee.member
13+
}
14+
foo(nil)

0 commit comments

Comments
 (0)