Skip to content

Backport: [clang] Serialization: support hashing null template arguments #141957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,7 @@ Miscellaneous Clang Crashes Fixed

- Fixed a crash when an unscoped enumeration declared by an opaque-enum-declaration within a class template
with a dependent underlying type is subject to integral promotion. (#GH117960)
- Fix code completion crash involving PCH serialzied templates. (#GH139019)

OpenACC Specific Changes
------------------------
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Serialization/TemplateArgumentHasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions clang/test/CodeCompletion/GH139019.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
Loading