return false;
}
+bool MemRegion::hasParametersStorage() const {
+ if (const MemSpaceRegion *MS = getMemorySpace())
+ return MS == getMemRegionManager()->getStackArgumentsRegion();
+
+ return false;
+}
+
bool MemRegion::hasGlobalsOrParametersStorage() const {
if (const MemSpaceRegion *MS = getMemorySpace()) {
MemRegionManager *Mgr = getMemRegionManager();
return UndefinedVal();
}
- if (R->hasStackStorage()) {
+ if (R->hasStackStorage() && !R->hasParametersStorage()) {
// Currently we don't reason specially about Clang-style vectors. Check
// if superR is a vector and if so return Unknown.
if (const TypedRegion *typedSuperR = dyn_cast<TypedRegion>(superR)) {
assert(0 && "Unknown default value");
}
- if (R->hasHeapOrStackStorage())
+ // FIXME: Is this correct? Should it be UnknownVal?
+ if (R->hasHeapStorage())
+ return UndefinedVal();
+
+ if (R->hasStackStorage() && !R->hasParametersStorage())
return UndefinedVal();
// If the region is already cast to another type, use that type to create the
-// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -verify %s
-
-// NOWORK: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
+// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -verify %s &&
+// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
#include <stdlib.h>
return x[0]; // no-warning
}
-struct baz { int x; };
-
-int struct_test(struct baz byVal) {
- return byVal.x; // no-warning;
+struct baz {
+ int x;
+ int y[2];
+};
+
+int struct_test(struct baz byVal, int flag) {
+ if (flag)
+ return byVal.x; // no-warning
+ else {
+ return byVal.y[0]; // no-warning
+ }
}
-