aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuliano Procida <gprocida@google.com>2024-04-17 16:45:22 +0100
committerGiuliano Procida <gprocida@google.com>2024-04-25 22:06:14 +0100
commitbd7ac2942c870ce664eae326d81c6c6b48da9599 (patch)
treeacdccbc9ebf580dd2f12ce67cecd01fa5d605bfe
parentcee934c475d281bee29eb13541311531dfb64103 (diff)
downloadstg-bd7ac2942c870ce664eae326d81c6c6b48da9599.tar.gz
comparison: use a cleaner enum for Ignore options
We lose the automatically-sized bitset type but gain not having to maintain a list of powers of 2. PiperOrigin-RevId: 625696627 Change-Id: Ibd6f3f6311e1a16be37cc5d2e209773500020858
-rw-r--r--comparison.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/comparison.h b/comparison.h
index 034c16a..81eccf5 100644
--- a/comparison.h
+++ b/comparison.h
@@ -23,6 +23,7 @@
#define STG_COMPARISON_H_
#include <cstddef>
+#include <cstdint>
#include <functional>
#include <map>
#include <memory>
@@ -32,7 +33,6 @@
#include <sstream>
#include <string>
#include <string_view>
-#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
@@ -46,19 +46,19 @@ namespace stg {
struct Ignore {
enum Value {
// noise reduction
- SYMBOL_TYPE_PRESENCE = 1<<0,
- TYPE_DECLARATION_STATUS = 1<<1,
- PRIMITIVE_TYPE_ENCODING = 1<<2,
- MEMBER_SIZE = 1<<3,
- ENUM_UNDERLYING_TYPE = 1<<4,
- QUALIFIER = 1<<5,
- SYMBOL_CRC = 1<<6,
+ SYMBOL_TYPE_PRESENCE,
+ TYPE_DECLARATION_STATUS,
+ PRIMITIVE_TYPE_ENCODING,
+ MEMBER_SIZE,
+ ENUM_UNDERLYING_TYPE,
+ QUALIFIER,
+ SYMBOL_CRC,
// ABI compatibility testing
- INTERFACE_ADDITION = 1<<7,
- TYPE_DEFINITION_ADDITION = 1<<8,
+ INTERFACE_ADDITION,
+ TYPE_DEFINITION_ADDITION,
};
- using Bitset = std::underlying_type_t<Value>;
+ using Bitset = uint16_t;
Ignore() = default;
template <typename... Values>
@@ -69,10 +69,10 @@ struct Ignore {
}
void Set(Value other) {
- bitset |= static_cast<Bitset>(other);
+ bitset = bitset | (1 << other);
}
bool Test(Value other) const {
- return bitset & static_cast<Bitset>(other);
+ return bitset & (1 << other);
}
Bitset bitset = 0;