https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/217675

Rename a function to be more descriptive and add documentation.

>From 7490a380784b6171bf8ddfc517a8190d6aa8d825 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Thu, 20 Aug 2026 17:42:51 +0200
Subject: [PATCH] [clang][ExprConst] Post-merge review for relaxed evaluation

Rename a function to be more descriptive and add documentation.
---
 clang/include/clang/AST/Expr.h    | 8 ++++++++
 clang/lib/AST/ByteCode/Interp.cpp | 2 +-
 clang/lib/AST/ByteCode/State.cpp  | 5 +++--
 clang/lib/AST/ByteCode/State.h    | 5 ++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 112af378258fc..7d4cc10245c0d 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -561,6 +561,10 @@ class Expr : public ValueStmt {
   ///
   /// Note: This does not perform the implicit conversions required by C++11
   /// [expr.const]p5.
+  ///
+  /// If \p AllowRelaxedEval is \c true, this will allow certain constructs 
that
+  /// are not valid per the specification.
+  // FIXME: Add proper documentation about the constructs we allow.
   std::optional<llvm::APSInt>
   getIntegerConstantExpr(const ASTContext &Ctx,
                          bool AllowRelaxedEval = false) const;
@@ -575,6 +579,10 @@ class Expr : public ValueStmt {
   ///
   /// Note: This does not perform the implicit conversions required by C++11
   /// [expr.const]p5.
+  ///
+  /// If \p AllowRelaxedEval is \c true, this will allow certain constructs 
that
+  /// are not valid per the specification.
+  // FIXME: Add proper documentation about the constructs we allow.
   bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result = nullptr,
                            bool AllowRelaxedEval = false) const;
 
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 37378f41f0a56..bf7bce1a2da13 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1592,7 +1592,7 @@ static bool diagnoseTypeIdField(InterpState &S, CodePtr 
OpPC,
 }
 
 static bool allowNullSubObj(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
-  return Ptr.isZero() && S.shouldRelaxDiag(S.Current->getSource(OpPC).getLoc(),
+  return Ptr.isZero() && S.emitRelaxedDiag(S.Current->getSource(OpPC).getLoc(),
                                            
diag::note_constexpr_null_subobject);
 }
 
diff --git a/clang/lib/AST/ByteCode/State.cpp b/clang/lib/AST/ByteCode/State.cpp
index 925e2eddf0ef4..d8e9504e1a8e5 100644
--- a/clang/lib/AST/ByteCode/State.cpp
+++ b/clang/lib/AST/ByteCode/State.cpp
@@ -18,10 +18,11 @@ using namespace clang::interp;
 
 State::~State() {}
 
-bool State::shouldRelaxDiag(const SourceLocation &Loc, diag::kind DiagId) {
+bool State::emitRelaxedDiag(SourceLocation Loc, diag::kind DiagId) {
   if (!Ctx.getLangOpts().MSVCCompat ||
       (!EvalStatus.ExtendedDiag && !InConstantContext))
     return false;
+
   switch (DiagId) {
   case diag::note_constexpr_invalid_cast_ptrtoint:
     addExtendedDiag(Loc, diag::warn_relaxed_constant_fold_cast);
@@ -59,7 +60,7 @@ OptionalDiagnostic State::FFDiag(SourceInfo SI, diag::kind 
DiagId,
 
 OptionalDiagnostic State::CCEDiag(SourceLocation Loc, diag::kind DiagId,
                                   unsigned ExtraNotes) {
-  if (shouldRelaxDiag(Loc, DiagId)) {
+  if (emitRelaxedDiag(Loc, DiagId)) {
     setActiveDiagnostic(false);
     return OptionalDiagnostic();
   }
diff --git a/clang/lib/AST/ByteCode/State.h b/clang/lib/AST/ByteCode/State.h
index 97af0bf2b6866..0fed26e14007b 100644
--- a/clang/lib/AST/ByteCode/State.h
+++ b/clang/lib/AST/ByteCode/State.h
@@ -92,7 +92,10 @@ class State {
   ASTContext &getASTContext() const { return Ctx; }
   const LangOptions &getLangOpts() const { return Ctx.getLangOpts(); }
 
-  bool shouldRelaxDiag(const SourceLocation &Loc, diag::kind DiagId);
+  /// If \c DiagId should be relaxed as per the current evaluation settings,
+  /// emit it as a warning instead of an error. Returns \c true if a relaxed
+  /// diagnostic was emitted, \c false otherwise.
+  bool emitRelaxedDiag(SourceLocation Loc, diag::kind DiagId);
 
   /// Note that we have had a side-effect, and determine whether we should
   /// keep evaluating.

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to