[PATCH] D114769: [C++20] [Modules] [Concepts] Recognize same concepts more precisely in Serialization
Chuanqi Xu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 7 23:14:23 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe166755a6919: [C++20] [Modules] [Concepts] Recognize same concepts more precisely in… (authored by ChuanqiXu).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114769/new/
https://reviews.llvm.org/D114769
Files:
clang/lib/Serialization/ASTReaderDecl.cpp
clang/test/Modules/Inputs/concept/A.cppm
clang/test/Modules/Inputs/concept/foo.h
clang/test/Modules/concept.cppm
Index: clang/test/Modules/concept.cppm
===================================================================
--- /dev/null
+++ clang/test/Modules/concept.cppm
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: %clang -std=c++20 %S/Inputs/concept/A.cppm --precompile -o %t/A.pcm
+// RUN: %clang -std=c++20 -fprebuilt-module-path=%t -I%S/Inputs/concept %s -c -Xclang -verify
+// expected-no-diagnostics
+
+module;
+#include "foo.h"
+export module B;
+import A;
Index: clang/test/Modules/Inputs/concept/foo.h
===================================================================
--- /dev/null
+++ clang/test/Modules/Inputs/concept/foo.h
@@ -0,0 +1,13 @@
+#ifndef FOO_H
+#define FOO_H
+
+template <class T>
+concept Range = requires(T &t) { t.begin(); };
+
+struct A {
+public:
+ template <Range T>
+ using range_type = T;
+};
+
+#endif
Index: clang/test/Modules/Inputs/concept/A.cppm
===================================================================
--- /dev/null
+++ clang/test/Modules/Inputs/concept/A.cppm
@@ -0,0 +1,3 @@
+module;
+#include "foo.h"
+export module A;
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===================================================================
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2948,6 +2948,7 @@
static bool isSameTemplateParameterList(const ASTContext &C,
const TemplateParameterList *X,
const TemplateParameterList *Y);
+static bool isSameEntity(NamedDecl *X, NamedDecl *Y);
/// Determine whether two template parameters are similar enough
/// that they may be used in declarations of the same template.
@@ -2967,7 +2968,9 @@
if (!TXTC != !TYTC)
return false;
if (TXTC && TYTC) {
- if (TXTC->getNamedConcept() != TYTC->getNamedConcept())
+ auto *NCX = TXTC->getNamedConcept();
+ auto *NCY = TYTC->getNamedConcept();
+ if (!NCX || !NCY || !isSameEntity(NCX, NCY))
return false;
if (TXTC->hasExplicitTemplateArgs() != TYTC->hasExplicitTemplateArgs())
return false;
@@ -3111,11 +3114,12 @@
/// Determine whether the two declarations refer to the same entity.
static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
- assert(X->getDeclName() == Y->getDeclName() && "Declaration name mismatch!");
-
if (X == Y)
return true;
+ if (X->getDeclName() != Y->getDeclName())
+ return false;
+
// Must be in the same context.
//
// Note that we can't use DeclContext::Equals here, because the DeclContexts
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114769.392656.patch
Type: text/x-patch
Size: 2585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211208/7e8284e3/attachment.bin>
More information about the cfe-commits
mailing list