Skip to content

[clang][bytecode] Fix source range of uncalled base dtor #111683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

tbaederr
Copy link
Contributor

@tbaederr tbaederr commented Oct 9, 2024

Make this emit the same source range as the current interpreter.

Make this emit the same source range as the current interpreter.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 9, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 9, 2024

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

Make this emit the same source range as the current interpreter.


Full diff: https://github.com/llvm/llvm-project/pull/111683.diff

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/EvaluationResult.cpp (+3-2)
  • (modified) clang/test/Misc/constexpr-subobj-init-source-ranges.cpp (+1)
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;

@tbaederr tbaederr merged commit 208584d into llvm:main Oct 9, 2024
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants