Author: Luke Nihlen Date: 2022-08-30T19:10:15Z New Revision: c9aba600745131fca4f7333d7c2e21556c2577cc
URL: https://github.com/llvm/llvm-project/commit/c9aba600745131fca4f7333d7c2e21556c2577cc DIFF: https://github.com/llvm/llvm-project/commit/c9aba600745131fca4f7333d7c2e21556c2577cc.diff LOG: [clang] Don't emit debug vtable information for consteval functions Fixes https://github.com/llvm/llvm-project/issues/55065 Reviewed By: shafik Differential Revision: https://reviews.llvm.org/D132874 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/cxx20-consteval-crash.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 824ab42706334..f946018b361c3 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -198,10 +198,11 @@ C++20 Feature Support and `DR1734 <https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1734>`_. - Class member variables are now in scope when parsing a ``requires`` clause. Fixes `GH55216 <https://github.com/llvm/llvm-project/issues/55216>`_. - - Correctly set expression evaluation context as 'immediate function context' in consteval functions. This fixes `GH51182 <https://github.com/llvm/llvm-project/issues/51182>` +- Fixes an assert crash caused by looking up missing vtable information on ``consteval`` + virtual functions. Fixes `GH55065 <https://github.com/llvm/llvm-project/issues/55065>`_. C++2b Feature Support diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 3d78a13d30aa8..4b7e290f6480c 100644 --- 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 *CGDebugInfo::CreateCXXMemberFunction( 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 index 8aa87187d6c2f..da1c78db9af56 100644 --- 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 @@ int foo() { 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 + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits