diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -188,10 +188,11 @@ and `DR1734 `_. - Class member variables are now in scope when parsing a ``requires`` clause. Fixes `GH55216 `_. - - Correctly set expression evaluation context as 'immediate function context' in consteval functions. This fixes `GH51182 ` +- Fixes an assert crash caused by looking up missing vtable information on ``consteval`` + virtual functions. Fixes `GH55065 `_. C++2b Feature Support diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -26,6 +26,7 @@ #include "clang/AST/Expr.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/VTableBuilder.h" #include "clang/Basic/CodeGenOptions.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" @@ -1758,7 +1759,7 @@ llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero; int ThisAdjustment = 0; - if (Method->isVirtual()) { + if (VTableContextBase::hasVtableSlot(Method)) { if (Method->isPure()) SPFlags |= llvm::DISubprogram::SPFlagPureVirtual; else diff --git a/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp b/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp --- a/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp +++ b/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-linux-gnu -std=c++20 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -emit-obj -debug-info-kind=constructor -std=c++20 %s -o - namespace PR50787 { // This code would previously cause a crash. @@ -71,3 +72,23 @@ return function(Item{'a'}, Item{'a'}); } } // namespace Issue58871 + +namespace Issue55065 { +struct Base { + consteval virtual int Get() const = 0; +}; + +struct Derived : Base { + consteval int Get() const override { + return 42; + } +}; + +int foo() { + constexpr Derived a; + + auto val = a.Get(); + return val; +} +} // namespace Issue55065 +