[clang] Serialization: support hashing null template arguments · llvm/llvm-project@7759bb5 (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit 7759bb5
[clang] Serialization: support hashing null template arguments
When performing overload resolution during code completion, clang will allow incomplete substitutions in more places than would be allowed for valid code, because for completion to work well, it needs clang to keep going so it can explore the space of possibilities. Notably, we accept instantiating declarations will null template arguments, and this works fine, except that when lazily loading serialzied templated declarations, the template argument hasher assumes null arguments can't be used. This patch makes the hasher happily accept that.Fixes #139019
File tree
3 files changed
lines changed
3 files changed
lines changed
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1118,6 +1118,7 @@ Miscellaneous Clang Crashes Fixed | ||
1118 | 1118 | |
1119 | 1119 | - Fixed a crash when an unscoped enumeration declared by an opaque-enum-declaration within a class template |
1120 | 1120 | with a dependent underlying type is subject to integral promotion. (#GH117960) |
1121 | +- Fix code completion crash involving PCH serialzied templates. (#GH139019) | |
1121 | 1122 | |
1122 | 1123 | OpenACC Specific Changes |
1123 | 1124 | ------------------------ |
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -65,7 +65,9 @@ void TemplateArgumentHasher::AddTemplateArgument(TemplateArgument TA) { | ||
65 | 65 | |
66 | 66 | switch (Kind) { |
67 | 67 | 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; | |
69 | 71 | case TemplateArgument::Type: |
70 | 72 | AddQualType(TA.getAsType()); |
71 | 73 | break; |
Lines changed: 26 additions & 0 deletions
Original file line number | Diff line number | Diff 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 | +} |