forked from OSchip/llvm-project
[analysis] Re-discard type sugar when casting values retrieved from the Store.
Canonicalization was accidentally omitted in 6d3f43ec
.
This commit is contained in:
parent
89a2bef27a
commit
f0ced2ddb4
|
@ -394,8 +394,8 @@ SVal StoreManager::attemptDownCast(SVal Base, QualType TargetType,
|
|||
}
|
||||
|
||||
static bool hasSameUnqualifiedPointeeType(QualType ty1, QualType ty2) {
|
||||
return ty1->getPointeeType().getTypePtr() ==
|
||||
ty2->getPointeeType().getTypePtr();
|
||||
return ty1->getPointeeType().getCanonicalType().getTypePtr() ==
|
||||
ty2->getPointeeType().getCanonicalType().getTypePtr();
|
||||
}
|
||||
|
||||
/// CastRetrievedVal - Used by subclasses of StoreManager to implement
|
||||
|
@ -427,7 +427,7 @@ SVal StoreManager::CastRetrievedVal(SVal V, const TypedValueRegion *R,
|
|||
// correctly every time we need it.
|
||||
if (castTy->isPointerType() && !castTy->isVoidPointerType())
|
||||
if (const auto *SR = dyn_cast_or_null<SymbolicRegion>(V.getAsRegion())) {
|
||||
QualType sr = SR->getSymbol()->getType();
|
||||
QualType sr = SR->getSymbol()->getType();
|
||||
if (!hasSameUnqualifiedPointeeType(sr, castTy))
|
||||
return loc::MemRegionVal(castRegion(SR, castTy));
|
||||
}
|
||||
|
|
|
@ -54,3 +54,21 @@ int work3(const Params * const params) {
|
|||
sum += fooList[i]; // no-warning
|
||||
return sum;
|
||||
}
|
||||
|
||||
typedef Params ParamsTypedef;
|
||||
typedef const ParamsTypedef *ConstParamsTypedef;
|
||||
|
||||
static void create4(ConstParamsTypedef const params, int fooList[]) {
|
||||
int tmpList[SIZE] = {0};
|
||||
for (int i = 0; i < params->noOfSymbols; i++)
|
||||
fooList[i] = tmpList[i];
|
||||
}
|
||||
|
||||
int work4(Params * const params) {
|
||||
int fooList[SIZE];
|
||||
create4(params, fooList);
|
||||
int sum = 0;
|
||||
for (int i = 0; i < params->noOfSymbols; i++)
|
||||
sum += fooList[i]; // no-warning
|
||||
return sum;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue