Skip to content

Commit 3ff8ed1

Browse files
author
git apple-llvm automerger
committed
Merge commit '43043adcfbc6' from llvm.org/main into apple/main
2 parents 16785c4 + 43043ad commit 3ff8ed1

File tree

4 files changed

+95
-18
lines changed

4 files changed

+95
-18
lines changed

clang/include/clang/AST/TypeLoc.h

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,30 +1749,79 @@ class DependentAddressSpaceTypeLoc
17491749

17501750
// FIXME: size expression and attribute locations (or keyword if we
17511751
// ever fully support altivec syntax).
1752-
class VectorTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1753-
VectorTypeLoc,
1754-
VectorType> {
1752+
struct VectorTypeLocInfo {
1753+
SourceLocation NameLoc;
1754+
};
1755+
1756+
class VectorTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, VectorTypeLoc,
1757+
VectorType, VectorTypeLocInfo> {
1758+
public:
1759+
SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1760+
1761+
void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
1762+
1763+
SourceRange getLocalSourceRange() const {
1764+
return SourceRange(getNameLoc(), getNameLoc());
1765+
}
1766+
1767+
void initializeLocal(ASTContext &Context, SourceLocation Loc) {
1768+
setNameLoc(Loc);
1769+
}
1770+
1771+
TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
1772+
1773+
QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
17551774
};
17561775

17571776
// FIXME: size expression and attribute locations (or keyword if we
17581777
// ever fully support altivec syntax).
17591778
class DependentVectorTypeLoc
1760-
: public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1761-
DependentVectorTypeLoc,
1762-
DependentVectorType> {};
1779+
: public ConcreteTypeLoc<UnqualTypeLoc, DependentVectorTypeLoc,
1780+
DependentVectorType, VectorTypeLocInfo> {
1781+
public:
1782+
SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
17631783

1764-
// FIXME: size expression and attribute locations.
1765-
class ExtVectorTypeLoc : public InheritingConcreteTypeLoc<VectorTypeLoc,
1766-
ExtVectorTypeLoc,
1767-
ExtVectorType> {
1784+
void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
1785+
1786+
SourceRange getLocalSourceRange() const {
1787+
return SourceRange(getNameLoc(), getNameLoc());
1788+
}
1789+
1790+
void initializeLocal(ASTContext &Context, SourceLocation Loc) {
1791+
setNameLoc(Loc);
1792+
}
1793+
1794+
TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
1795+
1796+
QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
17681797
};
17691798

1799+
// FIXME: size expression and attribute locations.
1800+
class ExtVectorTypeLoc
1801+
: public InheritingConcreteTypeLoc<VectorTypeLoc, ExtVectorTypeLoc,
1802+
ExtVectorType> {};
1803+
17701804
// FIXME: attribute locations.
17711805
// For some reason, this isn't a subtype of VectorType.
1772-
class DependentSizedExtVectorTypeLoc :
1773-
public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
1774-
DependentSizedExtVectorTypeLoc,
1775-
DependentSizedExtVectorType> {
1806+
class DependentSizedExtVectorTypeLoc
1807+
: public ConcreteTypeLoc<UnqualTypeLoc, DependentSizedExtVectorTypeLoc,
1808+
DependentSizedExtVectorType, VectorTypeLocInfo> {
1809+
public:
1810+
SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; }
1811+
1812+
void setNameLoc(SourceLocation Loc) { this->getLocalData()->NameLoc = Loc; }
1813+
1814+
SourceRange getLocalSourceRange() const {
1815+
return SourceRange(getNameLoc(), getNameLoc());
1816+
}
1817+
1818+
void initializeLocal(ASTContext &Context, SourceLocation Loc) {
1819+
setNameLoc(Loc);
1820+
}
1821+
1822+
TypeLoc getElementLoc() const { return getInnerTypeLoc(); }
1823+
1824+
QualType getInnerType() const { return this->getTypePtr()->getElementType(); }
17761825
};
17771826

17781827
struct MatrixTypeLocInfo {

clang/lib/Sema/SemaType.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6136,6 +6136,17 @@ namespace {
61366136
void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
61376137
TL.setExpansionLoc(Chunk.Loc);
61386138
}
6139+
void VisitVectorTypeLoc(VectorTypeLoc TL) { TL.setNameLoc(Chunk.Loc); }
6140+
void VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
6141+
TL.setNameLoc(Chunk.Loc);
6142+
}
6143+
void VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
6144+
TL.setNameLoc(Chunk.Loc);
6145+
}
6146+
void
6147+
VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
6148+
TL.setNameLoc(Chunk.Loc);
6149+
}
61396150

61406151
void VisitTypeLoc(TypeLoc TL) {
61416152
llvm_unreachable("unsupported TypeLoc kind in declarator!");

clang/lib/Sema/TreeTransform.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5178,7 +5178,7 @@ template <typename Derived>
51785178
QualType TreeTransform<Derived>::TransformDependentVectorType(
51795179
TypeLocBuilder &TLB, DependentVectorTypeLoc TL) {
51805180
const DependentVectorType *T = TL.getTypePtr();
5181-
QualType ElementType = getDerived().TransformType(T->getElementType());
5181+
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
51825182
if (ElementType.isNull())
51835183
return QualType();
51845184

@@ -5219,7 +5219,7 @@ QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType(
52195219
const DependentSizedExtVectorType *T = TL.getTypePtr();
52205220

52215221
// FIXME: ext vector locs should be nested
5222-
QualType ElementType = getDerived().TransformType(T->getElementType());
5222+
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
52235223
if (ElementType.isNull())
52245224
return QualType();
52255225

@@ -5386,7 +5386,7 @@ template <typename Derived>
53865386
QualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB,
53875387
VectorTypeLoc TL) {
53885388
const VectorType *T = TL.getTypePtr();
5389-
QualType ElementType = getDerived().TransformType(T->getElementType());
5389+
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
53905390
if (ElementType.isNull())
53915391
return QualType();
53925392

@@ -5409,7 +5409,7 @@ template<typename Derived>
54095409
QualType TreeTransform<Derived>::TransformExtVectorType(TypeLocBuilder &TLB,
54105410
ExtVectorTypeLoc TL) {
54115411
const VectorType *T = TL.getTypePtr();
5412-
QualType ElementType = getDerived().TransformType(T->getElementType());
5412+
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
54135413
if (ElementType.isNull())
54145414
return QualType();
54155415

clang/test/SemaCXX/vector.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,3 +513,20 @@ void use(char16 c) {
513513
}
514514

515515
} // namespace PR45780
516+
517+
namespace PR48540 {
518+
// The below used to cause an OOM error, or an assert, make sure it is still
519+
// valid.
520+
int (__attribute__((vector_size(16))) a);
521+
522+
template <typename T, int I>
523+
struct S {
524+
T (__attribute__((vector_size(16))) a);
525+
int (__attribute__((vector_size(I))) b);
526+
T (__attribute__((vector_size(I))) c);
527+
};
528+
529+
void use() {
530+
S<int, 16> s;
531+
}
532+
} // namespace PR48540

0 commit comments

Comments
 (0)