[cfe-commits] r73952 - in /cfe/trunk: include/clang/Analysis/PathSensitive/ValueManager.h lib/Analysis/SVals.cpp lib/Analysis/ValueManager.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Mon Jun 22 23:22:22 PDT 2009
Author: zhongxingxu
Date: Tue Jun 23 01:22:22 2009
New Revision: 73952
URL: http://llvm.org/viewvc/llvm-project?rev=73952&view=rev
Log:
Split ValueManager method definitions into its own source file.
No functionality change.
Added:
cfe/trunk/lib/Analysis/ValueManager.cpp
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h
cfe/trunk/lib/Analysis/SVals.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h?rev=73952&r1=73951&r2=73952&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h Tue Jun 23 01:22:22 2009
@@ -9,7 +9,7 @@
//
// This file defines ValueManager, a class that manages symbolic values
// and SVals created for use by GRExprEngine and related classes. It
-// wraps SymbolManager, MemRegionManager, and BasicValueFactory.
+// wraps and owns SymbolManager, MemRegionManager, and BasicValueFactory.
//
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Analysis/SVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SVals.cpp?rev=73952&r1=73951&r2=73952&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/SVals.cpp (original)
+++ cfe/trunk/lib/Analysis/SVals.cpp Tue Jun 23 01:22:22 2009
@@ -236,53 +236,6 @@
return UndefinedVal();
}
-//===----------------------------------------------------------------------===//
-// Utility methods for constructing SVals.
-//===----------------------------------------------------------------------===//
-
-SVal ValueManager::makeZeroVal(QualType T) {
- if (Loc::IsLocType(T))
- return Loc::MakeNull(BasicVals);
-
- if (T->isIntegerType())
- return NonLoc::MakeVal(BasicVals, 0, T);
-
- // FIXME: Handle floats.
- // FIXME: Handle structs.
- return UnknownVal();
-}
-
-SVal ValueManager::makeZeroArrayIndex() {
- return nonloc::ConcreteInt(BasicVals.getZeroWithPtrWidth(false));
-}
-
-//===----------------------------------------------------------------------===//
-// Utility methods for constructing Non-Locs.
-//===----------------------------------------------------------------------===//
-
-NonLoc ValueManager::makeNonLoc(SymbolRef sym) {
- return nonloc::SymbolVal(sym);
-}
-
-NonLoc ValueManager::makeIntVal(const APSInt& V) {
- return nonloc::ConcreteInt(BasicVals.getValue(V));
-}
-
-NonLoc ValueManager::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
- const APSInt& v, QualType T) {
- // The Environment ensures we always get a persistent APSInt in
- // BasicValueFactory, so we don't need to get the APSInt from
- // BasicValueFactory again.
- assert(!Loc::IsLocType(T));
- return nonloc::SymExprVal(SymMgr.getSymIntExpr(lhs, op, v, T));
-}
-
-NonLoc ValueManager::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
- const SymExpr *rhs, QualType T) {
- assert(SymMgr.getType(lhs) == SymMgr.getType(rhs));
- assert(!Loc::IsLocType(T));
- return nonloc::SymExprVal(SymMgr.getSymSymExpr(lhs, op, rhs, T));
-}
NonLoc NonLoc::MakeIntVal(BasicValueFactory& BasicVals, uint64_t X,
bool isUnsigned) {
@@ -317,84 +270,12 @@
return nonloc::ConcreteInt(BasicVals.getTruthValue(b));
}
-NonLoc ValueManager::makeTruthVal(bool b, QualType T) {
- return nonloc::ConcreteInt(BasicVals.getTruthValue(b, T));
-}
NonLoc NonLoc::MakeCompoundVal(QualType T, llvm::ImmutableList<SVal> Vals,
BasicValueFactory& BasicVals) {
return nonloc::CompoundVal(BasicVals.getCompoundValData(T, Vals));
}
-SVal ValueManager::getRegionValueSymbolVal(const MemRegion* R, QualType T) {
- SymbolRef sym = SymMgr.getRegionValueSymbol(R, T);
-
- if (const TypedRegion* TR = dyn_cast<TypedRegion>(R)) {
- if (T.isNull())
- T = TR->getValueType(SymMgr.getContext());
-
- // If T is of function pointer type, create a CodeTextRegion wrapping a
- // symbol.
- if (T->isFunctionPointerType()) {
- return Loc::MakeVal(MemMgr.getCodeTextRegion(sym, T));
- }
-
- if (Loc::IsLocType(T))
- return Loc::MakeVal(MemMgr.getSymbolicRegion(sym));
-
- // Only handle integers for now.
- if (T->isIntegerType() && T->isScalarType())
- return makeNonLoc(sym);
- }
-
- return UnknownVal();
-}
-
-SVal ValueManager::getConjuredSymbolVal(const Expr* E, unsigned Count) {
- QualType T = E->getType();
- SymbolRef sym = SymMgr.getConjuredSymbol(E, Count);
-
- // If T is of function pointer type, create a CodeTextRegion wrapping a
- // symbol.
- if (T->isFunctionPointerType()) {
- return Loc::MakeVal(MemMgr.getCodeTextRegion(sym, T));
- }
-
- if (Loc::IsLocType(T))
- return Loc::MakeVal(MemMgr.getSymbolicRegion(sym));
-
- if (T->isIntegerType() && T->isScalarType())
- return makeNonLoc(sym);
-
- return UnknownVal();
-}
-
-SVal ValueManager::getConjuredSymbolVal(const Expr* E, QualType T,
- unsigned Count) {
-
- SymbolRef sym = SymMgr.getConjuredSymbol(E, T, Count);
-
- // If T is of function pointer type, create a CodeTextRegion wrapping a
- // symbol.
- if (T->isFunctionPointerType()) {
- return Loc::MakeVal(MemMgr.getCodeTextRegion(sym, T));
- }
-
- if (Loc::IsLocType(T))
- return Loc::MakeVal(MemMgr.getSymbolicRegion(sym));
-
- if (T->isIntegerType() && T->isScalarType())
- return makeNonLoc(sym);
-
- return UnknownVal();
-}
-
-SVal ValueManager::getFunctionPointer(const FunctionDecl* FD) {
- CodeTextRegion* R
- = MemMgr.getCodeTextRegion(FD, Context.getPointerType(FD->getType()));
- return loc::MemRegionVal(R);
-}
-
nonloc::LocAsInteger nonloc::LocAsInteger::Make(BasicValueFactory& Vals, Loc V,
unsigned Bits) {
return LocAsInteger(Vals.getPersistentSValWithData(V, Bits));
Added: cfe/trunk/lib/Analysis/ValueManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ValueManager.cpp?rev=73952&view=auto
==============================================================================
--- cfe/trunk/lib/Analysis/ValueManager.cpp (added)
+++ cfe/trunk/lib/Analysis/ValueManager.cpp Tue Jun 23 01:22:22 2009
@@ -0,0 +1,141 @@
+//== ValueManager.cpp - Aggregate manager of symbols and SVals --*- C++ -*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines ValueManager, a class that manages symbolic values
+// and SVals created for use by GRExprEngine and related classes. It
+// wraps and owns SymbolManager, MemRegionManager, and BasicValueFactory.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Analysis/PathSensitive/ValueManager.h"
+
+using namespace clang;
+using namespace llvm;
+
+//===----------------------------------------------------------------------===//
+// Utility methods for constructing SVals.
+//===----------------------------------------------------------------------===//
+
+SVal ValueManager::makeZeroVal(QualType T) {
+ if (Loc::IsLocType(T))
+ return Loc::MakeNull(BasicVals);
+
+ if (T->isIntegerType())
+ return NonLoc::MakeVal(BasicVals, 0, T);
+
+ // FIXME: Handle floats.
+ // FIXME: Handle structs.
+ return UnknownVal();
+}
+
+SVal ValueManager::makeZeroArrayIndex() {
+ return nonloc::ConcreteInt(BasicVals.getZeroWithPtrWidth(false));
+}
+
+//===----------------------------------------------------------------------===//
+// Utility methods for constructing Non-Locs.
+//===----------------------------------------------------------------------===//
+
+NonLoc ValueManager::makeNonLoc(SymbolRef sym) {
+ return nonloc::SymbolVal(sym);
+}
+
+NonLoc ValueManager::makeIntVal(const APSInt& V) {
+ return nonloc::ConcreteInt(BasicVals.getValue(V));
+}
+
+NonLoc ValueManager::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
+ const APSInt& v, QualType T) {
+ // The Environment ensures we always get a persistent APSInt in
+ // BasicValueFactory, so we don't need to get the APSInt from
+ // BasicValueFactory again.
+ assert(!Loc::IsLocType(T));
+ return nonloc::SymExprVal(SymMgr.getSymIntExpr(lhs, op, v, T));
+}
+
+NonLoc ValueManager::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
+ const SymExpr *rhs, QualType T) {
+ assert(SymMgr.getType(lhs) == SymMgr.getType(rhs));
+ assert(!Loc::IsLocType(T));
+ return nonloc::SymExprVal(SymMgr.getSymSymExpr(lhs, op, rhs, T));
+}
+
+NonLoc ValueManager::makeTruthVal(bool b, QualType T) {
+ return nonloc::ConcreteInt(BasicVals.getTruthValue(b, T));
+}
+
+SVal ValueManager::getRegionValueSymbolVal(const MemRegion* R, QualType T) {
+ SymbolRef sym = SymMgr.getRegionValueSymbol(R, T);
+
+ if (const TypedRegion* TR = dyn_cast<TypedRegion>(R)) {
+ if (T.isNull())
+ T = TR->getValueType(SymMgr.getContext());
+
+ // If T is of function pointer type, create a CodeTextRegion wrapping a
+ // symbol.
+ if (T->isFunctionPointerType()) {
+ return Loc::MakeVal(MemMgr.getCodeTextRegion(sym, T));
+ }
+
+ if (Loc::IsLocType(T))
+ return Loc::MakeVal(MemMgr.getSymbolicRegion(sym));
+
+ // Only handle integers for now.
+ if (T->isIntegerType() && T->isScalarType())
+ return makeNonLoc(sym);
+ }
+
+ return UnknownVal();
+}
+
+SVal ValueManager::getConjuredSymbolVal(const Expr* E, unsigned Count) {
+ QualType T = E->getType();
+ SymbolRef sym = SymMgr.getConjuredSymbol(E, Count);
+
+ // If T is of function pointer type, create a CodeTextRegion wrapping a
+ // symbol.
+ if (T->isFunctionPointerType()) {
+ return Loc::MakeVal(MemMgr.getCodeTextRegion(sym, T));
+ }
+
+ if (Loc::IsLocType(T))
+ return Loc::MakeVal(MemMgr.getSymbolicRegion(sym));
+
+ if (T->isIntegerType() && T->isScalarType())
+ return makeNonLoc(sym);
+
+ return UnknownVal();
+}
+
+SVal ValueManager::getConjuredSymbolVal(const Expr* E, QualType T,
+ unsigned Count) {
+
+ SymbolRef sym = SymMgr.getConjuredSymbol(E, T, Count);
+
+ // If T is of function pointer type, create a CodeTextRegion wrapping a
+ // symbol.
+ if (T->isFunctionPointerType()) {
+ return Loc::MakeVal(MemMgr.getCodeTextRegion(sym, T));
+ }
+
+ if (Loc::IsLocType(T))
+ return Loc::MakeVal(MemMgr.getSymbolicRegion(sym));
+
+ if (T->isIntegerType() && T->isScalarType())
+ return makeNonLoc(sym);
+
+ return UnknownVal();
+}
+
+SVal ValueManager::getFunctionPointer(const FunctionDecl* FD) {
+ CodeTextRegion* R
+ = MemMgr.getCodeTextRegion(FD, Context.getPointerType(FD->getType()));
+ return loc::MemRegionVal(R);
+}
+
More information about the cfe-commits
mailing list