This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGc50a4b3f9749: [Modules] Incorrect ODR detection for unresolved using type (authored by ChuanqiXu).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D115792/new/ https://reviews.llvm.org/D115792 Files: clang/include/clang/AST/ASTContext.h clang/include/clang/AST/TypeProperties.td clang/lib/AST/ASTContext.cpp clang/test/Modules/Inputs/odr_using_dependent_name/X.cppm clang/test/Modules/Inputs/odr_using_dependent_name/foo.h clang/test/Modules/odr_using_dependent_name.cppm
Index: clang/test/Modules/odr_using_dependent_name.cppm =================================================================== --- /dev/null +++ clang/test/Modules/odr_using_dependent_name.cppm @@ -0,0 +1,9 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: %clang -std=c++20 %S/Inputs/odr_using_dependent_name/X.cppm --precompile -o %t/X.pcm +// RUN: %clang -std=c++20 -I%S/Inputs/odr_using_dependent_name -fprebuilt-module-path=%t %s --precompile -c +// expected-no-diagnostics +module; +#include "foo.h" +export module Y; +import X; Index: clang/test/Modules/Inputs/odr_using_dependent_name/foo.h =================================================================== --- /dev/null +++ clang/test/Modules/Inputs/odr_using_dependent_name/foo.h @@ -0,0 +1,9 @@ +template <class T> +struct bar { + using Ty = int; +}; +template <class T> +struct foo : public bar<T> { + using typename bar<T>::Ty; + void baz(Ty); +}; Index: clang/test/Modules/Inputs/odr_using_dependent_name/X.cppm =================================================================== --- /dev/null +++ clang/test/Modules/Inputs/odr_using_dependent_name/X.cppm @@ -0,0 +1,3 @@ +module; +#include "foo.h" +export module X; Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -4568,9 +4568,7 @@ assert(Enum->isFirstDecl() && "enum has previous declaration"); return getEnumType(Enum); } else if (const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(Decl)) { - Type *newType = new (*this, TypeAlignment) UnresolvedUsingType(Using); - Decl->TypeForDecl = newType; - Types.push_back(newType); + return getUnresolvedUsingType(Using); } else llvm_unreachable("TypeDecl without a type?"); @@ -4619,6 +4617,22 @@ return QualType(newType, 0); } +QualType ASTContext::getUnresolvedUsingType( + const UnresolvedUsingTypenameDecl *Decl) const { + if (Decl->TypeForDecl) + return QualType(Decl->TypeForDecl, 0); + + if (const UnresolvedUsingTypenameDecl *CanonicalDecl = + Decl->getCanonicalDecl()) + if (CanonicalDecl->TypeForDecl) + return QualType(Decl->TypeForDecl = CanonicalDecl->TypeForDecl, 0); + + Type *newType = new (*this, TypeAlignment) UnresolvedUsingType(Decl); + Decl->TypeForDecl = newType; + Types.push_back(newType); + return QualType(newType, 0); +} + QualType ASTContext::getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) { Index: clang/include/clang/AST/TypeProperties.td =================================================================== --- clang/include/clang/AST/TypeProperties.td +++ clang/include/clang/AST/TypeProperties.td @@ -358,7 +358,7 @@ } def : Creator<[{ - return ctx.getTypeDeclType(cast<UnresolvedUsingTypenameDecl>(declaration)); + return ctx.getUnresolvedUsingType(cast<UnresolvedUsingTypenameDecl>(declaration)); }]>; } Index: clang/include/clang/AST/ASTContext.h =================================================================== --- clang/include/clang/AST/ASTContext.h +++ clang/include/clang/AST/ASTContext.h @@ -1564,6 +1564,9 @@ QualType getEnumType(const EnumDecl *Decl) const; + QualType + getUnresolvedUsingType(const UnresolvedUsingTypenameDecl *Decl) const; + QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const; QualType getAttributedType(attr::Kind attrKind,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits