[cfe-commits] r156369 - in /cfe/trunk: lib/StaticAnalyzer/Core/Environment.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp test/Analysis/misc-ps-region-store.cpp
Ted Kremenek
kremenek at apple.com
Mon May 7 22:13:40 PDT 2012
Author: kremenek
Date: Tue May 8 00:13:40 2012
New Revision: 156369
URL: http://llvm.org/viewvc/llvm-project?rev=156369&view=rev
Log:
Teach the analyzer about CXXScaleValueInitExpr.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/misc-ps-region-store.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp?rev=156369&r1=156368&r2=156369&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp Tue May 8 00:13:40 2012
@@ -71,6 +71,11 @@
else
return svalBuilder.makeBoolVal(cast<CXXBoolLiteralExpr>(E));
}
+ case Stmt::CXXScalarValueInitExprClass:
+ case Stmt::ImplicitValueInitExprClass: {
+ QualType Ty = cast<Expr>(E)->getType();
+ return svalBuilder.makeZeroVal(Ty);
+ }
case Stmt::IntegerLiteralClass: {
// In C++, this expression may have been bound to a temporary object.
SVal const *X = ExprBindings.lookup(EnvironmentEntry(E, LCtx));
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=156369&r1=156368&r2=156369&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Tue May 8 00:13:40 2012
@@ -496,7 +496,6 @@
case Stmt::CXXTypeidExprClass:
case Stmt::CXXUuidofExprClass:
case Stmt::CXXUnresolvedConstructExprClass:
- case Stmt::CXXScalarValueInitExprClass:
case Stmt::DependentScopeDeclRefExprClass:
case Stmt::UnaryTypeTraitExprClass:
case Stmt::BinaryTypeTraitExprClass:
@@ -573,15 +572,6 @@
// Implicitly handled by Environment::getSVal().
break;
- case Stmt::ImplicitValueInitExprClass: {
- ProgramStateRef state = Pred->getState();
- QualType ty = cast<ImplicitValueInitExpr>(S)->getType();
- SVal val = svalBuilder.makeZeroVal(ty);
- Bldr.generateNode(S, Pred, state->BindExpr(S, Pred->getLocationContext(),
- val));
- break;
- }
-
case Stmt::ExprWithCleanupsClass:
// Handled due to fully linearised CFG.
break;
@@ -619,6 +609,8 @@
case Stmt::AddrLabelExprClass:
case Stmt::IntegerLiteralClass:
case Stmt::CharacterLiteralClass:
+ case Stmt::ImplicitValueInitExprClass:
+ case Stmt::CXXScalarValueInitExprClass:
case Stmt::CXXBoolLiteralExprClass:
case Stmt::ObjCBoolLiteralExprClass:
case Stmt::FloatingLiteralClass:
Modified: cfe/trunk/test/Analysis/misc-ps-region-store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.cpp?rev=156369&r1=156368&r2=156369&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.cpp (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.cpp Tue May 8 00:13:40 2012
@@ -578,3 +578,17 @@
if (y == 0)
return;
}
+
+// Test handling CXXScalarValueInitExprs.
+void rdar11401827() {
+ int x = int();
+ if (!x) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null pointer}}
+ }
+ else {
+ int *p = 0;
+ *p = 0xDEADBEEF;
+ }
+}
+
More information about the cfe-commits
mailing list