[libcxx-commits] [libcxxabi] [clang] Correct end for the `CastOperation.OpRange` (PR #69480)
Botond István Horváth via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 20 02:13:15 PDT 2023
https://github.com/HoBoIs updated https://github.com/llvm/llvm-project/pull/69480
>From f75c2e75042d6d8f5a093967a56f3f59d7e541f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Botond=20Istv=C3=A1n=20Horv=C3=A1th?=
<56926027+HoBoIs at users.noreply.github.com>
Date: Wed, 18 Oct 2023 18:05:01 +0200
Subject: [PATCH 1/3] 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())
>From c5b49768eaa4f4ceab110a9fc35a9fa0924409f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Botond=20Istv=C3=A1n=20Horv=C3=A1th?=
<56926027+HoBoIs at users.noreply.github.com>
Date: Thu, 19 Oct 2023 13:47:47 +0200
Subject: [PATCH 2/3] Added a test to misc-source-ranges.cpp
---
clang/test/Misc/misc-source-ranges.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/clang/test/Misc/misc-source-ranges.cpp b/clang/test/Misc/misc-source-ranges.cpp
index 7a9d9d057dac407..5bc50f7a4281072 100644
--- a/clang/test/Misc/misc-source-ranges.cpp
+++ b/clang/test/Misc/misc-source-ranges.cpp
@@ -1,7 +1,13 @@
-// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info -Wcast-function-type-strict %s 2>&1 | FileCheck %s
struct S {
char a : 12 - 12;
};
// CHECK: misc-source-ranges.cpp:[[@LINE-2]]:8:{[[@LINE-2]]:12-[[@LINE-2]]:19}
+using fun = long(*)(int&);
+fun foo(){
+ long (*f_ptr)(const int&);
+ return fun(f_ptr);
+}
+// CHECK: misc-source-ranges.cpp:[[@LINE-2]]:10:{[[@LINE-2]]:10-[[@LINE-2]]:20}
>From bc65adadd2cb605b5655223a6781de746d534b2d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Botond=20Istv=C3=A1n=20Horv=C3=A1th?=
<56926027+HoBoIs at users.noreply.github.com>
Date: Fri, 20 Oct 2023 11:12:59 +0200
Subject: [PATCH 3/3] Update ReleaseNotes.rst
---
clang/docs/ReleaseNotes.rst | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index eee48431d716878..4b67a5dce0945d3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -326,6 +326,25 @@ Improvements to Clang's diagnostics
- Clang now always diagnoses when using non-standard layout types in ``offsetof`` .
(`#64619: <https://github.com/llvm/llvm-project/issues/64619>`_)
+- When describing a warning/error in a function-style type converson clang underscored only until
+ the end of the expression we convert from. Now clang underscores the until the closing bracket.
+
+ Before:
+
+ .. code-block:: text
+
+ 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:
+
+ .. code-block:: text
+
+ 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*/);
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
Bug Fixes in This Version
-------------------------
- Fixed an issue where a class template specialization whose declaration is
More information about the libcxx-commits
mailing list