Skip to content

Commit b6cc8fd

Browse files
mizvekovsvkeerthy
authored andcommitted
[clang] Serialization: support hashing null template arguments (#141890)
1 parent 31feb33 commit b6cc8fd

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ Miscellaneous Clang Crashes Fixed
821821
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
822822

823823
- Fixed crash when ``-print-stats`` is enabled in compiling IR files. (#GH131608)
824+
- Fix code completion crash involving PCH serialzied templates. (#GH139019)
824825

825826
OpenACC Specific Changes
826827
------------------------

clang/lib/Serialization/TemplateArgumentHasher.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ void TemplateArgumentHasher::AddTemplateArgument(TemplateArgument TA) {
6565

6666
switch (Kind) {
6767
case TemplateArgument::Null:
68-
llvm_unreachable("Expected valid TemplateArgument");
68+
// These can occur in incomplete substitutions performed with code
69+
// completion (see PartialOverloading).
70+
break;
6971
case TemplateArgument::Type:
7072
AddQualType(TA.getAsType());
7173
break;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir %t
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %clang_cc1 -std=c++20 %t/test.hpp -emit-pch -o %t/1.pch
6+
// RUN: %clang_cc1 -std=c++20 %t/test.cpp -include-pch %t/1.pch -code-completion-at=%t/test.cpp:7:17
7+
8+
//--- test.hpp
9+
#pragma once
10+
class provider_t
11+
{
12+
public:
13+
template<class T>
14+
void emit(T *data)
15+
{}
16+
};
17+
18+
//--- test.cpp
19+
#include "test.hpp"
20+
21+
void test()
22+
{
23+
provider_t *focus;
24+
void *data;
25+
focus->emit(&data);
26+
}

0 commit comments

Comments
 (0)