[clang] [clang] SourceLocIdentKind::Function should not be dependent (PR #94942)
Qizhi Hu via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 13 06:13:42 PDT 2024
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94942
>From 96f4e2a5c82296b61e53189135d88a2d2b0da9f4 Mon Sep 17 00:00:00 2001
From: Qizhi Hu <836744285 at qq.com>
Date: Mon, 10 Jun 2024 16:53:54 +0800
Subject: [PATCH] [clang] SourceLocIdentKind::Function should not be dependent
---
clang/docs/ReleaseNotes.rst | 1 +
clang/include/clang/AST/Expr.h | 2 --
clang/test/CodeGenCXX/PR80210.cpp | 34 +++++++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 2 deletions(-)
create mode 100644 clang/test/CodeGenCXX/PR80210.cpp
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cf1ba02cbc4b2..efe78139de6fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -846,6 +846,7 @@ Bug Fixes to C++ Support
- Fix a crash caused by improper use of ``__array_extent``. (#GH80474)
- Fixed several bugs in capturing variables within unevaluated contexts. (#GH63845), (#GH67260), (#GH69307),
(#GH88081), (#GH89496), (#GH90669) and (#GH91633).
+- Fix a crash when SourceLocExpr instantiated in a dependent context. (GH80210).
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index f2bf667636dc9..f1f7d49cc6c63 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4786,8 +4786,6 @@ class SourceLocExpr final : public Expr {
static bool MayBeDependent(SourceLocIdentKind Kind) {
switch (Kind) {
- case SourceLocIdentKind::Function:
- case SourceLocIdentKind::FuncSig:
case SourceLocIdentKind::SourceLocStruct:
return true;
default:
diff --git a/clang/test/CodeGenCXX/PR80210.cpp b/clang/test/CodeGenCXX/PR80210.cpp
new file mode 100644
index 0000000000000..fdd3beb99209e
--- /dev/null
+++ b/clang/test/CodeGenCXX/PR80210.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++20 %s -emit-llvm -o /dev/null -verify -triple %itanium_abi_triple
+// RUN: %clang_cc1 -std=c++20 %s -emit-llvm -o /dev/null -verify -triple %ms_abi_triple
+
+// expected-no-diagnostics
+
+struct BasicPersistent;
+template <typename> BasicPersistent &&__declval(int);
+template <typename _Tp> auto declval() -> decltype(__declval<_Tp>(0));
+template <typename _Tp> _Tp forward;
+template <typename _Tp, typename... _Args>
+auto construct_at(_Tp *, _Args...) -> decltype(new _Tp(declval<_Args>()...)) {return 0;}
+template <typename> struct allocator;
+template <typename> struct allocator_traits;
+template <typename _Tp> struct allocator_traits<allocator<_Tp>> {
+ using pointer = _Tp *;
+ template <typename _Up, typename... _Args>
+ static void construct(_Up __p, _Args...) {
+ construct_at(__p, forward<_Args>...);
+ }
+};
+struct __alloc_traits : allocator_traits<allocator<BasicPersistent>> {
+} push_back___x;
+__alloc_traits::pointer _M_impl_0;
+template <typename... _Args> void emplace_back(_Args...) {
+ __alloc_traits::construct(_M_impl_0, forward<_Args>...);
+}
+struct SourceLocation {
+ static SourceLocation Current(const char * = __builtin_FUNCTION());
+};
+struct BasicPersistent {
+ BasicPersistent(BasicPersistent &&,
+ SourceLocation = SourceLocation::Current());
+};
+void CFXJSE_EngineAddObjectToUpArray() { emplace_back(push_back___x); }
More information about the cfe-commits
mailing list