File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed
Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,14 @@ function(gtl_set_target_options my_target)
88 $<$<CXX_COMPILER_ID:GNU>:-pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Winit-self -Wmissing-include -dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wswitch-default -Wunused -Wno-interference-size>
99 $<$<CXX_COMPILER_ID:MSVC >:/W4 /Zc:__cplusplus /bigobj>
1010 )
11+
12+ if (GTL_SANITIZE)
13+ set (clang_san_options -g -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero
14+ -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -fPIE
15+ -fno-omit-frame-pointer )
16+ target_compile_options (${my_target} PUBLIC ${clang_san_options} )
17+ target_link_options (${my_target} PUBLIC ${clang_san_options} )
18+ endif ()
1119endfunction ()
1220
1321# -------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ std::mt19937_64* GetSharedRng() {
7272 return rng;
7373}
7474
75- enum Enum {
75+ enum Enum : uint64_t {
7676 kEnumEmpty ,
7777 kEnumDeleted ,
7878};
@@ -99,24 +99,15 @@ template<>
9999struct Generator <Enum> {
100100 Enum operator ()() const {
101101 std::uniform_int_distribution<typename std::underlying_type<Enum>::type> dist;
102-
103- while (true ) {
104- auto variate = dist (*GetSharedRng ());
105- if (variate != kEnumEmpty && variate != kEnumDeleted )
106- return static_cast <Enum>(variate);
107- }
102+ return static_cast <Enum>(dist (*GetSharedRng ()));
108103 }
109104};
110105
111106template <>
112107struct Generator <EnumClass> {
113108 EnumClass operator ()() const {
114109 std::uniform_int_distribution<typename std::underlying_type<EnumClass>::type> dist;
115- while (true ) {
116- EnumClass variate = static_cast <EnumClass>(dist (*GetSharedRng ()));
117- if (variate != EnumClass::kEmpty && variate != EnumClass::kDeleted )
118- return static_cast <EnumClass>(variate);
119- }
110+ return static_cast <EnumClass>(dist (*GetSharedRng ()));
120111 }
121112};
122113
You can’t perform that action at this time.
0 commit comments