File tree 3 files changed +27
-4
lines changed
3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -96,17 +96,25 @@ struct CPPCHECKLIB FileSettings {
96
96
97
97
hash ^= std::hash<std::string>{}(standard);
98
98
99
- for (const auto &undef : undefs)
99
+ for (const auto &undef : undefs) {
100
+ hash = rotateLeft (hash, 1 );
100
101
hash ^= std::hash<std::string>{}(undef);
102
+ }
101
103
102
- for (const auto &includePath : includePaths)
104
+ for (const auto &includePath : includePaths) {
105
+ hash = rotateLeft (hash, 1 );
103
106
hash ^= std::hash<std::string>{}(includePath);
107
+ }
104
108
105
- for (const auto &systemIncludePath : systemIncludePaths)
109
+ for (const auto &systemIncludePath : systemIncludePaths) {
110
+ hash = rotateLeft (hash, 1 );
106
111
hash ^= std::hash<std::string>{}(systemIncludePath);
112
+ }
107
113
108
- for (const auto &define : splitString (defines, ' ;' ))
114
+ for (const auto &define : splitString (defines, ' ;' )) {
115
+ hash = rotateLeft (hash, 1 );
109
116
hash ^= std::hash<std::string>{}(define);
117
+ }
110
118
}
111
119
112
120
std::string cfg;
Original file line number Diff line number Diff line change @@ -397,6 +397,12 @@ static inline T* empty_if_null(T* p)
397
397
return default_if_null (p, " " );
398
398
}
399
399
400
+ template <typename T>
401
+ static inline T rotateLeft (T value, std::size_t amount)
402
+ {
403
+ return (value << amount) | (value >> (8 * sizeof (T) - amount));
404
+ }
405
+
400
406
/* *
401
407
* Split string by given sperator.
402
408
* @param str The string to split
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ class TestUtils : public TestFixture {
44
44
TEST_CASE (splitString);
45
45
TEST_CASE (as_const);
46
46
TEST_CASE (memoize);
47
+ TEST_CASE (rotateLeft);
47
48
}
48
49
49
50
void isValidGlobPattern () const {
@@ -535,6 +536,14 @@ class TestUtils : public TestFixture {
535
536
ASSERT_EQUALS (1 , callF ());
536
537
ASSERT_EQUALS (1 , count);
537
538
}
539
+
540
+ void rotateLeft () const {
541
+ uint8_t value_u8 = 0b01010101 ;
542
+ ASSERT_EQUALS (::rotateLeft (value_u8, 1 ), 0b10101010 );
543
+
544
+ uint64_t value_u64 = 0xABCDEF0123456789 ;
545
+ ASSERT_EQUALS (::rotateLeft (value_u64, 8 ), 0xCDEF0123456789AB );
546
+ }
538
547
};
539
548
540
549
REGISTER_TEST (TestUtils)
You can’t perform that action at this time.
0 commit comments