Ted Kremenek | f5fce10 | 2008-08-25 19:33:03 +0000 | [diff] [blame^] | 1 | //==- Regions.cpp - Abstract memory locations ----------------------*- 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 Region and its subclasses. Regions represent abstract |
| 11 | // memory locations. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "clang/Analysis/PathSensitive/Regions.h" |
| 16 | #include "clang/Analysis/PathSensitive/BasicValueFactory.h" |
| 17 | #include "clang/AST/ASTContext.h" |
| 18 | |
| 19 | using namespace clang; |
| 20 | |
| 21 | RegionExtent VarRegion::getExtent(BasicValueFactory& BV) const { |
| 22 | QualType T = getDecl()->getType(); |
| 23 | |
| 24 | // FIXME: Add support for VLAs. This may require passing in additional |
| 25 | // information, or tracking a different region type. |
| 26 | if (!T.getTypePtr()->isConstantSizeType()) |
| 27 | return UnknownExtent(); |
| 28 | |
| 29 | ASTContext& C = BV.getContext(); |
| 30 | assert (!T->isObjCInterfaceType()); // @interface not a possible VarDecl type. |
| 31 | assert (T != C.VoidTy); // void not a possible VarDecl type. |
| 32 | return IntExtent(BV.getValue(C.getTypeSize(T), C.VoidPtrTy)); |
| 33 | } |
| 34 | |