Skip to content

Commit d39ebda

Browse files
vabridgerseinvbri
authored and
einvbri
committed
[analyzer] Cleanup a FIXME in SValBuilder.cpp
This change follows up on a FIXME submitted with D105974. This change simply let's the reference case fall through to return a concrete 'true' instead of a nonloc pointer of appropriate length set to NULL. Reviewed By: NoQ Differential Revision: https://reviews.llvm.org/D107720
1 parent 0cecb42 commit d39ebda

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -725,16 +725,12 @@ SVal SValBuilder::evalCastSubKind(loc::MemRegionVal V, QualType CastTy,
725725
// This change is needed for architectures with varying
726726
// pointer widths. See the amdgcn opencl reproducer with
727727
// this change as an example: solver-sym-simplification-ptr-bool.cl
728-
// FIXME: We could encounter a reference here,
729-
// try returning a concrete 'true' since it might
730-
// be easier on the solver.
731728
// FIXME: Cleanup remainder of `getZeroWithPtrWidth ()`
732729
// and `getIntWithPtrWidth()` functions to prevent future
733730
// confusion
734-
const llvm::APSInt &Zero = Ty->isReferenceType()
735-
? BasicVals.getZeroWithPtrWidth()
736-
: BasicVals.getZeroWithTypeSize(Ty);
737-
return makeNonLoc(Sym, BO_NE, Zero, CastTy);
731+
if (!Ty->isReferenceType())
732+
return makeNonLoc(Sym, BO_NE, BasicVals.getZeroWithTypeSize(Ty),
733+
CastTy);
738734
}
739735
// Non-symbolic memory regions are always true.
740736
return makeTruthVal(true, CastTy);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core \
2+
// RUN: -analyzer-checker=debug.ExprInspection -verify %s
3+
4+
void clang_analyzer_dump(bool);
5+
6+
void foo(int &x) {
7+
int *p = &x; // 'p' is the same SVal as 'x'
8+
bool b = p;
9+
clang_analyzer_dump(b); // expected-warning {{1 U1b}}
10+
}

0 commit comments

Comments
 (0)