[cfe-commits] r59245 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h lib/Analysis/GRExprEngine.cpp test/Analysis/array-struct.c
Ted Kremenek
kremenek at apple.com
Thu Nov 13 07:42:32 PST 2008
Author: kremenek
Date: Thu Nov 13 09:42:31 2008
New Revision: 59245
URL: http://llvm.org/viewvc/llvm-project?rev=59245&view=rev
Log:
- Revert r59229 and r59232: AllocRegion should be immutable.
- Temporarily disabled test Analysis/array-struct.c for region store.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
cfe/trunk/lib/Analysis/GRExprEngine.cpp
cfe/trunk/test/Analysis/array-struct.c
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h?rev=59245&r1=59244&r2=59245&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Thu Nov 13 09:42:31 2008
@@ -37,9 +37,9 @@
class MemRegion : public llvm::FoldingSetNode {
public:
enum Kind { MemSpaceRegionKind, SymbolicRegionKind,
+ AllocaRegionKind,
// Typed regions.
BEG_TYPED_REGIONS,
- AllocaRegionKind,
CompoundLiteralRegionKind,
StringRegionKind, ElementRegionKind,
// Decl Regions.
@@ -102,6 +102,34 @@
}
};
+/// AllocaRegion - A region that represents an untyped blob of bytes created
+/// by a call to 'alloca'.
+class AllocaRegion : public SubRegion {
+ friend class MemRegionManager;
+protected:
+ unsigned Cnt; // Block counter. Used to distinguish different pieces of
+ // memory allocated by alloca at the same call site.
+ const Expr* Ex;
+
+ AllocaRegion(const Expr* ex, unsigned cnt, const MemRegion* superRegion)
+ : SubRegion(superRegion, AllocaRegionKind), Cnt(cnt), Ex(ex) {}
+
+public:
+
+ const Expr* getExpr() const { return Ex; }
+
+ void Profile(llvm::FoldingSetNodeID& ID) const;
+
+ static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr* Ex,
+ unsigned Cnt);
+
+ void print(llvm::raw_ostream& os) const;
+
+ static bool classof(const MemRegion* R) {
+ return R->getKind() == AllocaRegionKind;
+ }
+};
+
/// SymbolicRegion - A special, "non-concrete" region. Unlike other region
/// clases, SymbolicRegion represents a region that serves as an alias for
/// either a real region, a NULL pointer, etc. It essentially is used to
@@ -142,42 +170,6 @@
}
};
-/// AllocaRegion - A region that represents an untyped blob of bytes created
-/// by a call to 'alloca'.
-class AllocaRegion : public TypedRegion {
- friend class MemRegionManager;
-protected:
- unsigned Cnt; // Block counter. Used to distinguish different pieces of
- // memory allocated by alloca at the same call site.
- const Expr* Ex;
-
- QualType T;
-
- AllocaRegion(const Expr* ex, unsigned cnt, const MemRegion* superRegion)
- : TypedRegion(superRegion, AllocaRegionKind), Cnt(cnt), Ex(ex) {}
-
-public:
-
- const Expr* getExpr() const { return Ex; }
-
- void setType(QualType t) { T = t; }
-
- QualType getType(ASTContext& C) const {
- return C.getCanonicalType(T);
- }
-
- void Profile(llvm::FoldingSetNodeID& ID) const;
-
- static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr* Ex,
- unsigned Cnt);
-
- void print(llvm::raw_ostream& os) const;
-
- static bool classof(const MemRegion* R) {
- return R->getKind() == AllocaRegionKind;
- }
-};
-
/// StringRegion - Region associated with a StringLiteral.
class StringRegion : public TypedRegion {
friend class MemRegionManager;
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=59245&r1=59244&r2=59245&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Thu Nov 13 09:42:31 2008
@@ -1681,26 +1681,6 @@
continue;
}
- // Cast alloca'ed pointer to typed pointer.
- if (isa<loc::MemRegionVal>(V)) {
- if (const AllocaRegion* AR =
- dyn_cast<AllocaRegion>(cast<loc::MemRegionVal>(V).getRegion())) {
-
- // Set the AllocaRegion's type.
- const_cast<AllocaRegion*>(AR)->setType(T);
-
- // Set the CastExpr's value to a pointer to the first element.
- MemRegionManager& RM = getStateManager().getRegionManager();
-
- llvm::APSInt Zero(llvm::APInt::getNullValue(32), false);
- SVal ZeroIdx(nonloc::ConcreteInt(getBasicVals().getValue(Zero)));
- const ElementRegion* ER = RM.getElementRegion(ZeroIdx, AR);
-
- MakeNode(Dst, CastE, N, BindExpr(St, CastE, loc::MemRegionVal(ER)));
- continue;
- }
- }
-
// All other cases.
MakeNode(Dst, CastE, N, BindExpr(St, CastE, EvalCast(V, CastE->getType())));
}
Modified: cfe/trunk/test/Analysis/array-struct.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/array-struct.c?rev=59245&r1=59244&r2=59245&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/array-struct.c (original)
+++ cfe/trunk/test/Analysis/array-struct.c Thu Nov 13 09:42:31 2008
@@ -1,5 +1,5 @@
-// RUN: clang -checker-simple -verify %s &&
-// RUN: clang -checker-simple -analyzer-store-region -verify %s
+// RUN: clang -checker-simple -verify %s
+// DISABLED: clang -checker-simple -analyzer-store-region -verify %s
struct s {
int data;
More information about the cfe-commits
mailing list