Skip to content

[Clang importer] Restore historical definition of "Boolean for Objective-C" #64330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/ClangImporter/ImportName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ static bool isErrorOutParameter(const clang::ParmVarDecl *param,

static bool isBoolType(clang::ASTContext &ctx, clang::QualType type) {
do {
if (type->isBooleanType())
return true;

// Check whether we have a typedef for "BOOL" or "Boolean".
if (auto typedefType = dyn_cast<clang::TypedefType>(type.getTypePtr())) {
auto typedefDecl = typedefType->getDecl();
Expand Down Expand Up @@ -1857,7 +1854,7 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
return ImportedName();
auto toType = conversionDecl->getConversionType();
// Only import `operator bool()` for now.
if (isBoolType(clangSema.Context, toType)) {
if (toType->isBooleanType()) {
isFunction = true;
baseName = "__convertToBool";
addEmptyArgNamesForClangFunction(conversionDecl, argumentNames);
Expand Down
5 changes: 5 additions & 0 deletions test/ClangImporter/objc_parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ func customAccessors(_ hive: Hive, bee: Bee) {
hive.`guard` = bee // no-warning
}

// Properties with bool don't use the getter.
func boolProperties(_ hive: Hive) {
markUsed(hive.empty)
}

// instancetype/Dynamic Self invocation.
func testDynamicSelf(_ queen: Bee, wobbler: NSWobbling) {
var hive = Hive()
Expand Down
2 changes: 2 additions & 0 deletions test/Inputs/clang-importer-sdk/usr/include/Foundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import <CoreFoundation.h>
#import <CoreGraphics.h>
#endif
#import <stdbool.h>

#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))

Expand Down Expand Up @@ -262,6 +263,7 @@ __attribute__((warn_unused_result)) NSString *NSStringToNSString(NSString *str);
@property (nonnull) NSDictionary<id <NSCopying>, Bee *> *anythingToBees;

@property(getter=isMakingHoney) BOOL makingHoney;
@property(readonly,getter=isEmpty) bool empty;
@property(setter=assignGuard:) id guard;

+ (instancetype)hiveWithQueen:(Bee *)queen;
Expand Down