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();
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 const auto PTMD = this->getPTMData();
219 return getAs<nonloc::ConcreteInt>() || getAs<loc::ConcreteInt>();
224 return LV->getValue() == I;
226 return NV->getValue() == I;
241 const llvm::APSInt*
X =
294 case UndefinedValKind:
302 case nonloc::ConcreteIntKind: {
303 const auto &
Value = castAs<nonloc::ConcreteInt>().
getValue();
304 os <<
Value <<
' ' << (
Value.isSigned() ?
'S' :
'U')
305 <<
Value.getBitWidth() <<
'b';
308 case nonloc::SymbolValKind:
309 os << castAs<nonloc::SymbolVal>().getSymbol();
312 case nonloc::LocAsIntegerKind: {
317 case nonloc::CompoundValKind: {
319 os <<
"compoundVal{";
321 for (
const auto &I : C) {
323 os <<
' '; first =
false;
333 case nonloc::LazyCompoundValKind: {
335 os <<
"lazyCompoundVal{" <<
const_cast<void *
>(C.
getStore())
340 case nonloc::PointerToMemberKind: {
341 os <<
"pointerToMember{";
343 castAs<nonloc::PointerToMember>();
347 for (
const auto &I : CastRes) {
349 os <<
' '; first =
false;
354 os << (*I).getType().getAsString();
361 assert(
false &&
"Pretty-printed not implemented for this NonLoc.");
368 case loc::ConcreteIntKind:
369 os << castAs<loc::ConcreteInt>().
getValue().getZExtValue() <<
" (Loc)";
371 case loc::GotoLabelKind:
372 os <<
"&&" << castAs<loc::GotoLabel>().getLabel()->getName();
374 case loc::MemRegionValKind:
375 os << '&' << castAs<loc::MemRegionVal>().getRegion()->getString();
378 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
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
const MemRegion * StripCasts(bool StripBaseCasts=true) 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 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