clang  3.7.0
SValBuilder.cpp
Go to the documentation of this file.
1 // SValBuilder.cpp - Basic class for all SValBuilder implementations -*- C++ -*-
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines SValBuilder, the base class for all (complete) SValBuilder
11 // implementations.
12 //
13 //===----------------------------------------------------------------------===//
14 
16 #include "clang/AST/DeclCXX.h"
17 #include "clang/AST/ExprCXX.h"
22 
23 using namespace clang;
24 using namespace ento;
25 
26 //===----------------------------------------------------------------------===//
27 // Basic SVal creation.
28 //===----------------------------------------------------------------------===//
29 
30 void SValBuilder::anchor() { }
31 
33  if (Loc::isLocType(type))
34  return makeNull();
35 
36  if (type->isIntegralOrEnumerationType())
37  return makeIntVal(0, type);
38 
39  // FIXME: Handle floats.
40  // FIXME: Handle structs.
41  return UnknownVal();
42 }
43 
45  const llvm::APSInt& rhs, QualType type) {
46  // The Environment ensures we always get a persistent APSInt in
47  // BasicValueFactory, so we don't need to get the APSInt from
48  // BasicValueFactory again.
49  assert(lhs);
50  assert(!Loc::isLocType(type));
51  return nonloc::SymbolVal(SymMgr.getSymIntExpr(lhs, op, rhs, type));
52 }
53 
54 NonLoc SValBuilder::makeNonLoc(const llvm::APSInt& lhs,
55  BinaryOperator::Opcode op, const SymExpr *rhs,
56  QualType type) {
57  assert(rhs);
58  assert(!Loc::isLocType(type));
59  return nonloc::SymbolVal(SymMgr.getIntSymExpr(lhs, op, rhs, type));
60 }
61 
63  const SymExpr *rhs, QualType type) {
64  assert(lhs && rhs);
65  assert(!Loc::isLocType(type));
66  return nonloc::SymbolVal(SymMgr.getSymSymExpr(lhs, op, rhs, type));
67 }
68 
70  QualType fromTy, QualType toTy) {
71  assert(operand);
72  assert(!Loc::isLocType(toTy));
73  return nonloc::SymbolVal(SymMgr.getCastSymbol(operand, fromTy, toTy));
74 }
75 
77  if (val.isUnknownOrUndef())
78  return val;
79 
80  // Common case: we have an appropriately sized integer.
82  const llvm::APSInt& I = CI->getValue();
83  if (I.getBitWidth() == ArrayIndexWidth && I.isSigned())
84  return val;
85  }
86 
88 }
89 
91  return makeTruthVal(boolean->getValue());
92 }
93 
96  QualType T = region->getValueType();
97 
99  return UnknownVal();
100 
101  SymbolRef sym = SymMgr.getRegionValueSymbol(region);
102 
103  if (Loc::isLocType(T))
105 
106  return nonloc::SymbolVal(sym);
107 }
108 
110  const Expr *Ex,
111  const LocationContext *LCtx,
112  unsigned Count) {
113  QualType T = Ex->getType();
114 
115  // Compute the type of the result. If the expression is not an R-value, the
116  // result should be a location.
117  QualType ExType = Ex->getType();
118  if (Ex->isGLValue())
119  T = LCtx->getAnalysisDeclContext()->getASTContext().getPointerType(ExType);
120 
121  return conjureSymbolVal(SymbolTag, Ex, LCtx, T, Count);
122 }
123 
125  const Expr *expr,
126  const LocationContext *LCtx,
127  QualType type,
128  unsigned count) {
130  return UnknownVal();
131 
132  SymbolRef sym = SymMgr.conjureSymbol(expr, LCtx, type, count, symbolTag);
133 
134  if (Loc::isLocType(type))
136 
137  return nonloc::SymbolVal(sym);
138 }
139 
140 
142  const LocationContext *LCtx,
143  QualType type,
144  unsigned visitCount) {
146  return UnknownVal();
147 
148  SymbolRef sym = SymMgr.conjureSymbol(stmt, LCtx, type, visitCount);
149 
150  if (Loc::isLocType(type))
152 
153  return nonloc::SymbolVal(sym);
154 }
155 
158  const LocationContext *LCtx,
159  unsigned VisitCount) {
160  QualType T = E->getType();
161  assert(Loc::isLocType(T));
163 
164  SymbolRef sym = SymMgr.conjureSymbol(E, LCtx, T, VisitCount);
166 }
167 
169  const MemRegion *region,
170  const Expr *expr, QualType type,
171  unsigned count) {
172  assert(SymbolManager::canSymbolicate(type) && "Invalid metadata symbol type");
173 
174  SymbolRef sym =
175  SymMgr.getMetadataSymbol(region, expr, type, count, symbolTag);
176 
177  if (Loc::isLocType(type))
179 
180  return nonloc::SymbolVal(sym);
181 }
182 
185  const TypedValueRegion *region) {
186  QualType T = region->getValueType();
187 
189  return UnknownVal();
190 
191  SymbolRef sym = SymMgr.getDerivedSymbol(parentSymbol, region);
192 
193  if (Loc::isLocType(T))
195 
196  return nonloc::SymbolVal(sym);
197 }
198 
201 }
202 
204  CanQualType locTy,
205  const LocationContext *locContext,
206  unsigned blockCount) {
207  const BlockTextRegion *BC =
208  MemMgr.getBlockTextRegion(block, locTy, locContext->getAnalysisDeclContext());
209  const BlockDataRegion *BD = MemMgr.getBlockDataRegion(BC, locContext,
210  blockCount);
211  return loc::MemRegionVal(BD);
212 }
213 
214 /// Return a memory region for the 'this' object reference.
216  const StackFrameContext *SFC) {
218  getCXXThisRegion(D->getThisType(getContext()), SFC));
219 }
220 
221 /// Return a memory region for the 'this' object reference.
223  const StackFrameContext *SFC) {
224  const Type *T = D->getTypeForDecl();
226  return loc::MemRegionVal(getRegionManager().getCXXThisRegion(PT, SFC));
227 }
228 
230  E = E->IgnoreParens();
231 
232  switch (E->getStmtClass()) {
233  // Handle expressions that we treat differently from the AST's constant
234  // evaluator.
235  case Stmt::AddrLabelExprClass:
236  return makeLoc(cast<AddrLabelExpr>(E));
237 
238  case Stmt::CXXScalarValueInitExprClass:
239  case Stmt::ImplicitValueInitExprClass:
240  return makeZeroVal(E->getType());
241 
242  case Stmt::ObjCStringLiteralClass: {
243  const ObjCStringLiteral *SL = cast<ObjCStringLiteral>(E);
244  return makeLoc(getRegionManager().getObjCStringRegion(SL));
245  }
246 
247  case Stmt::StringLiteralClass: {
248  const StringLiteral *SL = cast<StringLiteral>(E);
249  return makeLoc(getRegionManager().getStringRegion(SL));
250  }
251 
252  // Fast-path some expressions to avoid the overhead of going through the AST's
253  // constant evaluator
254  case Stmt::CharacterLiteralClass: {
255  const CharacterLiteral *C = cast<CharacterLiteral>(E);
256  return makeIntVal(C->getValue(), C->getType());
257  }
258 
259  case Stmt::CXXBoolLiteralExprClass:
260  return makeBoolVal(cast<CXXBoolLiteralExpr>(E));
261 
262  case Stmt::IntegerLiteralClass:
263  return makeIntVal(cast<IntegerLiteral>(E));
264 
265  case Stmt::ObjCBoolLiteralExprClass:
266  return makeBoolVal(cast<ObjCBoolLiteralExpr>(E));
267 
268  case Stmt::CXXNullPtrLiteralExprClass:
269  return makeNull();
270 
271  case Stmt::ImplicitCastExprClass: {
272  const CastExpr *CE = cast<CastExpr>(E);
273  if (CE->getCastKind() == CK_ArrayToPointerDecay) {
274  Optional<SVal> ArrayVal = getConstantVal(CE->getSubExpr());
275  if (!ArrayVal)
276  return None;
277  return evalCast(*ArrayVal, CE->getType(), CE->getSubExpr()->getType());
278  }
279  // FALLTHROUGH
280  }
281 
282  // If we don't have a special case, fall back to the AST's constant evaluator.
283  default: {
284  // Don't try to come up with a value for materialized temporaries.
285  if (E->isGLValue())
286  return None;
287 
288  ASTContext &Ctx = getContext();
289  llvm::APSInt Result;
290  if (E->EvaluateAsInt(Result, Ctx))
291  return makeIntVal(Result);
292 
293  if (Loc::isLocType(E->getType()))
295  return makeNull();
296 
297  return None;
298  }
299  }
300 }
301 
302 //===----------------------------------------------------------------------===//
303 
306  NonLoc LHS, NonLoc RHS,
307  QualType ResultTy) {
308  if (!State->isTainted(RHS) && !State->isTainted(LHS))
309  return UnknownVal();
310 
311  const SymExpr *symLHS = LHS.getAsSymExpr();
312  const SymExpr *symRHS = RHS.getAsSymExpr();
313  // TODO: When the Max Complexity is reached, we should conjure a symbol
314  // instead of generating an Unknown value and propagate the taint info to it.
315  const unsigned MaxComp = 10000; // 100000 28X
316 
317  if (symLHS && symRHS &&
318  (symLHS->computeComplexity() + symRHS->computeComplexity()) < MaxComp)
319  return makeNonLoc(symLHS, Op, symRHS, ResultTy);
320 
321  if (symLHS && symLHS->computeComplexity() < MaxComp)
323  return makeNonLoc(symLHS, Op, rInt->getValue(), ResultTy);
324 
325  if (symRHS && symRHS->computeComplexity() < MaxComp)
327  return makeNonLoc(lInt->getValue(), Op, symRHS, ResultTy);
328 
329  return UnknownVal();
330 }
331 
332 
334  SVal lhs, SVal rhs, QualType type) {
335 
336  if (lhs.isUndef() || rhs.isUndef())
337  return UndefinedVal();
338 
339  if (lhs.isUnknown() || rhs.isUnknown())
340  return UnknownVal();
341 
342  if (Optional<Loc> LV = lhs.getAs<Loc>()) {
343  if (Optional<Loc> RV = rhs.getAs<Loc>())
344  return evalBinOpLL(state, op, *LV, *RV, type);
345 
346  return evalBinOpLN(state, op, *LV, rhs.castAs<NonLoc>(), type);
347  }
348 
349  if (Optional<Loc> RV = rhs.getAs<Loc>()) {
350  // Support pointer arithmetic where the addend is on the left
351  // and the pointer on the right.
352  assert(op == BO_Add);
353 
354  // Commute the operands.
355  return evalBinOpLN(state, op, *RV, lhs.castAs<NonLoc>(), type);
356  }
357 
358  return evalBinOpNN(state, op, lhs.castAs<NonLoc>(), rhs.castAs<NonLoc>(),
359  type);
360 }
361 
364  DefinedOrUnknownSVal rhs) {
365  return evalBinOp(state, BO_EQ, lhs, rhs, getConditionType())
367 }
368 
369 /// Recursively check if the pointer types are equal modulo const, volatile,
370 /// and restrict qualifiers. Also, assume that all types are similar to 'void'.
371 /// Assumes the input types are canonical.
373  QualType FromTy) {
374  while (Context.UnwrapSimilarPointerTypes(ToTy, FromTy)) {
375  Qualifiers Quals1, Quals2;
376  ToTy = Context.getUnqualifiedArrayType(ToTy, Quals1);
377  FromTy = Context.getUnqualifiedArrayType(FromTy, Quals2);
378 
379  // Make sure that non-cvr-qualifiers the other qualifiers (e.g., address
380  // spaces) are identical.
381  Quals1.removeCVRQualifiers();
382  Quals2.removeCVRQualifiers();
383  if (Quals1 != Quals2)
384  return false;
385  }
386 
387  // If we are casting to void, the 'From' value can be used to represent the
388  // 'To' value.
389  if (ToTy->isVoidType())
390  return true;
391 
392  if (ToTy != FromTy)
393  return false;
394 
395  return true;
396 }
397 
398 // FIXME: should rewrite according to the cast kind.
399 SVal SValBuilder::evalCast(SVal val, QualType castTy, QualType originalTy) {
400  castTy = Context.getCanonicalType(castTy);
401  originalTy = Context.getCanonicalType(originalTy);
402  if (val.isUnknownOrUndef() || castTy == originalTy)
403  return val;
404 
405  if (castTy->isBooleanType()) {
406  if (val.isUnknownOrUndef())
407  return val;
408  if (val.isConstant())
409  return makeTruthVal(!val.isZeroConstant(), castTy);
410  if (!Loc::isLocType(originalTy) &&
411  !originalTy->isIntegralOrEnumerationType() &&
412  !originalTy->isMemberPointerType())
413  return UnknownVal();
414  if (SymbolRef Sym = val.getAsSymbol(true)) {
416  // FIXME: If we had a state here, we could see if the symbol is known to
417  // be zero, but we don't.
418  return makeNonLoc(Sym, BO_NE, BVF.getValue(0, Sym->getType()), castTy);
419  }
420  // Loc values are not always true, they could be weakly linked functions.
421  if (Optional<Loc> L = val.getAs<Loc>())
422  return evalCastFromLoc(*L, castTy);
423 
424  Loc L = val.castAs<nonloc::LocAsInteger>().getLoc();
425  return evalCastFromLoc(L, castTy);
426  }
427 
428  // For const casts, casts to void, just propagate the value.
429  if (!castTy->isVariableArrayType() && !originalTy->isVariableArrayType())
431  Context.getPointerType(originalTy)))
432  return val;
433 
434  // Check for casts from pointers to integers.
435  if (castTy->isIntegralOrEnumerationType() && Loc::isLocType(originalTy))
436  return evalCastFromLoc(val.castAs<Loc>(), castTy);
437 
438  // Check for casts from integers to pointers.
439  if (Loc::isLocType(castTy) && originalTy->isIntegralOrEnumerationType()) {
441  if (const MemRegion *R = LV->getLoc().getAsRegion()) {
442  StoreManager &storeMgr = StateMgr.getStoreManager();
443  R = storeMgr.castRegion(R, castTy);
444  return R ? SVal(loc::MemRegionVal(R)) : UnknownVal();
445  }
446  return LV->getLoc();
447  }
448  return dispatchCast(val, castTy);
449  }
450 
451  // Just pass through function and block pointers.
452  if (originalTy->isBlockPointerType() || originalTy->isFunctionPointerType()) {
453  assert(Loc::isLocType(castTy));
454  return val;
455  }
456 
457  // Check for casts from array type to another type.
458  if (const ArrayType *arrayT =
459  dyn_cast<ArrayType>(originalTy.getCanonicalType())) {
460  // We will always decay to a pointer.
461  QualType elemTy = arrayT->getElementType();
462  val = StateMgr.ArrayToPointer(val.castAs<Loc>(), elemTy);
463 
464  // Are we casting from an array to a pointer? If so just pass on
465  // the decayed value.
466  if (castTy->isPointerType() || castTy->isReferenceType())
467  return val;
468 
469  // Are we casting from an array to an integer? If so, cast the decayed
470  // pointer value to an integer.
471  assert(castTy->isIntegralOrEnumerationType());
472 
473  // FIXME: Keep these here for now in case we decide soon that we
474  // need the original decayed type.
475  // QualType elemTy = cast<ArrayType>(originalTy)->getElementType();
476  // QualType pointerTy = C.getPointerType(elemTy);
477  return evalCastFromLoc(val.castAs<Loc>(), castTy);
478  }
479 
480  // Check for casts from a region to a specific type.
481  if (const MemRegion *R = val.getAsRegion()) {
482  // Handle other casts of locations to integers.
483  if (castTy->isIntegralOrEnumerationType())
484  return evalCastFromLoc(loc::MemRegionVal(R), castTy);
485 
486  // FIXME: We should handle the case where we strip off view layers to get
487  // to a desugared type.
488  if (!Loc::isLocType(castTy)) {
489  // FIXME: There can be gross cases where one casts the result of a function
490  // (that returns a pointer) to some other value that happens to fit
491  // within that pointer value. We currently have no good way to
492  // model such operations. When this happens, the underlying operation
493  // is that the caller is reasoning about bits. Conceptually we are
494  // layering a "view" of a location on top of those bits. Perhaps
495  // we need to be more lazy about mutual possible views, even on an
496  // SVal? This may be necessary for bit-level reasoning as well.
497  return UnknownVal();
498  }
499 
500  // We get a symbolic function pointer for a dereference of a function
501  // pointer, but it is of function type. Example:
502 
503  // struct FPRec {
504  // void (*my_func)(int * x);
505  // };
506  //
507  // int bar(int x);
508  //
509  // int f1_a(struct FPRec* foo) {
510  // int x;
511  // (*foo->my_func)(&x);
512  // return bar(x)+1; // no-warning
513  // }
514 
515  assert(Loc::isLocType(originalTy) || originalTy->isFunctionType() ||
516  originalTy->isBlockPointerType() || castTy->isReferenceType());
517 
518  StoreManager &storeMgr = StateMgr.getStoreManager();
519 
520  // Delegate to store manager to get the result of casting a region to a
521  // different type. If the MemRegion* returned is NULL, this expression
522  // Evaluates to UnknownVal.
523  R = storeMgr.castRegion(R, castTy);
524  return R ? SVal(loc::MemRegionVal(R)) : UnknownVal();
525  }
526 
527  return dispatchCast(val, castTy);
528 }
const SymExpr * getAsSymExpr() const
Definition: SVals.cpp:128
CastKind getCastKind() const
Definition: Expr.h:2709
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
Definition: ASTMatchers.h:1110
TypedValueRegion - An abstract class representing regions having a typed value.
Definition: MemRegion.h:498
nonloc::ConcreteInt makeIntVal(const IntegerLiteral *integer)
Definition: SValBuilder.h:232
DefinedSVal getBlockPointer(const BlockDecl *block, CanQualType locTy, const LocationContext *locContext, unsigned blockCount)
ASTContext & getASTContext() const
MemRegion - The root abstract class for all memory regions.
Definition: MemRegion.h:77
bool getValue() const
Definition: ExprCXX.h:446
bool isMemberPointerType() const
Definition: Type.h:5256
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
Definition: ASTMatchers.h:826
const IntSymExpr * getIntSymExpr(const llvm::APSInt &lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
virtual QualType getValueType() const =0
SVal makeSymExprValNN(ProgramStateRef state, BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy)
Constructs a symbolic expression for two non-location values.
ProgramStateManager & StateMgr
Definition: SValBuilder.h:45
bool isBooleanType() const
Definition: Type.h:5489
bool isBlockPointerType() const
Definition: Type.h:5238
SVal evalCast(SVal val, QualType castTy, QualType originalType)
Value representing integer constant.
Definition: SVals.h:339
MemRegionManager MemMgr
Manages the creation of memory regions.
Definition: SValBuilder.h:43
virtual SVal dispatchCast(SVal val, QualType castTy)=0
loc::MemRegionVal getCXXThis(const CXXMethodDecl *D, const StackFrameContext *SFC)
Return a memory region for the 'this' object reference.
NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType type)
Definition: SValBuilder.cpp:44
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
Definition: DeclCXX.cpp:1592
unsigned getValue() const
Definition: Expr.h:1349
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
Definition: Expr.cpp:3225
bool isZeroConstant() const
Definition: SVals.cpp:186
Defines the clang::Expr interface and subclasses for C++ expressions.
bool isVoidType() const
Definition: Type.h:5426
const MemRegion * castRegion(const MemRegion *region, QualType CastToTy)
Definition: Store.cpp:62
Symbolic value. These values used to capture symbolic execution of the program.
Definition: SymbolManager.h:42
const SymbolDerived * getDerivedSymbol(SymbolRef parentSymbol, const TypedValueRegion *R)
virtual SVal evalCastFromNonLoc(NonLoc val, QualType castTy)=0
virtual SVal evalBinOpLN(ProgramStateRef state, BinaryOperator::Opcode op, Loc lhs, NonLoc rhs, QualType resultTy)=0
MemRegionManager & getRegionManager()
Definition: SValBuilder.h:140
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:89
LineState State
unsigned computeComplexity() const
bool isReferenceType() const
Definition: Type.h:5241
static bool canSymbolicate(QualType T)
const BlockDataRegion * getBlockDataRegion(const BlockTextRegion *bc, const LocationContext *lc, unsigned blockCount)
Definition: MemRegion.cpp:855
AnalysisDeclContext * getAnalysisDeclContext() const
DefinedOrUnknownSVal getDerivedRegionValueSymbolVal(SymbolRef parentSymbol, const TypedValueRegion *region)
Expr * getSubExpr()
Definition: Expr.h:2713
const FunctionTextRegion * getFunctionTextRegion(const NamedDecl *FD)
Definition: MemRegion.cpp:929
const SymbolicRegion * getSymbolicRegion(SymbolRef Sym)
Retrieve or create a "symbolic" memory region.
Definition: MemRegion.cpp:941
static bool isLocType(QualType T)
Definition: SVals.h:291
const BlockTextRegion * getBlockTextRegion(const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC)
Definition: MemRegion.cpp:934
BinaryOperatorKind
bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2)
bool isUnknownOrUndef() const
Definition: SVals.h:125
const SymIntExpr * getSymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType t)
DefinedOrUnknownSVal getRegionValueSymbolVal(const TypedValueRegion *region)
Make a unique symbol for value of region.
Definition: SValBuilder.cpp:95
DefinedSVal getFunctionPointer(const FunctionDecl *func)
bool isConstant() const
Definition: SVals.cpp:174
ASTContext * Context
nonloc::ConcreteInt makeBoolVal(const ObjCBoolLiteralExpr *boolean)
Definition: SValBuilder.h:238
Loc makeLoc(SymbolRef sym)
Definition: SValBuilder.h:300
bool isFunctionPointerType() const
Definition: Type.h:5250
DefinedOrUnknownSVal makeZeroVal(QualType type)
Construct an SVal representing '0' for the specified type.
Definition: SValBuilder.cpp:32
const Type * getTypeForDecl() const
Definition: Decl.h:2557
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
Definition: SVals.h:86
bool isVariableArrayType() const
Definition: Type.h:5280
const QualType ArrayIndexTy
The scalar type to use for array indices.
Definition: SValBuilder.h:48
virtual SVal evalBinOpLL(ProgramStateRef state, BinaryOperator::Opcode op, Loc lhs, Loc rhs, QualType resultTy)=0
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
SVal evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op, SVal lhs, SVal rhs, QualType type)
bool isGLValue() const
Definition: Expr.h:253
The result type of a method or function.
QualType getConditionType() const
Definition: SValBuilder.h:126
void removeCVRQualifiers(unsigned mask)
Definition: Type.h:253
const SymbolCast * getCastSymbol(const SymExpr *Operand, QualType From, QualType To)
const SymSymExpr * getSymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Definition: Type.h:5476
SymbolManager SymMgr
Manages the creation of symbols.
Definition: SValBuilder.h:40
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag, const Expr *expr, const LocationContext *LCtx, unsigned count)
Create a new symbol with a unique 'name'.
virtual SVal evalCastFromLoc(Loc val, QualType castTy)=0
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1717
ASTContext & getContext()
Definition: SValBuilder.h:121
const SymbolRegionValue * getRegionValueSymbol(const TypedValueRegion *R)
Make a unique symbol for MemRegion R according to its kind.
const SymbolMetadata * getMetadataSymbol(const MemRegion *R, const Stmt *S, QualType T, unsigned VisitCount, const void *SymbolTag=nullptr)
Creates a metadata symbol associated with a specific region.
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
Definition: Expr.h:666
static bool shouldBeModeledWithNoOp(ASTContext &Context, QualType ToTy, QualType FromTy)
bool isUndef() const
Definition: SVals.h:121
DefinedOrUnknownSVal getConjuredHeapSymbolVal(const Expr *E, const LocationContext *LCtx, unsigned Count)
Conjure a symbol representing heap allocated memory region.
virtual SVal evalBinOpNN(ProgramStateRef state, BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy)=0
const unsigned ArrayIndexWidth
The width of the scalar type used for array indices.
Definition: SValBuilder.h:51
QualType getType() const
Definition: Expr.h:125
const SymbolicRegion * getSymbolicHeapRegion(SymbolRef sym)
Return a unique symbolic region belonging to heap memory space.
Definition: MemRegion.cpp:945
SVal ArrayToPointer(Loc Array, QualType ElementTy)
Definition: ProgramState.h:519
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchers.h:1639
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
DefinedSVal getMetadataSymbolVal(const void *symbolTag, const MemRegion *region, const Expr *expr, QualType type, unsigned count)
Represents symbolic expression.
Definition: SVals.h:313
const MemRegion * getAsRegion() const
Definition: SVals.cpp:135
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:1855
SVal convertToArrayIndex(SVal val)
Definition: SValBuilder.cpp:76
const SymbolConjured * conjureSymbol(const Stmt *E, const LocationContext *LCtx, QualType T, unsigned VisitCount, const void *SymbolTag=nullptr)
BasicValueFactory & getBasicValueFactory()
Definition: SValBuilder.h:134
QualType getCanonicalType() const
Definition: Type.h:5055
bool isUnknown() const
Definition: SVals.h:117
bool isFunctionType() const
Definition: Type.h:5229
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a C++ struct/union/class.
Definition: DeclCXX.h:285
DefinedOrUnknownSVal evalEQ(ProgramStateRef state, DefinedOrUnknownSVal lhs, DefinedOrUnknownSVal rhs)
Optional< SVal > getConstantVal(const Expr *E)
SymbolRef getAsSymbol(bool IncludeBaseRegions=false) const
If this SVal wraps a symbol return that SymbolRef. Otherwise, return 0.
Definition: SVals.cpp:111
nonloc::ConcreteInt makeTruthVal(bool b, QualType type)
Definition: SValBuilder.h:288
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:434
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
Definition: SVals.h:75
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
Expr * IgnoreParens() LLVM_READONLY
Definition: Expr.cpp:2408
bool isPointerType() const
Definition: Type.h:5232