[PATCH] D43801: [analyzer] Only attempt to get the value of locations of known type

George Karpenkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 11:31:05 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL326233: [analyzer] Only attempt to get the value of locations of known type (authored by george.karpenkov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43801?vs=136027&id=136118#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43801

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  cfe/trunk/test/Analysis/novoidtypecrash.c


Index: cfe/trunk/test/Analysis/novoidtypecrash.c
===================================================================
--- cfe/trunk/test/Analysis/novoidtypecrash.c
+++ cfe/trunk/test/Analysis/novoidtypecrash.c
@@ -0,0 +1,8 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core %s
+a;
+b(void **c) { // no-crash
+  *c = a;
+  int *d;
+  b(&d);
+  *d;
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
@@ -73,9 +73,9 @@
     return;
 
   ProgramStateRef State = C.getState();
-  SVal V = State->getSVal(location.castAs<Loc>());
 
   if (isGlobalConstString(location)) {
+    SVal V = State->getSVal(location.castAs<Loc>());
     Optional<DefinedOrUnknownSVal> Constr = V.getAs<DefinedOrUnknownSVal>();
 
     if (Constr) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43801.136118.patch
Type: text/x-patch
Size: 972 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180227/c059fb1f/attachment.bin>


More information about the llvm-commits mailing list