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))
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))
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits