[PATCH] D44075: [analyzer] CStringChecker.cpp: Remove the duplicated check about null dereference on dest-buffer or src-buffer.

2018-03-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC326782: [analyzer] CStringChecker.cpp: Remove the duplicated 
check about null… (authored by henrywong, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44075?vs=136936=137167#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44075

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp


Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1033,21 +1033,6 @@
   if (stateNonZeroSize) {
 state = stateNonZeroSize;
 
-// Ensure the destination is not null. If it is NULL there will be a
-// NULL pointer dereference.
-state = checkNonNull(C, state, Dest, destVal);
-if (!state)
-  return;
-
-// Get the value of the Src.
-SVal srcVal = state->getSVal(Source, LCtx);
-
-// Ensure the source is not null. If it is NULL there will be a
-// NULL pointer dereference.
-state = checkNonNull(C, state, Source, srcVal);
-if (!state)
-  return;
-
 // Ensure the accesses are valid and that the buffers do not overlap.
 const char * const writeWarning =
   "Memory copy function overflows destination buffer";
@@ -2033,12 +2018,6 @@
 return;
   }
 
-  // Ensure the memory area is not null.
-  // If it is NULL there will be a NULL pointer dereference.
-  State = checkNonNull(C, StateNonZeroSize, Mem, MemVal);
-  if (!State)
-return;
-
   State = CheckBufferAccess(C, State, Size, Mem);
   if (!State)
 return;


Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1033,21 +1033,6 @@
   if (stateNonZeroSize) {
 state = stateNonZeroSize;
 
-// Ensure the destination is not null. If it is NULL there will be a
-// NULL pointer dereference.
-state = checkNonNull(C, state, Dest, destVal);
-if (!state)
-  return;
-
-// Get the value of the Src.
-SVal srcVal = state->getSVal(Source, LCtx);
-
-// Ensure the source is not null. If it is NULL there will be a
-// NULL pointer dereference.
-state = checkNonNull(C, state, Source, srcVal);
-if (!state)
-  return;
-
 // Ensure the accesses are valid and that the buffers do not overlap.
 const char * const writeWarning =
   "Memory copy function overflows destination buffer";
@@ -2033,12 +2018,6 @@
 return;
   }
 
-  // Ensure the memory area is not null.
-  // If it is NULL there will be a NULL pointer dereference.
-  State = checkNonNull(C, StateNonZeroSize, Mem, MemVal);
-  if (!State)
-return;
-
   State = CheckBufferAccess(C, State, Size, Mem);
   if (!State)
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44075: [analyzer] CStringChecker.cpp: Remove the duplicated check about null dereference on dest-buffer or src-buffer.

2018-03-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Making `CStringChecker` smaller is an accomplishment on its own :)


Repository:
  rC Clang

https://reviews.llvm.org/D44075



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44075: [analyzer] CStringChecker.cpp: Remove the duplicated check about null dereference on dest-buffer or src-buffer.

2018-03-04 Thread Henry Wong via Phabricator via cfe-commits
MTC created this revision.
MTC added reviewers: dcoughlin, NoQ, xazax.hun, cfe-commits.
Herald added subscribers: a.sidorin, rnkovacs, szepet.
Herald added a reviewer: george.karpenkov.

`CheckBufferAccess()` calls `CheckNonNull()`, so there are some calls to 
`CheckNonNull()` that are useless.


Repository:
  rC Clang

https://reviews.llvm.org/D44075

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp


Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1033,21 +1033,6 @@
   if (stateNonZeroSize) {
 state = stateNonZeroSize;
 
-// Ensure the destination is not null. If it is NULL there will be a
-// NULL pointer dereference.
-state = checkNonNull(C, state, Dest, destVal);
-if (!state)
-  return;
-
-// Get the value of the Src.
-SVal srcVal = state->getSVal(Source, LCtx);
-
-// Ensure the source is not null. If it is NULL there will be a
-// NULL pointer dereference.
-state = checkNonNull(C, state, Source, srcVal);
-if (!state)
-  return;
-
 // Ensure the accesses are valid and that the buffers do not overlap.
 const char * const writeWarning =
   "Memory copy function overflows destination buffer";
@@ -2033,12 +2018,6 @@
 return;
   }
 
-  // Ensure the memory area is not null.
-  // If it is NULL there will be a NULL pointer dereference.
-  State = checkNonNull(C, StateNonZeroSize, Mem, MemVal);
-  if (!State)
-return;
-
   State = CheckBufferAccess(C, State, Size, Mem);
   if (!State)
 return;


Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1033,21 +1033,6 @@
   if (stateNonZeroSize) {
 state = stateNonZeroSize;
 
-// Ensure the destination is not null. If it is NULL there will be a
-// NULL pointer dereference.
-state = checkNonNull(C, state, Dest, destVal);
-if (!state)
-  return;
-
-// Get the value of the Src.
-SVal srcVal = state->getSVal(Source, LCtx);
-
-// Ensure the source is not null. If it is NULL there will be a
-// NULL pointer dereference.
-state = checkNonNull(C, state, Source, srcVal);
-if (!state)
-  return;
-
 // Ensure the accesses are valid and that the buffers do not overlap.
 const char * const writeWarning =
   "Memory copy function overflows destination buffer";
@@ -2033,12 +2018,6 @@
 return;
   }
 
-  // Ensure the memory area is not null.
-  // If it is NULL there will be a NULL pointer dereference.
-  State = checkNonNull(C, StateNonZeroSize, Mem, MemVal);
-  if (!State)
-return;
-
   State = CheckBufferAccess(C, State, Size, Mem);
   if (!State)
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits