Skip to content

[Clang] Fix crash when transforming a DependentAddressSpaceType #102206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
7 changes: 3 additions & 4 deletions clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -5836,9 +5837,7 @@ QualType TreeTransform<Derived>::TransformDependentAddressSpaceType(
NewTL.setAttrNameLoc(TL.getAttrNameLoc());

} else {
TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(
Result, getDerived().getBaseLocation());
TransformType(TLB, DI->getTypeLoc());
TLB.TypeWasModifiedSafely(Result);
}

return Result;
Expand Down
13 changes: 13 additions & 0 deletions clang/test/SemaTemplate/address_space-dependent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading