[clang] [clang][bytecode] Fix source range of uncalled base dtor (PR #111683)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 9 07:04:50 PDT 2024
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/111683
Make this emit the same source range as the current interpreter.
>From e9a62e3a7f0d14bde4c78f7b3abbd869bad8f4d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Wed, 9 Oct 2024 16:03:32 +0200
Subject: [PATCH] [clang][bytecode] Fix source range of uncalled base dtor
Make this emit the same source range as the current interpreter.
---
clang/lib/AST/ByteCode/EvaluationResult.cpp | 5 +++--
clang/test/Misc/constexpr-subobj-init-source-ranges.cpp | 1 +
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/clang/lib/AST/ByteCode/EvaluationResult.cpp b/clang/lib/AST/ByteCode/EvaluationResult.cpp
index 627d4b2f65be9d..c0d116cdf26c48 100644
--- a/clang/lib/AST/ByteCode/EvaluationResult.cpp
+++ b/clang/lib/AST/ByteCode/EvaluationResult.cpp
@@ -130,8 +130,9 @@ static bool CheckFieldsInitialized(InterpState &S, SourceLocation Loc,
const Descriptor *Desc = BasePtr.getDeclDesc();
if (const auto *CD = dyn_cast_if_present<CXXRecordDecl>(R->getDecl())) {
const auto &BS = *std::next(CD->bases_begin(), I);
- S.FFDiag(BS.getBaseTypeLoc(), diag::note_constexpr_uninitialized_base)
- << B.Desc->getType() << BS.getSourceRange();
+ SourceLocation TypeBeginLoc = BS.getBaseTypeLoc();
+ S.FFDiag(TypeBeginLoc, diag::note_constexpr_uninitialized_base)
+ << B.Desc->getType() << SourceRange(TypeBeginLoc, BS.getEndLoc());
} else {
S.FFDiag(Desc->getLocation(), diag::note_constexpr_uninitialized_base)
<< B.Desc->getType();
diff --git a/clang/test/Misc/constexpr-subobj-init-source-ranges.cpp b/clang/test/Misc/constexpr-subobj-init-source-ranges.cpp
index 342da2d8866687..990d1056d6d46e 100644
--- a/clang/test/Misc/constexpr-subobj-init-source-ranges.cpp
+++ b/clang/test/Misc/constexpr-subobj-init-source-ranges.cpp
@@ -1,4 +1,5 @@
// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info -fexperimental-new-constant-interpreter %s 2>&1 | FileCheck %s --strict-whitespace
struct DelBase {
constexpr DelBase() = delete;
More information about the cfe-commits
mailing list