Skip to content

Commit 60500e8

Browse files
committed
Introduce ansi-c/c_expr.h
This introduces a new header file, ansi-c/c_expr.h, which is to collect expressions that are specific to and internal to the C frontend.
1 parent ae4dca8 commit 60500e8

File tree

7 files changed

+9
-141
lines changed

7 files changed

+9
-141
lines changed

src/ansi-c/c_typecheck_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Author: Daniel Kroening, [email protected]
2121
#include <util/typecheck.h>
2222

2323
#include "ansi_c_declaration.h"
24+
#include "c_expr.h"
2425
#include "designator.h"
2526

2627
class c_typecheck_baset:

src/ansi-c/expr2c.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Author: Daniel Kroening, [email protected]
3232
#include <util/suffix.h>
3333
#include <util/symbol.h>
3434

35+
#include "c_expr.h"
3536
#include "c_misc.h"
3637
#include "c_qualifiers.h"
3738
#include "expr2c_class.h"

src/ansi-c/expr2c_class.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ Author: Daniel Kroening, [email protected]
2222
#include <util/std_code.h>
2323
#include <util/std_expr.h>
2424

25-
class qualifierst;
25+
class code_asmt;
2626
class namespacet;
27+
class qualifierst;
2728

2829
class expr2ct
2930
{

src/assembler/remove_asm.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Date: December 2014
1515

1616
#include "remove_asm.h"
1717

18+
#include <ansi-c/c_expr.h>
19+
1820
#include <util/c_types.h>
1921
#include <util/pointer_expr.h>
2022
#include <util/string_constant.h>

src/cpp/parse.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
2020
#include <util/std_types.h>
2121

2222
#include <ansi-c/ansi_c_y.tab.h>
23+
#include <ansi-c/c_expr.h>
2324
#include <ansi-c/merged_type.h>
2425

2526
#include "cpp_token_buffer.h"

src/goto-programs/goto_convert_class.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Author: Daniel Kroening, [email protected]
2222
#include <util/replace_expr.h>
2323
#include <util/std_code.h>
2424

25+
#include <ansi-c/c_expr.h>
26+
2527
#include "goto_program.h"
2628
#include "destructor_tree.h"
2729

src/util/std_code.h

Lines changed: 0 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,146 +1696,6 @@ inline code_continuet &to_code_continue(codet &code)
16961696
return static_cast<code_continuet &>(code);
16971697
}
16981698

1699-
/// \ref codet representation of an inline assembler statement.
1700-
class code_asmt:public codet
1701-
{
1702-
public:
1703-
code_asmt():codet(ID_asm)
1704-
{
1705-
}
1706-
1707-
explicit code_asmt(exprt expr) : codet(ID_asm, {std::move(expr)})
1708-
{
1709-
}
1710-
1711-
const irep_idt &get_flavor() const
1712-
{
1713-
return get(ID_flavor);
1714-
}
1715-
1716-
void set_flavor(const irep_idt &f)
1717-
{
1718-
set(ID_flavor, f);
1719-
}
1720-
};
1721-
1722-
template<> inline bool can_cast_expr<code_asmt>(const exprt &base)
1723-
{
1724-
return detail::can_cast_code_impl(base, ID_asm);
1725-
}
1726-
1727-
// to_code_asm only checks the code statement, so no validate_expr is
1728-
// provided for code_asmt
1729-
1730-
inline code_asmt &to_code_asm(codet &code)
1731-
{
1732-
PRECONDITION(code.get_statement() == ID_asm);
1733-
return static_cast<code_asmt &>(code);
1734-
}
1735-
1736-
inline const code_asmt &to_code_asm(const codet &code)
1737-
{
1738-
PRECONDITION(code.get_statement() == ID_asm);
1739-
return static_cast<const code_asmt &>(code);
1740-
}
1741-
1742-
/// \ref codet representation of an inline assembler statement,
1743-
/// for the gcc flavor.
1744-
class code_asm_gcct : public code_asmt
1745-
{
1746-
public:
1747-
code_asm_gcct()
1748-
{
1749-
set_flavor(ID_gcc);
1750-
operands().resize(5);
1751-
}
1752-
1753-
exprt &asm_text()
1754-
{
1755-
return op0();
1756-
}
1757-
1758-
const exprt &asm_text() const
1759-
{
1760-
return op0();
1761-
}
1762-
1763-
exprt &outputs()
1764-
{
1765-
return op1();
1766-
}
1767-
1768-
const exprt &outputs() const
1769-
{
1770-
return op1();
1771-
}
1772-
1773-
exprt &inputs()
1774-
{
1775-
return op2();
1776-
}
1777-
1778-
const exprt &inputs() const
1779-
{
1780-
return op2();
1781-
}
1782-
1783-
exprt &clobbers()
1784-
{
1785-
return op3();
1786-
}
1787-
1788-
const exprt &clobbers() const
1789-
{
1790-
return op3();
1791-
}
1792-
1793-
exprt &labels()
1794-
{
1795-
return operands()[4];
1796-
}
1797-
1798-
const exprt &labels() const
1799-
{
1800-
return operands()[4];
1801-
}
1802-
1803-
protected:
1804-
using code_asmt::op0;
1805-
using code_asmt::op1;
1806-
using code_asmt::op2;
1807-
using code_asmt::op3;
1808-
};
1809-
1810-
template <>
1811-
inline bool can_cast_expr<code_asm_gcct>(const exprt &base)
1812-
{
1813-
return detail::can_cast_code_impl(base, ID_asm);
1814-
}
1815-
1816-
inline void validate_expr(const code_asm_gcct &x)
1817-
{
1818-
validate_operands(x, 5, "code_asm_gcc must have five operands");
1819-
}
1820-
1821-
inline code_asm_gcct &to_code_asm_gcc(codet &code)
1822-
{
1823-
PRECONDITION(code.get_statement() == ID_asm);
1824-
PRECONDITION(to_code_asm(code).get_flavor() == ID_gcc);
1825-
code_asm_gcct &ret = static_cast<code_asm_gcct &>(code);
1826-
validate_expr(ret);
1827-
return ret;
1828-
}
1829-
1830-
inline const code_asm_gcct &to_code_asm_gcc(const codet &code)
1831-
{
1832-
PRECONDITION(code.get_statement() == ID_asm);
1833-
PRECONDITION(to_code_asm(code).get_flavor() == ID_gcc);
1834-
const code_asm_gcct &ret = static_cast<const code_asm_gcct &>(code);
1835-
validate_expr(ret);
1836-
return ret;
1837-
}
1838-
18391699
/// \ref codet representation of an expression statement.
18401700
/// It has one operand, which is the expression it stores.
18411701
class code_expressiont:public codet

0 commit comments

Comments
 (0)