From: Ted Kremenek Date: Thu, 28 Aug 2008 23:32:43 +0000 (+0000) Subject: Remove Regions.h and Regions.cpp, since we are now using an even more abstract repres... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05d0977a1c1a02bd2258113bbb623da43904c8ef;p=clang Remove Regions.h and Regions.cpp, since we are now using an even more abstract representation of "memory regions" in the static analyzer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55515 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/PathSensitive/Regions.h b/include/clang/Analysis/PathSensitive/Regions.h deleted file mode 100644 index d62b033726..0000000000 --- a/include/clang/Analysis/PathSensitive/Regions.h +++ /dev/null @@ -1,183 +0,0 @@ -//==- Regions.h - Abstract memory locations ------------------------*- C++ -*-// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines Region and its subclasses. Regions represent abstract -// memory locations. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/DataTypes.h" -#include "llvm/Support/Casting.h" -#include "llvm/ADT/FoldingSet.h" -#include "clang/Analysis/PathSensitive/SymbolManager.h" - -#ifndef LLVM_CLANG_ANALYSIS_REGIONS_H -#define LLVM_CLANG_ANALYSIS_REGIONS_H - -namespace llvm { - class APSInt; -} - -namespace clang { - -class BasicValueFactory; - - -//===----------------------------------------------------------------------===// -// Region Extents. -//===----------------------------------------------------------------------===// - -class RegionExtent { -public: - enum Kind { Unknown = 0, Int = 0, Sym = 1 }; - -protected: - const uintptr_t Raw; - RegionExtent(uintptr_t raw, Kind k) : Raw(raw | k) {} - uintptr_t getData() const { return Raw & ~0x1; } - -public: - // Folding-set profiling. - void Profile(llvm::FoldingSetNodeID& ID) const { - ID.AddPointer((void*) Raw); - } - // Comparing extents. - bool operator==(const RegionExtent& R) const { - return Raw == R.Raw; - } - bool operator!=(const RegionExtent& R) const { - return Raw != R.Raw; - } - // Implement isa support. - Kind getKind() const { return Kind(Raw & 0x1); } - uintptr_t getRaw() const { return Raw; } - - static inline bool classof(const RegionExtent*) { - return true; - } -}; - -class UnknownExtent : public RegionExtent { -public: - UnknownExtent() : RegionExtent(0,Unknown) {} - - // Implement isa support. - static inline bool classof(const RegionExtent* E) { - return E->getRaw() == 0; - } -}; - -class IntExtent : public RegionExtent { -public: - IntExtent(const llvm::APSInt& X) : RegionExtent((uintptr_t) &X, Int) {} - - const llvm::APSInt& getInt() const { - return *((llvm::APSInt*) getData()); - } - - // Implement isa support. - static inline bool classof(const RegionExtent* E) { - return E->getKind() == Int && E->getRaw() != 0; - } -}; - -class SymExtent : public RegionExtent { -public: - SymExtent(SymbolID S) : RegionExtent(S.getNumber() << 1, Sym) {} - - SymbolID getSymbol() const { return SymbolID(getData() >> 1); } - - // Implement isa support. - static inline bool classof(const RegionExtent* E) { - return E->getKind() == Sym; - } -}; - -//===----------------------------------------------------------------------===// -// Regions. -//===----------------------------------------------------------------------===// - -class Region { -public: - enum Kind { Var = 0x0, Anon = 0x1 }; - -private: - uintptr_t Raw; - -protected: - Region(const void* data, Kind kind) - : Raw((uintptr_t) data | (uintptr_t) kind) { - assert ((reinterpret_cast(const_cast(data)) & 0x1) == 0 - && "Address must have at least a 2-byte alignment."); - } - - const void* getData() const { return (const void*) (Raw & ~0x1); } - -public: - // Folding-set profiling. - void Profile(llvm::FoldingSetNodeID& ID) const { ID.AddPointer((void*) Raw); } - - // Comparing regions. - bool operator==(const Region& R) const { return Raw == R.Raw; } - bool operator!=(const Region& R) const { return Raw != R.Raw; } - - // Implement isa support. - Kind getKind() const { return Kind (Raw & 0x1); } - static inline bool classof(const Region*) { return true; } -}; - -//===----------------------------------------------------------------------===// -// Region Types. -//===----------------------------------------------------------------------===// - -class VarRegion : public Region { -public: - VarRegion(VarDecl* VD) : Region(VD, Region::Var) {} - - /// getDecl - Return the declaration of the variable the region represents. - const VarDecl* getDecl() const { return (const VarDecl*) getData(); } - operator const VarDecl*() const { return getDecl(); } - - RegionExtent getExtent(BasicValueFactory& BV) const; - - // Implement isa support. - static inline bool classof(const Region* R) { - return R->getKind() == Region::Var; - } - - static inline bool classof(const VarRegion*) { - return true; - } -}; - -class AnonRegion : public Region { -protected: - friend class Region; - - AnonRegion(uintptr_t RegionID) : Region((void*) (RegionID<<1), Region::Anon) { - assert (((RegionID << 1) >> 1) == RegionID); - } - -public: - - uintptr_t getID() const { return ((uintptr_t) getData()) >> 1; } - - // Implement isa support. - static inline bool classof(const Region* R) { - return R->getKind() == Region::Anon; - } - - static inline bool classof(const AnonRegion*) { - return true; - } -}; - -} // end clang namespace - -#endif diff --git a/lib/Analysis/Regions.cpp b/lib/Analysis/Regions.cpp deleted file mode 100644 index b725316243..0000000000 --- a/lib/Analysis/Regions.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//==- Regions.cpp - Abstract memory locations ----------------------*- C++ -*-// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines Region and its subclasses. Regions represent abstract -// memory locations. -// -//===----------------------------------------------------------------------===// - -#include "clang/Analysis/PathSensitive/Regions.h" -#include "clang/Analysis/PathSensitive/BasicValueFactory.h" -#include "clang/AST/ASTContext.h" - -using namespace clang; - -RegionExtent VarRegion::getExtent(BasicValueFactory& BV) const { - QualType T = getDecl()->getType(); - - // FIXME: Add support for VLAs. This may require passing in additional - // information, or tracking a different region type. - if (!T.getTypePtr()->isConstantSizeType()) - return UnknownExtent(); - - ASTContext& C = BV.getContext(); - assert (!T->isObjCInterfaceType()); // @interface not a possible VarDecl type. - assert (T != C.VoidTy); // void not a possible VarDecl type. - return IntExtent(BV.getValue(C.getTypeSize(T), C.VoidPtrTy)); -} -