[clang] 6131407 - [clang] Serialization: support hashing null template arguments (#141890)
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 28 22:08:15 PDT 2025
Author: Matheus Izvekov
Date: 2025-05-29T02:08:11-03:00
New Revision: 61314076f78327ffd5e1463c35373c7f4e52d30f
URL: https://github.com/llvm/llvm-project/commit/61314076f78327ffd5e1463c35373c7f4e52d30f
DIFF: https://github.com/llvm/llvm-project/commit/61314076f78327ffd5e1463c35373c7f4e52d30f.diff
LOG: [clang] Serialization: support hashing null template arguments (#141890)
Added:
clang/test/CodeCompletion/GH139019.cpp
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/Serialization/TemplateArgumentHasher.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 540552bc47e8d..32266fce4d3cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -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
------------------------
diff --git a/clang/lib/Serialization/TemplateArgumentHasher.cpp b/clang/lib/Serialization/TemplateArgumentHasher.cpp
index 3c7177b83ba52..aa61496d4aa0c 100644
--- a/clang/lib/Serialization/TemplateArgumentHasher.cpp
+++ b/clang/lib/Serialization/TemplateArgumentHasher.cpp
@@ -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;
diff --git a/clang/test/CodeCompletion/GH139019.cpp b/clang/test/CodeCompletion/GH139019.cpp
new file mode 100644
index 0000000000000..fed35b38362a1
--- /dev/null
+++ b/clang/test/CodeCompletion/GH139019.cpp
@@ -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);
+}
More information about the cfe-commits
mailing list