================
@@ -715,14 +715,19 @@ class LifetimeSafetySemaHelperImpl final : public
LifetimeSafetySemaHelper {
// after '->', placing the attribute in an invalid position.
// Instead use 'getLocalRangeEnd()' which gives the '->' location
// for trailing returns, so find the last token before it.
- const auto FTL = MDL.getAs<FunctionTypeLoc>();
- assert(FTL);
- InsertionPoint = Lexer::getLocForEndOfToken(
- Lexer::findPreviousToken(FTL.getLocalRangeEnd(),
S.getSourceManager(),
- S.getLangOpts(),
- /*IncludeComments=*/false)
- ->getLocation(),
- 0, S.getSourceManager(), S.getLangOpts());
+ // A parenthesised declarator (e.g. 'auto (f)() & -> T') wraps the
+ // FunctionTypeLoc inside a ParenTypeLoc. getAs<> does not look through
+ // ParenTypeLoc, so use getAsAdjusted<> which strips qualifying wrappers.
+ const auto FTL = MDL.getAsAdjusted<FunctionTypeLoc>();
+ if (!FTL)
----------------
NeKon69 wrote:
This is not the correct fix. The fix-it must appear. Because this is a valid
position.
```cpp
struct S {
auto (operator++)() & [[clang::lifetimebound]] -> S & { return *this; }
};
```
https://godbolt.org/z/TEoh57ncs
https://github.com/llvm/llvm-project/pull/237624
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits