MemRegion.h revision 72e032004b0d2c2c298e8e4f7027f23a21c0cc7d
131d157ae1ac2cd9c787dc3c1d28e64c682803844Jia Liu//== MemRegion.h - Abstract memory regions for static analysis --*- C++ -*--==// 20d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner// 30d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner// The LLVM Compiler Infrastructure 40d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner// 54ee451de366474b9c228b4e5fa573795a715216dChris Lattner// This file is distributed under the University of Illinois Open Source 64ee451de366474b9c228b4e5fa573795a715216dChris Lattner// License. See LICENSE.TXT for details. 70d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner// 80d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner//===----------------------------------------------------------------------===// 90d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner// 105b1b4489cf3a0f56f8be0673fc5cc380a32d277bEvan Cheng// This file defines MemRegion and its subclasses. MemRegion defines a 110d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner// partially-typed abstraction of memory useful for path-sensitive dataflow 120d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner// analyses. 130d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner// 147c90f73a1b06040d971a3dd95a491031ae6238d5Chris Lattner//===----------------------------------------------------------------------===// 15ffc0e73046f737d75e0a62b3a83ef19bcef111e3Evan Cheng 163e74d6fdd248e20a280f1dff3da9a6c689c2c4c3Evan Cheng#ifndef LLVM_CLANG_ANALYSIS_MEMREGION_H 1794214703d97d8d9dfca88174ffc7e94820a85e62Evan Cheng#define LLVM_CLANG_ANALYSIS_MEMREGION_H 1894214703d97d8d9dfca88174ffc7e94820a85e62Evan Cheng 19ebdeeab812beec0385b445f3d4c41a114e0d972fEvan Cheng#include "clang/AST/Decl.h" 20385e930d55f3ecd3c9538823dfa5896a12461845Evan Cheng#include "clang/AST/DeclObjC.h" 2194214703d97d8d9dfca88174ffc7e94820a85e62Evan Cheng#include "clang/Analysis/PathSensitive/SymbolManager.h" 220d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner#include "clang/Analysis/PathSensitive/SVals.h" 230d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner#include "clang/AST/ASTContext.h" 242d24e2a396a1d211baaeedf32148a3b657240170David Blaikie#include "llvm/Support/Casting.h" 252d24e2a396a1d211baaeedf32148a3b657240170David Blaikie#include "llvm/ADT/FoldingSet.h" 26276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Cheng#include "llvm/ADT/ImmutableList.h" 27276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Cheng#include "llvm/ADT/ImmutableMap.h" 280ddff1b5359433faf2eb1c4ff5320ddcbd42f52fEvan Cheng#include "llvm/Support/Allocator.h" 2987c06d617917f4a388fbe9db81198e13cde3e431Chris Lattner#include <string> 3087c06d617917f4a388fbe9db81198e13cde3e431Chris Lattner 3187c06d617917f4a388fbe9db81198e13cde3e431Chris Lattnernamespace llvm { class raw_ostream; } 3287c06d617917f4a388fbe9db81198e13cde3e431Chris Lattner 33184cc4ac60dc853fac3baa5e96d5f662d311b2fbChris Lattnernamespace clang { 340d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner 35276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Chengclass MemRegionManager; 36276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Cheng 37276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Cheng 38276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Cheng/// MemRegion - The root abstract class for all memory regions. 39276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Chengclass MemRegion : public llvm::FoldingSetNode { 40276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Chengpublic: 4187c06d617917f4a388fbe9db81198e13cde3e431Chris Lattner enum Kind { MemSpaceRegionKind, 42276365dd4bc0c2160f91fd8062ae1fc90c86c324Evan Cheng SymbolicRegionKind, 430d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner AllocaRegionKind, 440d170a7969e7e36ad00afe596f2937f0c74d2b49Chris Lattner // Typed regions. 450ddff1b5359433faf2eb1c4ff5320ddcbd42f52fEvan Cheng BEG_TYPED_REGIONS, 46d74ea2bbd8bb630331f35ead42d385249bd42af8Chris Lattner CodeTextRegionKind, 47 CompoundLiteralRegionKind, 48 StringRegionKind, ElementRegionKind, 49 TypedViewRegionKind, 50 // Decl Regions. 51 BEG_DECL_REGIONS, 52 VarRegionKind, FieldRegionKind, 53 ObjCIvarRegionKind, ObjCObjectRegionKind, 54 END_DECL_REGIONS, 55 END_TYPED_REGIONS }; 56private: 57 const Kind kind; 58 59protected: 60 MemRegion(Kind k) : kind(k) {} 61 virtual ~MemRegion(); 62 63public: 64 // virtual MemExtent getExtent(MemRegionManager& mrm) const = 0; 65 virtual void Profile(llvm::FoldingSetNodeID& ID) const = 0; 66 67 std::string getString() const; 68 69 virtual void print(llvm::raw_ostream& os) const; 70 71 Kind getKind() const { return kind; } 72 73 template<typename RegionTy> const RegionTy* getAs() const; 74 75 virtual bool isBoundable(ASTContext&) const { return true; } 76 77 static bool classof(const MemRegion*) { return true; } 78}; 79 80/// MemSpaceRegion - A memory region that represents and "memory space"; 81/// for example, the set of global variables, the stack frame, etc. 82class MemSpaceRegion : public MemRegion { 83 friend class MemRegionManager; 84 MemSpaceRegion() : MemRegion(MemSpaceRegionKind) {} 85 86public: 87 //RegionExtent getExtent() const { return UndefinedExtent(); } 88 89 void Profile(llvm::FoldingSetNodeID& ID) const; 90 91 bool isBoundable(ASTContext &) const { return false; } 92 93 static bool classof(const MemRegion* R) { 94 return R->getKind() == MemSpaceRegionKind; 95 } 96}; 97 98/// SubRegion - A region that subsets another larger region. Most regions 99/// are subclasses of SubRegion. 100class SubRegion : public MemRegion { 101protected: 102 const MemRegion* superRegion; 103 SubRegion(const MemRegion* sReg, Kind k) : MemRegion(k), superRegion(sReg) {} 104 105public: 106 const MemRegion* getSuperRegion() const { 107 return superRegion; 108 } 109 110 bool isSubRegionOf(const MemRegion* R) const; 111 112 static bool classof(const MemRegion* R) { 113 return R->getKind() > MemSpaceRegionKind; 114 } 115}; 116 117/// AllocaRegion - A region that represents an untyped blob of bytes created 118/// by a call to 'alloca'. 119class AllocaRegion : public SubRegion { 120 friend class MemRegionManager; 121protected: 122 unsigned Cnt; // Block counter. Used to distinguish different pieces of 123 // memory allocated by alloca at the same call site. 124 const Expr* Ex; 125 126 AllocaRegion(const Expr* ex, unsigned cnt, const MemRegion* superRegion) 127 : SubRegion(superRegion, AllocaRegionKind), Cnt(cnt), Ex(ex) {} 128 129public: 130 131 const Expr* getExpr() const { return Ex; } 132 133 void Profile(llvm::FoldingSetNodeID& ID) const; 134 135 static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr* Ex, 136 unsigned Cnt); 137 138 void print(llvm::raw_ostream& os) const; 139 140 static bool classof(const MemRegion* R) { 141 return R->getKind() == AllocaRegionKind; 142 } 143}; 144 145/// TypedRegion - An abstract class representing regions that are typed. 146class TypedRegion : public SubRegion { 147protected: 148 TypedRegion(const MemRegion* sReg, Kind k) : SubRegion(sReg, k) {} 149 150public: 151 virtual QualType getRValueType(ASTContext &C) const = 0; 152 153 virtual QualType getLValueType(ASTContext& C) const { 154 // FIXME: We can possibly optimize this later to cache this value. 155 return C.getPointerType(getRValueType(C)); 156 } 157 158 QualType getDesugaredRValueType(ASTContext& C) const { 159 QualType T = getRValueType(C); 160 return T.getTypePtr() ? T->getDesugaredType() : T; 161 } 162 163 QualType getDesugaredLValueType(ASTContext& C) const { 164 return getLValueType(C)->getDesugaredType(); 165 } 166 167 bool isBoundable(ASTContext &C) const { 168 return !getRValueType(C).isNull(); 169 } 170 171 static bool classof(const MemRegion* R) { 172 unsigned k = R->getKind(); 173 return k > BEG_TYPED_REGIONS && k < END_TYPED_REGIONS; 174 } 175}; 176 177/// CodeTextRegion - A region that represents code texts of a function. It wraps 178/// two kinds of code texts: real function and symbolic function. Real function 179/// is a function declared in the program. Symbolic function is a function 180/// pointer that we don't know which function it points to. 181class CodeTextRegion : public TypedRegion { 182public: 183 enum CodeKind { Declared, Symbolic }; 184 185private: 186 // The function pointer kind that this CodeTextRegion represents. 187 CodeKind codekind; 188 189 // Data may be a SymbolRef or FunctionDecl*. 190 const void* Data; 191 192 // Cached function pointer type. 193 QualType LocationType; 194 195public: 196 197 CodeTextRegion(const FunctionDecl* fd, QualType t, const MemRegion* sreg) 198 : TypedRegion(sreg, CodeTextRegionKind), 199 codekind(Declared), 200 Data(fd), 201 LocationType(t) {} 202 203 CodeTextRegion(SymbolRef sym, QualType t, const MemRegion* sreg) 204 : TypedRegion(sreg, CodeTextRegionKind), 205 codekind(Symbolic), 206 Data(sym), 207 LocationType(t) {} 208 209 QualType getRValueType(ASTContext &C) const { 210 // Do not get the object type of a CodeTextRegion. 211 assert(0); 212 return QualType(); 213 } 214 215 QualType getLValueType(ASTContext &C) const { 216 return LocationType; 217 } 218 219 bool isDeclared() const { return codekind == Declared; } 220 221 const FunctionDecl* getDecl() const { 222 assert(codekind == Declared); 223 return static_cast<const FunctionDecl*>(Data); 224 } 225 226 SymbolRef getSymbol() const { 227 assert(codekind == Symbolic); 228 return const_cast<SymbolRef>(static_cast<const SymbolRef>(Data)); 229 } 230 231 bool isBoundable(ASTContext&) const { return false; } 232 233 virtual void print(llvm::raw_ostream& os) const; 234 235 void Profile(llvm::FoldingSetNodeID& ID) const; 236 237 static void ProfileRegion(llvm::FoldingSetNodeID& ID, 238 const void* data, QualType t); 239 240 static bool classof(const MemRegion* R) { 241 return R->getKind() == CodeTextRegionKind; 242 } 243}; 244 245/// SymbolicRegion - A special, "non-concrete" region. Unlike other region 246/// clases, SymbolicRegion represents a region that serves as an alias for 247/// either a real region, a NULL pointer, etc. It essentially is used to 248/// map the concept of symbolic values into the domain of regions. Symbolic 249/// regions do not need to be typed. 250class SymbolicRegion : public SubRegion { 251protected: 252 const SymbolRef sym; 253 254public: 255 SymbolicRegion(const SymbolRef s, const MemRegion* sreg) 256 : SubRegion(sreg, SymbolicRegionKind), sym(s) {} 257 258 SymbolRef getSymbol() const { 259 return sym; 260 } 261 262 void Profile(llvm::FoldingSetNodeID& ID) const; 263 264 static void ProfileRegion(llvm::FoldingSetNodeID& ID, SymbolRef sym); 265 266 void print(llvm::raw_ostream& os) const; 267 268 static bool classof(const MemRegion* R) { 269 return R->getKind() == SymbolicRegionKind; 270 } 271}; 272 273/// StringRegion - Region associated with a StringLiteral. 274class StringRegion : public TypedRegion { 275 friend class MemRegionManager; 276 const StringLiteral* Str; 277protected: 278 279 StringRegion(const StringLiteral* str, MemRegion* sreg) 280 : TypedRegion(sreg, StringRegionKind), Str(str) {} 281 282 static void ProfileRegion(llvm::FoldingSetNodeID& ID, 283 const StringLiteral* Str, 284 const MemRegion* superRegion); 285 286public: 287 288 const StringLiteral* getStringLiteral() const { return Str; } 289 290 QualType getRValueType(ASTContext& C) const; 291 292 void Profile(llvm::FoldingSetNodeID& ID) const { 293 ProfileRegion(ID, Str, superRegion); 294 } 295 296 void print(llvm::raw_ostream& os) const; 297 298 static bool classof(const MemRegion* R) { 299 return R->getKind() == StringRegionKind; 300 } 301}; 302 303class TypedViewRegion : public TypedRegion { 304 friend class MemRegionManager; 305 QualType LValueType; 306 307 TypedViewRegion(QualType lvalueType, const MemRegion* sreg) 308 : TypedRegion(sreg, TypedViewRegionKind), LValueType(lvalueType) {} 309 310 static void ProfileRegion(llvm::FoldingSetNodeID& ID, QualType T, 311 const MemRegion* superRegion); 312 313public: 314 315 void print(llvm::raw_ostream& os) const; 316 317 QualType getLValueType(ASTContext&) const { 318 return LValueType; 319 } 320 321 QualType getRValueType(ASTContext&) const { 322 const PointerType* PTy = LValueType->getAsPointerType(); 323 assert(PTy); 324 return PTy->getPointeeType(); 325 } 326 327 bool isBoundable(ASTContext &C) const { 328 return isa<PointerType>(LValueType); 329 } 330 331 void Profile(llvm::FoldingSetNodeID& ID) const { 332 ProfileRegion(ID, LValueType, superRegion); 333 } 334 335 static bool classof(const MemRegion* R) { 336 return R->getKind() == TypedViewRegionKind; 337 } 338 339 const MemRegion *removeViews() const; 340}; 341 342 343/// CompoundLiteralRegion - A memory region representing a compound literal. 344/// Compound literals are essentially temporaries that are stack allocated 345/// or in the global constant pool. 346class CompoundLiteralRegion : public TypedRegion { 347private: 348 friend class MemRegionManager; 349 const CompoundLiteralExpr* CL; 350 351 CompoundLiteralRegion(const CompoundLiteralExpr* cl, const MemRegion* sReg) 352 : TypedRegion(sReg, CompoundLiteralRegionKind), CL(cl) {} 353 354 static void ProfileRegion(llvm::FoldingSetNodeID& ID, 355 const CompoundLiteralExpr* CL, 356 const MemRegion* superRegion); 357public: 358 QualType getRValueType(ASTContext& C) const { 359 return C.getCanonicalType(CL->getType()); 360 } 361 362 void Profile(llvm::FoldingSetNodeID& ID) const; 363 364 void print(llvm::raw_ostream& os) const; 365 366 const CompoundLiteralExpr* getLiteralExpr() const { return CL; } 367 368 static bool classof(const MemRegion* R) { 369 return R->getKind() == CompoundLiteralRegionKind; 370 } 371}; 372 373class DeclRegion : public TypedRegion { 374protected: 375 const Decl* D; 376 377 DeclRegion(const Decl* d, const MemRegion* sReg, Kind k) 378 : TypedRegion(sReg, k), D(d) {} 379 380 static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Decl* D, 381 const MemRegion* superRegion, Kind k); 382 383public: 384 const Decl* getDecl() const { return D; } 385 void Profile(llvm::FoldingSetNodeID& ID) const; 386 387 QualType getRValueType(ASTContext& C) const = 0; 388 389 static bool classof(const MemRegion* R) { 390 unsigned k = R->getKind(); 391 return k > BEG_DECL_REGIONS && k < END_DECL_REGIONS; 392 } 393}; 394 395class VarRegion : public DeclRegion { 396 friend class MemRegionManager; 397 398 VarRegion(const VarDecl* vd, const MemRegion* sReg) 399 : DeclRegion(vd, sReg, VarRegionKind) {} 400 401 static void ProfileRegion(llvm::FoldingSetNodeID& ID, VarDecl* VD, 402 const MemRegion* superRegion) { 403 DeclRegion::ProfileRegion(ID, VD, superRegion, VarRegionKind); 404 } 405 406public: 407 const VarDecl* getDecl() const { return cast<VarDecl>(D); } 408 409 QualType getRValueType(ASTContext& C) const { 410 // FIXME: We can cache this if needed. 411 return C.getCanonicalType(getDecl()->getType()); 412 } 413 414 void print(llvm::raw_ostream& os) const; 415 416 static bool classof(const MemRegion* R) { 417 return R->getKind() == VarRegionKind; 418 } 419}; 420 421class FieldRegion : public DeclRegion { 422 friend class MemRegionManager; 423 424 FieldRegion(const FieldDecl* fd, const MemRegion* sReg) 425 : DeclRegion(fd, sReg, FieldRegionKind) {} 426 427public: 428 429 void print(llvm::raw_ostream& os) const; 430 431 const FieldDecl* getDecl() const { return cast<FieldDecl>(D); } 432 433 QualType getRValueType(ASTContext& C) const { 434 // FIXME: We can cache this if needed. 435 return C.getCanonicalType(getDecl()->getType()); 436 } 437 438 static void ProfileRegion(llvm::FoldingSetNodeID& ID, FieldDecl* FD, 439 const MemRegion* superRegion) { 440 DeclRegion::ProfileRegion(ID, FD, superRegion, FieldRegionKind); 441 } 442 443 static bool classof(const MemRegion* R) { 444 return R->getKind() == FieldRegionKind; 445 } 446}; 447 448class ObjCObjectRegion : public DeclRegion { 449 450 friend class MemRegionManager; 451 452 ObjCObjectRegion(const ObjCInterfaceDecl* ivd, const MemRegion* sReg) 453 : DeclRegion(ivd, sReg, ObjCObjectRegionKind) {} 454 455 static void ProfileRegion(llvm::FoldingSetNodeID& ID, ObjCInterfaceDecl* ivd, 456 const MemRegion* superRegion) { 457 DeclRegion::ProfileRegion(ID, ivd, superRegion, ObjCObjectRegionKind); 458 } 459 460public: 461 const ObjCInterfaceDecl* getInterface() const { 462 return cast<ObjCInterfaceDecl>(D); 463 } 464 465 QualType getRValueType(ASTContext& C) const { 466 ObjCInterfaceDecl* ID = const_cast<ObjCInterfaceDecl*>(getInterface()); 467 return C.getObjCInterfaceType(ID); 468 } 469 470 static bool classof(const MemRegion* R) { 471 return R->getKind() == ObjCObjectRegionKind; 472 } 473}; 474 475class ObjCIvarRegion : public DeclRegion { 476 477 friend class MemRegionManager; 478 479 ObjCIvarRegion(const ObjCIvarDecl* ivd, const MemRegion* sReg) 480 : DeclRegion(ivd, sReg, ObjCIvarRegionKind) {} 481 482 static void ProfileRegion(llvm::FoldingSetNodeID& ID, ObjCIvarDecl* ivd, 483 const MemRegion* superRegion) { 484 DeclRegion::ProfileRegion(ID, ivd, superRegion, ObjCIvarRegionKind); 485 } 486 487public: 488 const ObjCIvarDecl* getDecl() const { return cast<ObjCIvarDecl>(D); } 489 QualType getRValueType(ASTContext&) const { return getDecl()->getType(); } 490 491 static bool classof(const MemRegion* R) { 492 return R->getKind() == ObjCIvarRegionKind; 493 } 494}; 495 496class ElementRegion : public TypedRegion { 497 friend class MemRegionManager; 498 499 SVal Index; 500 501 ElementRegion(SVal Idx, const MemRegion* sReg) 502 : TypedRegion(sReg, ElementRegionKind), Index(Idx) { 503 assert((!isa<nonloc::ConcreteInt>(&Idx) || 504 cast<nonloc::ConcreteInt>(&Idx)->getValue().isSigned()) && 505 "The index must be signed"); 506 } 507 508 static void ProfileRegion(llvm::FoldingSetNodeID& ID, SVal Idx, 509 const MemRegion* superRegion); 510 511public: 512 513 SVal getIndex() const { return Index; } 514 515 QualType getRValueType(ASTContext&) const; 516 517 /// getArrayRegion - Return the region of the enclosing array. This is 518 /// the same as getSuperRegion() except that this returns a TypedRegion* 519 /// instead of a MemRegion*. 520 const TypedRegion* getArrayRegion() const { 521 return cast<TypedRegion>(getSuperRegion()); 522 } 523 524 void print(llvm::raw_ostream& os) const; 525 526 void Profile(llvm::FoldingSetNodeID& ID) const; 527 528 static bool classof(const MemRegion* R) { 529 return R->getKind() == ElementRegionKind; 530 } 531}; 532 533template<typename RegionTy> 534const RegionTy* MemRegion::getAs() const { 535 const MemRegion *R = this; 536 537 do { 538 if (const RegionTy* RT = dyn_cast<RegionTy>(R)) 539 return RT; 540 541 if (const TypedViewRegion *TR = dyn_cast<TypedViewRegion>(R)) { 542 R = TR->getSuperRegion(); 543 continue; 544 } 545 546 break; 547 } 548 while (R); 549 550 return 0; 551} 552 553//===----------------------------------------------------------------------===// 554// MemRegionManager - Factory object for creating regions. 555//===----------------------------------------------------------------------===// 556 557class MemRegionManager { 558 llvm::BumpPtrAllocator& A; 559 llvm::FoldingSet<MemRegion> Regions; 560 561 MemSpaceRegion* globals; 562 MemSpaceRegion* stack; 563 MemSpaceRegion* heap; 564 MemSpaceRegion* unknown; 565 MemSpaceRegion* code; 566 567public: 568 MemRegionManager(llvm::BumpPtrAllocator& a) 569 : A(a), globals(0), stack(0), heap(0), unknown(0), code(0) {} 570 571 ~MemRegionManager() {} 572 573 /// getStackRegion - Retrieve the memory region associated with the 574 /// current stack frame. 575 MemSpaceRegion* getStackRegion(); 576 577 /// getGlobalsRegion - Retrieve the memory region associated with 578 /// all global variables. 579 MemSpaceRegion* getGlobalsRegion(); 580 581 /// getHeapRegion - Retrieve the memory region associated with the 582 /// generic "heap". 583 MemSpaceRegion* getHeapRegion(); 584 585 /// getUnknownRegion - Retrieve the memory region associated with unknown 586 /// memory space. 587 MemSpaceRegion* getUnknownRegion(); 588 589 MemSpaceRegion* getCodeRegion(); 590 591 bool isGlobalsRegion(const MemRegion* R) { 592 assert(R); 593 return R == globals; 594 } 595 596 /// onStack - check if the region is allocated on the stack. 597 bool onStack(const MemRegion* R); 598 599 /// onHeap - check if the region is allocated on the heap, usually by malloc. 600 bool onHeap(const MemRegion* R); 601 602 /// getAllocaRegion - Retrieve a region associated with a call to alloca(). 603 AllocaRegion* getAllocaRegion(const Expr* Ex, unsigned Cnt); 604 605 /// getCompoundLiteralRegion - Retrieve the region associated with a 606 /// given CompoundLiteral. 607 CompoundLiteralRegion* 608 getCompoundLiteralRegion(const CompoundLiteralExpr* CL); 609 610 /// getSymbolicRegion - Retrieve or create a "symbolic" memory region. 611 SymbolicRegion* getSymbolicRegion(SymbolRef sym); 612 613 StringRegion* getStringRegion(const StringLiteral* Str); 614 615 /// getVarRegion - Retrieve or create the memory region associated with 616 /// a specified VarDecl. 617 VarRegion* getVarRegion(const VarDecl* vd); 618 619 ElementRegion* getElementRegion(SVal Idx, const TypedRegion* superRegion); 620 621 /// getFieldRegion - Retrieve or create the memory region associated with 622 /// a specified FieldDecl. 'superRegion' corresponds to the containing 623 /// memory region (which typically represents the memory representing 624 /// a structure or class). 625 FieldRegion* getFieldRegion(const FieldDecl* fd, 626 const MemRegion* superRegion); 627 628 /// getObjCObjectRegion - Retrieve or create the memory region associated with 629 /// the instance of a specified Objective-C class. 630 ObjCObjectRegion* getObjCObjectRegion(const ObjCInterfaceDecl* ID, 631 const MemRegion* superRegion); 632 633 /// getObjCIvarRegion - Retrieve or create the memory region associated with 634 /// a specified Objective-c instance variable. 'superRegion' corresponds 635 /// to the containing region (which typically represents the Objective-C 636 /// object). 637 ObjCIvarRegion* getObjCIvarRegion(const ObjCIvarDecl* ivd, 638 const MemRegion* superRegion); 639 640 TypedViewRegion* getTypedViewRegion(QualType LValueType, 641 const MemRegion* superRegion); 642 643 CodeTextRegion* getCodeTextRegion(SymbolRef sym, QualType t); 644 CodeTextRegion* getCodeTextRegion(const FunctionDecl* fd, QualType t); 645 646 bool hasStackStorage(const MemRegion* R); 647 648private: 649 MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region); 650}; 651} // end clang namespace 652 653namespace llvm { 654static inline raw_ostream& operator<<(raw_ostream& O, 655 const clang::MemRegion* R) { 656 R->print(O); 657 return O; 658} 659} // end llvm namespace 660 661#endif 662