summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2018-05-09 12:27:21 +0000
committerAlexander Kornienko <alexfh@google.com>2018-05-09 12:27:21 +0000
commit48fcfc3274a341a05b39e39e95d6353ebbb17ea8 (patch)
treec9faf7923e9f0246bfe6887502cd3ee4d34a7d57 /clang/lib/StaticAnalyzer/Core/RegionStore.cpp
parente0207a60dd246124f2515d55f5658b2c90dd20db (diff)
downloadbcm5719-llvm-48fcfc3274a341a05b39e39e95d6353ebbb17ea8.tar.gz
bcm5719-llvm-48fcfc3274a341a05b39e39e95d6353ebbb17ea8.zip
Fixes issue introduced by r331556.
Closes bug: https://bugs.llvm.org/show_bug.cgi?id=37357 Patch by Rafael Stahl! Differential revision: https://reviews.llvm.org/D46633 llvm-svn: 331870
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/RegionStore.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/RegionStore.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 557a89e6267..be4b5aa9189 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1711,13 +1711,15 @@ SVal RegionStoreManager::getBindingForField(RegionBindingsConstRef B,
if (const auto *VR = dyn_cast<VarRegion>(superR)) {
const VarDecl *VD = VR->getDecl();
QualType RecordVarTy = VD->getType();
+ unsigned Index = FD->getFieldIndex();
// Either the record variable or the field has to be const qualified.
if (RecordVarTy.isConstQualified() || Ty.isConstQualified())
if (const Expr *Init = VD->getInit())
if (const auto *InitList = dyn_cast<InitListExpr>(Init))
- if (const Expr *FieldInit = InitList->getInit(FD->getFieldIndex()))
- if (Optional<SVal> V = svalBuilder.getConstantVal(FieldInit))
- return *V;
+ if (Index < InitList->getNumInits())
+ if (const Expr *FieldInit = InitList->getInit(Index))
+ if (Optional<SVal> V = svalBuilder.getConstantVal(FieldInit))
+ return *V;
}
return getBindingForFieldOrElementCommon(B, R, Ty);
OpenPOWER on IntegriCloud