aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-09-14 04:35:37 +0000
committerDouglas Gregor <dgregor@apple.com>2012-09-14 04:35:37 +0000
commit6db351abf27e907b4a01570a6aa8e7b898522449 (patch)
treea53c861a4d97cd5e93303c837ddb5bbd06ec7fab
parentdd084276526db1d53edf2b6fc8c4c8187e6ab540 (diff)
In debugger mode, allow comparisons between pointers and integers
without a cast. Fixes <rdar://problem/11830912>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163873 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp5
-rw-r--r--test/SemaObjCXX/debugger-support.mm7
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index cfa9ccbfc3..3d143c8097 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -7214,7 +7214,10 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
(LHSType->isIntegerType() && RHSType->isAnyPointerType())) {
unsigned DiagID = 0;
bool isError = false;
- if ((LHSIsNull && LHSType->isIntegerType()) ||
+ if (LangOpts.DebuggerSupport) {
+ // Under a debugger, allow the comparison of pointers to integers,
+ // since users tend to want to compare addresses.
+ } else if ((LHSIsNull && LHSType->isIntegerType()) ||
(RHSIsNull && RHSType->isIntegerType())) {
if (IsRelational && !getLangOpts().CPlusPlus)
DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
diff --git a/test/SemaObjCXX/debugger-support.mm b/test/SemaObjCXX/debugger-support.mm
new file mode 100644
index 0000000000..1fb18b9c34
--- /dev/null
+++ b/test/SemaObjCXX/debugger-support.mm
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fdebugger-support -fsyntax-only -verify %s
+
+@class NSString;
+void testCompareAgainstPtr(int *ptr, NSString *ns) {
+ if (ptr == 17) {}
+ if (ns != 42) {}
+}