[clang] Serialization: support hashing null template arguments (#141890)

This commit is contained in:
Matheus Izvekov 2025-05-29 02:08:11 -03:00 committed by GitHub
parent 3788d45947
commit 61314076f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 1 deletions

View File

@ -821,6 +821,7 @@ Miscellaneous Clang Crashes Fixed
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed crash when ``-print-stats`` is enabled in compiling IR files. (#GH131608)
- Fix code completion crash involving PCH serialzied templates. (#GH139019)
OpenACC Specific Changes
------------------------

View File

@ -65,7 +65,9 @@ void TemplateArgumentHasher::AddTemplateArgument(TemplateArgument TA) {
switch (Kind) {
case TemplateArgument::Null:
llvm_unreachable("Expected valid TemplateArgument");
// These can occur in incomplete substitutions performed with code
// completion (see PartialOverloading).
break;
case TemplateArgument::Type:
AddQualType(TA.getAsType());
break;

View File

@ -0,0 +1,26 @@
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 %t/test.hpp -emit-pch -o %t/1.pch
// RUN: %clang_cc1 -std=c++20 %t/test.cpp -include-pch %t/1.pch -code-completion-at=%t/test.cpp:7:17
//--- test.hpp
#pragma once
class provider_t
{
public:
template<class T>
void emit(T *data)
{}
};
//--- test.cpp
#include "test.hpp"
void test()
{
provider_t *focus;
void *data;
focus->emit(&data);
}