summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/MemRegion.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-05-04 06:18:28 +0000
committerTed Kremenek <kremenek@apple.com>2009-05-04 06:18:28 +0000
commit02e508960c1d2f7bbe0018d95b0ca850291f1c70 (patch)
tree1aa07d92d89548acbcf46763ded7a2298d4503be /clang/lib/Analysis/MemRegion.cpp
parent5b07c7ec057de27677dc4c0db2df4c5e998e9384 (diff)
downloadbcm5719-llvm-02e508960c1d2f7bbe0018d95b0ca850291f1c70.tar.gz
bcm5719-llvm-02e508960c1d2f7bbe0018d95b0ca850291f1c70.zip
Per conversations with Zhongxing, add an 'element type' to
ElementRegion. I also removed 'ElementRegion::getArrayRegion', although we may need to add this back. This breaks a few test cases with RegionStore: - 'array-struct.c' triggers an infinite recursion in RegionStoreManager. Need to investigate. - misc-ps.m triggers a failure with RegionStoreManager as we now get the diagnostic: 'Line 159: Uninitialized or undefined return value returned to caller.' There were a bunch of places that needed to be edit RegionStoreManager, and we may not be passing all the correct 'element types' down from GRExprEngine. Zhongxing: When you get a chance, could you review this? I could have easily screwed up something basic in RegionStoreManager. llvm-svn: 70830
Diffstat (limited to 'clang/lib/Analysis/MemRegion.cpp')
-rw-r--r--clang/lib/Analysis/MemRegion.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/clang/lib/Analysis/MemRegion.cpp b/clang/lib/Analysis/MemRegion.cpp
index 81855ba61b5..78cd8146e48 100644
--- a/clang/lib/Analysis/MemRegion.cpp
+++ b/clang/lib/Analysis/MemRegion.cpp
@@ -96,15 +96,17 @@ void SymbolicRegion::Profile(llvm::FoldingSetNodeID& ID) const {
SymbolicRegion::ProfileRegion(ID, sym);
}
-void ElementRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, SVal Idx,
+void ElementRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
+ QualType ElementType, SVal Idx,
const MemRegion* superRegion) {
ID.AddInteger(MemRegion::ElementRegionKind);
+ ID.Add(ElementType);
ID.AddPointer(superRegion);
Idx.Profile(ID);
}
void ElementRegion::Profile(llvm::FoldingSetNodeID& ID) const {
- ElementRegion::ProfileRegion(ID, Index, superRegion);
+ ElementRegion::ProfileRegion(ID, ElementType, Index, superRegion);
}
void CodeTextRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, const void* data,
@@ -122,18 +124,6 @@ void CodeTextRegion::Profile(llvm::FoldingSetNodeID& ID) const {
// getLValueType() and getRValueType()
//===----------------------------------------------------------------------===//
-QualType ElementRegion::getRValueType(ASTContext& C) const {
- // Strip off typedefs from the ArrayRegion's RvalueType.
- QualType T = getArrayRegion()->getRValueType(C)->getDesugaredType();
-
- if (ArrayType* AT = dyn_cast<ArrayType>(T.getTypePtr()))
- return AT->getElementType();
-
- // If the RValueType of the array region isn't an ArrayType, then essentially
- // the element's
- return T;
-}
-
QualType StringRegion::getRValueType(ASTContext& C) const {
return Str->getType();
}
@@ -313,10 +303,11 @@ MemRegionManager::getCompoundLiteralRegion(const CompoundLiteralExpr* CL) {
}
ElementRegion*
-MemRegionManager::getElementRegion(SVal Idx, const TypedRegion* superRegion){
+MemRegionManager::getElementRegion(QualType elementType, SVal Idx,
+ const TypedRegion* superRegion){
llvm::FoldingSetNodeID ID;
- ElementRegion::ProfileRegion(ID, Idx, superRegion);
+ ElementRegion::ProfileRegion(ID, elementType, Idx, superRegion);
void* InsertPos;
MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
@@ -324,7 +315,7 @@ MemRegionManager::getElementRegion(SVal Idx, const TypedRegion* superRegion){
if (!R) {
R = (ElementRegion*) A.Allocate<ElementRegion>();
- new (R) ElementRegion(Idx, superRegion);
+ new (R) ElementRegion(elementType, Idx, superRegion);
Regions.InsertNode(R, InsertPos);
}
OpenPOWER on IntegriCloud