[clang] [clang-tools-extra] [libcxx] [clang] fix diagnostic printing of expressions ignoring LangOpts (PR #134693)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 8 10:40:09 PDT 2025


================
@@ -7379,6 +7379,14 @@ class RecoveryExpr final : public Expr,
   friend class ASTStmtWriter;
 };
 
+/// Insertion operator for diagnostics.  This allows sending
+/// Expr into a diagnostic with <<.
+inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
+                                             const Expr *E) {
+  DB.AddTaggedVal(reinterpret_cast<uint64_t>(E), DiagnosticsEngine::ak_expr);
----------------
shafik wrote:

I am not super sympathetic here, `reinterpret_cast` in a code review should have both the author and the reviewer on high alert and they should carefully examine the code and if we suspect the same pattern is used elsewhere we should confirm it is used consistently. Which in this case it is not. 

The PR was turned over pretty quickly w/o giving any of the other long list of reviewers a chance to comment.

https://github.com/llvm/llvm-project/pull/134693


More information about the cfe-commits mailing list