24#include "llvm/Support/Compiler.h" 
   25#include "llvm/Support/ErrorHandling.h" 
   26#include "llvm/Support/raw_ostream.h" 
   32void SymExpr::anchor() {}
 
   44  Sym->dumpToStream(
OS);
 
 
   49                                     const llvm::APSInt &
Value) {
 
   50  if (
Value.isUnsigned())
 
   54  if (
Value.isUnsigned())
 
 
   64  os << 
'(' << ToTy << 
") (";
 
   65  Operand->dumpToStream(os);
 
 
   74  Operand->dumpToStream(os);
 
 
   81  if (Elem.getParent() == 
nullptr ||
 
   82      Elem.getIndexInBlock() >= Elem.getParent()->size())
 
   84  switch (Elem->getKind()) {
 
   87      return Init->getInit();
 
   93    return Elem->castAs<
CFGScopeEnd>().getTriggerStmt();
 
 
  125    os << 
", S" << S->getID(LCtx->getDecl()->getASTContext());
 
  128  os << 
", #" << Count << 
'}';
 
 
  144void SymbolData::anchor() {}
 
  163  assert(!itr.empty() && 
"attempting to iterate on an 'end' iterator");
 
 
  169  assert(!itr.empty() && 
"attempting to dereference an 'end' iterator");
 
 
  173void SymExpr::symbol_iterator::expand() {
 
  174  const SymExpr *SE = itr.pop_back_val();
 
  177    case SymExpr::SymbolRegionValueKind:
 
  178    case SymExpr::SymbolConjuredKind:
 
  179    case SymExpr::SymbolDerivedKind:
 
  180    case SymExpr::SymbolExtentKind:
 
  181    case SymExpr::SymbolMetadataKind:
 
  183    case SymExpr::SymbolCastKind:
 
  186    case SymExpr::UnarySymExprKind:
 
  189    case SymExpr::SymIntExprKind:
 
  192    case SymExpr::IntSymExprKind:
 
  195    case SymExpr::SymSymExprKind: {
 
  197      itr.push_back(x->getLHS());
 
  198      itr.push_back(x->getRHS());
 
  202  llvm_unreachable(
"unhandled expansion case");
 
  210  return R->getValueType();
 
 
  214  ASTContext &Ctx = R->getMemRegionManager().getContext();
 
 
  223  return R->getValueType();
 
 
  227  T = 
T.getCanonicalType();
 
  232  if (
T->isIntegralOrEnumerationType())
 
  235  if (
T->isRecordType() && !
T->isUnionType())
 
 
  243  auto &dependencies = SymbolDependencies[Primary];
 
  245    dependencies = std::make_unique<SymbolRefSmallVectorTy>();
 
 
  252  SymbolDependTy::const_iterator I = SymbolDependencies.find(Primary);
 
  253  if (I == SymbolDependencies.end())
 
  255  return I->second.get();
 
 
  258void SymbolReaper::markDependentsLive(
SymbolRef sym) {
 
  260  SymbolMapTy::iterator LI = TheLiving.find(sym);
 
  261  assert(LI != TheLiving.end() && 
"The primary symbol is not live.");
 
  262  if (LI->second == HaveMarkedDependents)
 
  264  LI->second = HaveMarkedDependents;
 
  267    for (
const auto I : *Deps) {
 
  268      if (TheLiving.contains(I))
 
  276  TheLiving[sym] = NotProcessed;
 
  277  markDependentsLive(sym);
 
 
  290  for (
auto SR = dyn_cast<SubRegion>(region); SR;
 
  291       SR = dyn_cast<SubRegion>(SR->getSuperRegion())) {
 
  292    if (
const auto ER = dyn_cast<ElementRegion>(SR)) {
 
  293      SVal Idx = ER->getIndex();
 
 
  302    MetadataInUse.insert(sym);
 
 
  311  if (LiveRegionRoots.count(MR))
 
  314  if (
const auto *SR = dyn_cast<SymbolicRegion>(MR))
 
  315    return isLive(SR->getSymbol());
 
  317  if (
const auto *VR = dyn_cast<VarRegion>(MR))
 
 
  327bool SymbolReaper::isLazilyCopiedRegion(
const MemRegion *MR)
 const {
 
  332bool SymbolReaper::isReadableRegion(
const MemRegion *MR) {
 
  333  return isLiveRegion(MR) || isLazilyCopiedRegion(MR);
 
  337  if (TheLiving.count(sym)) {
 
  338    markDependentsLive(sym);
 
  345  case SymExpr::SymbolRegionValueKind:
 
  348  case SymExpr::SymbolConjuredKind:
 
  351  case SymExpr::SymbolDerivedKind:
 
  354  case SymExpr::SymbolExtentKind:
 
  357  case SymExpr::SymbolMetadataKind:
 
  358    KnownLive = MetadataInUse.count(sym) &&
 
  361      MetadataInUse.erase(sym);
 
  363  case SymExpr::SymIntExprKind:
 
  366  case SymExpr::IntSymExprKind:
 
  369  case SymExpr::SymSymExprKind:
 
  373  case SymExpr::SymbolCastKind:
 
  376  case SymExpr::UnarySymExprKind:
 
 
  395    if (LCtx->isParentOf(ELCtx))
 
 
  418  if (VarContext == CurrentContext) {
 
  431    if (!includeStoreBindings)
 
  434    unsigned &cachedQuery =
 
  435      const_cast<SymbolReaper *
>(
this)->includedRegionCache[VR];
 
  438      return cachedQuery == 1;
 
  442    if (
Store store = reapedStore.getStore()) {
 
  444        reapedStore.getStoreManager().includedInBindings(store, VR);
 
  445      cachedQuery = hasRegion ? 1 : 2;
 
  452  return VarContext->
isParentOf(CurrentContext);
 
 
Defines the clang::ASTContext interface.
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
static const MemRegion * getRegion(const CallEvent &Call, const MutexDescriptor &Descriptor, bool IsLock)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
StringRef getOpcodeStr() const
BinaryOperatorKind Opcode
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
Represents a function call that returns a C++ object by value.
Represents C++ constructor call.
Represents C++ object destructor generated from a call to delete.
Represents C++ base or member initializer from constructor's initialization list.
CXXCtorInitializer * getInitializer() const
Represents the point where the lifetime of an automatic object ends.
Represents the point where a loop ends.
Represents C++ allocator call.
Represents beginning of a scope implicitly generated by the compiler on encountering a CompoundStmt.
Represents end of a scope implicitly generated by the compiler after the last Stmt in a CompoundStmt'...
Represents C++ object destructor implicitly generated at the end of full expression for temporary obj...
This represents one expression.
bool isLive(const CFGBlock *B, const VarDecl *D)
Return true if a variable is live at the end of a specified block.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
bool isParentOf(const LocationContext *LC) const
const StackFrameContext * getStackFrame() const
A (possibly-)qualified type.
It represents a stack frame of the call stack (based on CallEvent).
Stmt - This represents one statement.
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
static void dumpToStreamImpl(raw_ostream &os, const SymExpr *Value)
static bool isLocType(QualType T)
MemRegion - The root abstract class for all memory regions.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getBaseRegion() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
llvm::iterator_range< SymExpr::symbol_iterator > symbols() const
Iterator over symbols that the current symbol depends on.
symbol_iterator()=default
bool operator!=(const symbol_iterator &X) const
symbol_iterator & operator++()
bool operator==(const symbol_iterator &X) const
const SymExpr * operator*()
virtual void dumpToStream(raw_ostream &os) const
SymExpr(Kind k, SymbolID Sym)
virtual void dump() const
SymbolID getSymbolID() const
Get a unique identifier for this symbol.
void dumpToStream(raw_ostream &os) const override
const Stmt * getStmt() const
StringRef getKindStr() const override
Get a string representation of the kind of the region.
void dumpToStream(raw_ostream &os) const override
QualType getType() const override
LLVM_ATTRIBUTE_RETURNS_NONNULL SymbolRef getParentSymbol() const
StringRef getKindStr() const override
Get a string representation of the kind of the region.
void dumpToStream(raw_ostream &os) const override
QualType getType() const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const TypedValueRegion * getRegion() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const SubRegion * getRegion() const
void dumpToStream(raw_ostream &os) const override
QualType getType() const override
StringRef getKindStr() const override
Get a string representation of the kind of the region.
void addSymbolDependency(const SymbolRef Primary, const SymbolRef Dependent)
Add artificial symbol dependency.
const SymbolRefSmallVectorTy * getDependentSymbols(const SymbolRef Primary)
static bool canSymbolicate(QualType T)
void markLive(SymbolRef sym)
Unconditionally marks a symbol as live.
void markElementIndicesLive(const MemRegion *region)
SymbolReaper(const StackFrameContext *Ctx, const Stmt *s, SymbolManager &symmgr, StoreManager &storeMgr)
Construct a reaper object, which removes everything which is not live before we execute statement s i...
void markInUse(SymbolRef sym)
Marks a symbol as important to a checker.
bool isLiveRegion(const MemRegion *region)
void markLazilyCopied(const MemRegion *region)
bool isLive(SymbolRef sym)
void dumpToStream(raw_ostream &os) const override
QualType getType() const override
StringRef getKindStr() const override
Get a string representation of the kind of the region.
void dumpToStream(raw_ostream &os) const override
const VarDecl * getDecl() const override=0
const StackFrameContext * getStackFrame() const
It might return null.
SmallVector< SymbolRef, 2 > SymbolRefSmallVectorTy
const SymExpr * SymbolRef
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
const FunctionProtoType * T
U cast(CodeGen::Address addr)