Skip to content

Commit

Permalink
Revert "[analyzer] Simplify SVal for simple NonLoc->Loc casts (#66463)"
Browse files Browse the repository at this point in the history
This reverts commit 3ebf3dd.

I thought "Mergeing" will wait and confirm if the checks pass, and only
merge it if they succeed. Apparently, it's not the case here xD

The test is just broken in x86. See:
https://lab.llvm.org/buildbot/#/builders/109/builds/73686
  • Loading branch information
steakhal committed Sep 15, 2023
1 parent 71d6d81 commit 03693d5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
3 changes: 1 addition & 2 deletions clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ ProgramStateRef ExprEngine::handleLValueBitCast(
}
// Delegate to SValBuilder to process.
SVal OrigV = state->getSVal(Ex, LCtx);
SVal SimplifiedOrigV = svalBuilder.simplifySVal(state, OrigV);
SVal V = svalBuilder.evalCast(SimplifiedOrigV, T, ExTy);
SVal V = svalBuilder.evalCast(OrigV, T, ExTy);
// Negate the result if we're treating the boolean as a signed i1
if (CastE->getCastKind() == CK_BooleanToSignedIntegral && V.isValid())
V = svalBuilder.evalMinus(V.castAs<NonLoc>());
Expand Down
26 changes: 0 additions & 26 deletions clang/test/Analysis/symbol-simplification-nonloc-loc.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core %s \
// RUN: -triple x86_64-pc-linux-gnu -verify

void clang_analyzer_eval(int);

#define BINOP(OP) [](auto x, auto y) { return x OP y; }

template <typename BinOp>
Expand Down Expand Up @@ -75,27 +73,3 @@ void zoo1backwards() {
*(0 + p) = nullptr; // warn
**(0 + p) = 'a'; // no-warning: this should be unreachable
}

void test_simplified_before_cast_add(long t1) {
long long t2 = t1 + 3;
if (!t2) {
int *p = (int *) t2;
clang_analyzer_eval(p == 0); // expected-warning{{TRUE}}
}
}

void test_simplified_before_cast_sub(long t1) {
long long t2 = t1 - 3;
if (!t2) {
int *p = (int *) t2;
clang_analyzer_eval(p == 0); // expected-warning{{TRUE}}
}
}

void test_simplified_before_cast_mul(long t1) {
long long t2 = t1 * 3;
if (!t2) {
int *p = (int *) t2;
clang_analyzer_eval(p == 0); // expected-warning{{TRUE}}
}
}

0 comments on commit 03693d5

Please sign in to comment.