aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-11-09 23:55:21 +0000
committerJordan Rose <jordan_rose@apple.com>2012-11-09 23:55:21 +0000
commit87da0b757638011ce84fd57f72e15b20bb523b19 (patch)
tree65197dfab09826687585e8ac3ceaaa0be08cb33e
parentd1542c23b278f8420a938e8d6f192a55b225918e (diff)
-Wobjc-literal-compare: look through implicit casts.
This warning was failing to fire under ARC because of the implicit lifetime casts added around the object literal expression. <rdar://problem/11300873>, again. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167648 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp3
-rw-r--r--test/SemaObjC/objc-literal-comparison.m4
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 28a637180a..bf4abfcb74 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -6783,7 +6783,7 @@ static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc,
}
static bool isObjCObjectLiteral(ExprResult &E) {
- switch (E.get()->getStmtClass()) {
+ switch (E.get()->IgnoreParenImpCasts()->getStmtClass()) {
case Stmt::ObjCArrayLiteralClass:
case Stmt::ObjCDictionaryLiteralClass:
case Stmt::ObjCStringLiteralClass:
@@ -6875,6 +6875,7 @@ static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc,
LK_String
} LiteralKind;
+ Literal = Literal->IgnoreParenImpCasts();
switch (Literal->getStmtClass()) {
case Stmt::ObjCStringLiteralClass:
// "string literal"
diff --git a/test/SemaObjC/objc-literal-comparison.m b/test/SemaObjC/objc-literal-comparison.m
index f1aa8ecd91..0a1058291e 100644
--- a/test/SemaObjC/objc-literal-comparison.m
+++ b/test/SemaObjC/objc-literal-comparison.m
@@ -2,6 +2,10 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-everything -Wobjc-literal-compare "-Dnil=(id)0" -verify %s
// RUN: %clang_cc1 -fsyntax-only -Wno-everything -Wobjc-literal-compare "-Dnil=0" -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-everything -Wobjc-literal-compare -fobjc-arc "-Dnil=((id)0)" -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-everything -Wobjc-literal-compare -fobjc-arc "-Dnil=(id)0" -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-everything -Wobjc-literal-compare -fobjc-arc "-Dnil=0" -verify %s
+
// (test the warning flag as well)
typedef signed char BOOL;