llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: None (Sirraide) <details> <summary>Changes</summary> We were forgetting to pass the `TypeLocBuilder` along to `TransformType`, causing us to complain if we then tried to build a `DependentAddressSpaceTypeLoc` because the inner `TypeLoc` was missing from the TLB. Fixes #<!-- -->101685. --- Full diff: https://github.com/llvm/llvm-project/pull/102206.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Sema/TreeTransform.h (+3-2) - (modified) clang/test/SemaTemplate/address_space-dependent.cpp (+13) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 6f50ab07f1fc0..3ad87c68e28d9 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -164,6 +164,7 @@ Bug Fixes in This Version - Fixed the definition of ``ATOMIC_FLAG_INIT`` in ``<stdatomic.h>`` so it can be used in C++. - Fixed a failed assertion when checking required literal types in C context. (#GH101304). +- Fixed a crash when trying to transform a dependent address space type. Fixes #GH101685. Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 540e1e0cb8df0..fd96ebd812343 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -5803,7 +5803,8 @@ QualType TreeTransform<Derived>::TransformDependentAddressSpaceType( TypeLocBuilder &TLB, DependentAddressSpaceTypeLoc TL) { const DependentAddressSpaceType *T = TL.getTypePtr(); - QualType pointeeType = getDerived().TransformType(T->getPointeeType()); + QualType pointeeType = + getDerived().TransformType(TLB, TL.getPointeeTypeLoc()); if (pointeeType.isNull()) return QualType(); @@ -5838,7 +5839,7 @@ QualType TreeTransform<Derived>::TransformDependentAddressSpaceType( } else { TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo( Result, getDerived().getBaseLocation()); - TransformType(TLB, DI->getTypeLoc()); + TLB.TypeWasModifiedSafely(DI->getType()); } return Result; diff --git a/clang/test/SemaTemplate/address_space-dependent.cpp b/clang/test/SemaTemplate/address_space-dependent.cpp index c8cc67ef45211..2ca9b8007ab41 100644 --- a/clang/test/SemaTemplate/address_space-dependent.cpp +++ b/clang/test/SemaTemplate/address_space-dependent.cpp @@ -117,3 +117,16 @@ int main() { return 0; } + +namespace gh101685 { +template <int AS> +using ASPtrTy = void [[clang::address_space(AS)]] *; + +template <int AS> +struct EntryTy { + ASPtrTy<AS> Base; +}; + +ASPtrTy<1> x; +EntryTy<2> y; +} `````````` </details> https://github.com/llvm/llvm-project/pull/102206 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits