[clang] [Clang][Sema] fix crash of attribute transform (PR #78088)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 19 08:56:57 PST 2024
================
@@ -6124,7 +6124,11 @@ QualType TreeTransform<Derived>::TransformFunctionProtoType(
// "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
// and the end of the function-definition, member-declarator, or
// declarator.
- Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, ThisTypeQuals);
+ auto *RD =
+ dyn_cast_or_null<CXXRecordDecl>(SemaRef.getCurLexicalContext());
+ Sema::CXXThisScopeRAII ThisScope(
+ SemaRef, ThisContext == nullptr && nullptr != RD ? RD : ThisContext,
+ ThisTypeQuals);
----------------
AaronBallman wrote:
```suggestion
auto *RD =
dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
Sema::CXXThisScopeRAII ThisScope(
SemaRef, !ThisContext && RD ? RD : ThisContext,
ThisTypeQuals);
```
https://github.com/llvm/llvm-project/pull/78088
More information about the cfe-commits
mailing list