ChuanqiXu updated this revision to Diff 390668. ChuanqiXu added a comment. Fix tests under Debug mode. I need to remember run debug tests : (
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,7 @@ if (!TXTC != !TYTC) return false; if (TXTC && TYTC) { - if (TXTC->getNamedConcept() != TYTC->getNamedConcept()) + if (!isSameEntity(TXTC->getNamedConcept(), TYTC->getNamedConcept())) return false; if (TXTC->hasExplicitTemplateArgs() != TYTC->hasExplicitTemplateArgs()) return false; @@ -3111,11 +3112,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
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,7 @@ if (!TXTC != !TYTC) return false; if (TXTC && TYTC) { - if (TXTC->getNamedConcept() != TYTC->getNamedConcept()) + if (!isSameEntity(TXTC->getNamedConcept(), TYTC->getNamedConcept())) return false; if (TXTC->hasExplicitTemplateArgs() != TYTC->hasExplicitTemplateArgs()) return false; @@ -3111,11 +3112,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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits