Skip to content

Commit a187636

Browse files
committed
[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.
1 parent e01aa7b commit a187636

File tree

11 files changed

+34
-60
lines changed

11 files changed

+34
-60
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
15641564
/// Return a non-unique reference to the type for a variable array of
15651565
/// the specified element type.
15661566
QualType getVariableArrayType(QualType EltTy, Expr *NumElts,
1567-
ArraySizeModifier ASM, unsigned IndexTypeQuals,
1568-
SourceRange Brackets) const;
1567+
ArraySizeModifier ASM,
1568+
unsigned IndexTypeQuals) const;
15691569

15701570
/// Return a non-unique reference to the type for a dependently-sized
15711571
/// array of the specified element type.

clang/include/clang/AST/Type.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3827,14 +3827,9 @@ class VariableArrayType : public ArrayType {
38273827
/// a function block.
38283828
Stmt *SizeExpr;
38293829

3830-
/// The range spanned by the left and right array brackets.
3831-
SourceRange Brackets;
3832-
3833-
VariableArrayType(QualType et, QualType can, Expr *e,
3834-
ArraySizeModifier sm, unsigned tq,
3835-
SourceRange brackets)
3836-
: ArrayType(VariableArray, et, can, sm, tq, e),
3837-
SizeExpr((Stmt*) e), Brackets(brackets) {}
3830+
VariableArrayType(QualType et, QualType can, Expr *e, ArraySizeModifier sm,
3831+
unsigned tq)
3832+
: ArrayType(VariableArray, et, can, sm, tq, e), SizeExpr((Stmt *)e) {}
38383833

38393834
public:
38403835
friend class StmtIteratorBase;
@@ -3845,10 +3840,6 @@ class VariableArrayType : public ArrayType {
38453840
return (Expr*) SizeExpr;
38463841
}
38473842

3848-
SourceRange getBracketsRange() const { return Brackets; }
3849-
SourceLocation getLBracketLoc() const { return Brackets.getBegin(); }
3850-
SourceLocation getRBracketLoc() const { return Brackets.getEnd(); }
3851-
38523843
bool isSugared() const { return false; }
38533844
QualType desugar() const { return QualType(this, 0); }
38543845

clang/include/clang/AST/TypeProperties.td

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,13 @@ let Class = IncompleteArrayType in {
154154
}
155155

156156
let Class = VariableArrayType in {
157-
def : Property<"leftBracketLoc", SourceLocation> {
158-
let Read = [{ node->getLBracketLoc() }];
159-
}
160-
def : Property<"rightBracketLoc", SourceLocation> {
161-
let Read = [{ node->getRBracketLoc() }];
162-
}
163157
def : Property<"size", ExprRef> {
164158
let Read = [{ node->getSizeExpr() }];
165159
}
166160

167161
def : Creator<[{
168162
return ctx.getVariableArrayType(elementType, size, sizeModifier,
169-
indexQualifiers.getCVRQualifiers(),
170-
SourceRange(leftBracketLoc,
171-
rightBracketLoc));
163+
indexQualifiers.getCVRQualifiers());
172164
}]>;
173165
}
174166

clang/lib/AST/ASTContext.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4272,17 +4272,17 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const {
42724272
result =
42734273
getVariableArrayType(getVariableArrayDecayedType(iat->getElementType()),
42744274
/*size*/ nullptr, ArraySizeModifier::Normal,
4275-
iat->getIndexTypeCVRQualifiers(), SourceRange());
4275+
iat->getIndexTypeCVRQualifiers());
42764276
break;
42774277
}
42784278

42794279
// Turn VLA types into [*] types.
42804280
case Type::VariableArray: {
42814281
const auto *vat = cast<VariableArrayType>(ty);
4282-
result = getVariableArrayType(
4283-
getVariableArrayDecayedType(vat->getElementType()),
4284-
/*size*/ nullptr, ArraySizeModifier::Star,
4285-
vat->getIndexTypeCVRQualifiers(), vat->getBracketsRange());
4282+
result =
4283+
getVariableArrayType(getVariableArrayDecayedType(vat->getElementType()),
4284+
/*size*/ nullptr, ArraySizeModifier::Star,
4285+
vat->getIndexTypeCVRQualifiers());
42864286
break;
42874287
}
42884288
}
@@ -4295,8 +4295,7 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const {
42954295
/// variable array of the specified element type.
42964296
QualType ASTContext::getVariableArrayType(QualType EltTy, Expr *NumElts,
42974297
ArraySizeModifier ASM,
4298-
unsigned IndexTypeQuals,
4299-
SourceRange Brackets) const {
4298+
unsigned IndexTypeQuals) const {
43004299
// Since we don't unique expressions, it isn't possible to unique VLA's
43014300
// that have an expression provided for their size.
43024301
QualType Canon;
@@ -4306,12 +4305,12 @@ QualType ASTContext::getVariableArrayType(QualType EltTy, Expr *NumElts,
43064305
if (!EltTy.isCanonical() || EltTy.hasLocalQualifiers()) {
43074306
SplitQualType canonSplit = getCanonicalType(EltTy).split();
43084307
Canon = getVariableArrayType(QualType(canonSplit.Ty, 0), NumElts, ASM,
4309-
IndexTypeQuals, Brackets);
4308+
IndexTypeQuals);
43104309
Canon = getQualifiedType(Canon, canonSplit.Quals);
43114310
}
43124311

43134312
auto *New = new (*this, alignof(VariableArrayType))
4314-
VariableArrayType(EltTy, Canon, NumElts, ASM, IndexTypeQuals, Brackets);
4313+
VariableArrayType(EltTy, Canon, NumElts, ASM, IndexTypeQuals);
43154314

43164315
VariableArrayTypes.push_back(New);
43174316
Types.push_back(New);
@@ -6771,11 +6770,9 @@ QualType ASTContext::getUnqualifiedArrayType(QualType type,
67716770
}
67726771

67736772
if (const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
6774-
return getVariableArrayType(unqualElementType,
6775-
VAT->getSizeExpr(),
6773+
return getVariableArrayType(unqualElementType, VAT->getSizeExpr(),
67766774
VAT->getSizeModifier(),
6777-
VAT->getIndexTypeCVRQualifiers(),
6778-
VAT->getBracketsRange());
6775+
VAT->getIndexTypeCVRQualifiers());
67796776
}
67806777

67816778
const auto *DSAT = cast<DependentSizedArrayType>(AT);
@@ -7729,11 +7726,9 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) const {
77297726
DSAT->getIndexTypeCVRQualifiers()));
77307727

77317728
const auto *VAT = cast<VariableArrayType>(ATy);
7732-
return cast<ArrayType>(getVariableArrayType(NewEltTy,
7733-
VAT->getSizeExpr(),
7734-
VAT->getSizeModifier(),
7735-
VAT->getIndexTypeCVRQualifiers(),
7736-
VAT->getBracketsRange()));
7729+
return cast<ArrayType>(
7730+
getVariableArrayType(NewEltTy, VAT->getSizeExpr(), VAT->getSizeModifier(),
7731+
VAT->getIndexTypeCVRQualifiers()));
77377732
}
77387733

77397734
QualType ASTContext::getAdjustedParameterType(QualType T) const {

clang/lib/AST/ASTDiagnostic.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ QualType clang::desugarForDiagnostic(ASTContext &Context, QualType QT,
142142
ElementTy, CAT->getSize(), CAT->getSizeExpr(),
143143
CAT->getSizeModifier(), CAT->getIndexTypeCVRQualifiers());
144144
else if (const auto *VAT = dyn_cast<VariableArrayType>(AT))
145-
QT = Context.getVariableArrayType(
146-
ElementTy, VAT->getSizeExpr(), VAT->getSizeModifier(),
147-
VAT->getIndexTypeCVRQualifiers(), VAT->getBracketsRange());
145+
QT = Context.getVariableArrayType(ElementTy, VAT->getSizeExpr(),
146+
VAT->getSizeModifier(),
147+
VAT->getIndexTypeCVRQualifiers());
148148
else if (const auto *DSAT = dyn_cast<DependentSizedArrayType>(AT))
149149
QT = Context.getDependentSizedArrayType(
150150
ElementTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),

clang/lib/AST/ASTImporter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,12 +1295,11 @@ ASTNodeImporter::VisitVariableArrayType(const VariableArrayType *T) {
12951295
Error Err = Error::success();
12961296
QualType ToElementType = importChecked(Err, T->getElementType());
12971297
Expr *ToSizeExpr = importChecked(Err, T->getSizeExpr());
1298-
SourceRange ToBracketsRange = importChecked(Err, T->getBracketsRange());
12991298
if (Err)
13001299
return std::move(Err);
13011300
return Importer.getToContext().getVariableArrayType(
13021301
ToElementType, ToSizeExpr, T->getSizeModifier(),
1303-
T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1302+
T->getIndexTypeCVRQualifiers());
13041303
}
13051304

13061305
ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,8 +1941,6 @@ void TextNodeDumper::VisitConstantArrayType(const ConstantArrayType *T) {
19411941
}
19421942

19431943
void TextNodeDumper::VisitVariableArrayType(const VariableArrayType *T) {
1944-
OS << " ";
1945-
dumpSourceRange(T->getBracketsRange());
19461944
VisitArrayType(T);
19471945
}
19481946

clang/lib/AST/Type.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,7 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
10971097

10981098
return Ctx.getVariableArrayType(elementType, T->getSizeExpr(),
10991099
T->getSizeModifier(),
1100-
T->getIndexTypeCVRQualifiers(),
1101-
T->getBracketsRange());
1100+
T->getIndexTypeCVRQualifiers());
11021101
}
11031102

11041103
QualType VisitIncompleteArrayType(const IncompleteArrayType *T) {

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,7 +3797,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
37973797
RValue::get(NumOfElements));
37983798
KmpTaskAffinityInfoArrayTy = C.getVariableArrayType(
37993799
KmpTaskAffinityInfoTy, OVE, ArraySizeModifier::Normal,
3800-
/*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
3800+
/*IndexTypeQuals=*/0);
38013801
// Properly emit variable-sized array.
38023802
auto *PD = ImplicitParamDecl::Create(C, KmpTaskAffinityInfoArrayTy,
38033803
ImplicitParamKind::Other);
@@ -4260,7 +4260,7 @@ std::pair<llvm::Value *, Address> CGOpenMPRuntime::emitDependClause(
42604260
RValue::get(NumOfElements));
42614261
KmpDependInfoArrayTy =
42624262
C.getVariableArrayType(KmpDependInfoTy, OVE, ArraySizeModifier::Normal,
4263-
/*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
4263+
/*IndexTypeQuals=*/0);
42644264
// CGF.EmitVariablyModifiedType(KmpDependInfoArrayTy);
42654265
// Properly emit variable-sized array.
42664266
auto *PD = ImplicitParamDecl::Create(C, KmpDependInfoArrayTy,

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19120,7 +19120,7 @@ static bool actOnOMPReductionKindClause(
1912019120
Type,
1912119121
new (Context)
1912219122
OpaqueValueExpr(ELoc, Context.getSizeType(), VK_PRValue),
19123-
ArraySizeModifier::Normal, /*IndexTypeQuals=*/0, SourceRange());
19123+
ArraySizeModifier::Normal, /*IndexTypeQuals=*/0);
1912419124
} else if (!ASE && !OASE &&
1912519125
Context.getAsArrayType(D->getType().getNonReferenceType())) {
1912619126
PrivateTy = D->getType().getNonReferenceType();
@@ -19360,7 +19360,7 @@ static bool actOnOMPReductionKindClause(
1936019360
OpaqueValueExpr(ELoc, S.Context.getSizeType(), VK_PRValue);
1936119361
QualType ArrayTy = S.Context.getVariableArrayType(
1936219362
PrivateTy, Dim, ArraySizeModifier::Normal,
19363-
/*IndexTypeQuals=*/0, {ELoc, ELoc});
19363+
/*IndexTypeQuals=*/0);
1936419364
VarDecl *TempArrayVD =
1936519365
buildVarDecl(S, ELoc, ArrayTy, D->getName(),
1936619366
D->hasAttrs() ? &D->getAttrs() : nullptr);

0 commit comments

Comments
 (0)