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 15 #include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h" 16 #include "clang/AST/DeclCXX.h" 17 #include "clang/AST/ExprCXX.h" 18 #include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h" 19 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" 20 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" 21 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" 22 23 using namespace clang; 24 using namespace ento; 25 26 //===----------------------------------------------------------------------===// 27 // Basic SVal creation. 28 //===----------------------------------------------------------------------===// 29 30 void SValBuilder::anchor() { } 31 32 DefinedOrUnknownSVal SValBuilder::makeZeroVal(QualType type) { 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 44 NonLoc SValBuilder::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, 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 62 NonLoc SValBuilder::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op, 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 69 NonLoc SValBuilder::makeNonLoc(const SymExpr *operand, 70 QualType fromTy, QualType toTy) { 71 assert(operand); 72 assert(!Loc::isLocType(toTy)); 73 return nonloc::SymbolVal(SymMgr.getCastSymbol(operand, fromTy, toTy)); 74 } 75 76 SVal SValBuilder::convertToArrayIndex(SVal val) { 77 if (val.isUnknownOrUndef()) 78 return val; 79 80 // Common case: we have an appropriately sized integer. 81 if (Optional<nonloc::ConcreteInt> CI = val.getAs<nonloc::ConcreteInt>()) { 82 const llvm::APSInt& I = CI->getValue(); 83 if (I.getBitWidth() == ArrayIndexWidth && I.isSigned()) 84 return val; 85 } 86 87 return evalCastFromNonLoc(val.castAs<NonLoc>(), ArrayIndexTy); 88 } 89 90 nonloc::ConcreteInt SValBuilder::makeBoolVal(const CXXBoolLiteralExpr *boolean){ 91 return makeTruthVal(boolean->getValue()); 92 } 93 94 DefinedOrUnknownSVal 95 SValBuilder::getRegionValueSymbolVal(const TypedValueRegion* region) { 96 QualType T = region->getValueType(); 97 98 if (T->isNullPtrType()) 99 return makeZeroVal(T); 100 101 if (!SymbolManager::canSymbolicate(T)) 102 return UnknownVal(); 103 104 SymbolRef sym = SymMgr.getRegionValueSymbol(region); 105 106 if (Loc::isLocType(T)) 107 return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym)); 108 109 return nonloc::SymbolVal(sym); 110 } 111 112 DefinedOrUnknownSVal SValBuilder::conjureSymbolVal(const void *SymbolTag, 113 const Expr *Ex, 114 const LocationContext *LCtx, 115 unsigned Count) { 116 QualType T = Ex->getType(); 117 118 if (T->isNullPtrType()) 119 return makeZeroVal(T); 120 121 // Compute the type of the result. If the expression is not an R-value, the 122 // result should be a location. 123 QualType ExType = Ex->getType(); 124 if (Ex->isGLValue()) 125 T = LCtx->getAnalysisDeclContext()->getASTContext().getPointerType(ExType); 126 127 return conjureSymbolVal(SymbolTag, Ex, LCtx, T, Count); 128 } 129 130 DefinedOrUnknownSVal SValBuilder::conjureSymbolVal(const void *symbolTag, 131 const Expr *expr, 132 const LocationContext *LCtx, 133 QualType type, 134 unsigned count) { 135 if (type->isNullPtrType()) 136 return makeZeroVal(type); 137 138 if (!SymbolManager::canSymbolicate(type)) 139 return UnknownVal(); 140 141 SymbolRef sym = SymMgr.conjureSymbol(expr, LCtx, type, count, symbolTag); 142 143 if (Loc::isLocType(type)) 144 return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym)); 145 146 return nonloc::SymbolVal(sym); 147 } 148 149 150 DefinedOrUnknownSVal SValBuilder::conjureSymbolVal(const Stmt *stmt, 151 const LocationContext *LCtx, 152 QualType type, 153 unsigned visitCount) { 154 if (type->isNullPtrType()) 155 return makeZeroVal(type); 156 157 if (!SymbolManager::canSymbolicate(type)) 158 return UnknownVal(); 159 160 SymbolRef sym = SymMgr.conjureSymbol(stmt, LCtx, type, visitCount); 161 162 if (Loc::isLocType(type)) 163 return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym)); 164 165 return nonloc::SymbolVal(sym); 166 } 167 168 DefinedOrUnknownSVal 169 SValBuilder::getConjuredHeapSymbolVal(const Expr *E, 170 const LocationContext *LCtx, 171 unsigned VisitCount) { 172 QualType T = E->getType(); 173 assert(Loc::isLocType(T)); 174 assert(SymbolManager::canSymbolicate(T)); 175 if (T->isNullPtrType()) 176 return makeZeroVal(T); 177 178 SymbolRef sym = SymMgr.conjureSymbol(E, LCtx, T, VisitCount); 179 return loc::MemRegionVal(MemMgr.getSymbolicHeapRegion(sym)); 180 } 181 182 DefinedSVal SValBuilder::getMetadataSymbolVal(const void *symbolTag, 183 const MemRegion *region, 184 const Expr *expr, QualType type, 185 const LocationContext *LCtx, 186 unsigned count) { 187 assert(SymbolManager::canSymbolicate(type) && "Invalid metadata symbol type"); 188 189 SymbolRef sym = 190 SymMgr.getMetadataSymbol(region, expr, type, LCtx, count, symbolTag); 191 192 if (Loc::isLocType(type)) 193 return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym)); 194 195 return nonloc::SymbolVal(sym); 196 } 197 198 DefinedOrUnknownSVal 199 SValBuilder::getDerivedRegionValueSymbolVal(SymbolRef parentSymbol, 200 const TypedValueRegion *region) { 201 QualType T = region->getValueType(); 202 203 if (T->isNullPtrType()) 204 return makeZeroVal(T); 205 206 if (!SymbolManager::canSymbolicate(T)) 207 return UnknownVal(); 208 209 SymbolRef sym = SymMgr.getDerivedSymbol(parentSymbol, region); 210 211 if (Loc::isLocType(T)) 212 return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym)); 213 214 return nonloc::SymbolVal(sym); 215 } 216 217 DefinedSVal SValBuilder::getFunctionPointer(const FunctionDecl *func) { 218 return loc::MemRegionVal(MemMgr.getFunctionCodeRegion(func)); 219 } 220 221 DefinedSVal SValBuilder::getBlockPointer(const BlockDecl *block, 222 CanQualType locTy, 223 const LocationContext *locContext, 224 unsigned blockCount) { 225 const BlockCodeRegion *BC = 226 MemMgr.getBlockCodeRegion(block, locTy, locContext->getAnalysisDeclContext()); 227 const BlockDataRegion *BD = MemMgr.getBlockDataRegion(BC, locContext, 228 blockCount); 229 return loc::MemRegionVal(BD); 230 } 231 232 /// Return a memory region for the 'this' object reference. 233 loc::MemRegionVal SValBuilder::getCXXThis(const CXXMethodDecl *D, 234 const StackFrameContext *SFC) { 235 return loc::MemRegionVal(getRegionManager(). 236 getCXXThisRegion(D->getThisType(getContext()), SFC)); 237 } 238 239 /// Return a memory region for the 'this' object reference. 240 loc::MemRegionVal SValBuilder::getCXXThis(const CXXRecordDecl *D, 241 const StackFrameContext *SFC) { 242 const Type *T = D->getTypeForDecl(); 243 QualType PT = getContext().getPointerType(QualType(T, 0)); 244 return loc::MemRegionVal(getRegionManager().getCXXThisRegion(PT, SFC)); 245 } 246 247 Optional<SVal> SValBuilder::getConstantVal(const Expr *E) { 248 E = E->IgnoreParens(); 249 250 switch (E->getStmtClass()) { 251 // Handle expressions that we treat differently from the AST's constant 252 // evaluator. 253 case Stmt::AddrLabelExprClass: 254 return makeLoc(cast<AddrLabelExpr>(E)); 255 256 case Stmt::CXXScalarValueInitExprClass: 257 case Stmt::ImplicitValueInitExprClass: 258 return makeZeroVal(E->getType()); 259 260 case Stmt::ObjCStringLiteralClass: { 261 const ObjCStringLiteral *SL = cast<ObjCStringLiteral>(E); 262 return makeLoc(getRegionManager().getObjCStringRegion(SL)); 263 } 264 265 case Stmt::StringLiteralClass: { 266 const StringLiteral *SL = cast<StringLiteral>(E); 267 return makeLoc(getRegionManager().getStringRegion(SL)); 268 } 269 270 // Fast-path some expressions to avoid the overhead of going through the AST's 271 // constant evaluator 272 case Stmt::CharacterLiteralClass: { 273 const CharacterLiteral *C = cast<CharacterLiteral>(E); 274 return makeIntVal(C->getValue(), C->getType()); 275 } 276 277 case Stmt::CXXBoolLiteralExprClass: 278 return makeBoolVal(cast<CXXBoolLiteralExpr>(E)); 279 280 case Stmt::TypeTraitExprClass: { 281 const TypeTraitExpr *TE = cast<TypeTraitExpr>(E); 282 return makeTruthVal(TE->getValue(), TE->getType()); 283 } 284 285 case Stmt::IntegerLiteralClass: 286 return makeIntVal(cast<IntegerLiteral>(E)); 287 288 case Stmt::ObjCBoolLiteralExprClass: 289 return makeBoolVal(cast<ObjCBoolLiteralExpr>(E)); 290 291 case Stmt::CXXNullPtrLiteralExprClass: 292 return makeNull(); 293 294 case Stmt::ImplicitCastExprClass: { 295 const CastExpr *CE = cast<CastExpr>(E); 296 switch (CE->getCastKind()) { 297 default: 298 break; 299 case CK_ArrayToPointerDecay: 300 case CK_BitCast: { 301 const Expr *SE = CE->getSubExpr(); 302 Optional<SVal> Val = getConstantVal(SE); 303 if (!Val) 304 return None; 305 return evalCast(*Val, CE->getType(), SE->getType()); 306 } 307 } 308 // FALLTHROUGH 309 } 310 311 // If we don't have a special case, fall back to the AST's constant evaluator. 312 default: { 313 // Don't try to come up with a value for materialized temporaries. 314 if (E->isGLValue()) 315 return None; 316 317 ASTContext &Ctx = getContext(); 318 llvm::APSInt Result; 319 if (E->EvaluateAsInt(Result, Ctx)) 320 return makeIntVal(Result); 321 322 if (Loc::isLocType(E->getType())) 323 if (E->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNotNull)) 324 return makeNull(); 325 326 return None; 327 } 328 } 329 } 330 331 //===----------------------------------------------------------------------===// 332 333 SVal SValBuilder::makeSymExprValNN(ProgramStateRef State, 334 BinaryOperator::Opcode Op, 335 NonLoc LHS, NonLoc RHS, 336 QualType ResultTy) { 337 if (!State->isTainted(RHS) && !State->isTainted(LHS)) 338 return UnknownVal(); 339 340 const SymExpr *symLHS = LHS.getAsSymExpr(); 341 const SymExpr *symRHS = RHS.getAsSymExpr(); 342 // TODO: When the Max Complexity is reached, we should conjure a symbol 343 // instead of generating an Unknown value and propagate the taint info to it. 344 const unsigned MaxComp = 10000; // 100000 28X 345 346 if (symLHS && symRHS && 347 (symLHS->computeComplexity() + symRHS->computeComplexity()) < MaxComp) 348 return makeNonLoc(symLHS, Op, symRHS, ResultTy); 349 350 if (symLHS && symLHS->computeComplexity() < MaxComp) 351 if (Optional<nonloc::ConcreteInt> rInt = RHS.getAs<nonloc::ConcreteInt>()) 352 return makeNonLoc(symLHS, Op, rInt->getValue(), ResultTy); 353 354 if (symRHS && symRHS->computeComplexity() < MaxComp) 355 if (Optional<nonloc::ConcreteInt> lInt = LHS.getAs<nonloc::ConcreteInt>()) 356 return makeNonLoc(lInt->getValue(), Op, symRHS, ResultTy); 357 358 return UnknownVal(); 359 } 360 361 362 SVal SValBuilder::evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op, 363 SVal lhs, SVal rhs, QualType type) { 364 365 if (lhs.isUndef() || rhs.isUndef()) 366 return UndefinedVal(); 367 368 if (lhs.isUnknown() || rhs.isUnknown()) 369 return UnknownVal(); 370 371 if (lhs.getAs<nonloc::LazyCompoundVal>() || 372 rhs.getAs<nonloc::LazyCompoundVal>()) { 373 return UnknownVal(); 374 } 375 376 if (Optional<Loc> LV = lhs.getAs<Loc>()) { 377 if (Optional<Loc> RV = rhs.getAs<Loc>()) 378 return evalBinOpLL(state, op, *LV, *RV, type); 379 380 return evalBinOpLN(state, op, *LV, rhs.castAs<NonLoc>(), type); 381 } 382 383 if (Optional<Loc> RV = rhs.getAs<Loc>()) { 384 // Support pointer arithmetic where the addend is on the left 385 // and the pointer on the right. 386 assert(op == BO_Add); 387 388 // Commute the operands. 389 return evalBinOpLN(state, op, *RV, lhs.castAs<NonLoc>(), type); 390 } 391 392 return evalBinOpNN(state, op, lhs.castAs<NonLoc>(), rhs.castAs<NonLoc>(), 393 type); 394 } 395 396 DefinedOrUnknownSVal SValBuilder::evalEQ(ProgramStateRef state, 397 DefinedOrUnknownSVal lhs, 398 DefinedOrUnknownSVal rhs) { 399 return evalBinOp(state, BO_EQ, lhs, rhs, getConditionType()) 400 .castAs<DefinedOrUnknownSVal>(); 401 } 402 403 /// Recursively check if the pointer types are equal modulo const, volatile, 404 /// and restrict qualifiers. Also, assume that all types are similar to 'void'. 405 /// Assumes the input types are canonical. 406 static bool shouldBeModeledWithNoOp(ASTContext &Context, QualType ToTy, 407 QualType FromTy) { 408 while (Context.UnwrapSimilarPointerTypes(ToTy, FromTy)) { 409 Qualifiers Quals1, Quals2; 410 ToTy = Context.getUnqualifiedArrayType(ToTy, Quals1); 411 FromTy = Context.getUnqualifiedArrayType(FromTy, Quals2); 412 413 // Make sure that non-cvr-qualifiers the other qualifiers (e.g., address 414 // spaces) are identical. 415 Quals1.removeCVRQualifiers(); 416 Quals2.removeCVRQualifiers(); 417 if (Quals1 != Quals2) 418 return false; 419 } 420 421 // If we are casting to void, the 'From' value can be used to represent the 422 // 'To' value. 423 if (ToTy->isVoidType()) 424 return true; 425 426 if (ToTy != FromTy) 427 return false; 428 429 return true; 430 } 431 432 // Handles casts of type CK_IntegralCast. 433 // At the moment, this function will redirect to evalCast, except when the range 434 // of the original value is known to be greater than the max of the target type. 435 SVal SValBuilder::evalIntegralCast(ProgramStateRef state, SVal val, 436 QualType castTy, QualType originalTy) { 437 438 // No truncations if target type is big enough. 439 if (getContext().getTypeSize(castTy) >= getContext().getTypeSize(originalTy)) 440 return evalCast(val, castTy, originalTy); 441 442 const SymExpr *se = val.getAsSymbolicExpression(); 443 if (!se) // Let evalCast handle non symbolic expressions. 444 return evalCast(val, castTy, originalTy); 445 446 // Find the maximum value of the target type. 447 APSIntType ToType(getContext().getTypeSize(castTy), 448 castTy->isUnsignedIntegerType()); 449 llvm::APSInt ToTypeMax = ToType.getMaxValue(); 450 NonLoc ToTypeMaxVal = 451 makeIntVal(ToTypeMax.isUnsigned() ? ToTypeMax.getZExtValue() 452 : ToTypeMax.getSExtValue(), 453 castTy) 454 .castAs<NonLoc>(); 455 // Check the range of the symbol being casted against the maximum value of the 456 // target type. 457 NonLoc FromVal = val.castAs<NonLoc>(); 458 QualType CmpTy = getConditionType(); 459 NonLoc CompVal = 460 evalBinOpNN(state, BO_LE, FromVal, ToTypeMaxVal, CmpTy).castAs<NonLoc>(); 461 ProgramStateRef IsNotTruncated, IsTruncated; 462 std::tie(IsNotTruncated, IsTruncated) = state->assume(CompVal); 463 if (!IsNotTruncated && IsTruncated) { 464 // Symbol is truncated so we evaluate it as a cast. 465 NonLoc CastVal = makeNonLoc(se, originalTy, castTy); 466 return CastVal; 467 } 468 return evalCast(val, castTy, originalTy); 469 } 470 471 // FIXME: should rewrite according to the cast kind. 472 SVal SValBuilder::evalCast(SVal val, QualType castTy, QualType originalTy) { 473 castTy = Context.getCanonicalType(castTy); 474 originalTy = Context.getCanonicalType(originalTy); 475 if (val.isUnknownOrUndef() || castTy == originalTy) 476 return val; 477 478 if (castTy->isBooleanType()) { 479 if (val.isUnknownOrUndef()) 480 return val; 481 if (val.isConstant()) 482 return makeTruthVal(!val.isZeroConstant(), castTy); 483 if (!Loc::isLocType(originalTy) && 484 !originalTy->isIntegralOrEnumerationType() && 485 !originalTy->isMemberPointerType()) 486 return UnknownVal(); 487 if (SymbolRef Sym = val.getAsSymbol(true)) { 488 BasicValueFactory &BVF = getBasicValueFactory(); 489 // FIXME: If we had a state here, we could see if the symbol is known to 490 // be zero, but we don't. 491 return makeNonLoc(Sym, BO_NE, BVF.getValue(0, Sym->getType()), castTy); 492 } 493 // Loc values are not always true, they could be weakly linked functions. 494 if (Optional<Loc> L = val.getAs<Loc>()) 495 return evalCastFromLoc(*L, castTy); 496 497 Loc L = val.castAs<nonloc::LocAsInteger>().getLoc(); 498 return evalCastFromLoc(L, castTy); 499 } 500 501 // For const casts, casts to void, just propagate the value. 502 if (!castTy->isVariableArrayType() && !originalTy->isVariableArrayType()) 503 if (shouldBeModeledWithNoOp(Context, Context.getPointerType(castTy), 504 Context.getPointerType(originalTy))) 505 return val; 506 507 // Check for casts from pointers to integers. 508 if (castTy->isIntegralOrEnumerationType() && Loc::isLocType(originalTy)) 509 return evalCastFromLoc(val.castAs<Loc>(), castTy); 510 511 // Check for casts from integers to pointers. 512 if (Loc::isLocType(castTy) && originalTy->isIntegralOrEnumerationType()) { 513 if (Optional<nonloc::LocAsInteger> LV = val.getAs<nonloc::LocAsInteger>()) { 514 if (const MemRegion *R = LV->getLoc().getAsRegion()) { 515 StoreManager &storeMgr = StateMgr.getStoreManager(); 516 R = storeMgr.castRegion(R, castTy); 517 return R ? SVal(loc::MemRegionVal(R)) : UnknownVal(); 518 } 519 return LV->getLoc(); 520 } 521 return dispatchCast(val, castTy); 522 } 523 524 // Just pass through function and block pointers. 525 if (originalTy->isBlockPointerType() || originalTy->isFunctionPointerType()) { 526 assert(Loc::isLocType(castTy)); 527 return val; 528 } 529 530 // Check for casts from array type to another type. 531 if (const ArrayType *arrayT = 532 dyn_cast<ArrayType>(originalTy.getCanonicalType())) { 533 // We will always decay to a pointer. 534 QualType elemTy = arrayT->getElementType(); 535 val = StateMgr.ArrayToPointer(val.castAs<Loc>(), elemTy); 536 537 // Are we casting from an array to a pointer? If so just pass on 538 // the decayed value. 539 if (castTy->isPointerType() || castTy->isReferenceType()) 540 return val; 541 542 // Are we casting from an array to an integer? If so, cast the decayed 543 // pointer value to an integer. 544 assert(castTy->isIntegralOrEnumerationType()); 545 546 // FIXME: Keep these here for now in case we decide soon that we 547 // need the original decayed type. 548 // QualType elemTy = cast<ArrayType>(originalTy)->getElementType(); 549 // QualType pointerTy = C.getPointerType(elemTy); 550 return evalCastFromLoc(val.castAs<Loc>(), castTy); 551 } 552 553 // Check for casts from a region to a specific type. 554 if (const MemRegion *R = val.getAsRegion()) { 555 // Handle other casts of locations to integers. 556 if (castTy->isIntegralOrEnumerationType()) 557 return evalCastFromLoc(loc::MemRegionVal(R), castTy); 558 559 // FIXME: We should handle the case where we strip off view layers to get 560 // to a desugared type. 561 if (!Loc::isLocType(castTy)) { 562 // FIXME: There can be gross cases where one casts the result of a function 563 // (that returns a pointer) to some other value that happens to fit 564 // within that pointer value. We currently have no good way to 565 // model such operations. When this happens, the underlying operation 566 // is that the caller is reasoning about bits. Conceptually we are 567 // layering a "view" of a location on top of those bits. Perhaps 568 // we need to be more lazy about mutual possible views, even on an 569 // SVal? This may be necessary for bit-level reasoning as well. 570 return UnknownVal(); 571 } 572 573 // We get a symbolic function pointer for a dereference of a function 574 // pointer, but it is of function type. Example: 575 576 // struct FPRec { 577 // void (*my_func)(int * x); 578 // }; 579 // 580 // int bar(int x); 581 // 582 // int f1_a(struct FPRec* foo) { 583 // int x; 584 // (*foo->my_func)(&x); 585 // return bar(x)+1; // no-warning 586 // } 587 588 assert(Loc::isLocType(originalTy) || originalTy->isFunctionType() || 589 originalTy->isBlockPointerType() || castTy->isReferenceType()); 590 591 StoreManager &storeMgr = StateMgr.getStoreManager(); 592 593 // Delegate to store manager to get the result of casting a region to a 594 // different type. If the MemRegion* returned is NULL, this expression 595 // Evaluates to UnknownVal. 596 R = storeMgr.castRegion(R, castTy); 597 return R ? SVal(loc::MemRegionVal(R)) : UnknownVal(); 598 } 599 600 return dispatchCast(val, castTy); 601 } 602