[cfe-commits] r163261 - in /cfe/trunk: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp test/Analysis/diagnostics/deref-track-symbolic-region.c
Jordan Rose
jordan_rose at apple.com
Wed Sep 5 15:38:41 PDT 2012
On Sep 5, 2012, at 15:31 , Anna Zaks <ganna at apple.com> wrote:
> Author: zaks
> Date: Wed Sep 5 17:31:55 2012
> New Revision: 163261
>
> URL: http://llvm.org/viewvc/llvm-project?rev=163261&view=rev
> Log:
> [analyzer] NullOrUndef diagnostics: track symbols binded to regions.
>
> If a region is binded to a symbolic value, we should track the symbol.
>
> (The code I changed was not previously exercised by the regression
> tests.)
>
> Added:
> cfe/trunk/test/Analysis/diagnostics/deref-track-symbolic-region.c
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=163261&r1=163260&r2=163261&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed Sep 5 17:31:55 2012
> @@ -54,7 +54,9 @@
> return U->getSubExpr()->IgnoreParenCasts();
> }
> else if (const MemberExpr *ME = dyn_cast<MemberExpr>(S)) {
> - return ME->getBase()->IgnoreParenCasts();
> + if (ME->isArrow()) {
> + return ME->getBase()->IgnoreParenCasts();
> + }
> }
This won't catch base regions that are references. Admittedly, such a thing is undefined behavior in C++, but we still warn about it.
S &s = getSomeReference();
if (&s == 0) return;
s.foo = 5;
More information about the cfe-commits
mailing list