no-outofbounds.c still fails. Previously it passed because the array index
is mistakenly a loc::ConcreteInt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70844
91177308-0d34-0410-b5e6-
96231b3b80d8
/// makeZeroVal - Construct an SVal representing '0' for the specified type.
SVal makeZeroVal(QualType T);
-
+ /// makeZeroIndex - Construct an SVal representing '0' index for array
+ /// elements.
+ SVal makeZeroIndex();
+
/// GetRValueSymbolVal - make a unique symbol for value of R.
SVal getRValueSymbolVal(const MemRegion* R);
const MemRegion *R = cast<loc::MemRegionVal>(BaseL).getRegion();
if (isa<ElementRegion>(R)) {
- // Basic example:
- // char buf[100];
- // char *q = &buf[1]; // p points to ElementRegion(buf,Unknown)
- // &q[10]
- //assert(cast<ElementRegion>(R)->getIndex().isUnknown());
+ // int x;
+ // char* y = (char*) &x;
+ // 'y' => ElementRegion(0, VarRegion('x'))
+ // y[0] = 'a';
return Base;
}
return UnknownVal();
}
+SVal ValueManager::makeZeroIndex() {
+ return nonloc::ConcreteInt(BasicVals.getZeroWithPtrWidth(false));
+}
+
//===----------------------------------------------------------------------===//
// Utility methods for constructing Non-Locs.
//===----------------------------------------------------------------------===//
// the types aren't the same, so we construct an ElementRegion.
// FIXME: We should have a standard query function to get the size
// of the array index.
- SVal Idx = ValMgr.makeZeroVal(ValMgr.getContext().VoidPtrTy);
+ SVal Idx = ValMgr.makeZeroIndex();
// If the super region is an element region, strip it away.
// FIXME: Is this the right thing to do in all cases?
// RUN: clang-cc -checker-cfref -analyze -analyzer-store=region -verify %s &&
// RUN: clang-cc -checker-cfref -analyze -analyzer-store=basic -verify %s
-
+// XFAIL
void f() {
long x = 0;
char *y = (char*) &x;