Author: Vlad Serebrennikov Date: 2023-10-31T18:06:34+03:00 New Revision: 49fd28d9601dde429436655ec74234e895c60b89
URL: https://github.com/llvm/llvm-project/commit/49fd28d9601dde429436655ec74234e895c60b89 DIFF: https://github.com/llvm/llvm-project/commit/49fd28d9601dde429436655ec74234e895c60b89.diff LOG: [clang][NFC] Refactor `ArrayType::ArraySizeModifier` This patch moves `ArraySizeModifier` before `Type` declaration so that it's complete at `ArrayTypeBitfields` declaration. It's also converted to scoped enum along the way. Added: Modified: clang/include/clang/AST/ASTContext.h clang/include/clang/AST/PropertiesBase.td clang/include/clang/AST/Type.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/JSONNodeDumper.cpp clang/lib/AST/ODRHash.cpp clang/lib/AST/ScanfFormatString.cpp clang/lib/AST/TextNodeDumper.cpp clang/lib/AST/Type.cpp clang/lib/AST/TypePrinter.cpp clang/lib/CodeGen/CGAtomic.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGObjC.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/Targets/XCore.cpp clang/lib/ExtractAPI/DeclarationFragments.cpp clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp clang/lib/Frontend/Rewrite/RewriteObjC.cpp clang/lib/Index/USRGeneration.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaType.cpp clang/lib/Sema/TreeTransform.h Removed: ################################################################################ diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 8ad0514ee2ce227..24d22a9c692cd34 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1430,8 +1430,7 @@ 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, - ArrayType::ArraySizeModifier ASM, - unsigned IndexTypeQuals, + ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const; /// Return a non-unique reference to the type for a dependently-sized @@ -1440,21 +1439,19 @@ class ASTContext : public RefCountedBase<ASTContext> { /// FIXME: We will need these to be uniqued, or at least comparable, at some /// point. QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, - ArrayType::ArraySizeModifier ASM, + ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const; /// Return a unique reference to the type for an incomplete array of /// the specified element type. - QualType getIncompleteArrayType(QualType EltTy, - ArrayType::ArraySizeModifier ASM, + QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const; /// Return the unique reference to the type for a constant array of /// the specified element type. QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, - const Expr *SizeExpr, - ArrayType::ArraySizeModifier ASM, + const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const; /// Return a type for a constant array for a string literal of the diff --git a/clang/include/clang/AST/PropertiesBase.td b/clang/include/clang/AST/PropertiesBase.td index c6fe790e1964b05..129e6e0136964f8 100644 --- a/clang/include/clang/AST/PropertiesBase.td +++ b/clang/include/clang/AST/PropertiesBase.td @@ -74,7 +74,7 @@ def APInt : PropertyType<"llvm::APInt"> { let PassByReference = 1; } def APSInt : PropertyType<"llvm::APSInt"> { let PassByReference = 1; } def APValue : PropertyType { let PassByReference = 1; } def APValueKind : EnumPropertyType<"APValue::ValueKind">; -def ArraySizeModifier : EnumPropertyType<"ArrayType::ArraySizeModifier">; +def ArraySizeModifier : EnumPropertyType<"ArraySizeModifier">; def AttrKind : EnumPropertyType<"attr::Kind">; def AutoTypeKeyword : EnumPropertyType; def Bool : PropertyType<"bool">; diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 1e8e1303e65f6ba..080a5b045ed4da9 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -1569,6 +1569,12 @@ enum class AutoTypeKeyword { GNUAutoType }; +/// Capture whether this is a normal array (e.g. int X[4]) +/// an array with a static size (e.g. int X[static 4]), or an array +/// with a star size (e.g. int X[*]). +/// 'static' is only allowed on function parameters. +enum class ArraySizeModifier { Normal, Static, Star }; + /// The base class of the type hierarchy. /// /// A central concept with types is that each type always has a canonical @@ -1660,7 +1666,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { /// Storage class qualifiers from declarations like /// 'int X[static restrict 4]'. For function parameters only. - /// Actually an ArrayType::ArraySizeModifier. + /// Actually an ArraySizeModifier. unsigned SizeModifier : 3; }; enum { NumArrayTypeBits = NumTypeBits + 6 }; @@ -3086,15 +3092,6 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { /// Represents an array type, per C99 6.7.5.2 - Array Declarators. class ArrayType : public Type, public llvm::FoldingSetNode { -public: - /// Capture whether this is a normal array (e.g. int X[4]) - /// an array with a static size (e.g. int X[static 4]), or an array - /// with a star size (e.g. int X[*]). - /// 'static' is only allowed on function parameters. - enum ArraySizeModifier { - Normal, Static, Star - }; - private: /// The element type of the array. QualType ElementType; @@ -3218,7 +3215,7 @@ class IncompleteArrayType : public ArrayType { static void Profile(llvm::FoldingSetNodeID &ID, QualType ET, ArraySizeModifier SizeMod, unsigned TypeQuals) { ID.AddPointer(ET.getAsOpaquePtr()); - ID.AddInteger(SizeMod); + ID.AddInteger(llvm::to_underlying(SizeMod)); ID.AddInteger(TypeQuals); } }; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 1e9752345ffd173..91a4211a5cf5cce 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -2080,9 +2080,9 @@ class Sema final { SourceLocation Loc, DeclarationName Entity); QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity); - QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, - Expr *ArraySize, unsigned Quals, - SourceRange Brackets, DeclarationName Entity); + QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, + unsigned Quals, SourceRange Brackets, + DeclarationName Entity); QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc); QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc); diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 349c559b48b410f..e64bb0cf29dbbe1 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -3497,7 +3497,7 @@ QualType ASTContext::getMemberPointerType(QualType T, const Type *Cls) const { QualType ASTContext::getConstantArrayType(QualType EltTy, const llvm::APInt &ArySizeIn, const Expr *SizeExpr, - ArrayType::ArraySizeModifier ASM, + ArraySizeModifier ASM, unsigned IndexTypeQuals) const { assert((EltTy->isDependentType() || EltTy->isIncompleteType() || EltTy->isConstantSizeType()) && @@ -3663,12 +3663,10 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const { // Turn incomplete types into [*] types. case Type::IncompleteArray: { const auto *iat = cast<IncompleteArrayType>(ty); - result = getVariableArrayType( - getVariableArrayDecayedType(iat->getElementType()), - /*size*/ nullptr, - ArrayType::Normal, - iat->getIndexTypeCVRQualifiers(), - SourceRange()); + result = + getVariableArrayType(getVariableArrayDecayedType(iat->getElementType()), + /*size*/ nullptr, ArraySizeModifier::Normal, + iat->getIndexTypeCVRQualifiers(), SourceRange()); break; } @@ -3676,11 +3674,9 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const { case Type::VariableArray: { const auto *vat = cast<VariableArrayType>(ty); result = getVariableArrayType( - getVariableArrayDecayedType(vat->getElementType()), - /*size*/ nullptr, - ArrayType::Star, - vat->getIndexTypeCVRQualifiers(), - vat->getBracketsRange()); + getVariableArrayDecayedType(vat->getElementType()), + /*size*/ nullptr, ArraySizeModifier::Star, + vat->getIndexTypeCVRQualifiers(), vat->getBracketsRange()); break; } } @@ -3691,9 +3687,8 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const { /// getVariableArrayType - Returns a non-unique reference to the type for a /// variable array of the specified element type. -QualType ASTContext::getVariableArrayType(QualType EltTy, - Expr *NumElts, - ArrayType::ArraySizeModifier ASM, +QualType ASTContext::getVariableArrayType(QualType EltTy, Expr *NumElts, + ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const { // Since we don't unique expressions, it isn't possible to unique VLA's @@ -3722,7 +3717,7 @@ QualType ASTContext::getVariableArrayType(QualType EltTy, /// type. QualType ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements, - ArrayType::ArraySizeModifier ASM, + ArraySizeModifier ASM, unsigned elementTypeQuals, SourceRange brackets) const { assert((!numElements || numElements->isTypeDependent() || @@ -3785,7 +3780,7 @@ QualType ASTContext::getDependentSizedArrayType(QualType elementType, } QualType ASTContext::getIncompleteArrayType(QualType elementType, - ArrayType::ArraySizeModifier ASM, + ArraySizeModifier ASM, unsigned elementTypeQuals) const { llvm::FoldingSetNodeID ID; IncompleteArrayType::Profile(ID, elementType, ASM, elementTypeQuals); @@ -8857,9 +8852,8 @@ static TypedefDecl *CreatePowerABIBuiltinVaListDecl(const ASTContext *Context) { // typedef __va_list_tag __builtin_va_list[1]; llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1); - QualType VaListTagArrayType - = Context->getConstantArrayType(VaListTagTypedefType, - Size, nullptr, ArrayType::Normal, 0); + QualType VaListTagArrayType = Context->getConstantArrayType( + VaListTagTypedefType, Size, nullptr, ArraySizeModifier::Normal, 0); return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list"); } @@ -8913,7 +8907,7 @@ CreateX86_64ABIBuiltinVaListDecl(const ASTContext *Context) { // typedef struct __va_list_tag __builtin_va_list[1]; llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1); QualType VaListTagArrayType = Context->getConstantArrayType( - VaListTagType, Size, nullptr, ArrayType::Normal, 0); + VaListTagType, Size, nullptr, ArraySizeModifier::Normal, 0); return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list"); } @@ -8921,7 +8915,7 @@ static TypedefDecl *CreatePNaClABIBuiltinVaListDecl(const ASTContext *Context) { // typedef int __builtin_va_list[4]; llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 4); QualType IntArrayType = Context->getConstantArrayType( - Context->IntTy, Size, nullptr, ArrayType::Normal, 0); + Context->IntTy, Size, nullptr, ArraySizeModifier::Normal, 0); return Context->buildImplicitTypedef(IntArrayType, "__builtin_va_list"); } @@ -9016,7 +9010,7 @@ CreateSystemZBuiltinVaListDecl(const ASTContext *Context) { // typedef __va_list_tag __builtin_va_list[1]; llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1); QualType VaListTagArrayType = Context->getConstantArrayType( - VaListTagType, Size, nullptr, ArrayType::Normal, 0); + VaListTagType, Size, nullptr, ArraySizeModifier::Normal, 0); return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list"); } @@ -9067,7 +9061,7 @@ static TypedefDecl *CreateHexagonBuiltinVaListDecl(const ASTContext *Context) { // typedef __va_list_tag __builtin_va_list[1]; llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 1); QualType VaListTagArrayType = Context->getConstantArrayType( - VaListTagTypedefType, Size, nullptr, ArrayType::Normal, 0); + VaListTagTypedefType, Size, nullptr, ArraySizeModifier::Normal, 0); return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list"); } @@ -10762,12 +10756,10 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, bool OfBlockPointer, return RHS; if (LCAT) return getConstantArrayType(ResultType, LCAT->getSize(), - LCAT->getSizeExpr(), - ArrayType::ArraySizeModifier(), 0); + LCAT->getSizeExpr(), ArraySizeModifier(), 0); if (RCAT) return getConstantArrayType(ResultType, RCAT->getSize(), - RCAT->getSizeExpr(), - ArrayType::ArraySizeModifier(), 0); + RCAT->getSizeExpr(), ArraySizeModifier(), 0); if (LVAT && getCanonicalType(LHSElem) == getCanonicalType(ResultType)) return LHS; if (RVAT && getCanonicalType(RHSElem) == getCanonicalType(ResultType)) @@ -10786,8 +10778,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, bool OfBlockPointer, } if (getCanonicalType(LHSElem) == getCanonicalType(ResultType)) return LHS; if (getCanonicalType(RHSElem) == getCanonicalType(ResultType)) return RHS; - return getIncompleteArrayType(ResultType, - ArrayType::ArraySizeModifier(), 0); + return getIncompleteArrayType(ResultType, ArraySizeModifier(), 0); } case Type::FunctionNoProto: return mergeFunctionTypes(LHS, RHS, OfBlockPointer, Unqualified, @@ -12224,7 +12215,7 @@ QualType ASTContext::getStringLiteralArrayType(QualType EltTy, // Get an array type for the string, according to C99 6.4.5. This includes // the null terminator character. return getConstantArrayType(EltTy, llvm::APInt(32, Length + 1), nullptr, - ArrayType::Normal, /*IndexTypeQuals*/ 0); + ArraySizeModifier::Normal, /*IndexTypeQuals*/ 0); } StringLiteral * diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index f6f71ce6bfe0f50..aea26d380b8e822 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -6776,8 +6776,8 @@ static bool HandleOperatorNewCall(EvalInfo &Info, const CallExpr *E, return false; } - QualType AllocType = Info.Ctx.getConstantArrayType(ElemType, Size, nullptr, - ArrayType::Normal, 0); + QualType AllocType = Info.Ctx.getConstantArrayType( + ElemType, Size, nullptr, ArraySizeModifier::Normal, 0); APValue *Val = Info.createHeapAlloc(E, AllocType, Result); *Val = APValue(APValue::UninitArray(), 0, Size.getZExtValue()); Result.addArray(Info, E, cast<ConstantArrayType>(AllocType)); @@ -9039,8 +9039,8 @@ class PointerExprEvaluator QualType CharTy = Info.Ctx.CharTy.withConst(); APInt Size(Info.Ctx.getTypeSize(Info.Ctx.getSizeType()), ResultStr.size() + 1); - QualType ArrayTy = Info.Ctx.getConstantArrayType(CharTy, Size, nullptr, - ArrayType::Normal, 0); + QualType ArrayTy = Info.Ctx.getConstantArrayType( + CharTy, Size, nullptr, ArraySizeModifier::Normal, 0); StringLiteral *SL = StringLiteral::Create(Info.Ctx, ResultStr, StringLiteral::Ordinary, @@ -9863,7 +9863,7 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) { } AllocType = Info.Ctx.getConstantArrayType(AllocType, ArrayBound, nullptr, - ArrayType::Normal, 0); + ArraySizeModifier::Normal, 0); } else { assert(!AllocType->isArrayType() && "array allocation with non-array new"); diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp index 25b94ec5616b19c..60598bd0a80bbad 100644 --- a/clang/lib/AST/JSONNodeDumper.cpp +++ b/clang/lib/AST/JSONNodeDumper.cpp @@ -646,13 +646,13 @@ void JSONNodeDumper::VisitRValueReferenceType(const ReferenceType *RT) { void JSONNodeDumper::VisitArrayType(const ArrayType *AT) { switch (AT->getSizeModifier()) { - case ArrayType::Star: + case ArraySizeModifier::Star: JOS.attribute("sizeModifier", "*"); break; - case ArrayType::Static: + case ArraySizeModifier::Static: JOS.attribute("sizeModifier", "static"); break; - case ArrayType::Normal: + case ArraySizeModifier::Normal: break; } diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp index 7f9b5eb52e367eb..22bd914c02687e4 100644 --- a/clang/lib/AST/ODRHash.cpp +++ b/clang/lib/AST/ODRHash.cpp @@ -931,7 +931,7 @@ class ODRTypeVisitor : public TypeVisitor<ODRTypeVisitor> { void VisitArrayType(const ArrayType *T) { AddQualType(T->getElementType()); - ID.AddInteger(T->getSizeModifier()); + ID.AddInteger(llvm::to_underlying(T->getSizeModifier())); VisitQualifiers(T->getIndexTypeQualifiers()); VisitType(T); } diff --git a/clang/lib/AST/ScanfFormatString.cpp b/clang/lib/AST/ScanfFormatString.cpp index d6ff1a616285f85..64c430e623b577e 100644 --- a/clang/lib/AST/ScanfFormatString.cpp +++ b/clang/lib/AST/ScanfFormatString.cpp @@ -446,7 +446,7 @@ bool ScanfSpecifier::fixType(QualType QT, QualType RawQT, // If we know the target array length, we can use it as a field width. if (const ConstantArrayType *CAT = Ctx.getAsConstantArrayType(RawQT)) { - if (CAT->getSizeModifier() == ArrayType::Normal) + if (CAT->getSizeModifier() == ArraySizeModifier::Normal) FieldWidth = OptionalAmount(OptionalAmount::Constant, CAT->getSize().getZExtValue() - 1, "", 0, false); diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index ca609cf2d2060c1..60f053e6daaaadd 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -1549,12 +1549,12 @@ void TextNodeDumper::VisitRValueReferenceType(const ReferenceType *T) { void TextNodeDumper::VisitArrayType(const ArrayType *T) { switch (T->getSizeModifier()) { - case ArrayType::Normal: + case ArraySizeModifier::Normal: break; - case ArrayType::Static: + case ArraySizeModifier::Static: OS << " static"; break; - case ArrayType::Star: + case ArraySizeModifier::Star: OS << " *"; break; } diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 8389b1423058197..2a89b2077154390 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -156,7 +156,7 @@ ArrayType::ArrayType(TypeClass tc, QualType et, QualType can, : TypeDependence::None)), ElementType(et) { ArrayTypeBits.IndexTypeQuals = tq; - ArrayTypeBits.SizeModifier = sm; + ArrayTypeBits.SizeModifier = llvm::to_underlying(sm); } unsigned ConstantArrayType::getNumAddressingBits(const ASTContext &Context, @@ -218,7 +218,7 @@ void ConstantArrayType::Profile(llvm::FoldingSetNodeID &ID, unsigned TypeQuals) { ID.AddPointer(ET.getAsOpaquePtr()); ID.AddInteger(ArraySize.getZExtValue()); - ID.AddInteger(SizeMod); + ID.AddInteger(llvm::to_underlying(SizeMod)); ID.AddInteger(TypeQuals); ID.AddBoolean(SizeExpr != nullptr); if (SizeExpr) @@ -239,7 +239,7 @@ void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID, unsigned TypeQuals, Expr *E) { ID.AddPointer(ET.getAsOpaquePtr()); - ID.AddInteger(SizeMod); + ID.AddInteger(llvm::to_underlying(SizeMod)); ID.AddInteger(TypeQuals); E->Profile(ID, Context, true); } diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index b9f6c0eeb450d2c..f6e69b988f41deb 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -529,7 +529,7 @@ void TypePrinter::printConstantArrayAfter(const ConstantArrayType *T, OS << ' '; } - if (T->getSizeModifier() == ArrayType::Static) + if (T->getSizeModifier() == ArraySizeModifier::Static) OS << "static "; OS << T->getSize().getZExtValue() << ']'; @@ -562,9 +562,9 @@ void TypePrinter::printVariableArrayAfter(const VariableArrayType *T, OS << ' '; } - if (T->getSizeModifier() == VariableArrayType::Static) + if (T->getSizeModifier() == ArraySizeModifier::Static) OS << "static "; - else if (T->getSizeModifier() == VariableArrayType::Star) + else if (T->getSizeModifier() == ArraySizeModifier::Star) OS << '*'; if (T->getSizeExpr()) diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp index 83ad6739015b8d2..f7c597e181b0bd9 100644 --- a/clang/lib/CodeGen/CGAtomic.cpp +++ b/clang/lib/CodeGen/CGAtomic.cpp @@ -101,9 +101,9 @@ namespace { llvm::APInt Size( /*numBits=*/32, C.toCharUnitsFromBits(AtomicSizeInBits).getQuantity()); - AtomicTy = - C.getConstantArrayType(C.CharTy, Size, nullptr, ArrayType::Normal, - /*IndexTypeQuals=*/0); + AtomicTy = C.getConstantArrayType(C.CharTy, Size, nullptr, + ArraySizeModifier::Normal, + /*IndexTypeQuals=*/0); } AtomicAlign = ValueAlign = lvalue.getAlignment(); } else if (lvalue.isVectorElt()) { diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index dce5ee5888c458e..a90d0fdd2efbff6 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5292,7 +5292,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, -> std::tuple<llvm::Value *, llvm::Value *, llvm::Value *> { llvm::APInt ArraySize(32, NumArgs - First); QualType SizeArrayTy = getContext().getConstantArrayType( - getContext().getSizeType(), ArraySize, nullptr, ArrayType::Normal, + getContext().getSizeType(), ArraySize, nullptr, + ArraySizeModifier::Normal, /*IndexTypeQuals=*/0); auto Tmp = CreateMemTemp(SizeArrayTy, "block_sizes"); llvm::Value *TmpPtr = Tmp.getPointer(); diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index e1e1ad7e6a17b20..d0ee70c8d712727 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -3062,7 +3062,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, // indicates dereferenceability, and if the size is constant we can // use the dereferenceable attribute (which requires the size in // bytes). - if (ArrTy->getSizeModifier() == ArrayType::Static) { + if (ArrTy->getSizeModifier() == ArraySizeModifier::Static) { QualType ETy = ArrTy->getElementType(); llvm::Align Alignment = CGM.getNaturalTypeAlignment(ETy).getAsAlign(); @@ -3086,7 +3086,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, // For C99 VLAs with the static keyword, we don't know the size so // we can't use the dereferenceable attribute, but in addrspace(0) // we know that it must be nonnull. - if (ArrTy->getSizeModifier() == VariableArrayType::Static) { + if (ArrTy->getSizeModifier() == ArraySizeModifier::Static) { QualType ETy = ArrTy->getElementType(); llvm::Align Alignment = CGM.getNaturalTypeAlignment(ETy).getAsAlign(); diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0aaf678bf287c6e..2fb4fa46f51a58c 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3876,7 +3876,7 @@ void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit, QualType ET = CGM.getContext().getAsArrayType(T)->getElementType(); T = CGM.getContext().getConstantArrayType(ET, ConstVal, nullptr, - ArrayType::Normal, 0); + ArraySizeModifier::Normal, 0); } Name = VD->getName(); @@ -4548,7 +4548,7 @@ CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD, if (NumPaddingBytes.isPositive()) { llvm::APInt pad(32, NumPaddingBytes.getQuantity()); FType = CGM.getContext().getConstantArrayType( - CGM.getContext().CharTy, pad, nullptr, ArrayType::Normal, 0); + CGM.getContext().CharTy, pad, nullptr, ArraySizeModifier::Normal, 0); EltTys.push_back(CreateMemberType(Unit, FType, "", &FieldOffset)); } } diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index aa3a0ff57003d7c..5c967f97018f800 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -149,9 +149,9 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, llvm::APInt APNumElements(Context.getTypeSize(Context.getSizeType()), NumElements); QualType ElementType = Context.getObjCIdType().withConst(); - QualType ElementArrayType - = Context.getConstantArrayType(ElementType, APNumElements, nullptr, - ArrayType::Normal, /*IndexTypeQuals=*/0); + QualType ElementArrayType = Context.getConstantArrayType( + ElementType, APNumElements, nullptr, ArraySizeModifier::Normal, + /*IndexTypeQuals=*/0); // Allocate the temporary array(s). Address Objects = CreateMemTemp(ElementArrayType, "objects"); @@ -1801,10 +1801,9 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){ Selector FastEnumSel = CGM.getContext().Selectors.getSelector(std::size(II), &II[0]); - QualType ItemsTy = - getContext().getConstantArrayType(getContext().getObjCIdType(), - llvm::APInt(32, NumItems), nullptr, - ArrayType::Normal, 0); + QualType ItemsTy = getContext().getConstantArrayType( + getContext().getObjCIdType(), llvm::APInt(32, NumItems), nullptr, + ArraySizeModifier::Normal, 0); Address ItemsPtr = CreateMemTemp(ItemsTy, "items.ptr"); // Emit the collection pointer. In ARC, we do a retain. diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index bcd67b7205c7dd2..01786774aad6b41 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -2368,7 +2368,7 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF, if (DidIt.isValid()) { llvm::APInt ArraySize(/*unsigned int numBits=*/32, CopyprivateVars.size()); QualType CopyprivateArrayTy = C.getConstantArrayType( - C.VoidPtrTy, ArraySize, nullptr, ArrayType::Normal, + C.VoidPtrTy, ArraySize, nullptr, ArraySizeModifier::Normal, /*IndexTypeQuals=*/0); // Create a list of all private variables for copyprivate. Address CopyprivateList = @@ -3938,9 +3938,9 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, VK_PRValue); CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE, RValue::get(NumOfElements)); - KmpTaskAffinityInfoArrayTy = - C.getVariableArrayType(KmpTaskAffinityInfoTy, OVE, ArrayType::Normal, - /*IndexTypeQuals=*/0, SourceRange(Loc, Loc)); + KmpTaskAffinityInfoArrayTy = C.getVariableArrayType( + KmpTaskAffinityInfoTy, OVE, ArraySizeModifier::Normal, + /*IndexTypeQuals=*/0, SourceRange(Loc, Loc)); // Properly emit variable-sized array. auto *PD = ImplicitParamDecl::Create(C, KmpTaskAffinityInfoArrayTy, ImplicitParamDecl::Other); @@ -3952,7 +3952,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, KmpTaskAffinityInfoArrayTy = C.getConstantArrayType( KmpTaskAffinityInfoTy, llvm::APInt(C.getTypeSize(C.getSizeType()), NumAffinities), nullptr, - ArrayType::Normal, /*IndexTypeQuals=*/0); + ArraySizeModifier::Normal, /*IndexTypeQuals=*/0); AffinitiesArray = CGF.CreateMemTemp(KmpTaskAffinityInfoArrayTy, ".affs.arr.addr"); AffinitiesArray = CGF.Builder.CreateConstArrayGEP(AffinitiesArray, 0); @@ -4397,7 +4397,7 @@ std::pair<llvm::Value *, Address> CGOpenMPRuntime::emitDependClause( CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE, RValue::get(NumOfElements)); KmpDependInfoArrayTy = - C.getVariableArrayType(KmpDependInfoTy, OVE, ArrayType::Normal, + C.getVariableArrayType(KmpDependInfoTy, OVE, ArraySizeModifier::Normal, /*IndexTypeQuals=*/0, SourceRange(Loc, Loc)); // CGF.EmitVariablyModifiedType(KmpDependInfoArrayTy); // Properly emit variable-sized array. @@ -4410,7 +4410,7 @@ std::pair<llvm::Value *, Address> CGOpenMPRuntime::emitDependClause( } else { KmpDependInfoArrayTy = C.getConstantArrayType( KmpDependInfoTy, llvm::APInt(/*numBits=*/64, NumDependencies), nullptr, - ArrayType::Normal, /*IndexTypeQuals=*/0); + ArraySizeModifier::Normal, /*IndexTypeQuals=*/0); DependenciesArray = CGF.CreateMemTemp(KmpDependInfoArrayTy, ".dep.arr.addr"); DependenciesArray = CGF.Builder.CreateConstArrayGEP(DependenciesArray, 0); @@ -4490,7 +4490,7 @@ Address CGOpenMPRuntime::emitDepobjDependClause( } else { QualType KmpDependInfoArrayTy = C.getConstantArrayType( KmpDependInfoTy, llvm::APInt(/*numBits=*/64, NumDependencies + 1), - nullptr, ArrayType::Normal, /*IndexTypeQuals=*/0); + nullptr, ArraySizeModifier::Normal, /*IndexTypeQuals=*/0); CharUnits Sz = C.getTypeSizeInChars(KmpDependInfoArrayTy); Size = CGM.getSize(Sz.alignTo(Align)); NumDepsVal = llvm::ConstantInt::get(CGF.IntPtrTy, NumDependencies); @@ -5106,9 +5106,9 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc, ++Size; } llvm::APInt ArraySize(/*unsigned int numBits=*/32, Size); - QualType ReductionArrayTy = - C.getConstantArrayType(C.VoidPtrTy, ArraySize, nullptr, ArrayType::Normal, - /*IndexTypeQuals=*/0); + QualType ReductionArrayTy = C.getConstantArrayType( + C.VoidPtrTy, ArraySize, nullptr, ArraySizeModifier::Normal, + /*IndexTypeQuals=*/0); Address ReductionList = CGF.CreateMemTemp(ReductionArrayTy, ".omp.reduction.red_list"); const auto *IPriv = Privates.begin(); @@ -5577,8 +5577,9 @@ llvm::Value *CGOpenMPRuntime::emitTaskReductionInit( QualType RDType = C.getRecordType(RD); unsigned Size = Data.ReductionVars.size(); llvm::APInt ArraySize(/*numBits=*/64, Size); - QualType ArrayRDType = C.getConstantArrayType( - RDType, ArraySize, nullptr, ArrayType::Normal, /*IndexTypeQuals=*/0); + QualType ArrayRDType = + C.getConstantArrayType(RDType, ArraySize, nullptr, + ArraySizeModifier::Normal, /*IndexTypeQuals=*/0); // kmp_task_red_input_t .rd_input.[Size]; Address TaskRedInput = CGF.CreateMemTemp(ArrayRDType, ".rd_input."); ReductionCodeGen RCG(Data.ReductionVars, Data.ReductionOrigs, @@ -11164,8 +11165,8 @@ void CGOpenMPRuntime::emitDoacrossInit(CodeGenFunction &CGF, RD = cast<RecordDecl>(KmpDimTy->getAsTagDecl()); } llvm::APInt Size(/*numBits=*/32, NumIterations.size()); - QualType ArrayTy = - C.getConstantArrayType(KmpDimTy, Size, nullptr, ArrayType::Normal, 0); + QualType ArrayTy = C.getConstantArrayType(KmpDimTy, Size, nullptr, + ArraySizeModifier::Normal, 0); Address DimsAddr = CGF.CreateMemTemp(ArrayTy, "dims"); CGF.EmitNullInitialization(DimsAddr, ArrayTy); @@ -11217,7 +11218,7 @@ static void EmitDoacrossOrdered(CodeGenFunction &CGF, CodeGenModule &CGM, CGM.getContext().getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/1); llvm::APInt Size(/*numBits=*/32, C->getNumLoops()); QualType ArrayTy = CGM.getContext().getConstantArrayType( - Int64Ty, Size, nullptr, ArrayType::Normal, 0); + Int64Ty, Size, nullptr, ArraySizeModifier::Normal, 0); Address CntAddr = CGF.CreateMemTemp(ArrayTy, ".cnt.addr"); for (unsigned I = 0, E = C->getNumLoops(); I < E; ++I) { const Expr *CounterVal = C->getLoopData(I); diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index 9d00ebae702802a..bd9329b8e2d4113 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -174,8 +174,8 @@ static RecordDecl *buildRecordForGlobalizedVars( } } else { llvm::APInt ArraySize(32, BufSize); - Type = C.getConstantArrayType(Type, ArraySize, nullptr, ArrayType::Normal, - 0); + Type = C.getConstantArrayType(Type, ArraySize, nullptr, + ArraySizeModifier::Normal, 0); Field = FieldDecl::Create( C, GlobalizedRD, Loc, Loc, VD->getIdentifier(), Type, C.getTrivialTypeSourceInfo(Type, SourceLocation()), @@ -2934,9 +2934,9 @@ void CGOpenMPRuntimeGPU::emitReduction( ++Size; } llvm::APInt ArraySize(/*unsigned int numBits=*/32, Size); - QualType ReductionArrayTy = - C.getConstantArrayType(C.VoidPtrTy, ArraySize, nullptr, ArrayType::Normal, - /*IndexTypeQuals=*/0); + QualType ReductionArrayTy = C.getConstantArrayType( + C.VoidPtrTy, ArraySize, nullptr, ArraySizeModifier::Normal, + /*IndexTypeQuals=*/0); Address ReductionList = CGF.CreateMemTemp(ReductionArrayTy, ".omp.reduction.red_list"); auto IPriv = Privates.begin(); diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index a4e80a4a9e1fd75..3e2ed50a5750254 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -5062,7 +5062,7 @@ void CodeGenFunction::EmitOMPTargetTaskBasedDirective( getContext(), getContext().getTranslationUnitDecl(), /*NumParams=*/0); llvm::APInt ArrSize(/*numBits=*/32, InputInfo.NumberOfTargetItems); QualType BaseAndPointerAndMapperType = getContext().getConstantArrayType( - getContext().VoidPtrTy, ArrSize, nullptr, ArrayType::Normal, + getContext().VoidPtrTy, ArrSize, nullptr, ArraySizeModifier::Normal, /*IndexTypeQuals=*/0); BPVD = createImplicitFirstprivateForType( getContext(), Data, BaseAndPointerAndMapperType, CD, S.getBeginLoc()); @@ -5070,7 +5070,7 @@ void CodeGenFunction::EmitOMPTargetTaskBasedDirective( getContext(), Data, BaseAndPointerAndMapperType, CD, S.getBeginLoc()); QualType SizesType = getContext().getConstantArrayType( getContext().getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/1), - ArrSize, nullptr, ArrayType::Normal, + ArrSize, nullptr, ArraySizeModifier::Normal, /*IndexTypeQuals=*/0); SVD = createImplicitFirstprivateForType(getContext(), Data, SizesType, CD, S.getBeginLoc()); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index b1a6683a66bd052..fc135ce80d82f13 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -6094,12 +6094,10 @@ QualType CodeGenModule::getObjCFastEnumerationStateType() { D->startDefinition(); QualType FieldTypes[] = { - Context.UnsignedLongTy, - Context.getPointerType(Context.getObjCIdType()), - Context.getPointerType(Context.UnsignedLongTy), - Context.getConstantArrayType(Context.UnsignedLongTy, - llvm::APInt(32, 5), nullptr, ArrayType::Normal, 0) - }; + Context.UnsignedLongTy, Context.getPointerType(Context.getObjCIdType()), + Context.getPointerType(Context.UnsignedLongTy), + Context.getConstantArrayType(Context.UnsignedLongTy, llvm::APInt(32, 5), + nullptr, ArraySizeModifier::Normal, 0)}; for (size_t i = 0; i < 4; ++i) { FieldDecl *Field = FieldDecl::Create(Context, diff --git a/clang/lib/CodeGen/Targets/XCore.cpp b/clang/lib/CodeGen/Targets/XCore.cpp index 8be240c018d06c2..aeb48f851e16936 100644 --- a/clang/lib/CodeGen/Targets/XCore.cpp +++ b/clang/lib/CodeGen/Targets/XCore.cpp @@ -543,7 +543,7 @@ static bool appendArrayType(SmallStringEnc &Enc, QualType QT, const ArrayType *AT, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC, StringRef NoSizeEnc) { - if (AT->getSizeModifier() != ArrayType::Normal) + if (AT->getSizeModifier() != ArraySizeModifier::Normal) return false; Enc += "a("; if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT)) diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp index 5c5a9df65052715..06552d011a2d41d 100644 --- a/clang/lib/ExtractAPI/DeclarationFragments.cpp +++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp @@ -266,12 +266,12 @@ DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForType( After.append("[", DeclarationFragments::FragmentKind::Text); switch (AT->getSizeModifier()) { - case ArrayType::Normal: + case ArraySizeModifier::Normal: break; - case ArrayType::Static: + case ArraySizeModifier::Static: Fragments.append("static", DeclarationFragments::FragmentKind::Keyword); break; - case ArrayType::Star: + case ArraySizeModifier::Star: Fragments.append("*", DeclarationFragments::FragmentKind::Text); break; } diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index 94bd2befd0b2a81..4b961e036fcdda9 100644 --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -600,7 +600,7 @@ namespace { StringLiteral *getStringLiteral(StringRef Str) { QualType StrType = Context->getConstantArrayType( Context->CharTy, llvm::APInt(32, Str.size() + 1), nullptr, - ArrayType::Normal, 0); + ArraySizeModifier::Normal, 0); return StringLiteral::Create(*Context, Str, StringLiteral::Ordinary, /*Pascal=*/false, StrType, SourceLocation()); } diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp index 520fbe940aa3bb6..89ffb8908d37b73 100644 --- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -499,7 +499,7 @@ namespace { StringLiteral *getStringLiteral(StringRef Str) { QualType StrType = Context->getConstantArrayType( Context->CharTy, llvm::APInt(32, Str.size() + 1), nullptr, - ArrayType::Normal, 0); + ArraySizeModifier::Normal, 0); return StringLiteral::Create(*Context, Str, StringLiteral::Ordinary, /*Pascal=*/false, StrType, SourceLocation()); } diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp index 614f5d8d2cad520..0eee6fe6d820739 100644 --- a/clang/lib/Index/USRGeneration.cpp +++ b/clang/lib/Index/USRGeneration.cpp @@ -927,13 +927,13 @@ void USRGenerator::VisitType(QualType T) { if (const auto *const AT = dyn_cast<ArrayType>(T)) { Out << '{'; switch (AT->getSizeModifier()) { - case ArrayType::Static: + case ArraySizeModifier::Static: Out << 's'; break; - case ArrayType::Star: + case ArraySizeModifier::Star: Out << '*'; break; - case ArrayType::Normal: + case ArraySizeModifier::Normal: Out << 'n'; break; } diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index acb765559e6a8d4..8e78d2c11f92d61 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -1333,8 +1333,8 @@ void Sema::ActOnEndOfTranslationUnit() { // Set the length of the array to 1 (C99 6.9.2p5). Diag(VD->getLocation(), diag::warn_tentative_incomplete_array); llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true); - QualType T = Context.getConstantArrayType(ArrayT->getElementType(), One, - nullptr, ArrayType::Normal, 0); + QualType T = Context.getConstantArrayType( + ArrayT->getElementType(), One, nullptr, ArraySizeModifier::Normal, 0); VD->setType(T); } else if (RequireCompleteType(VD->getLocation(), VD->getType(), diag::err_tentative_def_incomplete_type)) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 44f698abdb9fe21..a022eed37971646 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -17286,7 +17286,7 @@ static void diagnoseArrayStarInParamType(Sema &S, QualType PType, if (!AT) return; - if (AT->getSizeModifier() != ArrayType::Star) { + if (AT->getSizeModifier() != ArraySizeModifier::Star) { diagnoseArrayStarInParamType(S, AT->getElementType(), Loc); return; } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c4979b51e68f5e2..d1550f1289068e9 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3389,7 +3389,7 @@ static bool EquivalentArrayTypes(QualType Old, QualType New, if (Ty->isIncompleteArrayType() || Ty->isPointerType()) return true; if (const auto *VAT = Ctx.getAsVariableArrayType(Ty)) - return VAT->getSizeModifier() == ArrayType::ArraySizeModifier::Star; + return VAT->getSizeModifier() == ArraySizeModifier::Star; return false; }; @@ -3401,8 +3401,8 @@ static bool EquivalentArrayTypes(QualType Old, QualType New, if (Old->isVariableArrayType() && New->isVariableArrayType()) { const auto *OldVAT = Ctx.getAsVariableArrayType(Old); const auto *NewVAT = Ctx.getAsVariableArrayType(New); - if ((OldVAT->getSizeModifier() == ArrayType::ArraySizeModifier::Star) ^ - (NewVAT->getSizeModifier() == ArrayType::ArraySizeModifier::Star)) + if ((OldVAT->getSizeModifier() == ArraySizeModifier::Star) ^ + (NewVAT->getSizeModifier() == ArraySizeModifier::Star)) return false; return true; } @@ -6595,7 +6595,7 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T, } QualType FoldedArrayType = Context.getConstantArrayType( - ElemTy, Res, VLATy->getSizeExpr(), ArrayType::Normal, 0); + ElemTy, Res, VLATy->getSizeExpr(), ArraySizeModifier::Normal, 0); return Qs.apply(Context, FoldedArrayType); } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index c2772bfb71c77e9..83519476f074249 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3741,14 +3741,14 @@ ExprResult Sema::BuildPredefinedExpr(SourceLocation Loc, ConvertUTF8ToWideString(Context.getTypeSizeInChars(ResTy).getQuantity(), Str, RawChars); ResTy = Context.getConstantArrayType(ResTy, LengthI, nullptr, - ArrayType::Normal, + ArraySizeModifier::Normal, /*IndexTypeQuals*/ 0); SL = StringLiteral::Create(Context, RawChars, StringLiteral::Wide, /*Pascal*/ false, ResTy, Loc); } else { ResTy = Context.adjustStringLiteralBaseType(Context.CharTy.withConst()); ResTy = Context.getConstantArrayType(ResTy, LengthI, nullptr, - ArrayType::Normal, + ArraySizeModifier::Normal, /*IndexTypeQuals*/ 0); SL = StringLiteral::Create(Context, Str, StringLiteral::Ordinary, /*Pascal*/ false, ResTy, Loc); @@ -4003,7 +4003,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { unsigned Length = Literal.getUDSuffixOffset(); QualType StrTy = Context.getConstantArrayType( Context.adjustStringLiteralBaseType(Context.CharTy.withConst()), - llvm::APInt(32, Length + 1), nullptr, ArrayType::Normal, 0); + llvm::APInt(32, Length + 1), nullptr, ArraySizeModifier::Normal, 0); Expr *Lit = StringLiteral::Create(Context, StringRef(TokSpelling.data(), Length), StringLiteral::Ordinary, @@ -6784,7 +6784,7 @@ Sema::CheckStaticArrayArgument(SourceLocation CallLoc, QualType OrigTy = Param->getOriginalType(); const ArrayType *AT = Context.getAsArrayType(OrigTy); - if (!AT || AT->getSizeModifier() != ArrayType::Static) + if (!AT || AT->getSizeModifier() != ArraySizeModifier::Static) return; if (ArgExpr->isNullPointerConstant(Context, diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 6344c9102330a00..e97740705621829 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -2402,10 +2402,10 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, AllocType, llvm::APInt(Context.getTypeSize(Context.getSizeType()), *KnownArraySize), - *ArraySize, ArrayType::Normal, 0); + *ArraySize, ArraySizeModifier::Normal, 0); else if (ArraySize) - InitType = - Context.getIncompleteArrayType(AllocType, ArrayType::Normal, 0); + InitType = Context.getIncompleteArrayType(AllocType, + ArraySizeModifier::Normal, 0); else InitType = AllocType; @@ -6915,9 +6915,9 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc, case Array: if (auto *CAT = cast_or_null<ConstantArrayType>(ClassOrBound)) return Ctx.getConstantArrayType(T, CAT->getSize(), nullptr, - ArrayType::Normal, 0); + ArraySizeModifier::Normal, 0); else - return Ctx.getIncompleteArrayType(T, ArrayType::Normal, 0); + return Ctx.getIncompleteArrayType(T, ArraySizeModifier::Normal, 0); } llvm_unreachable("unknown step kind"); } diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 8f945bc764befa9..ec796def96ad3d8 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -200,9 +200,8 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT, // being initialized to a string literal. llvm::APInt ConstVal(32, StrLength); // Return a new array type (C99 6.7.8p22). - DeclT = S.Context.getConstantArrayType(IAT->getElementType(), - ConstVal, nullptr, - ArrayType::Normal, 0); + DeclT = S.Context.getConstantArrayType( + IAT->getElementType(), ConstVal, nullptr, ArraySizeModifier::Normal, 0); updateStringLiteralType(Str, DeclT); return; } @@ -2053,7 +2052,7 @@ void InitListChecker::CheckArrayType(const InitializedEntity &Entity, } DeclType = SemaRef.Context.getConstantArrayType( - elementType, maxElements, nullptr, ArrayType::Normal, 0); + elementType, maxElements, nullptr, ArraySizeModifier::Normal, 0); } if (!hadError) { // If there are any members of the array that get value-initialized, check @@ -4057,7 +4056,7 @@ static bool TryInitializerListConstruction(Sema &S, E.withConst(), llvm::APInt(S.Context.getTypeSize(S.Context.getSizeType()), List->getNumInits()), - nullptr, clang::ArrayType::Normal, 0); + nullptr, clang::ArraySizeModifier::Normal, 0); InitializedEntity HiddenArray = InitializedEntity::InitializeTemporary(ArrayType); InitializationKind Kind = InitializationKind::CreateDirectList( @@ -5513,7 +5512,7 @@ static void TryOrBuildParenListInitialization( if (ResultType.isNull()) { ResultType = S.Context.getConstantArrayType( AT->getElementType(), llvm::APInt(/*numBits=*/32, ArrayLength), - /*SizeExpr=*/nullptr, ArrayType::Normal, 0); + /*SizeExpr=*/nullptr, ArraySizeModifier::Normal, 0); } } else if (auto *RT = Entity.getType()->getAs<RecordType>()) { bool IsUnion = RT->isUnionType(); @@ -9237,10 +9236,8 @@ ExprResult InitializationSequence::Perform(Sema &S, if (const ConstantArrayType *ConstantSource = S.Context.getAsConstantArrayType(CurInit.get()->getType())) { *ResultType = S.Context.getConstantArrayType( - IncompleteDest->getElementType(), - ConstantSource->getSize(), - ConstantSource->getSizeExpr(), - ArrayType::Normal, 0); + IncompleteDest->getElementType(), ConstantSource->getSize(), + ConstantSource->getSizeExpr(), ArraySizeModifier::Normal, 0); } } } @@ -9508,7 +9505,7 @@ static void diagnoseListInit(Sema &S, const InitializedEntity &Entity, E.withConst(), llvm::APInt(S.Context.getTypeSize(S.Context.getSizeType()), InitList->getNumInits()), - nullptr, clang::ArrayType::Normal, 0); + nullptr, clang::ArraySizeModifier::Normal, 0); InitializedEntity HiddenArray = InitializedEntity::InitializeTemporary(ArrayType); return diagnoseListInit(S, HiddenArray, InitList); diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 75f9e152dca9297..a471a20aa720087 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -19656,7 +19656,7 @@ static bool actOnOMPReductionKindClause( if (ConstantLengthOASE && !SingleElement) { for (llvm::APSInt &Size : ArraySizes) PrivateTy = Context.getConstantArrayType(PrivateTy, Size, nullptr, - ArrayType::Normal, + ArraySizeModifier::Normal, /*IndexTypeQuals=*/0); } } @@ -19683,7 +19683,7 @@ static bool actOnOMPReductionKindClause( Type, new (Context) OpaqueValueExpr(ELoc, Context.getSizeType(), VK_PRValue), - ArrayType::Normal, /*IndexTypeQuals=*/0, SourceRange()); + ArraySizeModifier::Normal, /*IndexTypeQuals=*/0, SourceRange()); } else if (!ASE && !OASE && Context.getAsArrayType(D->getType().getNonReferenceType())) { PrivateTy = D->getType().getNonReferenceType(); @@ -19921,9 +19921,9 @@ static bool actOnOMPReductionKindClause( // Build temp array for prefix sum. auto *Dim = new (S.Context) OpaqueValueExpr(ELoc, S.Context.getSizeType(), VK_PRValue); - QualType ArrayTy = - S.Context.getVariableArrayType(PrivateTy, Dim, ArrayType::Normal, - /*IndexTypeQuals=*/0, {ELoc, ELoc}); + QualType ArrayTy = S.Context.getVariableArrayType( + PrivateTy, Dim, ArraySizeModifier::Normal, + /*IndexTypeQuals=*/0, {ELoc, ELoc}); VarDecl *TempArrayVD = buildVarDecl(S, ELoc, ArrayTy, D->getName(), D->hasAttrs() ? &D->getAttrs() : nullptr); diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index db386fef0661c05..d3d2dfed2ce0cc2 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5386,7 +5386,7 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType, } llvm::APInt Size(S.Context.getTypeSize(S.Context.getSizeType()), e); ContTy = S.Context.getConstantArrayType(InitTy, Size, nullptr, - ArrayType::Normal, 0); + ArraySizeModifier::Normal, 0); } } diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index dea77fae4cadb59..37491925d750a20 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2475,7 +2475,7 @@ bool Sema::checkArrayElementAlignment(QualType EltTy, SourceLocation Loc) { /// /// \returns A suitable array type, if there are no errors. Otherwise, /// returns a NULL type. -QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, +QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity) { @@ -2635,7 +2635,7 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, llvm::APSInt ConstVal(Context.getTypeSize(Context.getSizeType())); if (!ArraySize) { - if (ASM == ArrayType::Star) { + if (ASM == ArraySizeModifier::Star) { Diag(Loc, VLADiag); if (VLAIsError) return QualType(); @@ -2722,10 +2722,10 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, // If this is not C99, diagnose array size modifiers on non-VLAs. if (!getLangOpts().C99 && !T->isVariableArrayType() && - (ASM != ArrayType::Normal || Quals != 0)) { + (ASM != ArraySizeModifier::Normal || Quals != 0)) { Diag(Loc, getLangOpts().CPlusPlus ? diag::err_c99_array_usage_cxx : diag::ext_c99_array_usage) - << ASM; + << llvm::to_underlying(ASM); } // OpenCL v2.0 s6.12.5 - Arrays of blocks are not supported. @@ -5156,7 +5156,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, } DeclaratorChunk::ArrayTypeInfo &ATI = DeclType.Arr; Expr *ArraySize = static_cast<Expr*>(ATI.NumElts); - ArrayType::ArraySizeModifier ASM; + ArraySizeModifier ASM; // Microsoft property fields can have multiple sizeless array chunks // (i.e. int x[][][]). Skip all of these except one to avoid creating @@ -5171,31 +5171,32 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, } if (ATI.isStar) - ASM = ArrayType::Star; + ASM = ArraySizeModifier::Star; else if (ATI.hasStatic) - ASM = ArrayType::Static; + ASM = ArraySizeModifier::Static; else - ASM = ArrayType::Normal; - if (ASM == ArrayType::Star && !D.isPrototypeContext()) { + ASM = ArraySizeModifier::Normal; + if (ASM == ArraySizeModifier::Star && !D.isPrototypeContext()) { // FIXME: This check isn't quite right: it allows star in prototypes // for function definitions, and disallows some edge cases detailed // in http://gcc.gnu.org/ml/gcc-patches/2009-02/msg00133.html S.Diag(DeclType.Loc, diag::err_array_star_outside_prototype); - ASM = ArrayType::Normal; + ASM = ArraySizeModifier::Normal; D.setInvalidType(true); } // C99 6.7.5.2p1: The optional type qualifiers and the keyword static // shall appear only in a declaration of a function parameter with an // array type, ... - if (ASM == ArrayType::Static || ATI.TypeQuals) { + if (ASM == ArraySizeModifier::Static || ATI.TypeQuals) { if (!(D.isPrototypeContext() || D.getContext() == DeclaratorContext::KNRTypeList)) { - S.Diag(DeclType.Loc, diag::err_array_static_outside_prototype) << - (ASM == ArrayType::Static ? "'static'" : "type qualifier"); + S.Diag(DeclType.Loc, diag::err_array_static_outside_prototype) + << (ASM == ArraySizeModifier::Static ? "'static'" + : "type qualifier"); // Remove the 'static' and the type qualifiers. - if (ASM == ArrayType::Static) - ASM = ArrayType::Normal; + if (ASM == ArraySizeModifier::Static) + ASM = ArraySizeModifier::Normal; ATI.TypeQuals = 0; D.setInvalidType(true); } @@ -5203,10 +5204,11 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // C99 6.7.5.2p1: ... and then only in the outermost array type // derivation. if (hasOuterPointerLikeChunk(D, chunkIndex)) { - S.Diag(DeclType.Loc, diag::err_array_static_not_outermost) << - (ASM == ArrayType::Static ? "'static'" : "type qualifier"); - if (ASM == ArrayType::Static) - ASM = ArrayType::Normal; + S.Diag(DeclType.Loc, diag::err_array_static_not_outermost) + << (ASM == ArraySizeModifier::Static ? "'static'" + : "type qualifier"); + if (ASM == ArraySizeModifier::Static) + ASM = ArraySizeModifier::Normal; ATI.TypeQuals = 0; D.setInvalidType(true); } @@ -5216,8 +5218,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // necessary if they're marked 'static'. if (complainAboutMissingNullability == CAMN_Yes && !hasNullabilityAttr(DeclType.getAttrs()) && - ASM != ArrayType::Static && - D.isPrototypeContext() && + ASM != ArraySizeModifier::Static && D.isPrototypeContext() && !hasOuterPointerLikeChunk(D, chunkIndex)) { checkNullabilityConsistency(S, SimplePointerKind::Array, DeclType.Loc); } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 17ebfe14cecad34..e990cc2e60c8da4 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -878,12 +878,9 @@ class TreeTransform { /// By default, performs semantic analysis when building the array type. /// Subclasses may override this routine to provide diff erent behavior. /// Also by default, all of the other Rebuild*Array - QualType RebuildArrayType(QualType ElementType, - ArrayType::ArraySizeModifier SizeMod, - const llvm::APInt *Size, - Expr *SizeExpr, - unsigned IndexTypeQuals, - SourceRange BracketsRange); + QualType RebuildArrayType(QualType ElementType, ArraySizeModifier SizeMod, + const llvm::APInt *Size, Expr *SizeExpr, + unsigned IndexTypeQuals, SourceRange BracketsRange); /// Build a new constant array type given the element type, size /// modifier, (known) size of the array, and index type qualifiers. @@ -891,9 +888,8 @@ class TreeTransform { /// By default, performs semantic analysis when building the array type. /// Subclasses may override this routine to provide diff erent behavior. QualType RebuildConstantArrayType(QualType ElementType, - ArrayType::ArraySizeModifier SizeMod, - const llvm::APInt &Size, - Expr *SizeExpr, + ArraySizeModifier SizeMod, + const llvm::APInt &Size, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange); @@ -903,7 +899,7 @@ class TreeTransform { /// By default, performs semantic analysis when building the array type. /// Subclasses may override this routine to provide diff erent behavior. QualType RebuildIncompleteArrayType(QualType ElementType, - ArrayType::ArraySizeModifier SizeMod, + ArraySizeModifier SizeMod, unsigned IndexTypeQuals, SourceRange BracketsRange); @@ -913,8 +909,7 @@ class TreeTransform { /// By default, performs semantic analysis when building the array type. /// Subclasses may override this routine to provide diff erent behavior. QualType RebuildVariableArrayType(QualType ElementType, - ArrayType::ArraySizeModifier SizeMod, - Expr *SizeExpr, + ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange); @@ -924,7 +919,7 @@ class TreeTransform { /// By default, performs semantic analysis when building the array type. /// Subclasses may override this routine to provide diff erent behavior. QualType RebuildDependentSizedArrayType(QualType ElementType, - ArrayType::ArraySizeModifier SizeMod, + ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange); @@ -14918,14 +14913,10 @@ QualType TreeTransform<Derived>::RebuildObjCObjectPointerType( return SemaRef.Context.getObjCObjectPointerType(PointeeType); } -template<typename Derived> -QualType -TreeTransform<Derived>::RebuildArrayType(QualType ElementType, - ArrayType::ArraySizeModifier SizeMod, - const llvm::APInt *Size, - Expr *SizeExpr, - unsigned IndexTypeQuals, - SourceRange BracketsRange) { +template <typename Derived> +QualType TreeTransform<Derived>::RebuildArrayType( + QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size, + Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) { if (SizeExpr || !Size) return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr, IndexTypeQuals, BracketsRange, @@ -14953,47 +14944,35 @@ TreeTransform<Derived>::RebuildArrayType(QualType ElementType, getDerived().getBaseEntity()); } -template<typename Derived> -QualType -TreeTransform<Derived>::RebuildConstantArrayType(QualType ElementType, - ArrayType::ArraySizeModifier SizeMod, - const llvm::APInt &Size, - Expr *SizeExpr, - unsigned IndexTypeQuals, - SourceRange BracketsRange) { +template <typename Derived> +QualType TreeTransform<Derived>::RebuildConstantArrayType( + QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size, + Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) { return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr, IndexTypeQuals, BracketsRange); } -template<typename Derived> -QualType -TreeTransform<Derived>::RebuildIncompleteArrayType(QualType ElementType, - ArrayType::ArraySizeModifier SizeMod, - unsigned IndexTypeQuals, - SourceRange BracketsRange) { +template <typename Derived> +QualType TreeTransform<Derived>::RebuildIncompleteArrayType( + QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals, + SourceRange BracketsRange) { return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr, IndexTypeQuals, BracketsRange); } -template<typename Derived> -QualType -TreeTransform<Derived>::RebuildVariableArrayType(QualType ElementType, - ArrayType::ArraySizeModifier SizeMod, - Expr *SizeExpr, - unsigned IndexTypeQuals, - SourceRange BracketsRange) { +template <typename Derived> +QualType TreeTransform<Derived>::RebuildVariableArrayType( + QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, + unsigned IndexTypeQuals, SourceRange BracketsRange) { return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, SizeExpr, IndexTypeQuals, BracketsRange); } -template<typename Derived> -QualType -TreeTransform<Derived>::RebuildDependentSizedArrayType(QualType ElementType, - ArrayType::ArraySizeModifier SizeMod, - Expr *SizeExpr, - unsigned IndexTypeQuals, - SourceRange BracketsRange) { +template <typename Derived> +QualType TreeTransform<Derived>::RebuildDependentSizedArrayType( + QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, + unsigned IndexTypeQuals, SourceRange BracketsRange) { return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, SizeExpr, IndexTypeQuals, BracketsRange); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits