Skip to content

Commit 5cfd7b5

Browse files
committed
IRGen: Fix conversion of qualified Clang TypeDecls
... or something. This manifested as a crash when emitting an @objc thunk for an NS_STRING_ENUM type. Fixes <rdar://problem/35140812>.
1 parent f549f35 commit 5cfd7b5

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lib/IRGen/GenClangType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,8 @@ clang::CanQualType ClangTypeConverter::convert(IRGenModule &IGM, CanType type) {
705705
if (auto clangDecl = decl->getClangDecl()) {
706706
if (auto clangTypeDecl = dyn_cast<clang::TypeDecl>(clangDecl)) {
707707
auto &ctx = IGM.getClangASTContext();
708-
return ctx.getCanonicalType(ctx.getTypeDeclType(clangTypeDecl));
708+
return ctx.getCanonicalType(ctx.getTypeDeclType(clangTypeDecl))
709+
.getUnqualifiedType();
709710
} else if (auto ifaceDecl = dyn_cast<clang::ObjCInterfaceDecl>(clangDecl)) {
710711
auto &ctx = IGM.getClangASTContext();
711712
auto clangType = ctx.getObjCInterfaceType(ifaceDecl);

test/IRGen/Inputs/clang_string_enum.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <Foundation/Foundation.h>
2+
3+
typedef NSString * const PandaStyle NS_STRING_ENUM;
4+
5+
extern PandaStyle PandaStyleCute;

test/IRGen/clang_string_enum.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-ir %s -import-objc-header %S/Inputs/clang_string_enum.h > /dev/null
3+
4+
// REQUIRES: objc_interop
5+
6+
import Foundation
7+
8+
class PandaCub : NSObject {}
9+
10+
extension PandaCub {
11+
@objc func cuddle(_: PandaStyle) { }
12+
}

0 commit comments

Comments
 (0)