[PATCH] D13408: Skip NonNull sema checks in unevaluated contexts.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 8 17:18:59 PDT 2015


EricWF updated the summary for this revision.
EricWF updated this revision to Diff 36910.

http://reviews.llvm.org/D13408

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/non-null-warning.c

Index: test/Sema/non-null-warning.c
===================================================================
--- test/Sema/non-null-warning.c
+++ test/Sema/non-null-warning.c
@@ -37,6 +37,9 @@
   return 0; // expected-warning {{null returned from function that requires a non-null return value}}
 }
 
+#define SAFE_CALL(X) if (X) foo(X)
 int main () {
   foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
+  SAFE_CALL(0); // expect no diagnostic for unreachable code.
 }
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1151,7 +1151,8 @@
                                  const Expr *ArgExpr,
                                  SourceLocation CallSiteLoc) {
   if (CheckNonNullExpr(S, ArgExpr))
-    S.Diag(CallSiteLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
+    S.DiagRuntimeBehavior(CallSiteLoc, ArgExpr,
+           S.PDiag(diag::warn_null_arg) << ArgExpr->getSourceRange());
 }
 
 bool Sema::GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13408.36910.patch
Type: text/x-patch
Size: 1196 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151009/02bda03b/attachment.bin>


More information about the cfe-commits mailing list