https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/135511
Source locations should be handled at the TypeLoc level, and these locations are already wired up to the base ArrayLoc. There was nothing important using these, so just remove. >From e01aa7b78e6b1971e2fedbcad788630a3a92e7c0 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov <mizve...@gmail.com> Date: Sat, 12 Apr 2025 21:31:40 -0300 Subject: [PATCH 1/2] [clang] AST: remove source locations from DependentSizedArrayType Source locations should be handled at the TypeLoc level, and these locations are already wired up to the base ArrayLoc. There was nothing important wired to these, so just remove. --- clang/include/clang/AST/ASTContext.h | 3 +- clang/include/clang/AST/Type.h | 10 +----- clang/include/clang/AST/TypeProperties.td | 14 ++------ clang/lib/AST/ASTContext.cpp | 39 ++++++++------------- clang/lib/AST/ASTDiagnostic.cpp | 2 +- clang/lib/AST/ASTImporter.cpp | 3 +- clang/lib/AST/MicrosoftMangle.cpp | 2 +- clang/lib/AST/TextNodeDumper.cpp | 2 -- clang/lib/AST/Type.cpp | 6 ++-- clang/lib/Sema/SemaInit.cpp | 26 +++----------- clang/lib/Sema/SemaType.cpp | 2 +- clang/test/AST/ast-dump-array.cpp | 4 +-- clang/test/SemaTemplate/deduction-guide.cpp | 2 +- 13 files changed, 32 insertions(+), 83 deletions(-) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 0f6c727f6f9ca..d8d0b79bd67d9 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1574,8 +1574,7 @@ class ASTContext : public RefCountedBase<ASTContext> { /// point. QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, - unsigned IndexTypeQuals, - SourceRange Brackets) const; + unsigned IndexTypeQuals) const; /// Return a unique reference to the type for an incomplete array of /// the specified element type. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index fe62120a25643..89ec32cecec07 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3884,12 +3884,8 @@ class DependentSizedArrayType : public ArrayType { /// type will have its size deduced from an initializer. Stmt *SizeExpr; - /// The range spanned by the left and right array brackets. - SourceRange Brackets; - DependentSizedArrayType(QualType et, QualType can, Expr *e, - ArraySizeModifier sm, unsigned tq, - SourceRange brackets); + ArraySizeModifier sm, unsigned tq); public: friend class StmtIteratorBase; @@ -3900,10 +3896,6 @@ class DependentSizedArrayType : public ArrayType { return (Expr*) SizeExpr; } - SourceRange getBracketsRange() const { return Brackets; } - SourceLocation getLBracketLoc() const { return Brackets.getBegin(); } - SourceLocation getRBracketLoc() const { return Brackets.getEnd(); } - bool isSugared() const { return false; } QualType desugar() const { return QualType(this, 0); } diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 3bf9239e9cbf5..6b2570d251173 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -173,21 +173,11 @@ let Class = VariableArrayType in { } let Class = DependentSizedArrayType in { - def : Property<"size", ExprRef> { - let Read = [{ node->getSizeExpr() }]; - } - def : Property<"leftBracketLoc", SourceLocation> { - let Read = [{ node->getLBracketLoc() }]; - } - def : Property<"rightBracketLoc", SourceLocation> { - let Read = [{ node->getRBracketLoc() }]; - } + def : Property<"size", ExprRef> { let Read = [{ node->getSizeExpr() }]; } def : Creator<[{ return ctx.getDependentSizedArrayType(elementType, size, sizeModifier, - indexQualifiers.getCVRQualifiers(), - SourceRange(leftBracketLoc, - rightBracketLoc)); + indexQualifiers.getCVRQualifiers()); }]>; } diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 46bd1977d688d..76438e0a08652 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4261,11 +4261,8 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const { case Type::DependentSizedArray: { const auto *dat = cast<DependentSizedArrayType>(ty); result = getDependentSizedArrayType( - getVariableArrayDecayedType(dat->getElementType()), - dat->getSizeExpr(), - dat->getSizeModifier(), - dat->getIndexTypeCVRQualifiers(), - dat->getBracketsRange()); + getVariableArrayDecayedType(dat->getElementType()), dat->getSizeExpr(), + dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers()); break; } @@ -4324,11 +4321,10 @@ QualType ASTContext::getVariableArrayType(QualType EltTy, Expr *NumElts, /// getDependentSizedArrayType - Returns a non-unique reference to /// the type for a dependently-sized array of the specified element /// type. -QualType ASTContext::getDependentSizedArrayType(QualType elementType, - Expr *numElements, - ArraySizeModifier ASM, - unsigned elementTypeQuals, - SourceRange brackets) const { +QualType +ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements, + ArraySizeModifier ASM, + unsigned elementTypeQuals) const { assert((!numElements || numElements->isTypeDependent() || numElements->isValueDependent()) && "Size must be type- or value-dependent!"); @@ -4354,7 +4350,7 @@ QualType ASTContext::getDependentSizedArrayType(QualType elementType, auto *newType = new (*this, alignof(DependentSizedArrayType)) DependentSizedArrayType(elementType, QualType(), numElements, ASM, - elementTypeQuals, brackets); + elementTypeQuals); DependentSizedArrayTypes.InsertNode(newType, insertPos); Types.push_back(newType); return QualType(newType, 0); @@ -4364,7 +4360,7 @@ QualType ASTContext::getDependentSizedArrayType(QualType elementType, if (!canonTy) { canonTy = new (*this, alignof(DependentSizedArrayType)) DependentSizedArrayType(QualType(canonElementType.Ty, 0), QualType(), - numElements, ASM, elementTypeQuals, brackets); + numElements, ASM, elementTypeQuals); DependentSizedArrayTypes.InsertNode(canonTy, insertPos); Types.push_back(canonTy); } @@ -4383,7 +4379,7 @@ QualType ASTContext::getDependentSizedArrayType(QualType elementType, // of the element type. auto *sugaredType = new (*this, alignof(DependentSizedArrayType)) DependentSizedArrayType(elementType, canon, numElements, ASM, - elementTypeQuals, brackets); + elementTypeQuals); Types.push_back(sugaredType); return QualType(sugaredType, 0); } @@ -6784,8 +6780,7 @@ QualType ASTContext::getUnqualifiedArrayType(QualType type, const auto *DSAT = cast<DependentSizedArrayType>(AT); return getDependentSizedArrayType(unqualElementType, DSAT->getSizeExpr(), - DSAT->getSizeModifier(), 0, - SourceRange()); + DSAT->getSizeModifier(), 0); } /// Attempt to unwrap two types that may both be array types with the same bound @@ -7729,12 +7724,9 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) const { IAT->getIndexTypeCVRQualifiers())); if (const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy)) - return cast<ArrayType>( - getDependentSizedArrayType(NewEltTy, - DSAT->getSizeExpr(), - DSAT->getSizeModifier(), - DSAT->getIndexTypeCVRQualifiers(), - DSAT->getBracketsRange())); + return cast<ArrayType>(getDependentSizedArrayType( + NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(), + DSAT->getIndexTypeCVRQualifiers())); const auto *VAT = cast<VariableArrayType>(ATy); return cast<ArrayType>(getVariableArrayType(NewEltTy, @@ -13846,10 +13838,7 @@ static QualType getCommonNonSugarTypeNode(ASTContext &Ctx, const Type *X, return Ctx.getDependentSizedArrayType( getCommonArrayElementType(Ctx, AX, QX, AY, QY), getCommonSizeExpr(Ctx, AX, AY), getCommonSizeModifier(AX, AY), - getCommonIndexTypeCVRQualifiers(AX, AY), - AX->getBracketsRange() == AY->getBracketsRange() - ? AX->getBracketsRange() - : SourceRange()); + getCommonIndexTypeCVRQualifiers(AX, AY)); } case Type::ConstantArray: { const auto *AX = cast<ConstantArrayType>(X), diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 5baff6c1e13e9..6f83d331c4a50 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -148,7 +148,7 @@ QualType clang::desugarForDiagnostic(ASTContext &Context, QualType QT, else if (const auto *DSAT = dyn_cast<DependentSizedArrayType>(AT)) QT = Context.getDependentSizedArrayType( ElementTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(), - DSAT->getIndexTypeCVRQualifiers(), DSAT->getBracketsRange()); + DSAT->getIndexTypeCVRQualifiers()); else if (const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) QT = Context.getIncompleteArrayType(ElementTy, IAT->getSizeModifier(), IAT->getIndexTypeCVRQualifiers()); diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 378734e9c1909..a0fead56f0219 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -1308,7 +1308,6 @@ ExpectedType ASTNodeImporter::VisitDependentSizedArrayType( Error Err = Error::success(); QualType ToElementType = importChecked(Err, T->getElementType()); Expr *ToSizeExpr = importChecked(Err, T->getSizeExpr()); - SourceRange ToBracketsRange = importChecked(Err, T->getBracketsRange()); if (Err) return std::move(Err); // SizeExpr may be null if size is not specified directly. @@ -1316,7 +1315,7 @@ ExpectedType ASTNodeImporter::VisitDependentSizedArrayType( return Importer.getToContext().getDependentSizedArrayType( ToElementType, ToSizeExpr, T->getSizeModifier(), - T->getIndexTypeCVRQualifiers(), ToBracketsRange); + T->getIndexTypeCVRQualifiers()); } ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType( diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 4d14614fc1ec7..88f6926929ea9 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -3312,7 +3312,7 @@ void MicrosoftCXXNameMangler::mangleArrayType(const ArrayType *T) { const DependentSizedArrayType *DSAT = getASTContext().getAsDependentSizedArrayType(ElementTy); Error(DSAT->getSizeExpr()->getExprLoc(), "dependent-length") - << DSAT->getBracketsRange(); + << DSAT->getSizeExpr()->getSourceRange(); return; } else { break; diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index be8d609974d81..aba869ebbea07 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -1949,8 +1949,6 @@ void TextNodeDumper::VisitVariableArrayType(const VariableArrayType *T) { void TextNodeDumper::VisitDependentSizedArrayType( const DependentSizedArrayType *T) { VisitArrayType(T); - OS << " "; - dumpSourceRange(T->getBracketsRange()); } void TextNodeDumper::VisitDependentSizedExtVectorType( diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 7898e6b90bf4b..82476170b82c5 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -279,10 +279,8 @@ QualType ArrayParameterType::getConstantArrayType(const ASTContext &Ctx) const { DependentSizedArrayType::DependentSizedArrayType(QualType et, QualType can, Expr *e, ArraySizeModifier sm, - unsigned tq, - SourceRange brackets) - : ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((Stmt *)e), - Brackets(brackets) {} + unsigned tq) + : ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((Stmt *)e) {} void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index efe2d03882f31..a1e4bb4321d53 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -7740,27 +7740,11 @@ ExprResult InitializationSequence::Perform(Sema &S, // introduced and such). So, we fall back to making the array // type a dependently-sized array type with no specified // bound. - if (isa<InitListExpr>((Expr *)Args[0])) { - SourceRange Brackets; - - // Scavange the location of the brackets from the entity, if we can. - if (auto *DD = dyn_cast_or_null<DeclaratorDecl>(Entity.getDecl())) { - if (TypeSourceInfo *TInfo = DD->getTypeSourceInfo()) { - TypeLoc TL = TInfo->getTypeLoc(); - if (IncompleteArrayTypeLoc ArrayLoc = - TL.getAs<IncompleteArrayTypeLoc>()) - Brackets = ArrayLoc.getBracketsRange(); - } - } - - *ResultType - = S.Context.getDependentSizedArrayType(ArrayT->getElementType(), - /*NumElts=*/nullptr, - ArrayT->getSizeModifier(), - ArrayT->getIndexTypeCVRQualifiers(), - Brackets); - } - + if (isa<InitListExpr>((Expr *)Args[0])) + *ResultType = S.Context.getDependentSizedArrayType( + ArrayT->getElementType(), + /*NumElts=*/nullptr, ArrayT->getSizeModifier(), + ArrayT->getIndexTypeCVRQualifiers()); } } if (Kind.getKind() == InitializationKind::IK_Direct && diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index e711a5c5d2a18..e7a6e23b0e5a0 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2218,7 +2218,7 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM, T = Context.getIncompleteArrayType(T, ASM, Quals); } } else if (ArraySize->isTypeDependent() || ArraySize->isValueDependent()) { - T = Context.getDependentSizedArrayType(T, ArraySize, ASM, Quals, Brackets); + T = Context.getDependentSizedArrayType(T, ArraySize, ASM, Quals); } else { ExprResult R = checkArraySize(*this, ArraySize, ConstVal, VLADiag, VLAIsError); diff --git a/clang/test/AST/ast-dump-array.cpp b/clang/test/AST/ast-dump-array.cpp index 418e4292680ee..15771f227df8a 100644 --- a/clang/test/AST/ast-dump-array.cpp +++ b/clang/test/AST/ast-dump-array.cpp @@ -22,9 +22,9 @@ class array { T data[Size]; using array_T_size = T[Size]; - // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'T[Size]' dependent <col:25, col:30> + // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'T[Size]' dependent using const_array_T_size = const T[Size]; - // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'const T[Size]' dependent <col:37, col:42> + // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'const T[Size]' dependent }; struct V {}; diff --git a/clang/test/SemaTemplate/deduction-guide.cpp b/clang/test/SemaTemplate/deduction-guide.cpp index 6db132ca37c7e..2888453a12f5b 100644 --- a/clang/test/SemaTemplate/deduction-guide.cpp +++ b/clang/test/SemaTemplate/deduction-guide.cpp @@ -475,7 +475,7 @@ A a{.f1 = {1}}; // CHECK-NEXT: `-RValueReferenceType {{.+}} 'int (&&)[N]' dependent // CHECK-NEXT: `-DependentSizedArrayType {{.+}} 'int[N]' dependent // CHECK-NEXT: |-BuiltinType {{.+}} 'int' -// CHECK-NEXT: `-DeclRefExpr {{.+}} <col:10> 'int' NonTypeTemplateParm {{.+}} 'N' 'int' +// CHECK-NEXT: `-DeclRefExpr {{.+}} <{{.+}}:10> 'int' NonTypeTemplateParm {{.+}} 'N' 'int' } // namespace GH83368 >From a18763628e82ad3934315d9b5cb3fb9bbc98563d Mon Sep 17 00:00:00 2001 From: Matheus Izvekov <mizve...@gmail.com> Date: Sat, 12 Apr 2025 22:05:41 -0300 Subject: [PATCH 2/2] [clang] AST: remove source locations from VariableSizedArrayType Source locations should be handled at the TypeLoc level, and these locations are already wired up to the base ArrayLoc. There was nothing important wired to these, so just remove. --- clang/include/clang/AST/ASTContext.h | 4 +-- clang/include/clang/AST/Type.h | 15 +++-------- clang/include/clang/AST/TypeProperties.td | 10 +------- clang/lib/AST/ASTContext.cpp | 31 ++++++++++------------- clang/lib/AST/ASTDiagnostic.cpp | 6 ++--- clang/lib/AST/ASTImporter.cpp | 3 +-- clang/lib/AST/TextNodeDumper.cpp | 2 -- clang/lib/AST/Type.cpp | 3 +-- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 4 +-- clang/lib/Sema/SemaOpenMP.cpp | 4 +-- clang/lib/Sema/SemaType.cpp | 12 ++++----- 11 files changed, 34 insertions(+), 60 deletions(-) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index d8d0b79bd67d9..3c78833a3f069 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1564,8 +1564,8 @@ class ASTContext : public RefCountedBase<ASTContext> { /// Return a non-unique reference to the type for a variable array of /// the specified element type. QualType getVariableArrayType(QualType EltTy, Expr *NumElts, - ArraySizeModifier ASM, unsigned IndexTypeQuals, - SourceRange Brackets) const; + ArraySizeModifier ASM, + unsigned IndexTypeQuals) const; /// Return a non-unique reference to the type for a dependently-sized /// array of the specified element type. diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 89ec32cecec07..74886ef0cd824 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3827,14 +3827,9 @@ class VariableArrayType : public ArrayType { /// a function block. Stmt *SizeExpr; - /// The range spanned by the left and right array brackets. - SourceRange Brackets; - - VariableArrayType(QualType et, QualType can, Expr *e, - ArraySizeModifier sm, unsigned tq, - SourceRange brackets) - : ArrayType(VariableArray, et, can, sm, tq, e), - SizeExpr((Stmt*) e), Brackets(brackets) {} + VariableArrayType(QualType et, QualType can, Expr *e, ArraySizeModifier sm, + unsigned tq) + : ArrayType(VariableArray, et, can, sm, tq, e), SizeExpr((Stmt *)e) {} public: friend class StmtIteratorBase; @@ -3845,10 +3840,6 @@ class VariableArrayType : public ArrayType { return (Expr*) SizeExpr; } - SourceRange getBracketsRange() const { return Brackets; } - SourceLocation getLBracketLoc() const { return Brackets.getBegin(); } - SourceLocation getRBracketLoc() const { return Brackets.getEnd(); } - bool isSugared() const { return false; } QualType desugar() const { return QualType(this, 0); } diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 6b2570d251173..f4b8ce0994ba8 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -154,21 +154,13 @@ let Class = IncompleteArrayType in { } let Class = VariableArrayType in { - def : Property<"leftBracketLoc", SourceLocation> { - let Read = [{ node->getLBracketLoc() }]; - } - def : Property<"rightBracketLoc", SourceLocation> { - let Read = [{ node->getRBracketLoc() }]; - } def : Property<"size", ExprRef> { let Read = [{ node->getSizeExpr() }]; } def : Creator<[{ return ctx.getVariableArrayType(elementType, size, sizeModifier, - indexQualifiers.getCVRQualifiers(), - SourceRange(leftBracketLoc, - rightBracketLoc)); + indexQualifiers.getCVRQualifiers()); }]>; } diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 76438e0a08652..dfae2f5511b43 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4272,17 +4272,17 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const { result = getVariableArrayType(getVariableArrayDecayedType(iat->getElementType()), /*size*/ nullptr, ArraySizeModifier::Normal, - iat->getIndexTypeCVRQualifiers(), SourceRange()); + iat->getIndexTypeCVRQualifiers()); break; } // Turn VLA types into [*] types. case Type::VariableArray: { const auto *vat = cast<VariableArrayType>(ty); - result = getVariableArrayType( - getVariableArrayDecayedType(vat->getElementType()), - /*size*/ nullptr, ArraySizeModifier::Star, - vat->getIndexTypeCVRQualifiers(), vat->getBracketsRange()); + result = + getVariableArrayType(getVariableArrayDecayedType(vat->getElementType()), + /*size*/ nullptr, ArraySizeModifier::Star, + vat->getIndexTypeCVRQualifiers()); break; } } @@ -4295,8 +4295,7 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const { /// variable array of the specified element type. QualType ASTContext::getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, - unsigned IndexTypeQuals, - SourceRange Brackets) const { + unsigned IndexTypeQuals) const { // Since we don't unique expressions, it isn't possible to unique VLA's // that have an expression provided for their size. QualType Canon; @@ -4306,12 +4305,12 @@ QualType ASTContext::getVariableArrayType(QualType EltTy, Expr *NumElts, if (!EltTy.isCanonical() || EltTy.hasLocalQualifiers()) { SplitQualType canonSplit = getCanonicalType(EltTy).split(); Canon = getVariableArrayType(QualType(canonSplit.Ty, 0), NumElts, ASM, - IndexTypeQuals, Brackets); + IndexTypeQuals); Canon = getQualifiedType(Canon, canonSplit.Quals); } auto *New = new (*this, alignof(VariableArrayType)) - VariableArrayType(EltTy, Canon, NumElts, ASM, IndexTypeQuals, Brackets); + VariableArrayType(EltTy, Canon, NumElts, ASM, IndexTypeQuals); VariableArrayTypes.push_back(New); Types.push_back(New); @@ -6771,11 +6770,9 @@ QualType ASTContext::getUnqualifiedArrayType(QualType type, } if (const auto *VAT = dyn_cast<VariableArrayType>(AT)) { - return getVariableArrayType(unqualElementType, - VAT->getSizeExpr(), + return getVariableArrayType(unqualElementType, VAT->getSizeExpr(), VAT->getSizeModifier(), - VAT->getIndexTypeCVRQualifiers(), - VAT->getBracketsRange()); + VAT->getIndexTypeCVRQualifiers()); } const auto *DSAT = cast<DependentSizedArrayType>(AT); @@ -7729,11 +7726,9 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) const { DSAT->getIndexTypeCVRQualifiers())); const auto *VAT = cast<VariableArrayType>(ATy); - return cast<ArrayType>(getVariableArrayType(NewEltTy, - VAT->getSizeExpr(), - VAT->getSizeModifier(), - VAT->getIndexTypeCVRQualifiers(), - VAT->getBracketsRange())); + return cast<ArrayType>( + getVariableArrayType(NewEltTy, VAT->getSizeExpr(), VAT->getSizeModifier(), + VAT->getIndexTypeCVRQualifiers())); } QualType ASTContext::getAdjustedParameterType(QualType T) const { diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp index 6f83d331c4a50..5c8acde452dbc 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -142,9 +142,9 @@ QualType clang::desugarForDiagnostic(ASTContext &Context, QualType QT, ElementTy, CAT->getSize(), CAT->getSizeExpr(), CAT->getSizeModifier(), CAT->getIndexTypeCVRQualifiers()); else if (const auto *VAT = dyn_cast<VariableArrayType>(AT)) - QT = Context.getVariableArrayType( - ElementTy, VAT->getSizeExpr(), VAT->getSizeModifier(), - VAT->getIndexTypeCVRQualifiers(), VAT->getBracketsRange()); + QT = Context.getVariableArrayType(ElementTy, VAT->getSizeExpr(), + VAT->getSizeModifier(), + VAT->getIndexTypeCVRQualifiers()); else if (const auto *DSAT = dyn_cast<DependentSizedArrayType>(AT)) QT = Context.getDependentSizedArrayType( ElementTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(), diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index a0fead56f0219..b55b8f2c14147 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -1295,12 +1295,11 @@ ASTNodeImporter::VisitVariableArrayType(const VariableArrayType *T) { Error Err = Error::success(); QualType ToElementType = importChecked(Err, T->getElementType()); Expr *ToSizeExpr = importChecked(Err, T->getSizeExpr()); - SourceRange ToBracketsRange = importChecked(Err, T->getBracketsRange()); if (Err) return std::move(Err); return Importer.getToContext().getVariableArrayType( ToElementType, ToSizeExpr, T->getSizeModifier(), - T->getIndexTypeCVRQualifiers(), ToBracketsRange); + T->getIndexTypeCVRQualifiers()); } ExpectedType ASTNodeImporter::VisitDependentSizedArrayType( diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index aba869ebbea07..837477c112f3d 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -1941,8 +1941,6 @@ void TextNodeDumper::VisitConstantArrayType(const ConstantArrayType *T) { } void TextNodeDumper::VisitVariableArrayType(const VariableArrayType *T) { - OS << " "; - dumpSourceRange(T->getBracketsRange()); VisitArrayType(T); } diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 82476170b82c5..62e48062cf241 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1097,8 +1097,7 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> { return Ctx.getVariableArrayType(elementType, T->getSizeExpr(), T->getSizeModifier(), - T->getIndexTypeCVRQualifiers(), - T->getBracketsRange()); + T->getIndexTypeCVRQualifiers()); } QualType VisitIncompleteArrayType(const IncompleteArrayType *T) { diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 5736864d4cc6b..918b064c3cfd5 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -3797,7 +3797,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, RValue::get(NumOfElements)); KmpTaskAffinityInfoArrayTy = C.getVariableArrayType( KmpTaskAffinityInfoTy, OVE, ArraySizeModifier::Normal, - /*IndexTypeQuals=*/0, SourceRange(Loc, Loc)); + /*IndexTypeQuals=*/0); // Properly emit variable-sized array. auto *PD = ImplicitParamDecl::Create(C, KmpTaskAffinityInfoArrayTy, ImplicitParamKind::Other); @@ -4260,7 +4260,7 @@ std::pair<llvm::Value *, Address> CGOpenMPRuntime::emitDependClause( RValue::get(NumOfElements)); KmpDependInfoArrayTy = C.getVariableArrayType(KmpDependInfoTy, OVE, ArraySizeModifier::Normal, - /*IndexTypeQuals=*/0, SourceRange(Loc, Loc)); + /*IndexTypeQuals=*/0); // CGF.EmitVariablyModifiedType(KmpDependInfoArrayTy); // Properly emit variable-sized array. auto *PD = ImplicitParamDecl::Create(C, KmpDependInfoArrayTy, diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index a382947455aef..0e44cfab6f216 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -19120,7 +19120,7 @@ static bool actOnOMPReductionKindClause( Type, new (Context) OpaqueValueExpr(ELoc, Context.getSizeType(), VK_PRValue), - ArraySizeModifier::Normal, /*IndexTypeQuals=*/0, SourceRange()); + ArraySizeModifier::Normal, /*IndexTypeQuals=*/0); } else if (!ASE && !OASE && Context.getAsArrayType(D->getType().getNonReferenceType())) { PrivateTy = D->getType().getNonReferenceType(); @@ -19360,7 +19360,7 @@ static bool actOnOMPReductionKindClause( OpaqueValueExpr(ELoc, S.Context.getSizeType(), VK_PRValue); QualType ArrayTy = S.Context.getVariableArrayType( PrivateTy, Dim, ArraySizeModifier::Normal, - /*IndexTypeQuals=*/0, {ELoc, ELoc}); + /*IndexTypeQuals=*/0); VarDecl *TempArrayVD = buildVarDecl(S, ELoc, ArrayTy, D->getName(), D->hasAttrs() ? &D->getAttrs() : nullptr); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index e7a6e23b0e5a0..33b1d8ca4dfa0 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2213,7 +2213,7 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM, if (VLAIsError) return QualType(); - T = Context.getVariableArrayType(T, nullptr, ASM, Quals, Brackets); + T = Context.getVariableArrayType(T, nullptr, ASM, Quals); } else { T = Context.getIncompleteArrayType(T, ASM, Quals); } @@ -2229,7 +2229,7 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM, // C99: an array with a non-ICE size is a VLA. We accept any expression // that we can fold to a non-zero positive value as a non-VLA as an // extension. - T = Context.getVariableArrayType(T, ArraySize, ASM, Quals, Brackets); + T = Context.getVariableArrayType(T, ArraySize, ASM, Quals); } else if (!T->isDependentType() && !T->isIncompleteType() && !T->isConstantSizeType()) { // C99: an array with an element type that has a non-constant-size is a @@ -2238,7 +2238,7 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM, Diag(Loc, VLADiag); if (VLAIsError) return QualType(); - T = Context.getVariableArrayType(T, ArraySize, ASM, Quals, Brackets); + T = Context.getVariableArrayType(T, ArraySize, ASM, Quals); } else { // C99 6.7.5.2p1: If the expression is a constant expression, it shall // have a value greater than zero. @@ -6947,9 +6947,9 @@ namespace { if (const auto *VAT = dyn_cast<VariableArrayType>(Old)) { QualType New = wrap(C, VAT->getElementType(), I); - return C.getVariableArrayType( - New, VAT->getSizeExpr(), VAT->getSizeModifier(), - VAT->getIndexTypeCVRQualifiers(), VAT->getBracketsRange()); + return C.getVariableArrayType(New, VAT->getSizeExpr(), + VAT->getSizeModifier(), + VAT->getIndexTypeCVRQualifiers()); } const auto *IAT = cast<IncompleteArrayType>(Old); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits