[PATCH] D122513: [analyzer] Fix "RhsLoc and LhsLoc bitwidth must be same"
Vince Bridgers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 28 17:00:08 PDT 2022
vabridgers added a comment.
I think I got it, looks like we're losing the width information at line 685, 686 below.
Looks like I need to adjust the bitwidth of V before returning.
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
671 SVal SValBuilder::evalCastSubKind(loc::ConcreteInt V, QualType CastTy,
672 QualType OriginalTy) {
673 // Pointer to bool.
674 if (CastTy->isBooleanType())
675 return makeTruthVal(V.getValue().getBoolValue(), CastTy);
676
677 // Pointer to integer.
678 if (CastTy->isIntegralOrEnumerationType()) {
679 llvm::APSInt Value = V.getValue();
680 BasicVals.getAPSIntType(CastTy).apply(Value);
681 return makeIntVal(Value);
682 }
683
684 // Pointer to any pointer.
685 if (Loc::isLocType(CastTy))
686 return V;
687
688 // Pointer to whatever else.
689 return UnknownVal();
690 }
Breakpoint 8, clang::ento::SValBuilder::evalCastSubKind (this=0xff34500, V=..., CastTy=..., OriginalTy=...)
at <root>/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:674
674 if (CastTy->isBooleanType())
(gdb) next
678 if (CastTy->isIntegralOrEnumerationType()) {
(gdb)
685 if (Loc::isLocType(CastTy))
(gdb) p V
$25 = {<clang::ento::Loc> = {<clang::ento::DefinedSVal> = {<clang::ento::DefinedOrUnknownSVal> = {<clang::ento::SVal> = {Data = 0xff37cf0,
Kind = 2}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}
(gdb) p V.dump()
0 (Loc)$26 = void
(gdb) p CastTy.dump()
PointerType 0xfede460 '__attribute__((address_space(3))) int *'
`-QualType 0xfede418 '__attribute__((address_space(3))) int' __attribute__((address_space(3)))
`-BuiltinType 0xfedd640 'int'
$27 = void
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122513/new/
https://reviews.llvm.org/D122513
More information about the cfe-commits
mailing list