-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We only ever inherit from `c_qualifierst` and can safely avoid the use of `dynamic_cast` by making `expr2ct` use `c_qualifierst` instead of `qualifierst`. The `clone()` facility introduced in #1831 (where `qualifierst` was introduced) remains in place to support derived implementations (like `java_qualifierst`). Also, reduce the number of explicit `c_qualifierst()` calls by making use of `convert` and `convert_with_identifier`.
- Loading branch information
1 parent
3877e0f
commit eabcf9c
Showing
9 changed files
with
45 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,45 +10,12 @@ Author: Daniel Kroening, [email protected] | |
#ifndef CPROVER_ANSI_C_C_QUALIFIERS_H | ||
#define CPROVER_ANSI_C_C_QUALIFIERS_H | ||
|
||
#include <iosfwd> | ||
#include <memory> | ||
#include <string> | ||
|
||
class typet; | ||
|
||
class qualifierst | ||
{ | ||
protected: | ||
// Only derived classes can construct | ||
qualifierst() = default; | ||
|
||
public: | ||
// Copy/move construction/assignment is deleted here and in derived classes | ||
qualifierst(const qualifierst &) = delete; | ||
qualifierst(qualifierst &&) = delete; | ||
qualifierst &operator=(const qualifierst &) = delete; | ||
qualifierst &operator=(qualifierst &&) = delete; | ||
|
||
// Destruction is virtual | ||
virtual ~qualifierst() = default; | ||
|
||
public: | ||
virtual std::unique_ptr<qualifierst> clone() const = 0; | ||
|
||
virtual std::size_t count() const = 0; | ||
|
||
virtual void clear() = 0; | ||
|
||
virtual void read(const typet &src) = 0; | ||
virtual void write(typet &src) const = 0; | ||
|
||
// String conversion | ||
virtual std::string as_string() const = 0; | ||
friend std::ostream &operator<<(std::ostream &, const qualifierst &); | ||
}; | ||
|
||
|
||
class c_qualifierst : public qualifierst | ||
class c_qualifierst | ||
{ | ||
public: | ||
c_qualifierst() | ||
|
@@ -62,12 +29,14 @@ class c_qualifierst : public qualifierst | |
read(src); | ||
} | ||
|
||
virtual ~c_qualifierst() = default; | ||
|
||
protected: | ||
c_qualifierst &operator=(const c_qualifierst &other); | ||
public: | ||
virtual std::unique_ptr<qualifierst> clone() const override; | ||
virtual std::unique_ptr<c_qualifierst> clone() const; | ||
|
||
virtual void clear() override | ||
virtual void clear() | ||
{ | ||
is_constant=false; | ||
is_volatile=false; | ||
|
@@ -91,9 +60,9 @@ class c_qualifierst : public qualifierst | |
|
||
// will likely add alignment here as well | ||
|
||
virtual std::string as_string() const override; | ||
virtual void read(const typet &src) override; | ||
virtual void write(typet &src) const override; | ||
virtual std::string as_string() const; | ||
virtual void read(const typet &src); | ||
virtual void write(typet &src) const; | ||
|
||
static void clear(typet &dest); | ||
|
||
|
@@ -141,7 +110,7 @@ class c_qualifierst : public qualifierst | |
return *this; | ||
} | ||
|
||
virtual std::size_t count() const override | ||
virtual std::size_t count() const | ||
{ | ||
return is_constant + is_volatile + is_restricted + is_atomic + is_ptr32 + | ||
is_ptr64 + is_nodiscard + is_noreturn; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ Author: Daniel Kroening, [email protected] | |
#include <util/std_code.h> | ||
|
||
class annotated_pointer_constant_exprt; | ||
class qualifierst; | ||
class c_qualifierst; | ||
class namespacet; | ||
class r_or_w_ok_exprt; | ||
class pointer_in_range_exprt; | ||
|
@@ -57,7 +57,7 @@ class expr2ct | |
|
||
virtual std::string convert_rec( | ||
const typet &src, | ||
const qualifierst &qualifiers, | ||
const c_qualifierst &qualifiers, | ||
const std::string &declarator); | ||
|
||
virtual std::string convert_struct_type( | ||
|
@@ -74,12 +74,12 @@ class expr2ct | |
|
||
virtual std::string convert_array_type( | ||
const typet &src, | ||
const qualifierst &qualifiers, | ||
const c_qualifierst &qualifiers, | ||
const std::string &declarator_str); | ||
|
||
std::string convert_array_type( | ||
const typet &src, | ||
const qualifierst &qualifiers, | ||
const c_qualifierst &qualifiers, | ||
const std::string &declarator_str, | ||
bool inc_size_if_possible); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters