[cfe-commits] r54859 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRStateTrait.h include/clang/Analysis/PathSensitive/GRWorkList.h lib/Analysis/GRState.cpp
Ted Kremenek
kremenek at apple.com
Sat Aug 16 19:59:30 PDT 2008
Author: kremenek
Date: Sat Aug 16 21:59:30 2008
New Revision: 54859
URL: http://llvm.org/viewvc/llvm-project?rev=54859&view=rev
Log:
Added GRStateTrait.h, which includes boilerplate code for creating specializations of GRStateTrait<>.
Modified GRStateTrait<ConstNotEq> in GRState to use the boilerplate in GRStateTrait<> for ImmutableMaps.
Added:
cfe/trunk/include/clang/Analysis/PathSensitive/GRStateTrait.h
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h
cfe/trunk/lib/Analysis/GRState.cpp
Added: cfe/trunk/include/clang/Analysis/PathSensitive/GRStateTrait.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRStateTrait.h?rev=54859&view=auto
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRStateTrait.h (added)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRStateTrait.h Sat Aug 16 21:59:30 2008
@@ -0,0 +1,67 @@
+//==- GRStateTrait.h - Partial implementations of GRStateTrait -----*- 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 partial implementations of template specializations of
+// the class GRStateTrait<>. GRStateTrait<> is used by GRState to implement
+// set/get methods for mapulating a GRState's generic data map.
+//
+//===----------------------------------------------------------------------===//
+
+
+#ifndef LLVM_CLANG_ANALYSIS_GRSTATETRAIT_H
+#define LLVM_CLANG_ANALYSIS_GRSTATETRAIT_H
+
+namespace llvm {
+ class BumpPtrAllocator;
+ template <typename K, typename D, typename I> class ImmutableMap;
+}
+
+namespace clang {
+ template <typename T> struct GRStatePartialTrait;
+
+ template <typename Key, typename Data, typename Info>
+ struct GRStatePartialTrait< llvm::ImmutableMap<Key,Data,Info> > {
+ typedef llvm::ImmutableMap<Key,Data,Info> data_type;
+ typedef typename data_type::Factory& context_type;
+ typedef Key key_type;
+ typedef Data value_type;
+ typedef const value_type* lookup_type;
+
+ static inline data_type MakeData(void* const* p) {
+ return p ? data_type((typename data_type::TreeTy*) *p) : data_type(0);
+ }
+ static inline void* MakeVoidPtr(data_type B) {
+ return B.getRoot();
+ }
+ static lookup_type Lookup(data_type B, key_type K) {
+ return B.lookup(K);
+ }
+ static data_type Set(data_type B, key_type K, value_type E,context_type F){
+ return F.Add(B, K, E);
+ }
+
+ static data_type Remove(data_type B, key_type K, context_type F) {
+ return F.Remove(B, K);
+ }
+
+ static inline context_type MakeContext(void* p) {
+ return *((typename data_type::Factory*) p);
+ }
+
+ static inline void* CreateContext(llvm::BumpPtrAllocator& Alloc) {
+ return new typename data_type::Factory(Alloc);
+ }
+
+ static inline void DeleteContext(void* Ctx) {
+ delete (typename data_type::Factory*) Ctx;
+ }
+ };
+} // end clang namespace
+
+#endif
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h?rev=54859&r1=54858&r2=54859&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRWorkList.h Sat Aug 16 21:59:30 2008
@@ -1,4 +1,4 @@
-//==- GRWorkList.h - Worklist class used by GRCoreEngine ---------------*- C++ -*-//
+//==- GRWorkList.h - Worklist class used by GRCoreEngine -----------*- C++ -*-//
//
// The LLVM Compiler Infrastructure
//
Modified: cfe/trunk/lib/Analysis/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRState.cpp?rev=54859&r1=54858&r2=54859&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRState.cpp (original)
+++ cfe/trunk/lib/Analysis/GRState.cpp Sat Aug 16 21:59:30 2008
@@ -11,6 +11,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Analysis/PathSensitive/GRStateTrait.h"
#include "clang/Analysis/PathSensitive/GRState.h"
#include "llvm/ADT/SmallSet.h"
#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
@@ -37,44 +38,9 @@
static int ConstNotEqTyIndex = 0;
namespace clang {
- template<> struct GRStateTrait<ConstNotEqTy> {
- typedef ConstNotEqTy data_type;
- typedef ConstNotEqTy::Factory& context_type;
- typedef SymbolID key_type;
- typedef GRState::IntSetTy value_type;
- typedef const GRState::IntSetTy* lookup_type;
-
- static data_type MakeData(void* const* p) {
- return p ? ConstNotEqTy((ConstNotEqTy::TreeTy*) *p) : ConstNotEqTy(0);
- }
- static void* MakeVoidPtr(ConstNotEqTy B) {
- return B.getRoot();
- }
- static void* GDMIndex() {
- return &ConstNotEqTyIndex;
- }
- static lookup_type Lookup(ConstNotEqTy B, SymbolID K) {
- return B.lookup(K);
- }
- static data_type Set(data_type B, key_type K, value_type E,context_type F){
- return F.Add(B, K, E);
- }
-
- static data_type Remove(ConstNotEqTy B, SymbolID K, context_type F) {
- return F.Remove(B, K);
- }
-
- static context_type MakeContext(void* p) {
- return *((ConstNotEqTy::Factory*) p);
- }
-
- static void* CreateContext(llvm::BumpPtrAllocator& Alloc) {
- return new ConstNotEqTy::Factory(Alloc);
- }
-
- static void DeleteContext(void* Ctx) {
- delete (ConstNotEqTy::Factory*) Ctx;
- }
+ template<>
+ struct GRStateTrait<ConstNotEqTy> : public GRStatePartialTrait<ConstNotEqTy> {
+ static inline void* GDMIndex() { return &ConstNotEqTyIndex; }
};
}
More information about the cfe-commits
mailing list