summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCast.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2017-08-11 00:06:49 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2017-08-11 00:06:49 +0000
commit8d7bdf6dffb56c31bb671be4476c9fb057eaf26d (patch)
tree31fc7b8a3223f44f877e9c749cd80814536e524e /clang/lib/Sema/SemaCast.cpp
parent6315d2d21d70f18d11d00015d1432f5964edafdb (diff)
downloadbcm5719-llvm-8d7bdf6dffb56c31bb671be4476c9fb057eaf26d.tar.gz
bcm5719-llvm-8d7bdf6dffb56c31bb671be4476c9fb057eaf26d.zip
[Sema][ObjC] Fix spurious -Wcast-qual warnings.
We do not meaningfully track object const-ness of Objective-C object types. Silence the -Wcast-qual warning that is issued when casting to or from Objective-C object types results in losing const qualification. rdar://problem/33807915 llvm-svn: 310672
Diffstat (limited to 'clang/lib/Sema/SemaCast.cpp')
-rw-r--r--clang/lib/Sema/SemaCast.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index ba2049d8a60..d603101c3fd 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -552,7 +552,14 @@ CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType,
Qualifiers SrcQuals, DestQuals;
Self.Context.getUnqualifiedArrayType(UnwrappedSrcType, SrcQuals);
Self.Context.getUnqualifiedArrayType(UnwrappedDestType, DestQuals);
-
+
+ // We do not meaningfully track object const-ness of Objective-C object
+ // types. Remove const from the source type if either the source or
+ // the destination is an Objective-C object type.
+ if (UnwrappedSrcType->isObjCObjectType() ||
+ UnwrappedDestType->isObjCObjectType())
+ SrcQuals.removeConst();
+
Qualifiers RetainedSrcQuals, RetainedDestQuals;
if (CheckCVR) {
RetainedSrcQuals.setCVRQualifiers(SrcQuals.getCVRQualifiers());
OpenPOWER on IntegriCloud