summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonard Chan <leonardchan@google.com>2019-05-20 22:42:19 +0000
committerLeonard Chan <leonardchan@google.com>2019-05-20 22:42:19 +0000
commit16beaae2a61cd75a1786d04134d59feb0be7b527 (patch)
tree8fe265df4e87b90f830744daf48550c33dc8c99c
parentc4c679c2324be85fc6306b913225fd2225a2e24c (diff)
downloadbcm5719-llvm-16beaae2a61cd75a1786d04134d59feb0be7b527.tar.gz
bcm5719-llvm-16beaae2a61cd75a1786d04134d59feb0be7b527.zip
[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
-rw-r--r--clang/lib/AST/Type.cpp6
-rw-r--r--clang/test/SemaObjC/nullability_macro.m16
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 590e534fbdf..101c5184a5a 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -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;
diff --git a/clang/test/SemaObjC/nullability_macro.m b/clang/test/SemaObjC/nullability_macro.m
new file mode 100644
index 00000000000..436bbea9c3c
--- /dev/null
+++ b/clang/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
OpenPOWER on IntegriCloud