Let StoreManager do different cast on arrays. BasicStore will just keep it intact.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58028 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h
index 87c180d..95a439e 100644
--- a/include/clang/Analysis/PathSensitive/GRState.h
+++ b/include/clang/Analysis/PathSensitive/GRState.h
@@ -405,6 +405,10 @@
return SetSVal(St, Ex, V, isBlkExpr, Invalidate);
}
+
+ SVal ArrayToPointer(SVal Array) {
+ return StoreMgr->ArrayToPointer(Array);
+ }
// Methods that manipulate the GDM.
const GRState* addGDM(const GRState* St, void* Key, void* Data);
diff --git a/include/clang/Analysis/PathSensitive/Store.h b/include/clang/Analysis/PathSensitive/Store.h
index 5a93e0e..f4f0415 100644
--- a/include/clang/Analysis/PathSensitive/Store.h
+++ b/include/clang/Analysis/PathSensitive/Store.h
@@ -61,6 +61,7 @@
virtual SVal getLValueElement(const GRState* St,
SVal Base, SVal Offset) = 0;
+ virtual SVal ArrayToPointer(SVal Array) = 0;
virtual Store
RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index cdecb19..70631ac 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -51,6 +51,8 @@
SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, SVal Base);
SVal getLValueField(const GRState* St, SVal Base, const FieldDecl* D);
SVal getLValueElement(const GRState* St, SVal Base, SVal Offset);
+
+ SVal ArrayToPointer(SVal Array) { return Array; }
virtual Store
RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index ae474be..4d771fb 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -1503,9 +1503,15 @@
MakeNode(Dst, CastE, N, SetSVal(St, CastE, V));
continue;
}
-
+
+ // StoreManager casts array to different values.
+ if (ExTy->isArrayType()) {
+ V = StateMgr.ArrayToPointer(V);
+ MakeNode(Dst, CastE, N, SetSVal(St, CastE, V));
+ continue;
+ }
+
// All other cases.
-
MakeNode(Dst, CastE, N, SetSVal(St, CastE, EvalCast(V, CastE->getType())));
}
}