Skip to content

Commit 3613f47

Browse files
tcorringhamtex3d
authored andcommitted
Update tools/clang/lib/CodeGen/CGHLSLMS.cpp
Adopting code suggested in review - there can only be one concrete base so the sort step isn't required. Co-authored-by: Tex Riddell <[email protected]>
1 parent eb88b69 commit 3613f47

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

tools/clang/lib/CodeGen/CGHLSLMS.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,24 +2572,15 @@ bool CGMSHLSLRuntime::FindDispatchGridSemantic(const CXXRecordDecl *RD,
25722572
CharUnits Offset) {
25732573
const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
25742574

2575-
// Collect any bases.
2576-
SmallVector<const CXXRecordDecl *, 4> Bases;
2575+
// Check (non-virtual) bases
25772576
for (const CXXBaseSpecifier &Base : RD->bases()) {
2578-
if (!Base.getType()->isDependentType())
2579-
Bases.push_back(Base.getType()->getAsCXXRecordDecl());
2580-
}
2581-
2582-
// Sort bases by offset.
2583-
std::stable_sort(Bases.begin(), Bases.end(),
2584-
[&](const CXXRecordDecl *L, const CXXRecordDecl *R) {
2585-
return Layout.getBaseClassOffset(L) <
2586-
Layout.getBaseClassOffset(R);
2587-
});
2588-
2589-
// Check bases in order
2590-
for (const CXXRecordDecl *Base : Bases) {
2591-
CharUnits BaseOffset = Offset + Layout.getBaseClassOffset(Base);
2592-
if (FindDispatchGridSemantic(Base, SDGRec, BaseOffset))
2577+
DXASSERT(!Base.getType()->isDependentType(),
2578+
"Node Record with dependent base class not caught by Sema");
2579+
if (Base.isVirtual() || Base.getType()->isDependentType())
2580+
continue;
2581+
CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl();
2582+
CharUnits BaseOffset = Offset + Layout.getBaseClassOffset(BaseDecl);
2583+
if (FindDispatchGridSemantic(BaseDecl, SDGRec, BaseOffset))
25932584
return true;
25942585
}
25952586

0 commit comments

Comments
 (0)