Skip to content

Commit d7015cc

Browse files
committed
[Fix] Support Apple clang 15
Apple's fork of the LLVM clang compiler appears to be stricter when the keyword `template` is required.
1 parent ee53858 commit d7015cc

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/backend/WasmAlgo.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ ChainedHashTable<IsGlobal>::~ChainedHashTable()
514514
Var<Ptr<void>> bucket_it(Ptr<void>(*it.to<uint32_t*>()));
515515
WHILE (not bucket_it.is_nullptr()) { // another entry in collision list
516516
const Var<Ptr<void>> tmp(bucket_it);
517-
bucket_it = Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).to<uint32_t*>());
517+
bucket_it = Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).template to<uint32_t*>());
518518
Module::Allocator().deallocate(tmp, entry_size_in_bytes_);
519519
}
520520
it += int32_t(sizeof(uint32_t));
@@ -605,7 +605,7 @@ void ChainedHashTable<IsGlobal>::teardown()
605605
Var<Ptr<void>> bucket_it(Ptr<void>(*it.to<uint32_t*>()));
606606
WHILE (not bucket_it.is_nullptr()) { // another entry in collision list
607607
const Var<Ptr<void>> tmp(bucket_it);
608-
bucket_it = Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).to<uint32_t*>());
608+
bucket_it = Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).template to<uint32_t*>());
609609
Module::Allocator().deallocate(tmp, entry_size_in_bytes_);
610610
}
611611
it += int32_t(sizeof(uint32_t));
@@ -662,7 +662,7 @@ void ChainedHashTable<IsGlobal>::clear()
662662
Module::Allocator().deallocate(tmp, entry_size_in_bytes_); // free collision list entry
663663
}
664664
#endif
665-
*(it + ptr_offset_in_bytes_).to<uint32_t*>() = 0U; // set to nullptr
665+
*(it + ptr_offset_in_bytes_).template to<uint32_t*>() = 0U; // set to nullptr
666666
it += int32_t(sizeof(uint32_t));
667667
}
668668
}
@@ -732,7 +732,7 @@ HashTable::entry_t ChainedHashTable<IsGlobal>::emplace_without_rehashing(std::ve
732732
Var<Ptr<void>> entry = Module::Allocator().allocate(entry_size_in_bytes_, entry_max_alignment_in_bytes_);
733733

734734
/*----- Iff no predication is used or predicate is fulfilled, insert entry at collision list's front. -----*/
735-
*(entry + ptr_offset_in_bytes_).to<uint32_t*>() = *bucket.to<uint32_t*>();
735+
*(entry + ptr_offset_in_bytes_).template to<uint32_t*>() = *bucket.to<uint32_t*>();
736736
*bucket.to<uint32_t*>() = pred ? Select(*pred, entry.to<uint32_t>(), *bucket.to<uint32_t*>())
737737
: entry.to<uint32_t>(); // FIXME: entry memory never freed iff predicate is not fulfilled
738738

@@ -784,13 +784,15 @@ std::pair<HashTable::entry_t, Boolx1> ChainedHashTable<IsGlobal>::try_emplace(st
784784
} ELSE {
785785
LOOP () {
786786
GOTO(equal_key(bucket_it, clone(key)), insert_entry); // clone key (see above)
787-
const Var<Ptr<void>> next_bucket_it(Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).to<uint32_t*>()));
787+
const Var<Ptr<void>> next_bucket_it(
788+
Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).template to<uint32_t*>())
789+
);
788790
BREAK(next_bucket_it.is_nullptr());
789791
bucket_it = next_bucket_it;
790792
CONTINUE();
791793
}
792794
};
793-
Wasm_insist(Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).to<uint32_t*>()).is_nullptr());
795+
Wasm_insist(Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).template to<uint32_t*>()).is_nullptr());
794796
if (pred)
795797
Wasm_insist(*pred or bucket_it == bucket - ptr_offset_in_bytes_,
796798
"predication dummy must always contain an empty collision list");
@@ -802,8 +804,8 @@ std::pair<HashTable::entry_t, Boolx1> ChainedHashTable<IsGlobal>::try_emplace(st
802804
Var<Ptr<void>> entry = Module::Allocator().allocate(entry_size_in_bytes_, entry_max_alignment_in_bytes_);
803805

804806
/*----- Iff no predication is used or predicate is fulfilled, insert entry at the collision list's end. -----*/
805-
*(bucket_it + ptr_offset_in_bytes_).to<uint32_t*>() = pred ? Select(*pred, entry.to<uint32_t>(), 0U)
806-
: entry.to<uint32_t>(); // FIXME: entry memory never freed iff predicate is not fulfilled
807+
*(bucket_it + ptr_offset_in_bytes_).template to<uint32_t*>() = pred ? Select(*pred, entry.to<uint32_t>(), 0U)
808+
: entry.to<uint32_t>(); // FIXME: entry memory never freed iff predicate is not fulfilled
807809

808810
/*----- Set bucket iterator to inserted entry. -----*/
809811
bucket_it = entry;
@@ -843,7 +845,7 @@ std::pair<HashTable::entry_t, Boolx1> ChainedHashTable<IsGlobal>::find(std::vect
843845
Var<Ptr<void>> bucket_it(Ptr<void>(*bucket.to<uint32_t*>()));
844846
WHILE (not bucket_it.is_nullptr()) { // another entry in collision list
845847
BREAK(equal_key(bucket_it, std::move(key))); // move key at last use
846-
bucket_it = Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).to<uint32_t*>());
848+
bucket_it = Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).template to<uint32_t*>());
847849
}
848850

