diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index cf1ba02cbc4b2f..efe78139de6fa8 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 f2bf667636dc9b..f1f7d49cc6c639 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 00000000000000..fdd3beb99209e8 --- /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 BasicPersistent &&__declval(int); +template auto declval() -> decltype(__declval<_Tp>(0)); +template _Tp forward; +template +auto construct_at(_Tp *, _Args...) -> decltype(new _Tp(declval<_Args>()...)) {return 0;} +template struct allocator; +template struct allocator_traits; +template struct allocator_traits> { + using pointer = _Tp *; + template + static void construct(_Up __p, _Args...) { + construct_at(__p, forward<_Args>...); + } +}; +struct __alloc_traits : allocator_traits> { +} push_back___x; +__alloc_traits::pointer _M_impl_0; +template 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); }