26 #include "llvm/ADT/Optional.h" 27 #include "llvm/Support/Casting.h" 28 #include "llvm/Support/Compiler.h" 29 #include "llvm/Support/ErrorHandling.h" 30 #include "llvm/Support/raw_ostream.h" 33 using namespace clang;
47 if (isa<SymbolConjured>(sym))
53 if (
const auto *SR = dyn_cast<SymbolicRegion>(R)) {
55 if (isa<SymbolConjured>(sym))
67 if (
const auto *FD = dyn_cast<FunctionDecl>(CTR->getDecl()))
71 if (
auto X = getAs<nonloc::PointerToMember>()) {
72 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(
X->getDecl()))
88 return X->getLoc().getAsLocSymbol(IncludeBaseRegions);
95 return SymR->getSymbol();
109 while (
const auto *SR = dyn_cast<SubRegion>(R)) {
110 if (
const auto *SymR = dyn_cast<SymbolicRegion>(SR))
111 return SymR->getSymbol();
113 R = SR->getSuperRegion();
130 return X->getSymbol();
139 return X->getSymbol();
153 return X->getRegion();
156 return X->getLoc().getAsRegion();
163 return R ? R->
StripCasts(StripBaseCasts) :
nullptr;
175 return getPTMData().isNull();
179 const auto PTMD = this->getPTMData();
223 return getAs<nonloc::ConcreteInt>() || getAs<loc::ConcreteInt>();
228 return LV->getValue() == I;
230 return NV->getValue() == I;
245 const llvm::APSInt*
X =
298 case UndefinedValKind:
306 case nonloc::ConcreteIntKind: {
307 const auto &
Value = castAs<nonloc::ConcreteInt>().
getValue();
308 os <<
Value <<
' ' << (
Value.isSigned() ?
'S' :
'U')
309 <<
Value.getBitWidth() <<
'b';
312 case nonloc::SymbolValKind:
313 os << castAs<nonloc::SymbolVal>().getSymbol();
316 case nonloc::LocAsIntegerKind: {
321 case nonloc::CompoundValKind: {
323 os <<
"compoundVal{";
325 for (
const auto &I : C) {
327 os <<
' '; first =
false;
337 case nonloc::LazyCompoundValKind: {
339 os <<
"lazyCompoundVal{" <<
const_cast<void *
>(C.
getStore())
344 case nonloc::PointerToMemberKind: {
345 os <<
"pointerToMember{";
347 castAs<nonloc::PointerToMember>();
351 for (
const auto &I : CastRes) {
353 os <<
' '; first =
false;
358 os << (*I).getType().getAsString();
365 assert(
false &&
"Pretty-printed not implemented for this NonLoc.");
372 case loc::ConcreteIntKind:
373 os << castAs<loc::ConcreteInt>().
getValue().getZExtValue() <<
" (Loc)";
375 case loc::GotoLabelKind:
376 os <<
"&&" << castAs<loc::GotoLabel>().getLabel()->getName();
378 case loc::MemRegionValKind:
379 os << '&' << castAs<loc::MemRegionVal>().getRegion()->getString();
382 llvm_unreachable(
"Pretty-printing not implemented for this Loc.");
Represents a function declaration or definition.
TypedValueRegion - An abstract class representing regions having a typed value.
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
MemRegion - The root abstract class for all memory regions.
SymbolRef getLocSymbolInBase() const
Get the symbol in the SVal or its base region.
C Language Family Type Representation.
llvm::ImmutableList< const CXXBaseSpecifier * >::iterator iterator
Value representing integer constant.
const DeclaratorDecl * getDecl() const
SymbolRef getAsLocSymbol(bool IncludeBaseRegions=false) const
If this SVal is a location and wraps a symbol, return that SymbolRef.
const SymbolicRegion * getSymbolicBase() const
If this is a symbolic region, returns the region.
void dumpToStream(raw_ostream &OS) const
ConcreteInt evalComplement(SValBuilder &svalBuilder) const
Value representing pointer-to-member.
llvm::ImmutableList< SVal >::iterator iterator
unsigned getNumBits() const
bool isNullMemberPointer() const
const SymExpr * getAsSymbolicExpression() const
getAsSymbolicExpression - If this Sval wraps a symbolic expression then return that expression...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void dumpToStream(raw_ostream &Out) const
void dumpToStream(raw_ostream &Out) const
SymbolRef getAsSymbol(bool IncludeBaseRegions=false) const
If this SVal wraps a symbol return that SymbolRef.
bool hasConjuredSymbol() const
hasConjuredSymbol - If this SVal wraps a conjured symbol, return true;
Represents a ValueDecl that came out of a declarator.
unsigned getSubKind() const
const RegionTy * getAs() const
SymbolicRegion - A special, "non-concrete" region.
const MemRegion * stripCasts(bool StripBaseCasts=true) const
Get the underlining region and strip casts.
static SVal getValue(SVal val, SValBuilder &svalBuilder)
bool isComparisonOp() const
FunctionCodeRegion - A region that represents code texts of function.
const MemRegion * getAsRegion() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
const llvm::APSInt * evalAPSInt(BinaryOperator::Opcode Op, const llvm::APSInt &V1, const llvm::APSInt &V2)
BaseKind getBaseKind() const
Dataflow Directional Tag Classes.
bool isZeroConstant() const
const void * getStore() const
SVal evalBinOp(BasicValueFactory &BasicVals, BinaryOperator::Opcode Op, const ConcreteInt &R) const
const MemRegion * StripCasts(bool StripBaseAndDerivedCasts=true) const
const llvm::APSInt & getValue() const
const FunctionDecl * getAsFunctionDecl() const
getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a CodeTextRegion wrapping a FunctionDecl...
BasicValueFactory & getBasicValueFactory()
SVal evalBinOp(SValBuilder &svalBuilder, BinaryOperator::Opcode Op, const ConcreteInt &R) const
llvm::PointerUnion< const DeclaratorDecl *, const PointerToMemberData * > PTMDataType
const SymExpr * getAsSymExpr() const
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
const TypedValueRegion * getRegion() const
std::string getQualifiedNameAsString() const
ConcreteInt evalMinus(SValBuilder &svalBuilder) const
const llvm::APSInt & getValue() const