849851
/*----- Key is found iff end of collision list is not yet reached. -----*/
@@ -863,7 +865,7 @@ void ChainedHashTable<IsGlobal>::for_each(callback_t Pipeline) const
863865
Var<Ptr<void>> bucket_it(Ptr<void>(*it.to<uint32_t*>()));
864866
WHILE (not bucket_it.is_nullptr()) { // another entry in collision list
865867
Pipeline(entry(bucket_it));
866-
bucket_it = Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).to<uint32_t*>());
868+
bucket_it = Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).template to<uint32_t*>());
867869
}
868870
it += int32_t(sizeof(uint32_t));
869871
}
@@ -899,7 +901,7 @@ void ChainedHashTable<IsGlobal>::for_each_in_equal_range(std::vector<SQL_t> key,
899901
Pipeline(entry(bucket_it));
900902
};
901903
}
902-
bucket_it = Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).to<uint32_t*>());
904+
bucket_it = Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).template to<uint32_t*>());
903905
}
904906
}
905907

@@ -1207,10 +1209,10 @@ void ChainedHashTable<IsGlobal>::rehash()
12071209
const Var<Ptr<void>> bucket(hash_to_bucket(std::move(key)));
12081210

12091211
/*----- Store next entry's address in old collision list (since it will be overwritten). -----*/
1210-
const Var<Ptr<void>> tmp(Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).to<uint32_t*>()));
1212+
const Var<Ptr<void>> tmp(Ptr<void>(*(bucket_it + ptr_offset_in_bytes_).template to<uint32_t*>()));
12111213

12121214
/*----- Insert old entry at new collision list's front. No reallocation of the entry is needed. -----*/
1213-
*(bucket_it + ptr_offset_in_bytes_).to<uint32_t*>() = *bucket.to<uint32_t*>();
1215+
*(bucket_it + ptr_offset_in_bytes_).template to<uint32_t*>() = *bucket.to<uint32_t*>();
12141216
*bucket.to<uint32_t*>() = bucket_it.to<uint32_t>();
12151217

12161218
/*----- Advance to next entry in old collision list. -----*/

src/backend/WasmAlgo.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ struct HashTable
162162
Boolx1 operator==(T _value) {
163163
auto [value, is_null] = _value.split();
164164
if (is_null_byte_) {
165-
auto is_null_ = (**is_null_byte_ bitand *is_null_mask_).to<bool>();
165+
auto is_null_ = (**is_null_byte_ bitand *is_null_mask_).template to<bool>();
166166
auto equal_nulls = is_null_.clone() == is_null;
167167
return equal_nulls and (is_null_ or *value_ == value);
168168
} else {
@@ -173,7 +173,7 @@ struct HashTable
173173
///> Loads the value of `this`.
174174
operator T() {
175175
if (is_null_byte_)
176-
return T(*value_, (**is_null_byte_ bitand *is_null_mask_).to<bool>());
176+
return T(*value_, (**is_null_byte_ bitand *is_null_mask_).template to<bool>());
177177
else
178178
return T(*value_);
179179
}
@@ -314,7 +314,7 @@ struct HashTable
314314
auto [equal_addrs_val, equal_addrs_is_null] = _equal_addrs.split();
315315
equal_addrs_is_null.discard(); // use potentially-null value but it is overruled if it is invalid, i.e. NULL
316316
if (addr_.can_be_null()) {
317-
auto is_nullptr_ = (**is_null_byte_ bitand *is_null_mask_).to<bool>();
317+
auto is_nullptr_ = (**is_null_byte_ bitand *is_null_mask_).template to<bool>();
318318
auto equal_nulls = is_nullptr_.clone() == is_nullptr;
319319
return equal_nulls and (is_nullptr_ or equal_addrs_val);
320320
} else {
@@ -325,7 +325,7 @@ struct HashTable
325325
///> Loads the value of `this`.
326326
operator NChar() {
327327
if (addr_.can_be_null()) {
328-
Boolx1 is_null = (**is_null_byte_ bitand *is_null_mask_).to<bool>();
328+
Boolx1 is_null = (**is_null_byte_ bitand *is_null_mask_).template to<bool>();
329329
return NChar(Select(is_null, Ptr<Charx1>::Nullptr(), addr_.val()), /* can_be_null= */ true,
330330
addr_.length(), addr_.guarantees_terminating_nul());
331331
} else {

0 commit comments

Comments
 (0)