From: Leonard Chan Date: Mon, 20 May 2019 22:42:19 +0000 (+0000) Subject: [Sema] Fix for build on some iOS programs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c0a4f459e50521676bead07a7b868a82e2f0fc55;p=clang [Sema] Fix for build on some iOS programs. Nullability attributes weren't being stripped for AttributedTypes that were wrapped in a MacroQualifiedType. This fix adds a check for this type and a test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361205 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 590e534fbd..101c5184a5 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -3929,7 +3929,11 @@ AttributedType::getImmediateNullability() const { } Optional AttributedType::stripOuterNullability(QualType &T) { - if (auto attributed = dyn_cast(T.getTypePtr())) { + QualType AttrTy = T; + if (auto MacroTy = dyn_cast(T)) + AttrTy = MacroTy->getUnderlyingType(); + + if (auto attributed = dyn_cast(AttrTy)) { if (auto nullability = attributed->getImmediateNullability()) { T = attributed->getModifiedType(); return nullability; diff --git a/test/SemaObjC/nullability_macro.m b/test/SemaObjC/nullability_macro.m new file mode 100644 index 0000000000..436bbea9c3 --- /dev/null +++ b/test/SemaObjC/nullability_macro.m @@ -0,0 +1,16 @@ +// Test that nullability attributes still get merged even though they are +// wrapped with a MacroQualifiedType. This should just compile with no errors. +// RUN: %clang_cc1 %s -Wno-objc-root-class -fsyntax-only -verify +#define UI_APPEARANCE_SELECTOR __attribute__((annotate("ui_appearance_selector"))) + +@class UIColor; + +@interface Test +@property(null_resettable, nonatomic, strong) UIColor *onTintColor UI_APPEARANCE_SELECTOR; // expected-warning{{treating Unicode character as whitespace}} +@end + +@implementation Test +- (void)setOnTintColor:(nullable UIColor *)onTintColor { +} + +@end