-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] Correct end for the CastOperation.OpRange
#69480
Conversation
@llvm/pr-subscribers-clang Author: Botond István Horváth (HoBoIs) ChangesSet 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.
After:
Full diff: https://github.com/llvm/llvm-project/pull/69480.diff 1 Files Affected:
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())
|
The output looks good, but you should probably add a test in |
CastOperation.OpRange
LGTM but let's ping @cjdb and @AaronBallman and check if they see a problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but please add a release note about the diagnostic improvement.
Set the correct end for the CastOperation.OpRange in CXXFunctionalCastExpr. Now it is the closing bracket's location instead of the parameter's location.
bc65ada
to
c065353
Compare
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 #66853 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*/); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reviewed By: AaronBallman, tbaederr GitHub PR: #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 #66853
Example:
Before:
After: