Skip to content

Commit dc5f031

Browse files
author
Daniel Kroening
committed
ID_* symbols are now constexpr
1 parent c6beb68 commit dc5f031

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

src/util/irep_ids.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,15 @@ const char *irep_ids_table[]=
2727

2828
#ifdef USE_DSTRING
2929

30-
enum class idt:unsigned
31-
{
32-
#define IREP_ID_ONE(the_id) id_##the_id,
33-
#define IREP_ID_TWO(the_id, str) id_##the_id,
34-
35-
#include "irep_ids.def" // NOLINT(build/include)
36-
};
37-
38-
#define IREP_ID_ONE(the_id) \
39-
const dstringt ID_##the_id=dstringt::make_from_table_index( \
40-
static_cast<unsigned>(idt::id_##the_id));
41-
#define IREP_ID_TWO(the_id, str) \
42-
const dstringt ID_##the_id=dstringt::make_from_table_index( \
43-
static_cast<unsigned>(idt::id_##the_id));
44-
4530
#else
4631

4732
#define IREP_ID_ONE(the_id) const std::string ID_##the_id(#the_id);
4833
#define IREP_ID_TWO(the_id, str) const std::string ID_##the_id(#the_id);
4934

50-
#endif
51-
5235
#include "irep_ids.def" // NOLINT(build/include)
5336

37+
#endif
38+
5439
string_containert::string_containert()
5540
{
5641
// pre-allocate empty string -- this gets index 0

src/util/irep_ids.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,29 @@ Author: Reuben Thomas, [email protected]
3535

3636
#ifdef USE_DSTRING
3737

38-
#define IREP_ID_ONE(the_id) extern const dstringt ID_##the_id;
39-
#define IREP_ID_TWO(the_id, str) extern const dstringt ID_##the_id;
38+
enum class idt:unsigned
39+
{
40+
#define IREP_ID_ONE(the_id) id_##the_id,
41+
#define IREP_ID_TWO(the_id, str) id_##the_id,
42+
43+
#include "irep_ids.def" // NOLINT(build/include)
44+
};
45+
46+
#ifdef __GNUC__
47+
#define IREP_ID_ONE(the_id) \
48+
constexpr dstringt ID_##the_id=dstringt::make_from_table_index( \
49+
static_cast<unsigned>(idt::id_##the_id));
50+
#define IREP_ID_TWO(the_id, str) \
51+
constexpr dstringt ID_##the_id=dstringt::make_from_table_index( \
52+
static_cast<unsigned>(idt::id_##the_id));
53+
#else
54+
#define IREP_ID_ONE(the_id) \
55+
const dstringt ID_##the_id=dstringt::make_from_table_index( \
56+
static_cast<unsigned>(idt::id_##the_id));
57+
#define IREP_ID_TWO(the_id, str) \
58+
const const dstringt ID_##the_id=dstringt::make_from_table_index( \
59+
static_cast<unsigned>(idt::id_##the_id));
60+
#endif
4061

4162
#else
4263

0 commit comments

Comments
 (0)