================
@@ -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)
----------------
ChenMiaoi wrote:

This fallback avoids the crash, but doesn't ensure that the Fix-It insertion 
point is valid.

https://github.com/llvm/llvm-project/pull/237624
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to