Skip to content

Commit c27ee11

Browse files
authored
Fixes to build with C++20 (#5332)
Add another template typename for pointer <-> ilist_iterator comparison operators. C++20 considers these ambiguous for the same reasons outlined in godotengine/godot#54058 The rest of the changes are general bug fixes which are now caught by the compiler.
1 parent c201a11 commit c27ee11

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

include/llvm/ADT/ilist.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,24 @@ void operator+(ilist_iterator<T>,int) = delete;
248248

249249
// operator!=/operator== - Allow mixed comparisons without dereferencing
250250
// the iterator, which could very likely be pointing to end().
251-
template<typename T>
252-
bool operator!=(const T* LHS, const ilist_iterator<const T> &RHS) {
251+
// HLSL Change Begin: Support for C++20
252+
template<typename T, typename U>
253+
bool operator!=(const T* LHS, const ilist_iterator<const U> &RHS) {
253254
return LHS != RHS.getNodePtrUnchecked();
254255
}
255-
template<typename T>
256-
bool operator==(const T* LHS, const ilist_iterator<const T> &RHS) {
256+
template<typename T, typename U>
257+
bool operator==(const T* LHS, const ilist_iterator<const U> &RHS) {
257258
return LHS == RHS.getNodePtrUnchecked();
258259
}
259-
template<typename T>
260-
bool operator!=(T* LHS, const ilist_iterator<T> &RHS) {
260+
template<typename T, typename U>
261+
bool operator!=(T* LHS, const ilist_iterator<U> &RHS) {
261262
return LHS != RHS.getNodePtrUnchecked();
262263
}
263-
template<typename T>
264-
bool operator==(T* LHS, const ilist_iterator<T> &RHS) {
264+
template<typename T, typename U>
265+
bool operator==(T* LHS, const ilist_iterator<U> &RHS) {
265266
return LHS == RHS.getNodePtrUnchecked();
266267
}
268+
// HLSL Change End
267269

268270

269271
// Allow ilist_iterators to convert into pointers to a node automatically when

lib/DxilDia/DxcPixLiveVariables_FragmentIterator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ class CompositeTypeFragmentIterator : public dxil_debug_info::MemberIterator {
212212
};
213213
std::vector<FragmentSizeAndOffset> m_fragmentLocations;
214214
unsigned m_currentFragment = 0;
215-
void CompositeTypeFragmentIterator::DetermineStructMemberSizesAndOffsets(
216-
llvm::DIType const*, uint64_t BaseOffset);
215+
void DetermineStructMemberSizesAndOffsets(llvm::DIType const*, uint64_t BaseOffset);
217216
};
218217

219218
unsigned SizeIfBaseType(llvm::DIType const* diType)

lib/DxilDia/DxilDiaSymbolManager.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace hlsl_symbols {
4040

4141
// HLSL Symbol Hierarchy
4242
// ---- ------ ---------
43-
//
43+
//
4444
// +---------------+
4545
// | Program (EXE) | Global Scope
4646
// +------+--------+
@@ -50,14 +50,14 @@ namespace hlsl_symbols {
5050
// +--------+-----------+
5151
// |
5252
// +------------+------------+--------+-------+------------+--------------+
53-
// | | | | | | |
53+
// | | | | | | |
5454
// +----^----+ +---^---+ +----^---+ | +---^---+ +----^----+ +-----^-----+
5555
// | Details | | Flags | | Target | | | Entry | | Defines | | Arguments | Synthetic Symbols
5656
// +---------+ +-------+ +--------+ | +-------+ +---------+ +-----------+
5757
// |
5858
// |
5959
// +---------------+------------+----+-----+-------------+-----------+
60-
// | | | | | |
60+
// | | | | | |
6161
// +-----^-----+ +-----^-----+ +--^--+ +---^--+ +---^--+ +--^--+
6262
// | Function0 | | Function1 | | ... | | UDT0 | | UDT1 | | ... | Source Symbols
6363
// +-----+-----+ +-----+-----+ +-----+ +---+--+ +---+--+ +-----+
@@ -111,14 +111,14 @@ struct TypedSymbol : public DISymbol<N> {
111111
if (ppRetVal == nullptr) {
112112
return E_INVALIDARG;
113113
}
114-
*ppRetVal = false;
114+
*ppRetVal = nullptr;
115115

116116
if (m_pType == nullptr) {
117117
return S_FALSE;
118118
}
119119

120120
Symbol *ret;
121-
IFR(m_pSession->SymMgr().GetSymbolByID(m_dwTypeID, &ret));
121+
IFR(this->m_pSession->SymMgr().GetSymbolByID(m_dwTypeID, &ret));
122122

123123
*ppRetVal = ret;
124124
return S_OK;
@@ -975,7 +975,7 @@ STDMETHODIMP dxil_dia::hlsl_symbols::VectorTypeSymbol::get_type(
975975
if (ppRetVal == nullptr) {
976976
return E_INVALIDARG;
977977
}
978-
*ppRetVal = false;
978+
*ppRetVal = nullptr;
979979

980980
Symbol *ret;
981981
IFR(m_pSession->SymMgr().GetSymbolByID(m_ElemTyID, &ret));
@@ -1570,7 +1570,7 @@ HRESULT dxil_dia::hlsl_symbols::SymbolManagerInit::CreateCompositeType(DWORD dwP
15701570
} else {
15711571
for (llvm::DINode *N : CT->getElements()) {
15721572
if (auto *Field = llvm::dyn_cast<llvm::DIType>(N)) {
1573-
std::unique_ptr<UDTScope> UDTScopeOverride;
1573+
std::unique_ptr<UDTScope> UDTScopeOverride;
15741574
if (Field->isStaticMember()) {
15751575
// Static members do not contribute to sizes or offsets.
15761576
UDTScopeOverride.reset(new UDTScope(&m_pCurUDT, nullptr));

0 commit comments

Comments
 (0)