summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaObjCProperty.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2015-12-08 22:45:17 +0000
committerDouglas Gregor <dgregor@apple.com>2015-12-08 22:45:17 +0000
commit1cbb289c7deb5cdd4e892e49c84ee602534dfe41 (patch)
tree0decacbe530a331c536d49af20462016785fa356 /clang/lib/Sema/SemaObjCProperty.cpp
parent8f64ca152985ac199ba8e2e6a94ebdba2ebd2db6 (diff)
downloadbcm5719-llvm-1cbb289c7deb5cdd4e892e49c84ee602534dfe41.tar.gz
bcm5719-llvm-1cbb289c7deb5cdd4e892e49c84ee602534dfe41.zip
Objective-C properties: fix bogus use of "isa<>" on a QualType.
The code used "isa" to check the type and then "getAs" to look through sugar; we need to look through the sugar when checking, too, otherwise any kind of sugar (nullability qualifiers in the example; or a typedef) will thwart this semantic check. Fixes rdar://problem/23804250. llvm-svn: 255066
Diffstat (limited to 'clang/lib/Sema/SemaObjCProperty.cpp')
-rw-r--r--clang/lib/Sema/SemaObjCProperty.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp
index f0948b77580..e204936b500 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/lib/Sema/SemaObjCProperty.cpp
@@ -1372,12 +1372,11 @@ bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property,
QualType PropertyIvarType = property->getType().getNonReferenceType();
bool compat = Context.hasSameType(PropertyIvarType, GetterType);
if (!compat) {
- if (isa<ObjCObjectPointerType>(PropertyIvarType) &&
- isa<ObjCObjectPointerType>(GetterType))
- compat =
- Context.canAssignObjCInterfaces(
- GetterType->getAs<ObjCObjectPointerType>(),
- PropertyIvarType->getAs<ObjCObjectPointerType>());
+ const ObjCObjectPointerType *propertyObjCPtr = nullptr;
+ const ObjCObjectPointerType *getterObjCPtr = nullptr;
+ if ((propertyObjCPtr = PropertyIvarType->getAs<ObjCObjectPointerType>()) &&
+ (getterObjCPtr = GetterType->getAs<ObjCObjectPointerType>()))
+ compat = Context.canAssignObjCInterfaces(getterObjCPtr, propertyObjCPtr);
else if (CheckAssignmentConstraints(Loc, GetterType, PropertyIvarType)
!= Compatible) {
Diag(Loc, diag::error_property_accessor_type)
OpenPOWER on IntegriCloud