diff --git a/clang/lib/StaticAnalyzer/Core/Store.cpp b/clang/lib/StaticAnalyzer/Core/Store.cpp index 20660d1c2d67..b33129c88cea 100644 --- a/clang/lib/StaticAnalyzer/Core/Store.cpp +++ b/clang/lib/StaticAnalyzer/Core/Store.cpp @@ -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(V.getAsRegion())) { - QualType sr = SR->getSymbol()->getType(); + QualType sr = SR->getSymbol()->getType(); if (!hasSameUnqualifiedPointeeType(sr, castTy)) return loc::MemRegionVal(castRegion(SR, castTy)); } diff --git a/clang/test/Analysis/uninit-val-const-likeness.c b/clang/test/Analysis/uninit-val-const-likeness.c index 1ee1aefe8dba..013ab7882755 100644 --- a/clang/test/Analysis/uninit-val-const-likeness.c +++ b/clang/test/Analysis/uninit-val-const-likeness.c @@ -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; +}