ROSE  0.11.145.0
AbstractLocation.h
1 #ifndef ROSE_BinaryAnalysis_AbstractLocation_H
2 #define ROSE_BinaryAnalysis_AbstractLocation_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 
6 #include <Rose/Location.h>
7 #include <Rose/BinaryAnalysis/BasicTypes.h>
8 #include <Rose/BinaryAnalysis/SmtSolver.h>
9 
10 #include <ostream>
11 #include <string>
12 
13 namespace Rose {
14 namespace BinaryAnalysis {
15 
32 class AbstractLocation: public Location {
33 public:
36 private:
37  RegisterDescriptor reg_;
38  Address addr_;
39  size_t nBytes_ = 0; // size of memory location, or zero if unknown
40  RegisterDictionaryPtr regdict_;
41 
42 public:
48  virtual ~AbstractLocation();
49 
52 
55 
68  explicit AbstractLocation(const Address&, size_t nBytes = 0);
69 
71  static AbstractLocation parse(const std::string&);
72 
73  virtual bool isValid() const override;
74  virtual std::string toString() const override;
75  virtual void print(std::ostream&) const override;
76  virtual std::string printableName() const override;
77  virtual bool isEqual(const Location&) const override;
78  virtual bool operator<(const Location&) const override;
79  virtual bool operator<=(const Location&) const override;
80  virtual bool operator>(const Location&) const override;
81  virtual bool operator>=(const Location&) const override;
82 
87  int compare(const AbstractLocation &other) const;
88 
93  bool isRegister() const;
94 
99  bool isAddress() const;
100 
107 
112  const Address getAddress() const;
113 
118  size_t nBytes() const;
119 
129  bool mayAlias(const AbstractLocation &other, const SmtSolverPtr &solver = SmtSolverPtr()) const;
130 
140  bool mustAlias(const AbstractLocation &other, const SmtSolverPtr &solver = SmtSolverPtr()) const;
141 
148  void print(std::ostream &out, const RegisterDictionaryPtr &regdict) const;
149  void print(std::ostream &out, InstructionSemantics::BaseSemantics::Formatter &fmt) const;
150  void print(std::ostream &out, const RegisterDictionaryPtr &regdict, InstructionSemantics::BaseSemantics::Formatter &fmt) const;
152 };
153 
154 } // namespace
155 } // namespace
156 
157 #endif
158 #endif
virtual bool isEqual(const Location &) const override
Equality and inequality.
virtual std::string toString() const override
Convert location to string.
size_t nBytes() const
Returns size of memory location in bytes.
AbstractLocation()
Default constructor.
Main namespace for the ROSE library.
static AbstractLocation parse(const std::string &)
Parse an abstract location from a string.
RegisterDescriptor getRegister() const
Returns register.
const Address getAddress() const
Returns memory address.
Describes (part of) a physical CPU register.
Base class for location types.
Definition: Location.h:23
virtual bool isValid() const override
Test whether this object is valid.
int compare(const AbstractLocation &other) const
Compare two abstract locations.
bool isAddress() const
Checks memory reference.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
bool mayAlias(const AbstractLocation &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
True if two abstract locations could be aliases.
std::shared_ptr< SmtSolver > SmtSolverPtr
Reference counting pointer.
virtual std::string printableName() const override
Convert location to escaped, parsable string.
bool mustAlias(const AbstractLocation &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
True if two abstract locations are certainly aliases.
virtual void print(std::ostream &) const override
Output location to a stream.
bool isRegister() const
Checks register reference.
AbstractLocation & operator=(const AbstractLocation &)
Assignment operator.