]> granicus.if.org Git - clang/commit
[analyzer] Improved diagnostic pruning for calls initializing values.
authorAnna Zaks <ganna@apple.com>
Wed, 29 Aug 2012 21:22:37 +0000 (21:22 +0000)
committerAnna Zaks <ganna@apple.com>
Wed, 29 Aug 2012 21:22:37 +0000 (21:22 +0000)
commit80de487e03dd0f44e4572e2122ebc1aa6a3961f5
tree4388c41e6efe5f7600ba369e668d157102adf1a1
parenta484fc73ec6331bcaad092270b4ab9c8d1df23c3
[analyzer] Improved diagnostic pruning for calls initializing values.

This heuristic addresses the case when a pointer (or ref) is passed
to a function, which initializes the variable (or sets it to something
other than '0'). On the branch where the inlined function does not
set the value, we report use of undefined value (or NULL pointer
dereference). The access happens in the caller and the path
through the callee would get pruned away with regular path pruning. To
solve this issue, we previously disabled diagnostic pruning completely
on undefined and null pointer dereference checks, which entailed very
verbose diagnostics in most cases. Furthermore, not all of the
undef value checks had the diagnostic pruning disabled.

This patch implements the following heuristic: if we pass a pointer (or
ref) to the region (on which the error is reported) into a function and
it's value is either undef or 'NULL' (and is a pointer), do not prune
the function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162863 91177308-0d34-0410-b5e6-96231b3b80d8
13 files changed:
include/clang/Analysis/ProgramPoint.h
include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp
lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp
lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
lib/StaticAnalyzer/Core/BugReporter.cpp
lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
test/Analysis/diagnostics/undef-value-caller.c
test/Analysis/diagnostics/undef-value-param.c [new file with mode: 0644]
test/Analysis/diagnostics/undef-value-param.m [new file with mode: 0644]