================
@@ -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)
----------------
aaditya8979 wrote:
Good point. When FTL is null we're still inside the trailing-return block, so
InsertionPoint covers the return type and isn't a valid attribute site. Updated
to return an empty fix-it in that case so the diagnostic fires without a
suggestion.
https://github.com/llvm/llvm-project/pull/237624
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits