klee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Context.cpp
Go to the documentation of this file.
1 //===-- Context.cpp -------------------------------------------------------===//
2 //
3 // The KLEE Symbolic Virtual Machine
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "Context.h"
11 
12 #include "klee/Expr.h"
13 
14 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
15 #include "llvm/IR/Type.h"
16 #include "llvm/IR/DerivedTypes.h"
17 #else
18 #include "llvm/Type.h"
19 #include "llvm/DerivedTypes.h"
20 #endif
21 
22 #include <cassert>
23 
24 using namespace klee;
25 
26 static bool Initialized = false;
28 
29 void Context::initialize(bool IsLittleEndian, Expr::Width PointerWidth) {
30  assert(!Initialized && "Duplicate context initialization!");
31  TheContext = Context(IsLittleEndian, PointerWidth);
32  Initialized = true;
33 }
34 
36  assert(Initialized && "Context has not been initialized!");
37  return TheContext;
38 }
39 
40 // FIXME: This is a total hack, just to avoid a layering issue until this stuff
41 // moves out of Expr.
42 
44  return SExtExpr::create(e, Context::get().getPointerWidth());
45 }
46 
48  return ZExtExpr::create(e, Context::get().getPointerWidth());
49 }
50 
52  return ConstantExpr::create(v, Context::get().getPointerWidth());
53 }
static Context TheContext
Definition: Context.cpp:27
static ref< ConstantExpr > createPointer(uint64_t v)
Definition: Context.cpp:51
static const Context & get()
get - Return the global singleton instance of the Context.
Definition: Context.cpp:35
static ref< Expr > createZExtToPointerWidth(ref< Expr > e)
Definition: Context.cpp:47
Context - Helper class for storing global information about a KLEE run.
Definition: Context.h:18
static ref< ConstantExpr > create(uint64_t v, Width w)
Definition: Expr.h:412
unsigned Width
The type of an expression is simply its width, in bits.
Definition: Expr.h:94
static void initialize(bool IsLittleEndian, Expr::Width PointerWidth)
initialize - Construct the global Context instance.
Definition: Context.cpp:29
static ref< Expr > createSExtToPointerWidth(ref< Expr > e)
Definition: Context.cpp:43
static bool Initialized
Definition: Context.cpp:26