Skip to content

Commit e824ae3

Browse files
authored
[SPIRV] Check if decl is identifier before getting name (microsoft#7012)
We hit an assert when trying to get the name of `operator()`. This is fixed by first checking if it function declatarion is an identifier. Fixes microsoft#6973
1 parent 9b9442c commit e824ae3

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,8 @@ void SpirvEmitter::HandleTranslationUnit(ASTContext &context) {
778778
}
779779
} else {
780780
const bool isPrototype = !funcDecl->isThisDeclarationADefinition();
781-
if (funcDecl->getName() == hlslEntryFunctionName && !isPrototype) {
781+
if (funcDecl->getIdentifier() &&
782+
funcDecl->getName() == hlslEntryFunctionName && !isPrototype) {
782783
addFunctionToWorkQueue(spvContext.getCurrentShaderModelKind(),
783784
funcDecl, /*isEntryFunction*/ true);
784785
numEntryPoints++;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %dxc -T cs_6_0 -E main -spirv -fcgl %s -spirv | FileCheck %s
2+
3+
4+
// CHECK: %src_main = OpFunction %void
5+
// CHECK: OpFunctionCall %void %S_operator_Call %s
6+
// CHECK: OpFunctionEnd
7+
// CHECK: %S_operator_Call = OpFunction %void None
8+
// CHECK-NEXT: OpFunctionParameter
9+
// CHECK-NEXT: OpLabel
10+
// CHECK-NEXT: OpReturn
11+
// CHECK-NEXT: OpFunctionEnd
12+
13+
14+
struct S
15+
{
16+
void operator()();
17+
};
18+
19+
void S::operator()()
20+
{
21+
}
22+
23+
[numthreads(8,8,1)]
24+
void main(uint32_t3 gl_GlobalInvocationID : SV_DispatchThreadID)
25+
{
26+
S s;
27+
s();
28+
}
29+

0 commit comments

Comments
 (0)