llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Botond István Horváth (HoBoIs)

<details>
<summary>Changes</summary>

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 &amp;)' to 'decltype(fun_ptr)' (aka 
'long (*)(int &amp;)') converts to incompatible function type 
[-Wcast-function-type-strict]
   24 | return decltype(fun_ptr)( f_ptr /*comment*/);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~
```
After:
```
warning: cast from 'long (*)(const int &amp;)' to 'decltype(fun_ptr)' (aka 
'long (*)(int &amp;)') converts to incompatible function type 
[-Wcast-function-type-strict]
   24 | return decltype(fun_ptr)( f_ptr /*comment*/);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

---
Full diff: https://github.com/llvm/llvm-project/pull/69480.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaCast.cpp (+1-1) 


``````````diff
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())

``````````

</details>


https://github.com/llvm/llvm-project/pull/69480
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to