Skip to content

Commit 9d83b7d

Browse files
[Sema] Fix isCanonical calculation in FunctionType::get.
Fixes rdar://problem/57644243.
1 parent 82d5fbd commit 9d83b7d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/AST/ASTContext.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,8 +3008,12 @@ FunctionType *FunctionType::get(ArrayRef<AnyFunctionType::Param> params,
30083008
void *mem = ctx.Allocate(allocSize, alignof(FunctionType), arena);
30093009

30103010
bool isCanonical = isFunctionTypeCanonical(params, result);
3011-
if (uncommon.hasValue())
3012-
isCanonical &= uncommon->ClangFunctionType->isCanonicalUnqualified();
3011+
if (uncommon.hasValue()) {
3012+
if (ctx.LangOpts.UseClangFunctionTypes)
3013+
isCanonical &= uncommon->ClangFunctionType->isCanonicalUnqualified();
3014+
else
3015+
isCanonical = false;
3016+
}
30133017

30143018
auto funcTy = new (mem) FunctionType(params, result, info,
30153019
isCanonical ? &ctx : nullptr,

test/Sema/clang_types_in_ast.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
// RUN: %target-swift-frontend %s -typecheck -DNOCRASH2 -sdk %clang-importer-sdk
55
// RUN: %target-swift-frontend %s -typecheck -DNOCRASH2 -sdk %clang-importer-sdk -use-clang-function-types
66
// RUN: %target-swift-frontend %s -DAUXMODULE -module-name Foo -emit-module -o %t
7-
// FIXME: rdar://problem/57644243 : We shouldn't crash if -use-clang-function-types is not enabled.
8-
// RUN: not --crash %target-swift-frontend %s -typecheck -DNOCRASH3 -I %t
7+
8+
// rdar://problem/57644243 : We shouldn't crash if -use-clang-function-types is not enabled.
9+
// RUN: %target-swift-frontend %s -typecheck -DNOCRASH3 -I %t
910

1011
// FIXME: [clang-function-type-serialization] This should stop crashing once we
1112
// start serializing clang function types.

0 commit comments

Comments
 (0)