[PATCH] D153241: [clang][Diagnostics] Provide source range to invalid casts in const expr
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 28 03:29:16 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG81fb21624578: [clang][Diagnostics] Provide source range to invalid casts in const expr (authored by tbaeder).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153241/new/
https://reviews.llvm.org/D153241
Files:
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/Interp/Interp.cpp
clang/test/Misc/constexpr-source-ranges.cpp
Index: clang/test/Misc/constexpr-source-ranges.cpp
===================================================================
--- clang/test/Misc/constexpr-source-ranges.cpp
+++ clang/test/Misc/constexpr-source-ranges.cpp
@@ -7,3 +7,9 @@
}
// CHECK: constexpr-source-ranges.cpp:5:3:{5:3-5:10}
+
+
+constexpr int I = 12;
+constexpr const int *P = &I;
+constexpr long L = (long)P;
+// CHECK: constexpr-source-ranges.cpp:14:20:{14:20-14:27}
Index: clang/lib/AST/Interp/Interp.cpp
===================================================================
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -469,7 +469,7 @@
const SourceInfo &E = S.Current->getSource(OpPC);
S.CCEDiag(E, diag::note_constexpr_invalid_cast)
- << 2 << S.getLangOpts().CPlusPlus;
+ << 2 << S.getLangOpts().CPlusPlus << S.Current->getRange(OpPC);
return false;
}
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -13773,7 +13773,7 @@
case CK_PointerToIntegral: {
CCEDiag(E, diag::note_constexpr_invalid_cast)
- << 2 << Info.Ctx.getLangOpts().CPlusPlus;
+ << 2 << Info.Ctx.getLangOpts().CPlusPlus << E->getSourceRange();
LValue LV;
if (!EvaluatePointer(SubExpr, LV, Info))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153241.545087.patch
Type: text/x-patch
Size: 1349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230728/fea3d9db/attachment.bin>
More information about the cfe-commits
mailing list