https://github.com/HoBoIs created 
https://github.com/llvm/llvm-project/pull/69480

Set the correct end for the CastOperation.OpRange in CXXFunctionalCastExpr. Now 
it is the closing bracket's location instead of the parameter's location.

This can lead to better highlight in the diagnostics. 
Similar to https://github.com/llvm/llvm-project/pull/66853
Example:
Before:
```
warning: cast from 'long (*)(const int &)' to 'decltype(fun_ptr)' (aka 'long 
(*)(int &)') converts to incompatible function type 
[-Wcast-function-type-strict]
   24 | return decltype(fun_ptr)( f_ptr /*comment*/);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
```
After:
```
warning: cast from 'long (*)(const int &)' to 'decltype(fun_ptr)' (aka 'long 
(*)(int &)') converts to incompatible function type 
[-Wcast-function-type-strict]
   24 | return decltype(fun_ptr)( f_ptr /*comment*/);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

From f75c2e75042d6d8f5a093967a56f3f59d7e541f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Botond=20Istv=C3=A1n=20Horv=C3=A1th?=
 <56926027+hob...@users.noreply.github.com>
Date: Wed, 18 Oct 2023 18:05:01 +0200
Subject: [PATCH] Correct end for the CastOperation.OpRange

Set the correct end for the CastOperation.OpRange in CXXFunctionalCastExpr. Now 
it is the closing bracket's location instead of the parameter's location.
---
 clang/lib/Sema/SemaCast.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 98b5879456e2175..87e6d1a2198fcea 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -3362,7 +3362,7 @@ ExprResult 
Sema::BuildCXXFunctionalCastExpr(TypeSourceInfo *CastTypeInfo,
   assert(LPLoc.isValid() && "List-initialization shouldn't get here.");
   CastOperation Op(*this, Type, CastExpr);
   Op.DestRange = CastTypeInfo->getTypeLoc().getSourceRange();
-  Op.OpRange = SourceRange(Op.DestRange.getBegin(), CastExpr->getEndLoc());
+  Op.OpRange = SourceRange(Op.DestRange.getBegin(), RPLoc);
 
   Op.CheckCXXCStyleCast(/*FunctionalCast=*/true, /*ListInit=*/false);
   if (Op.SrcExpr.isInvalid())

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to