[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.

llvm-svn: 361205
This commit is contained in:
Leonard Chan 2019-05-20 22:42:19 +00:00
parent c4c679c232
commit 16beaae2a6
2 changed files with 21 additions and 1 deletions

View File

@ -3929,7 +3929,11 @@ AttributedType::getImmediateNullability() const {
}
Optional<NullabilityKind> AttributedType::stripOuterNullability(QualType &T) {
if (auto attributed = dyn_cast<AttributedType>(T.getTypePtr())) {
QualType AttrTy = T;
if (auto MacroTy = dyn_cast<MacroQualifiedType>(T))
AttrTy = MacroTy->getUnderlyingType();
if (auto attributed = dyn_cast<AttributedType>(AttrTy)) {
if (auto nullability = attributed->getImmediateNullability()) {
T = attributed->getModifiedType();
return nullability;

View File

@ -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