2008-02-01 03:34:24 +08:00
|
|
|
//= RValues.cpp - Abstract RValues for Path-Sens. Value Tracking -*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2008-10-17 13:57:07 +08:00
|
|
|
// This file defines SVal, Loc, and NonLoc, classes that represent
|
2008-02-01 03:34:24 +08:00
|
|
|
// abstract r-values for use with path-sensitive value tracking.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-08-16 06:09:50 +08:00
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
|
2011-01-25 08:04:03 +08:00
|
|
|
#include "clang/AST/ExprObjC.h"
|
2008-08-11 13:35:13 +08:00
|
|
|
#include "clang/Basic/IdentifierTable.h"
|
2012-12-02 01:12:56 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2016-12-16 05:27:06 +08:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
2008-02-01 03:34:24 +08:00
|
|
|
using namespace clang;
|
2010-12-23 15:20:52 +08:00
|
|
|
using namespace ento;
|
2008-02-01 03:34:24 +08:00
|
|
|
using llvm::APSInt;
|
|
|
|
|
2008-02-15 07:25:54 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2009-03-26 11:35:11 +08:00
|
|
|
// Symbol iteration within an SVal.
|
2008-02-15 07:25:54 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-02-01 03:34:24 +08:00
|
|
|
|
2009-03-26 11:35:11 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Utility methods.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2008-02-07 06:50:25 +08:00
|
|
|
|
2009-05-12 18:10:00 +08:00
|
|
|
bool SVal::hasConjuredSymbol() const {
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<nonloc::SymbolVal> SV = getAs<nonloc::SymbolVal>()) {
|
2009-05-12 18:10:00 +08:00
|
|
|
SymbolRef sym = SV->getSymbol();
|
|
|
|
if (isa<SymbolConjured>(sym))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<loc::MemRegionVal> RV = getAs<loc::MemRegionVal>()) {
|
2009-05-12 18:10:00 +08:00
|
|
|
const MemRegion *R = RV->getRegion();
|
|
|
|
if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(R)) {
|
|
|
|
SymbolRef sym = SR->getSymbol();
|
|
|
|
if (isa<SymbolConjured>(sym))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-28 12:49:15 +08:00
|
|
|
const FunctionDecl *SVal::getAsFunctionDecl() const {
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>()) {
|
2009-04-20 13:24:46 +08:00
|
|
|
const MemRegion* R = X->getRegion();
|
2016-01-13 21:49:29 +08:00
|
|
|
if (const FunctionCodeRegion *CTR = R->getAs<FunctionCodeRegion>())
|
2012-09-18 03:13:56 +08:00
|
|
|
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CTR->getDecl()))
|
|
|
|
return FD;
|
2009-04-20 13:24:46 +08:00
|
|
|
}
|
|
|
|
|
2016-12-16 05:27:06 +08:00
|
|
|
if (auto X = getAs<nonloc::PointerToMember>()) {
|
|
|
|
if (const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(X->getDecl()))
|
|
|
|
return MD;
|
|
|
|
}
|
2014-05-27 10:45:47 +08:00
|
|
|
return nullptr;
|
2009-04-20 13:24:46 +08:00
|
|
|
}
|
|
|
|
|
2012-03-17 07:24:16 +08:00
|
|
|
/// \brief If this SVal is a location (subclasses Loc) and wraps a symbol,
|
|
|
|
/// return that SymbolRef. Otherwise return 0.
|
|
|
|
///
|
|
|
|
/// Implicit casts (ex: void* -> char*) can turn Symbolic region into Element
|
|
|
|
/// region. If that is the case, gets the underlining region.
|
2013-04-20 09:15:42 +08:00
|
|
|
/// When IncludeBaseRegions is set to true and the SubRegion is non-symbolic,
|
|
|
|
/// the first symbolic parent region is returned.
|
|
|
|
SymbolRef SVal::getAsLocSymbol(bool IncludeBaseRegions) const {
|
2012-03-17 07:24:16 +08:00
|
|
|
// FIXME: should we consider SymbolRef wrapped in CodeTextRegion?
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<nonloc::LocAsInteger> X = getAs<nonloc::LocAsInteger>())
|
2010-08-21 19:00:26 +08:00
|
|
|
return X->getLoc().getAsLocSymbol();
|
|
|
|
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>()) {
|
2013-04-20 09:15:42 +08:00
|
|
|
const MemRegion *R = X->getRegion();
|
|
|
|
if (const SymbolicRegion *SymR = IncludeBaseRegions ?
|
|
|
|
R->getSymbolicBase() :
|
|
|
|
dyn_cast<SymbolicRegion>(R->StripCasts()))
|
2009-07-30 05:43:22 +08:00
|
|
|
return SymR->getSymbol();
|
2009-03-04 06:06:47 +08:00
|
|
|
}
|
2014-05-27 10:45:47 +08:00
|
|
|
return nullptr;
|
2009-03-04 06:06:47 +08:00
|
|
|
}
|
|
|
|
|
2010-03-10 12:58:55 +08:00
|
|
|
/// Get the symbol in the SVal or its base region.
|
|
|
|
SymbolRef SVal::getLocSymbolInBase() const {
|
2013-02-21 06:23:23 +08:00
|
|
|
Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>();
|
2010-03-10 12:58:55 +08:00
|
|
|
|
|
|
|
if (!X)
|
2014-05-27 10:45:47 +08:00
|
|
|
return nullptr;
|
2010-03-10 12:58:55 +08:00
|
|
|
|
|
|
|
const MemRegion *R = X->getRegion();
|
|
|
|
|
|
|
|
while (const SubRegion *SR = dyn_cast<SubRegion>(R)) {
|
|
|
|
if (const SymbolicRegion *SymR = dyn_cast<SymbolicRegion>(SR))
|
|
|
|
return SymR->getSymbol();
|
|
|
|
else
|
|
|
|
R = SR->getSuperRegion();
|
|
|
|
}
|
|
|
|
|
2014-05-27 10:45:47 +08:00
|
|
|
return nullptr;
|
2010-03-10 12:58:55 +08:00
|
|
|
}
|
|
|
|
|
2011-12-07 07:12:27 +08:00
|
|
|
// TODO: The next 3 functions have to be simplified.
|
2012-03-17 07:24:16 +08:00
|
|
|
|
|
|
|
/// \brief If this SVal wraps a symbol return that SymbolRef.
|
2013-04-20 09:15:42 +08:00
|
|
|
/// Otherwise, return 0.
|
|
|
|
///
|
|
|
|
/// Casts are ignored during lookup.
|
|
|
|
/// \param IncludeBaseRegions The boolean that controls whether the search
|
|
|
|
/// should continue to the base regions if the region is not symbolic.
|
2017-10-12 17:42:12 +08:00
|
|
|
SymbolRef SVal::getAsSymbol(bool IncludeBaseRegions) const {
|
2012-03-17 07:24:16 +08:00
|
|
|
// FIXME: should we consider SymbolRef wrapped in CodeTextRegion?
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<nonloc::SymbolVal> X = getAs<nonloc::SymbolVal>())
|
2009-03-04 06:06:47 +08:00
|
|
|
return X->getSymbol();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2017-10-12 17:42:12 +08:00
|
|
|
return getAsLocSymbol(IncludeBaseRegions);
|
2009-03-04 06:06:47 +08:00
|
|
|
}
|
|
|
|
|
2009-03-26 11:35:11 +08:00
|
|
|
/// getAsSymbolicExpression - If this Sval wraps a symbolic expression then
|
|
|
|
/// return that expression. Otherwise return NULL.
|
|
|
|
const SymExpr *SVal::getAsSymbolicExpression() const {
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<nonloc::SymbolVal> X = getAs<nonloc::SymbolVal>())
|
2011-12-06 02:58:30 +08:00
|
|
|
return X->getSymbol();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-03-26 11:35:11 +08:00
|
|
|
return getAsSymbol();
|
|
|
|
}
|
2009-06-30 19:52:40 +08:00
|
|
|
|
2011-11-18 06:57:01 +08:00
|
|
|
const SymExpr* SVal::getAsSymExpr() const {
|
|
|
|
const SymExpr* Sym = getAsSymbol();
|
|
|
|
if (!Sym)
|
|
|
|
Sym = getAsSymbolicExpression();
|
|
|
|
return Sym;
|
|
|
|
}
|
|
|
|
|
2009-06-30 19:52:40 +08:00
|
|
|
const MemRegion *SVal::getAsRegion() const {
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>())
|
2009-06-30 19:52:40 +08:00
|
|
|
return X->getRegion();
|
|
|
|
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<nonloc::LocAsInteger> X = getAs<nonloc::LocAsInteger>())
|
2010-01-11 14:52:53 +08:00
|
|
|
return X->getLoc().getAsRegion();
|
|
|
|
|
2014-05-27 10:45:47 +08:00
|
|
|
return nullptr;
|
2009-06-30 19:52:40 +08:00
|
|
|
}
|
2009-03-26 11:35:11 +08:00
|
|
|
|
2012-08-14 06:11:34 +08:00
|
|
|
const MemRegion *loc::MemRegionVal::stripCasts(bool StripBaseCasts) const {
|
2009-07-30 02:14:27 +08:00
|
|
|
const MemRegion *R = getRegion();
|
2014-05-27 10:45:47 +08:00
|
|
|
return R ? R->StripCasts(StripBaseCasts) : nullptr;
|
2009-07-30 02:14:27 +08:00
|
|
|
}
|
|
|
|
|
2010-02-05 10:26:30 +08:00
|
|
|
const void *nonloc::LazyCompoundVal::getStore() const {
|
|
|
|
return static_cast<const LazyCompoundValData*>(Data)->getStore();
|
2009-08-06 09:20:57 +08:00
|
|
|
}
|
|
|
|
|
2013-02-02 03:49:57 +08:00
|
|
|
const TypedValueRegion *nonloc::LazyCompoundVal::getRegion() const {
|
2009-08-06 09:20:57 +08:00
|
|
|
return static_cast<const LazyCompoundValData*>(Data)->getRegion();
|
|
|
|
}
|
|
|
|
|
2016-12-16 05:27:06 +08:00
|
|
|
const DeclaratorDecl *nonloc::PointerToMember::getDecl() const {
|
|
|
|
const auto PTMD = this->getPTMData();
|
|
|
|
if (PTMD.isNull())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
const DeclaratorDecl *DD = nullptr;
|
|
|
|
if (PTMD.is<const DeclaratorDecl *>())
|
|
|
|
DD = PTMD.get<const DeclaratorDecl *>();
|
|
|
|
else
|
|
|
|
DD = PTMD.get<const PointerToMemberData *>()->getDeclaratorDecl();
|
|
|
|
|
|
|
|
return DD;
|
|
|
|
}
|
|
|
|
|
2008-10-31 02:01:28 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Other Iterators.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
nonloc::CompoundVal::iterator nonloc::CompoundVal::begin() const {
|
|
|
|
return getValue()->begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
nonloc::CompoundVal::iterator nonloc::CompoundVal::end() const {
|
|
|
|
return getValue()->end();
|
|
|
|
}
|
|
|
|
|
2016-12-16 05:27:06 +08:00
|
|
|
nonloc::PointerToMember::iterator nonloc::PointerToMember::begin() const {
|
|
|
|
const PTMDataType PTMD = getPTMData();
|
|
|
|
if (PTMD.is<const DeclaratorDecl *>())
|
|
|
|
return nonloc::PointerToMember::iterator();
|
|
|
|
return PTMD.get<const PointerToMemberData *>()->begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
nonloc::PointerToMember::iterator nonloc::PointerToMember::end() const {
|
|
|
|
const PTMDataType PTMD = getPTMData();
|
|
|
|
if (PTMD.is<const DeclaratorDecl *>())
|
|
|
|
return nonloc::PointerToMember::iterator();
|
|
|
|
return PTMD.get<const PointerToMemberData *>()->end();
|
|
|
|
}
|
|
|
|
|
2008-07-18 23:54:51 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Useful predicates.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-11-09 14:52:44 +08:00
|
|
|
bool SVal::isConstant() const {
|
2013-02-20 13:52:05 +08:00
|
|
|
return getAs<nonloc::ConcreteInt>() || getAs<loc::ConcreteInt>();
|
2009-11-09 14:52:44 +08:00
|
|
|
}
|
|
|
|
|
2010-07-07 05:43:29 +08:00
|
|
|
bool SVal::isConstant(int I) const {
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<loc::ConcreteInt> LV = getAs<loc::ConcreteInt>())
|
2013-02-20 13:52:05 +08:00
|
|
|
return LV->getValue() == I;
|
2013-02-21 06:23:23 +08:00
|
|
|
if (Optional<nonloc::ConcreteInt> NV = getAs<nonloc::ConcreteInt>())
|
2013-02-20 13:52:05 +08:00
|
|
|
return NV->getValue() == I;
|
|
|
|
return false;
|
2008-07-18 23:54:51 +08:00
|
|
|
}
|
|
|
|
|
2010-07-07 05:43:29 +08:00
|
|
|
bool SVal::isZeroConstant() const {
|
|
|
|
return isConstant(0);
|
|
|
|
}
|
|
|
|
|
2008-07-18 23:54:51 +08:00
|
|
|
|
2008-02-07 06:50:25 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2008-10-17 13:57:07 +08:00
|
|
|
// Transfer function dispatch for Non-Locs.
|
2008-02-07 06:50:25 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
SVal nonloc::ConcreteInt::evalBinOp(SValBuilder &svalBuilder,
|
2009-06-26 08:05:51 +08:00
|
|
|
BinaryOperator::Opcode Op,
|
2009-09-09 23:08:12 +08:00
|
|
|
const nonloc::ConcreteInt& R) const {
|
2008-07-18 23:59:33 +08:00
|
|
|
const llvm::APSInt* X =
|
2010-12-02 15:49:45 +08:00
|
|
|
svalBuilder.getBasicValueFactory().evalAPSInt(Op, getValue(), R.getValue());
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-02-29 04:32:03 +08:00
|
|
|
if (X)
|
2008-10-17 13:57:07 +08:00
|
|
|
return nonloc::ConcreteInt(*X);
|
2008-02-29 04:32:03 +08:00
|
|
|
else
|
|
|
|
return UndefinedVal();
|
2008-02-07 06:50:25 +08:00
|
|
|
}
|
|
|
|
|
2008-10-17 13:57:07 +08:00
|
|
|
nonloc::ConcreteInt
|
2010-12-02 15:49:45 +08:00
|
|
|
nonloc::ConcreteInt::evalComplement(SValBuilder &svalBuilder) const {
|
|
|
|
return svalBuilder.makeIntVal(~getValue());
|
2008-02-07 06:50:25 +08:00
|
|
|
}
|
|
|
|
|
2010-12-02 15:49:45 +08:00
|
|
|
nonloc::ConcreteInt
|
|
|
|
nonloc::ConcreteInt::evalMinus(SValBuilder &svalBuilder) const {
|
|
|
|
return svalBuilder.makeIntVal(-getValue());
|
2008-02-05 00:58:30 +08:00
|
|
|
}
|
|
|
|
|
2008-02-07 06:50:25 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2008-10-17 13:57:07 +08:00
|
|
|
// Transfer function dispatch for Locs.
|
2008-02-07 06:50:25 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2008-02-05 00:58:30 +08:00
|
|
|
|
2010-12-02 05:57:22 +08:00
|
|
|
SVal loc::ConcreteInt::evalBinOp(BasicValueFactory& BasicVals,
|
2008-10-31 01:53:23 +08:00
|
|
|
BinaryOperator::Opcode Op,
|
|
|
|
const loc::ConcreteInt& R) const {
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2013-03-23 09:21:29 +08:00
|
|
|
assert(BinaryOperator::isComparisonOp(Op) || Op == BO_Sub);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2013-03-23 09:21:29 +08:00
|
|
|
const llvm::APSInt *X = BasicVals.evalAPSInt(Op, getValue(), R.getValue());
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-02-29 04:32:03 +08:00
|
|
|
if (X)
|
2013-03-23 09:21:29 +08:00
|
|
|
return nonloc::ConcreteInt(*X);
|
2008-02-29 04:32:03 +08:00
|
|
|
else
|
|
|
|
return UndefinedVal();
|
2008-02-01 03:34:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Pretty-Printing.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-01-30 03:38:18 +08:00
|
|
|
LLVM_DUMP_METHOD void SVal::dump() const { dumpToStream(llvm::errs()); }
|
2008-02-22 02:02:17 +08:00
|
|
|
|
2011-08-13 07:37:29 +08:00
|
|
|
void SVal::dumpToStream(raw_ostream &os) const {
|
2009-09-09 23:08:12 +08:00
|
|
|
switch (getBaseKind()) {
|
2016-01-13 21:49:29 +08:00
|
|
|
case UnknownValKind:
|
2010-09-15 11:13:30 +08:00
|
|
|
os << "Unknown";
|
2009-09-09 23:08:12 +08:00
|
|
|
break;
|
2008-10-24 14:00:12 +08:00
|
|
|
case NonLocKind:
|
2013-02-20 13:52:05 +08:00
|
|
|
castAs<NonLoc>().dumpToStream(os);
|
2009-09-09 23:08:12 +08:00
|
|
|
break;
|
2008-10-24 14:00:12 +08:00
|
|
|
case LocKind:
|
2013-02-20 13:52:05 +08:00
|
|
|
castAs<Loc>().dumpToStream(os);
|
2009-09-09 23:08:12 +08:00
|
|
|
break;
|
2016-01-13 21:49:29 +08:00
|
|
|
case UndefinedValKind:
|
2009-07-14 07:53:06 +08:00
|
|
|
os << "Undefined";
|
2009-09-09 23:08:12 +08:00
|
|
|
break;
|
2008-10-24 14:00:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 07:37:29 +08:00
|
|
|
void NonLoc::dumpToStream(raw_ostream &os) const {
|
2009-09-09 23:08:12 +08:00
|
|
|
switch (getSubKind()) {
|
2010-12-23 10:42:31 +08:00
|
|
|
case nonloc::ConcreteIntKind: {
|
2013-02-20 13:52:05 +08:00
|
|
|
const nonloc::ConcreteInt& C = castAs<nonloc::ConcreteInt>();
|
2010-12-23 10:42:46 +08:00
|
|
|
if (C.getValue().isUnsigned())
|
|
|
|
os << C.getValue().getZExtValue();
|
|
|
|
else
|
|
|
|
os << C.getValue().getSExtValue();
|
|
|
|
os << ' ' << (C.getValue().isUnsigned() ? 'U' : 'S')
|
2010-12-23 10:42:31 +08:00
|
|
|
<< C.getValue().getBitWidth() << 'b';
|
2009-09-09 23:08:12 +08:00
|
|
|
break;
|
2010-12-23 10:42:31 +08:00
|
|
|
}
|
2011-12-06 02:58:30 +08:00
|
|
|
case nonloc::SymbolValKind: {
|
2013-02-20 13:52:05 +08:00
|
|
|
os << castAs<nonloc::SymbolVal>().getSymbol();
|
2008-10-24 14:00:12 +08:00
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
}
|
2008-10-24 14:00:12 +08:00
|
|
|
case nonloc::LocAsIntegerKind: {
|
2013-02-20 13:52:05 +08:00
|
|
|
const nonloc::LocAsInteger& C = castAs<nonloc::LocAsInteger>();
|
2009-07-14 07:53:06 +08:00
|
|
|
os << C.getLoc() << " [as " << C.getNumBits() << " bit integer]";
|
2008-10-24 14:00:12 +08:00
|
|
|
break;
|
|
|
|
}
|
2008-10-31 02:01:28 +08:00
|
|
|
case nonloc::CompoundValKind: {
|
2013-02-20 13:52:05 +08:00
|
|
|
const nonloc::CompoundVal& C = castAs<nonloc::CompoundVal>();
|
2009-07-15 04:21:36 +08:00
|
|
|
os << "compoundVal{";
|
2008-10-31 02:35:10 +08:00
|
|
|
bool first = true;
|
|
|
|
for (nonloc::CompoundVal::iterator I=C.begin(), E=C.end(); I!=E; ++I) {
|
2009-09-09 23:08:12 +08:00
|
|
|
if (first) {
|
2009-07-14 07:53:06 +08:00
|
|
|
os << ' '; first = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
os << ", ";
|
|
|
|
|
|
|
|
(*I).dumpToStream(os);
|
2008-10-31 02:35:10 +08:00
|
|
|
}
|
2009-07-15 04:21:36 +08:00
|
|
|
os << "}";
|
2008-10-31 02:01:28 +08:00
|
|
|
break;
|
2009-08-06 09:20:57 +08:00
|
|
|
}
|
|
|
|
case nonloc::LazyCompoundValKind: {
|
2013-02-20 13:52:05 +08:00
|
|
|
const nonloc::LazyCompoundVal &C = castAs<nonloc::LazyCompoundVal>();
|
2010-04-20 00:39:44 +08:00
|
|
|
os << "lazyCompoundVal{" << const_cast<void *>(C.getStore())
|
|
|
|
<< ',' << C.getRegion()
|
2009-08-06 09:20:57 +08:00
|
|
|
<< '}';
|
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
}
|
2016-12-16 05:27:06 +08:00
|
|
|
case nonloc::PointerToMemberKind: {
|
|
|
|
os << "pointerToMember{";
|
|
|
|
const nonloc::PointerToMember &CastRes =
|
|
|
|
castAs<nonloc::PointerToMember>();
|
|
|
|
if (CastRes.getDecl())
|
|
|
|
os << "|" << CastRes.getDecl()->getQualifiedNameAsString() << "|";
|
|
|
|
bool first = true;
|
|
|
|
for (const auto &I : CastRes) {
|
|
|
|
if (first) {
|
|
|
|
os << ' '; first = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
os << ", ";
|
|
|
|
|
|
|
|
os << (*I).getType().getAsString();
|
|
|
|
}
|
|
|
|
|
|
|
|
os << '}';
|
|
|
|
break;
|
|
|
|
}
|
2008-10-24 14:00:12 +08:00
|
|
|
default:
|
|
|
|
assert (false && "Pretty-printed not implemented for this NonLoc.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 07:37:29 +08:00
|
|
|
void Loc::dumpToStream(raw_ostream &os) const {
|
2009-09-09 23:08:12 +08:00
|
|
|
switch (getSubKind()) {
|
2008-10-24 14:00:12 +08:00
|
|
|
case loc::ConcreteIntKind:
|
2013-02-20 13:52:05 +08:00
|
|
|
os << castAs<loc::ConcreteInt>().getValue().getZExtValue() << " (Loc)";
|
2009-09-09 23:08:12 +08:00
|
|
|
break;
|
2008-10-24 14:00:12 +08:00
|
|
|
case loc::GotoLabelKind:
|
2013-02-20 13:52:05 +08:00
|
|
|
os << "&&" << castAs<loc::GotoLabel>().getLabel()->getName();
|
2008-10-24 14:00:12 +08:00
|
|
|
break;
|
2016-01-13 21:49:29 +08:00
|
|
|
case loc::MemRegionValKind:
|
2013-02-20 13:52:05 +08:00
|
|
|
os << '&' << castAs<loc::MemRegionVal>().getRegion()->getString();
|
2009-09-09 23:08:12 +08:00
|
|
|
break;
|
2008-10-24 14:00:12 +08:00
|
|
|
default:
|
2011-09-23 13:06:16 +08:00
|
|
|
llvm_unreachable("Pretty-printing not implemented for this Loc.");
|
2008-10-24 14:00:12 +08:00
|
|
|
}
|
|
|
|
}
|