[cfe-commits] r112233 - in /cfe/trunk: include/clang/Checker/PathSensitive/GRCoreEngine.h lib/Checker/GRExprEngine.cpp test/Analysis/misc-ps.m
Ted Kremenek
kremenek at apple.com
Thu Aug 26 15:19:33 PDT 2010
Author: kremenek
Date: Thu Aug 26 17:19:33 2010
New Revision: 112233
URL: http://llvm.org/viewvc/llvm-project?rev=112233&view=rev
Log:
Fix horrible GRExprEngine bug where switch statements with no 'case:' statements would cause the path to get prematurely aborted. Fixes <rdar://problem/8360854>.
Modified:
cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h
cfe/trunk/lib/Checker/GRExprEngine.cpp
cfe/trunk/test/Analysis/misc-ps.m
Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h?rev=112233&r1=112232&r2=112233&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRCoreEngine.h Thu Aug 26 17:19:33 2010
@@ -407,7 +407,8 @@
public:
iterator& operator++() { ++I; return *this; }
- bool operator!=(const iterator& X) const { return I != X.I; }
+ bool operator!=(const iterator &X) const { return I != X.I; }
+ bool operator==(const iterator &X) const { return I == X.I; }
const CaseStmt* getCase() const {
return llvm::cast<CaseStmt>((*I)->getLabel());
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=112233&r1=112232&r2=112233&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Thu Aug 26 17:19:33 2010
@@ -1489,9 +1489,11 @@
DefinedOrUnknownSVal CondV = cast<DefinedOrUnknownSVal>(CondV_untested);
const GRState *DefaultSt = state;
- bool defaultIsFeasible = false;
+
+ iterator I = builder.begin(), EI = builder.end();
+ bool defaultIsFeasible = I == EI;
- for (iterator I = builder.begin(), EI = builder.end(); I != EI; ++I) {
+ for ( ; I != EI; ++I) {
const CaseStmt* Case = I.getCase();
// Evaluate the LHS of the case value.
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=112233&r1=112232&r2=112233&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Thu Aug 26 17:19:33 2010
@@ -1045,3 +1045,14 @@
if (y == -20 && b != 0)
(void)*(char*)0; // no-warning
}
+
+// <rdar://problem/8360854> - Test that code after a switch statement with no
+// 'case:' labels is correctly evaluated.
+void r8360854(int n) {
+ switch (n) {
+ default: ;
+ }
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning{{null pointer}}
+}
+
More information about the cfe-commits
mailing list