-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang] Crash in clang codegen after CXXDependentScopeMemberExpr change #97483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@sdkrystian would you mind taking a look at this? It seems to be a regression from #92318 |
@llvm/issue-subscribers-clang-codegen Author: Mike Rice (mikerice1969)
Attached test crashes in clang codegen after fd87d76. The test has been creduced from some 600,000+ lines of preprocessed Windows blender code. The crash happens in the same place in the full code (but the expression is used).
|
The problem here is that we transform the first operand of binary |
Reduced to: struct A {
int x;
};
void operator&(A);
template<typename T>
struct B {
bool f() {
return T::x & 1; // should diagnose this as an invalid id-expression naming a non-static data member per [expr.prim.id.general] p4.
}
};
template struct B<A>; |
@mikerice1969 Have a fix ready in #97596 |
Thanks. Taking a look now. |
The full preprocessed test also seems to compile okay with this fix. @sdkrystian thanks for the quick fix! |
@llvm/issue-subscribers-clang-frontend Author: Mike Rice (mikerice1969)
Attached test crashes in clang codegen after fd87d76. The test has been creduced from some 600,000+ lines of preprocessed Windows blender code. The crash happens in the same place in the full code (but the expression is used).
|
…nary operator& (llvm#97596) Currently, `TreeTransform::TransformCXXOperatorCallExpr` calls `TreeTransform::TransformAddressOfOperand` to transform the first operand of a `CXXOperatorCallExpr` when its `OverloadOperatorKind` is `OO_Amp` -- regardless of arity. This results in the first operand of binary `operator&` being incorrectly transformed as if it was the operand of the address of operator in cases such as the following: ``` struct A { int x; }; void operator&(A, A); template<typename T> struct B { int f() { return T::x & 1; // invalid reference to 'A::x' is not diagnosed because 'T::x' is incorrectly transformed as if it was the operand of unary operator& } }; template struct B<A>; ``` Prior to llvm#92318 we would build a `CXXDependentScopeMemberExpr` for `T::x` (as with most dependent qualified names that were not member qualified names). Since `TreeTransform::TransformAddressOfOperand` only differs from `TransformExpr` for `DependentScopeDeclRefExpr` and `UnresolvedLookupExpr` operands, `T::x` was transformed "correctly". Now that we build a `DependentScopeDeclRefExpr` for `T::x`, it is incorrectly transformed as if it was the operand of the address of operator and we fail to diagnose the invalid reference to a non-static data member. This patch fixes the issue by only calling `TreeTransform::TransformAddressOfOperand` for `CXXOperatorCallExpr`s with a single operand. This fixes llvm#97483.
Attached test crashes in clang codegen after fd87d76. The test has been creduced from some 600,000+ lines of preprocessed Windows blender code. The crash happens in the same place in the full code (but the expression is used).
testcase.zip
The text was updated successfully, but these errors were encountered: