[PATCH] D84455: [Concepts] Fix a deserialization crash.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 30 00:26:58 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG73c12bd8ff1a: [Concepts] Fix a deserialization crash. (authored by hokein).
Changed prior to commit:
https://reviews.llvm.org/D84455?vs=280225&id=281811#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84455/new/
https://reviews.llvm.org/D84455
Files:
clang/lib/Serialization/ASTReaderDecl.cpp
clang/test/PCH/cxx2a-constraints-crash.cpp
Index: clang/test/PCH/cxx2a-constraints-crash.cpp
===================================================================
--- /dev/null
+++ clang/test/PCH/cxx2a-constraints-crash.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++2a -emit-pch %s -o %t
+// RUN: %clang_cc1 -std=c++2a -include-pch %t -verify %s
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template <typename T, typename U>
+concept not_same_as = true;
+
+template <int Kind>
+struct subrange {
+ template <not_same_as<int> R>
+ subrange(R) requires(Kind == 0);
+
+ template <not_same_as<int> R>
+ subrange(R) requires(Kind != 0);
+};
+
+template <typename R>
+subrange(R) -> subrange<42>;
+
+int main() {
+ int c;
+ subrange s(c);
+}
+
+#endif
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===================================================================
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2909,9 +2909,11 @@
return false;
if (TX->hasTypeConstraint() != TY->hasTypeConstraint())
return false;
- if (TX->hasTypeConstraint()) {
- const TypeConstraint *TXTC = TX->getTypeConstraint();
- const TypeConstraint *TYTC = TY->getTypeConstraint();
+ const TypeConstraint *TXTC = TX->getTypeConstraint();
+ const TypeConstraint *TYTC = TY->getTypeConstraint();
+ if (!TXTC != !TYTC)
+ return false;
+ if (TXTC && TYTC) {
if (TXTC->getNamedConcept() != TYTC->getNamedConcept())
return false;
if (TXTC->hasExplicitTemplateArgs() != TYTC->hasExplicitTemplateArgs())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84455.281811.patch
Type: text/x-patch
Size: 1579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200730/076141e7/attachment.bin>
More information about the cfe-commits
mailing list