Skip to content

Commit 11e1318

Browse files
authored
[Sema] Check FunctionDecl has identifier before getName. (#6439) (#6457)
Use identifier name without check the identifier exists will cause crash. Fixes #6426 --------- Co-authored-by: Tex Riddell <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> (cherry picked from commit 7581ff4)
1 parent 9c2b828 commit 11e1318

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

tools/clang/lib/Sema/SemaHLSL.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -15690,7 +15690,8 @@ void TryAddShaderAttrFromTargetProfile(Sema &S, FunctionDecl *FD,
1569015690

1569115691
// if this FD isn't the entry point, then we shouldn't add
1569215692
// a shader attribute to this decl, so just return
15693-
if (EntryPointName != FD->getIdentifier()->getName()) {
15693+
if (!FD->getIdentifier() ||
15694+
EntryPointName != FD->getIdentifier()->getName()) {
1569415695
return;
1569515696
}
1569615697

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %dxc -Tps_6_0 -verify %s
2+
3+
// expected-error@+1 {{overloading non-member 'operator==' is not allowed}}
4+
bool operator==(int lhs, int rhs) {
5+
return true;
6+
}
7+
8+
struct A {
9+
float a;
10+
int b;
11+
};
12+
13+
// expected-error@+1 {{overloading non-member 'operator>' is not allowed}}
14+
bool operator>(A a0, A a1) {
15+
return a1.a > a0.a && a1.b > a0.b;
16+
}
17+
// expected-error@+1 {{overloading non-member 'operator==' is not allowed}}
18+
bool operator==(A a0, int i) {
19+
return a0.b == i;
20+
}
21+
// expected-error@+1 {{overloading non-member 'operator<' is not allowed}}
22+
bool operator<(A a0, float f) {
23+
return a0.a < f;
24+
}
25+
// expected-error@+1 {{overloading 'operator++' is not allowed}}
26+
A operator++(A a0) {
27+
a0.a++;
28+
a0.b++;
29+
return a0;
30+
}
31+
32+
void main() {}

0 commit comments

Comments
 (0)