[PATCH] D100675: [clang] Do not crash on template specialization following a fatal error
Adam Czachorowski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 23 04:41:08 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGddfbdbfefae0: [clang] Do not crash on template specialization following a fatal error (authored by adamcz).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100675/new/
https://reviews.llvm.org/D100675
Files:
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaCXX/template-specialization-fatal.cpp
Index: clang/test/SemaCXX/template-specialization-fatal.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/template-specialization-fatal.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// Verify clang doesn't assert()-fail on template specialization happening after
+// fatal error.
+
+#include "not_found.h" // expected-error {{'not_found.h' file not found}}
+
+template <class A, class B, class = void>
+struct foo {};
+
+template <class A, class B>
+struct foo<A, B, decltype(static_cast<void (*)(B)>(0)(static_cast<A (*)()>(0)()))> {};
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===================================================================
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5466,6 +5466,9 @@
Deduced.end());
Sema::InstantiatingTemplate Inst(S, Info.getLocation(), P2, DeducedArgs,
Info);
+ if (Inst.isInvalid())
+ return false;
+
auto *TST1 = T1->castAs<TemplateSpecializationType>();
bool AtLeastAsSpecialized;
S.runWithSufficientStackSpace(Info.getLocation(), [&] {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100675.339982.patch
Type: text/x-patch
Size: 1221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210423/eba8c631/attachment.bin>
More information about the cfe-commits
mailing list