[clang] [libcxxabi] [llvm] [clang] Generalize static within array brackets (PR #244642)
Alejandro Colomar via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 23 05:02:13 PST 2026
https://github.com/alejandro-colomar updated https://github.com/llvm/llvm-project/pull/244642
>From 07a3015ffb153cd1f66293582d7932606bb174ae Mon Sep 17 00:00:00 2001
From: Alejandro Colomar <alx at kernel.org>
Date: Fri, 20 Nov 2026 15:23:35 +0100
Subject: [PATCH 1/2] [clang] Generalize static within array brackets
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n4018.htm>
Cc: Martin Uecker <uecker at tugraz.at>
Signed-off-by: Alejandro Colomar <alx at kernel.org>
---
clang/include/clang/Basic/DiagnosticGroups.td | 1 +
clang/include/clang/Basic/DiagnosticParseKinds.td | 7 +++----
clang/lib/Parse/ParseDecl.cpp | 6 ++----
clang/test/Parser/declarators.c | 4 +++-
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 9f43b8570ea035..b8731b7e818a61 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -31,6 +31,7 @@ def GNUAutoType : DiagGroup<"gnu-auto-type">;
def ArrayBounds : DiagGroup<"array-bounds">;
def ArrayBoundsPointerArithmetic : DiagGroup<"array-bounds-pointer-arithmetic">;
def ArrayParameter : DiagGroup<"array-parameter">;
+def UnspecifiedSizeWithStatic : DiagGroup<"unspecified-size-with-static">;
def AutoDisableVptrSanitizer : DiagGroup<"auto-disable-vptr-sanitizer">;
def Availability : DiagGroup<"availability">;
def Section : DiagGroup<"section">;
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 2be6ff8344cd6d..d759556c6a45b7 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -465,10 +465,9 @@ def err_unexpected_scope_on_base_decltype : Error<
def err_expected_class_name : Error<"expected class name">;
def err_expected_class_name_not_template :
Error<"'typename' is redundant; base classes are implicitly types">;
-def err_unspecified_vla_size_with_static : Error<
- "'static' may not be used with an unspecified variable length array size">;
-def err_unspecified_size_with_static : Error<
- "'static' may not be used without an array size">;
+def ext_unspecified_size_with_static : Extension<
+ "ISO C requires a length expression with 'static'">,
+ InGroup<UnspecifiedSizeWithStatic>;
def err_expected_parentheses_around_typename : Error<
"expected parentheses around type name in %0 expression">;
def err_expansion_stmt_requires_range : Error<
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index f20383f8374cc6..380f6d15f99f77 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -8049,8 +8049,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
ConsumeToken(); // Eat the '*'.
if (StaticLoc.isValid()) {
- Diag(StaticLoc, diag::err_unspecified_vla_size_with_static);
- StaticLoc = SourceLocation(); // Drop the static.
+ Diag(StaticLoc, diag::ext_unspecified_size_with_static);
}
isStar = true;
} else if (Tok.isNot(tok::r_square)) {
@@ -8070,8 +8069,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
}
} else {
if (StaticLoc.isValid()) {
- Diag(StaticLoc, diag::err_unspecified_size_with_static);
- StaticLoc = SourceLocation(); // Drop the static.
+ Diag(StaticLoc, diag::ext_unspecified_size_with_static);
}
}
diff --git a/clang/test/Parser/declarators.c b/clang/test/Parser/declarators.c
index 0a3580596646d5..571a7f21f3fd1c 100644
--- a/clang/test/Parser/declarators.c
+++ b/clang/test/Parser/declarators.c
@@ -7,7 +7,9 @@ void f1(int [*]);
void f2(int [const *]);
void f3(int [volatile const*]);
int f4(*XX)(void); /* expected-error {{cannot return}} expected-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}} */
-int f5(int [static]); /* expected-error {{'static' may not be used without an array size}} */
+int f5(int [static]); /* expected-warning {{ISO C requires a length expression with 'static'}} */
+int f5(int a[static]) {} /* expected-warning {{ISO C requires a length expression with 'static'}} */
+void f6(int [static *]); /* expected-warning {{ISO C requires a length expression with 'static'}} */
char ((((*X))));
>From b670da4bde7d983714fbf4c05989f181f38012bd Mon Sep 17 00:00:00 2001
From: Alejandro Colomar <alx at kernel.org>
Date: Mon, 23 Nov 2026 13:42:04 +0100
Subject: [PATCH 2/2] wip
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Build error:
[ 77%] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
In file included from /home/alx/src/llvm/llvm/main/clang/include/clang/AST/AbstractTypeReader.h:27,
from /home/alx/src/llvm/llvm/main/clang/lib/Serialization/ASTReader.cpp:21:
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc: In instantiation of ‘clang::QualType clang::serialization::AbstractTypeReader<T>::readConstantArrayType() [with PropertyReader = clang::ASTRecordReader]’:
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc:24:14: required from ‘clang::QualType clang::serialization::AbstractTypeReader<T>::read(clang::Type::TypeClass) [with PropertyReader = clang::ASTRecordReader]’
24 | return readConstantArrayType();
| ^~~~~~~~~~~~~~~~~~~~~
/home/alx/src/llvm/llvm/main/clang/lib/Serialization/ASTReader.cpp:7545:25: required from here
7545 | return TypeReader.read(*maybeClass);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc:164:49: error: ‘class clang::ASTRecordReader’ has no member named ‘readArraySizeStar’; did you mean ‘readArraySizeModifier’?
164 | ArraySizeStar sizeStar = R.find("sizeStar").readArraySizeStar();
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
| readArraySizeModifier
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc: In instantiation of ‘clang::QualType clang::serialization::AbstractTypeReader<T>::readArrayParameterType() [with PropertyReader = clang::ASTRecordReader]’:
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc:26:14: required from ‘clang::QualType clang::serialization::AbstractTypeReader<T>::read(clang::Type::TypeClass) [with PropertyReader = clang::ASTRecordReader]’
26 | return readArrayParameterType();
| ^~~~~~~~~~~~~~~~~~~~~~
/home/alx/src/llvm/llvm/main/clang/lib/Serialization/ASTReader.cpp:7545:25: required from here
7545 | return TypeReader.read(*maybeClass);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc:179:49: error: ‘class clang::ASTRecordReader’ has no member named ‘readArraySizeStar’; did you mean ‘readArraySizeModifier’?
179 | ArraySizeStar sizeStar = R.find("sizeStar").readArraySizeStar();
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
| readArraySizeModifier
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc: In instantiation of ‘clang::QualType clang::serialization::AbstractTypeReader<T>::readDependentSizedArrayType() [with PropertyReader = clang::ASTRecordReader]’:
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc:28:14: required from ‘clang::QualType clang::serialization::AbstractTypeReader<T>::read(clang::Type::TypeClass) [with PropertyReader = clang::ASTRecordReader]’
28 | return readDependentSizedArrayType();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/alx/src/llvm/llvm/main/clang/lib/Serialization/ASTReader.cpp:7545:25: required from here
7545 | return TypeReader.read(*maybeClass);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc:192:49: error: ‘class clang::ASTRecordReader’ has no member named ‘readArraySizeStar’; did you mean ‘readArraySizeModifier’?
192 | ArraySizeStar sizeStar = R.find("sizeStar").readArraySizeStar();
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
| readArraySizeModifier
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc: In instantiation of ‘clang::QualType clang::serialization::AbstractTypeReader<T>::readIncompleteArrayType() [with PropertyReader = clang::ASTRecordReader]’:
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc:30:14: required from ‘clang::QualType clang::serialization::AbstractTypeReader<T>::read(clang::Type::TypeClass) [with PropertyReader = clang::ASTRecordReader]’
30 | return readIncompleteArrayType();
| ^~~~~~~~~~~~~~~~~~~~~~~
/home/alx/src/llvm/llvm/main/clang/lib/Serialization/ASTReader.cpp:7545:25: required from here
7545 | return TypeReader.read(*maybeClass);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc:205:49: error: ‘class clang::ASTRecordReader’ has no member named ‘readArraySizeStar’; did you mean ‘readArraySizeModifier’?
205 | ArraySizeStar sizeStar = R.find("sizeStar").readArraySizeStar();
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
| readArraySizeModifier
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc: In instantiation of ‘clang::QualType clang::serialization::AbstractTypeReader<T>::readVariableArrayType() [with PropertyReader = clang::ASTRecordReader]’:
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc:32:14: required from ‘clang::QualType clang::serialization::AbstractTypeReader<T>::read(clang::Type::TypeClass) [with PropertyReader = clang::ASTRecordReader]’
32 | return readVariableArrayType();
| ^~~~~~~~~~~~~~~~~~~~~
/home/alx/src/llvm/llvm/main/clang/lib/Serialization/ASTReader.cpp:7545:25: required from here
7545 | return TypeReader.read(*maybeClass);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/home/alx/src/llvm/llvm/main/build/tools/clang/include/clang/AST/AbstractTypeReader.inc:218:49: error: ‘class clang::ASTRecordReader’ has no member named ‘readArraySizeStar’; did you mean ‘readArraySizeModifier’?
218 | ArraySizeStar sizeStar = R.find("sizeStar").readArraySizeStar();
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
| readArraySizeModifier
make[2]: *** [tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/build.make:93: tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o] Error 1
make[2]: Target 'tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/build' not remade because of errors.
make[1]: *** [CMakeFiles/Makefile2:209592: tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/all] Error 2
---
clang/include/clang/AST/ASTContext.h | 6 +-
clang/include/clang/AST/TypeBase.h | 57 ++++++-----
clang/include/clang/Sema/Sema.h | 4 +-
clang/lib/AST/ASTContext.cpp | 94 ++++++++++++-------
clang/lib/AST/ASTDiagnostic.cpp | 7 +-
clang/lib/AST/ASTImporter.cpp | 7 +-
clang/lib/AST/ByteCode/Compiler.cpp | 3 +-
clang/lib/AST/ByteCode/Descriptor.cpp | 2 +-
clang/lib/AST/ByteCode/Interp.cpp | 2 +-
clang/lib/AST/ByteCode/Interp.h | 3 +-
clang/lib/AST/ByteCode/InterpBuiltin.cpp | 3 +-
clang/lib/AST/ExprConstant.cpp | 9 +-
clang/lib/AST/JSONNodeDumper.cpp | 13 +--
clang/lib/AST/MicrosoftMangle.cpp | 2 +-
clang/lib/AST/TextNodeDumper.cpp | 11 +--
clang/lib/AST/Type.cpp | 25 +++--
clang/lib/AST/TypePrinter.cpp | 2 +-
clang/lib/CodeGen/CGAtomic.cpp | 1 +
clang/lib/CodeGen/CGBuiltin.cpp | 2 +-
clang/lib/CodeGen/CGDebugInfo.cpp | 6 +-
clang/lib/CodeGen/CGObjC.cpp | 4 +-
clang/lib/CodeGen/CGOpenMPRuntime.cpp | 25 +++--
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp | 3 +-
clang/lib/CodeGen/CGStmtOpenMP.cpp | 4 +-
clang/lib/CodeGen/CodeGenModule.cpp | 3 +-
clang/lib/ExtractAPI/DeclarationFragments.cpp | 13 +--
clang/lib/Parse/ParseInit.cpp | 3 +-
clang/lib/Sema/Sema.cpp | 3 +-
clang/lib/Sema/SemaChecking.cpp | 2 +-
clang/lib/Sema/SemaDecl.cpp | 8 +-
clang/lib/Sema/SemaExpr.cpp | 5 +-
clang/lib/Sema/SemaExprCXX.cpp | 11 ++-
clang/lib/Sema/SemaExprObjC.cpp | 3 +-
clang/lib/Sema/SemaHLSL.cpp | 4 +-
clang/lib/Sema/SemaInit.cpp | 20 ++--
clang/lib/Sema/SemaOpenMP.cpp | 6 +-
clang/lib/Sema/SemaOverload.cpp | 3 +-
clang/lib/Sema/SemaSYCL.cpp | 3 +-
clang/lib/Sema/SemaType.cpp | 37 +++++---
clang/lib/Sema/TreeTransform.h | 49 ++++++----
.../UnifiedSymbolResolution/USRGeneration.cpp | 5 +-
libcxxabi/test/DemangleTestCases.inc | 2 +-
.../Testing/Demangle/DemangleTestCases.inc | 2 +-
43 files changed, 288 insertions(+), 189 deletions(-)
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 9ad16898b32563..d8882a4336832c 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1819,7 +1819,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,
- ArraySizeModifier ASM,
+ ArraySizeModifier ASM, ArraySizeStar Star,
unsigned IndexTypeQuals) const;
/// Return a non-unique reference to the type for a dependently-sized
@@ -1828,18 +1828,20 @@ 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,
- ArraySizeModifier ASM,
+ ArraySizeModifier ASM, ArraySizeStar Star,
unsigned IndexTypeQuals) const;
/// Return a unique reference to the type for an incomplete array of
/// the specified element type.
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM,
+ ArraySizeStar Star,
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, ArraySizeModifier ASM,
+ ArraySizeStar Star,
unsigned IndexTypeQuals) const;
/// Return a type for a constant array for a string literal of the
diff --git a/clang/include/clang/AST/TypeBase.h b/clang/include/clang/AST/TypeBase.h
index dc376530f1506a..32e40658abc2e4 100644
--- a/clang/include/clang/AST/TypeBase.h
+++ b/clang/include/clang/AST/TypeBase.h
@@ -1847,6 +1847,7 @@ enum class AutoTypeKeyword {
};
enum class ArraySizeModifier;
+enum class ArraySizeStar;
enum class ElaboratedTypeKeyword;
enum class VectorKind;
@@ -1950,9 +1951,14 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
/// Storage class qualifiers from declarations like
/// 'int X[static restrict 4]'. For function parameters only.
LLVM_PREFERRED_TYPE(ArraySizeModifier)
- unsigned SizeModifier : 3;
+ unsigned SizeModifier : 1;
+
+ /// Star from declarations like 'int X[*]'.
+ /// For function parameters only.
+ LLVM_PREFERRED_TYPE(ArraySizeStar)
+ unsigned SizeStar : 1;
};
- enum { NumArrayTypeBits = NumTypeBits + 6 };
+ enum { NumArrayTypeBits = NumTypeBits + 5 };
class ConstantArrayTypeBitfields {
friend class ConstantArrayType;
@@ -3811,10 +3817,13 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
};
/// 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[*]).
+/// or an array with a static size (e.g. int X[static 4]).
/// 'static' is only allowed on function parameters.
-enum class ArraySizeModifier { Normal, Static, Star };
+enum class ArraySizeModifier { Normal, Static };
+
+/// Capture whether this is a normal array (e.g. int X[4])
+/// or an array with a star size (e.g. int X[*]).
+enum class ArraySizeStar { Normal, Star };
/// Represents an array type, per C99 6.7.5.2 - Array Declarators.
class ArrayType : public Type, public llvm::FoldingSetNode {
@@ -3826,7 +3835,7 @@ class ArrayType : public Type, public llvm::FoldingSetNode {
friend class ASTContext; // ASTContext creates these.
ArrayType(TypeClass tc, QualType et, QualType can, ArraySizeModifier sm,
- unsigned tq, const Expr *sz = nullptr);
+ ArraySizeStar st, unsigned tq, const Expr *sz = nullptr);
public:
QualType getElementType() const { return ElementType; }
@@ -3835,6 +3844,10 @@ class ArrayType : public Type, public llvm::FoldingSetNode {
return ArraySizeModifier(ArrayTypeBits.SizeModifier);
}
+ ArraySizeStar getSizeStar() const {
+ return ArraySizeStar(ArrayTypeBits.SizeStar);
+ }
+
Qualifiers getIndexTypeQualifiers() const {
return Qualifiers::fromCVRMask(getIndexTypeCVRQualifiers());
}
@@ -3871,8 +3884,8 @@ class ConstantArrayType : public ArrayType {
};
ConstantArrayType(QualType Et, QualType Can, uint64_t Width, uint64_t Sz,
- ArraySizeModifier SM, unsigned TQ)
- : ArrayType(ConstantArray, Et, Can, SM, TQ, nullptr), Size(Sz) {
+ ArraySizeModifier SM, ArraySizeStar ST, unsigned TQ)
+ : ArrayType(ConstantArray, Et, Can, SM, ST, TQ, nullptr), Size(Sz) {
ConstantArrayTypeBits.HasExternalSize = false;
ConstantArrayTypeBits.SizeWidth = Width / 8;
// The in-structure size stores the size in bytes rather than bits so we
@@ -3881,8 +3894,8 @@ class ConstantArrayType : public ArrayType {
}
ConstantArrayType(QualType Et, QualType Can, ExternalSize *SzPtr,
- ArraySizeModifier SM, unsigned TQ)
- : ArrayType(ConstantArray, Et, Can, SM, TQ, SzPtr->SizeExpr),
+ ArraySizeModifier SM, ArraySizeStar ST, unsigned TQ)
+ : ArrayType(ConstantArray, Et, Can, SM, ST, TQ, SzPtr->SizeExpr),
SizePtr(SzPtr) {
ConstantArrayTypeBits.HasExternalSize = true;
ConstantArrayTypeBits.SizeWidth = 0;
@@ -3894,11 +3907,12 @@ class ConstantArrayType : public ArrayType {
static ConstantArrayType *Create(const ASTContext &Ctx, QualType ET,
QualType Can, const llvm::APInt &Sz,
const Expr *SzExpr, ArraySizeModifier SzMod,
- unsigned Qual);
+ ArraySizeStar St, unsigned Qual);
protected:
ConstantArrayType(TypeClass Tc, const ConstantArrayType *ATy, QualType Can)
: ArrayType(Tc, ATy->getElementType(), Can, ATy->getSizeModifier(),
+ ATy->getSizeStar(),
ATy->getIndexTypeQualifiers().getAsOpaqueValue(), nullptr) {
ConstantArrayTypeBits.HasExternalSize =
ATy->ConstantArrayTypeBits.HasExternalSize;
@@ -4008,8 +4022,8 @@ class IncompleteArrayType : public ArrayType {
friend class ASTContext; // ASTContext creates these.
IncompleteArrayType(QualType et, QualType can,
- ArraySizeModifier sm, unsigned tq)
- : ArrayType(IncompleteArray, et, can, sm, tq) {}
+ ArraySizeModifier sm, ArraySizeStar st, unsigned tq)
+ : ArrayType(IncompleteArray, et, can, sm, st, tq) {}
public:
friend class StmtIteratorBase;
@@ -4022,12 +4036,13 @@ class IncompleteArrayType : public ArrayType {
}
void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, getElementType(), getSizeModifier(),
+ Profile(ID, getElementType(), getSizeModifier(), getSizeStar(),
getIndexTypeCVRQualifiers());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType ET,
- ArraySizeModifier SizeMod, unsigned TypeQuals) {
+ ArraySizeModifier SizeMod, ArraySizeStar ST,
+ unsigned TypeQuals) {
ID.AddPointer(ET.getAsOpaquePtr());
ID.AddInteger(llvm::to_underlying(SizeMod));
ID.AddInteger(TypeQuals);
@@ -4069,8 +4084,8 @@ class VariableArrayType : public ArrayType {
Stmt *SizeExpr;
VariableArrayType(QualType et, QualType can, Expr *e, ArraySizeModifier sm,
- unsigned tq)
- : ArrayType(VariableArray, et, can, sm, tq, e), SizeExpr((Stmt *)e) {}
+ ArraySizeStar st, unsigned tq)
+ : ArrayType(VariableArray, et, can, sm, st, tq, e), SizeExpr((Stmt *)e) {}
public:
friend class StmtIteratorBase;
@@ -4117,7 +4132,7 @@ class DependentSizedArrayType : public ArrayType {
Stmt *SizeExpr;
DependentSizedArrayType(QualType et, QualType can, Expr *e,
- ArraySizeModifier sm, unsigned tq);
+ ArraySizeModifier sm, ArraySizeStar st, unsigned tq);
public:
friend class StmtIteratorBase;
@@ -4136,12 +4151,12 @@ class DependentSizedArrayType : public ArrayType {
}
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) {
- Profile(ID, Context, getElementType(),
- getSizeModifier(), getIndexTypeCVRQualifiers(), getSizeExpr());
+ Profile(ID, Context, getElementType(), getSizeModifier(), getSizeStar(),
+ getIndexTypeCVRQualifiers(), getSizeExpr());
}
static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
- QualType ET, ArraySizeModifier SizeMod,
+ QualType ET, ArraySizeModifier SizeMod, ArraySizeStar ST,
unsigned TypeQuals, Expr *E);
};
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 0d13ea4c74ebf5..96e79651c88b43 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -15496,8 +15496,8 @@ class Sema final : public SemaBase {
///
/// \returns A suitable array type, if there are no errors. Otherwise,
/// returns a NULL type.
- QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize,
- unsigned Quals, SourceRange Brackets,
+ QualType BuildArrayType(QualType T, ArraySizeModifier ASM, ArraySizeStar Star,
+ Expr *ArraySize, unsigned Quals, SourceRange Brackets,
DeclarationName Entity);
/// Diagnose an array of \p NumElements elements of type \p ElementType
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7d5fd98b348941..7b0a30e28a8538 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4294,6 +4294,7 @@ QualType ASTContext::getConstantArrayType(QualType EltTy,
const llvm::APInt &ArySizeIn,
const Expr *SizeExpr,
ArraySizeModifier ASM,
+ ArraySizeStar Star,
unsigned IndexTypeQuals) const {
assert((EltTy->isDependentType() ||
EltTy->isIncompleteType() || EltTy->isConstantSizeType()) &&
@@ -4324,7 +4325,7 @@ QualType ASTContext::getConstantArrayType(QualType EltTy,
if (!EltTy.isCanonical() || EltTy.hasLocalQualifiers() || SizeExpr) {
SplitQualType canonSplit = getCanonicalType(EltTy).split();
Canon = getConstantArrayType(QualType(canonSplit.Ty, 0), ArySize, nullptr,
- ASM, IndexTypeQuals);
+ ASM, Star, IndexTypeQuals);
Canon = getQualifiedType(Canon, canonSplit.Quals);
// Get the new insert position for the node we care about.
@@ -4333,7 +4334,7 @@ QualType ASTContext::getConstantArrayType(QualType EltTy,
}
auto *New = ConstantArrayType::Create(*this, EltTy, Canon, ArySize, SizeExpr,
- ASM, IndexTypeQuals);
+ ASM, Star, IndexTypeQuals);
ConstantArrayTypes.insert(New, Token);
Types.push_back(New);
return QualType(New, 0);
@@ -4441,6 +4442,7 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const {
cat->getSize(),
cat->getSizeExpr(),
cat->getSizeModifier(),
+ cat->getSizeStar(),
cat->getIndexTypeCVRQualifiers());
break;
}
@@ -4449,7 +4451,8 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const {
const auto *dat = cast<DependentSizedArrayType>(ty);
result = getDependentSizedArrayType(
getVariableArrayDecayedType(dat->getElementType()), dat->getSizeExpr(),
- dat->getSizeModifier(), dat->getIndexTypeCVRQualifiers());
+ dat->getSizeModifier(), dat->getSizeStar(),
+ dat->getIndexTypeCVRQualifiers());
break;
}
@@ -4459,6 +4462,7 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const {
result =
getVariableArrayType(getVariableArrayDecayedType(iat->getElementType()),
/*size*/ nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal,
iat->getIndexTypeCVRQualifiers());
break;
}
@@ -4468,7 +4472,8 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const {
const auto *vat = cast<VariableArrayType>(ty);
result =
getVariableArrayType(getVariableArrayDecayedType(vat->getElementType()),
- /*size*/ nullptr, ArraySizeModifier::Star,
+ /*size*/ nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Star,
vat->getIndexTypeCVRQualifiers());
break;
}
@@ -4482,6 +4487,7 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const {
/// variable array of the specified element type.
QualType ASTContext::getVariableArrayType(QualType EltTy, Expr *NumElts,
ArraySizeModifier ASM,
+ ArraySizeStar Star,
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.
@@ -4491,13 +4497,13 @@ QualType ASTContext::getVariableArrayType(QualType EltTy, Expr *NumElts,
// FIXME: Check below should look for qualifiers behind sugar.
if (!EltTy.isCanonical() || EltTy.hasLocalQualifiers()) {
SplitQualType canonSplit = getCanonicalType(EltTy).split();
- Canon = getVariableArrayType(QualType(canonSplit.Ty, 0), NumElts, ASM,
+ Canon = getVariableArrayType(QualType(canonSplit.Ty, 0), NumElts, ASM, Star,
IndexTypeQuals);
Canon = getQualifiedType(Canon, canonSplit.Quals);
}
auto *New = new (*this, alignof(VariableArrayType))
- VariableArrayType(EltTy, Canon, NumElts, ASM, IndexTypeQuals);
+ VariableArrayType(EltTy, Canon, NumElts, ASM, Star, IndexTypeQuals);
VariableArrayTypes.push_back(New);
Types.push_back(New);
@@ -4510,6 +4516,7 @@ QualType ASTContext::getVariableArrayType(QualType EltTy, Expr *NumElts,
QualType
ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements,
ArraySizeModifier ASM,
+ ArraySizeStar star,
unsigned elementTypeQuals) const {
assert((!numElements || numElements->isTypeDependent() ||
numElements->isValueDependent()) &&
@@ -4521,7 +4528,7 @@ ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements,
llvm::FoldingSetNodeID ID;
DependentSizedArrayType::Profile(
ID, *this, numElements ? QualType(canonElementType.Ty, 0) : elementType,
- ASM, elementTypeQuals, numElements);
+ ASM, star, elementTypeQuals, numElements);
// Look for an existing type with these properties.
DependentSizedArrayType *canonTy = DependentSizedArrayTypes.lookup(ID, Token);
@@ -4534,7 +4541,7 @@ ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements,
return QualType(canonTy, 0);
auto *newType = new (*this, alignof(DependentSizedArrayType))
- DependentSizedArrayType(elementType, QualType(), numElements, ASM,
+ DependentSizedArrayType(elementType, QualType(), numElements, ASM, star,
elementTypeQuals);
DependentSizedArrayTypes.insert(newType, Token);
Types.push_back(newType);
@@ -4545,7 +4552,7 @@ ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements,
if (!canonTy) {
canonTy = new (*this, alignof(DependentSizedArrayType))
DependentSizedArrayType(QualType(canonElementType.Ty, 0), QualType(),
- numElements, ASM, elementTypeQuals);
+ numElements, ASM, star, elementTypeQuals);
DependentSizedArrayTypes.insert(canonTy, Token);
Types.push_back(canonTy);
}
@@ -4563,7 +4570,7 @@ ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements,
// Otherwise, we need to build a type which follows the spelling
// of the element type.
auto *sugaredType = new (*this, alignof(DependentSizedArrayType))
- DependentSizedArrayType(elementType, canon, numElements, ASM,
+ DependentSizedArrayType(elementType, canon, numElements, ASM, star,
elementTypeQuals);
Types.push_back(sugaredType);
return QualType(sugaredType, 0);
@@ -4571,9 +4578,10 @@ ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements,
QualType ASTContext::getIncompleteArrayType(QualType elementType,
ArraySizeModifier ASM,
+ ArraySizeStar Star,
unsigned elementTypeQuals) const {
llvm::FoldingSetNodeID ID;
- IncompleteArrayType::Profile(ID, elementType, ASM, elementTypeQuals);
+ IncompleteArrayType::Profile(ID, elementType, ASM, Star, elementTypeQuals);
llvm::FoldingSetInsertToken Token;
if (IncompleteArrayType *iat = IncompleteArrayTypes.lookup(ID, Token))
@@ -4588,7 +4596,7 @@ QualType ASTContext::getIncompleteArrayType(QualType elementType,
if (!elementType.isCanonical() || elementType.hasLocalQualifiers()) {
SplitQualType canonSplit = getCanonicalType(elementType).split();
canon = getIncompleteArrayType(QualType(canonSplit.Ty, 0),
- ASM, elementTypeQuals);
+ ASM, Star, elementTypeQuals);
canon = getQualifiedType(canon, canonSplit.Quals);
// Get the new insert position for the node we care about.
@@ -4597,7 +4605,7 @@ QualType ASTContext::getIncompleteArrayType(QualType elementType,
}
auto *newType = new (*this, alignof(IncompleteArrayType))
- IncompleteArrayType(elementType, canon, ASM, elementTypeQuals);
+ IncompleteArrayType(elementType, canon, ASM, Star, elementTypeQuals);
IncompleteArrayTypes.insert(newType, Token);
Types.push_back(newType);
@@ -4970,7 +4978,7 @@ ASTContext::getMatrixTypeWithLayout(QualType T,
QualType Result = getConstantArrayType(
getMatrixTypeWithLayout(CAT->getElementType(), Layout), CAT->getSize(),
- CAT->getSizeExpr(), CAT->getSizeModifier(),
+ CAT->getSizeExpr(), CAT->getSizeModifier(), CAT->getSizeStar(),
CAT->getIndexTypeCVRQualifiers());
if (isa<ArrayParameterType>(CAT))
Result = getArrayParameterType(Result);
@@ -7184,22 +7192,25 @@ QualType ASTContext::getUnqualifiedArrayType(QualType type,
if (const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
return getConstantArrayType(unqualElementType, CAT->getSize(),
- CAT->getSizeExpr(), CAT->getSizeModifier(), 0);
+ CAT->getSizeExpr(), CAT->getSizeModifier(),
+ CAT->getSizeStar(), 0);
}
if (const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
- return getIncompleteArrayType(unqualElementType, IAT->getSizeModifier(), 0);
+ return getIncompleteArrayType(unqualElementType, IAT->getSizeModifier(),
+ IAT->getSizeStar(), 0);
}
if (const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
return getVariableArrayType(unqualElementType, VAT->getSizeExpr(),
- VAT->getSizeModifier(),
+ VAT->getSizeModifier(), VAT->getSizeStar(),
VAT->getIndexTypeCVRQualifiers());
}
const auto *DSAT = cast<DependentSizedArrayType>(AT);
return getDependentSizedArrayType(unqualElementType, DSAT->getSizeExpr(),
- DSAT->getSizeModifier(), 0);
+ DSAT->getSizeModifier(),
+ DSAT->getSizeStar(), 0);
}
/// Attempt to unwrap two types that may both be array types with the same bound
@@ -8146,20 +8157,23 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) const {
return cast<ArrayType>(getConstantArrayType(NewEltTy, CAT->getSize(),
CAT->getSizeExpr(),
CAT->getSizeModifier(),
+ CAT->getSizeStar(),
CAT->getIndexTypeCVRQualifiers()));
if (const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
return cast<ArrayType>(getIncompleteArrayType(NewEltTy,
IAT->getSizeModifier(),
+ IAT->getSizeStar(),
IAT->getIndexTypeCVRQualifiers()));
if (const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
return cast<ArrayType>(getDependentSizedArrayType(
NewEltTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
- DSAT->getIndexTypeCVRQualifiers()));
+ DSAT->getSizeStar(), DSAT->getIndexTypeCVRQualifiers()));
const auto *VAT = cast<VariableArrayType>(ATy);
return cast<ArrayType>(
getVariableArrayType(NewEltTy, VAT->getSizeExpr(), VAT->getSizeModifier(),
+ VAT->getSizeStar(),
VAT->getIndexTypeCVRQualifiers()));
}
@@ -10060,7 +10074,7 @@ static TypedefDecl *CreateZOSVaListDecl(const ASTContext *Context) {
llvm::APInt Size(Context->getTypeSize(Context->getSizeType()), 2);
QualType T = Context->getPointerType(Context->CharTy);
QualType ArrayType = Context->getConstantArrayType(
- T, Size, nullptr, ArraySizeModifier::Normal, 0);
+ T, Size, nullptr, ArraySizeModifier::Normal, ArraySizeStar::Normal, 0);
return Context->buildImplicitTypedef(ArrayType, "__builtin_zos_va_list");
}
@@ -10196,7 +10210,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, ArraySizeModifier::Normal, 0);
+ VaListTagTypedefType, Size, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list");
}
@@ -10250,7 +10265,8 @@ 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, ArraySizeModifier::Normal, 0);
+ VaListTagType, Size, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list");
}
@@ -10345,7 +10361,8 @@ 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, ArraySizeModifier::Normal, 0);
+ VaListTagType, Size, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list");
}
@@ -10398,7 +10415,8 @@ 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, ArraySizeModifier::Normal, 0);
+ VaListTagTypedefType, Size, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list");
}
@@ -12211,10 +12229,12 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, bool OfBlockPointer,
return RHS;
if (LCAT)
return getConstantArrayType(ResultType, LCAT->getSize(),
- LCAT->getSizeExpr(), ArraySizeModifier(), 0);
+ LCAT->getSizeExpr(), ArraySizeModifier(),
+ ArraySizeStar(), 0);
if (RCAT)
return getConstantArrayType(ResultType, RCAT->getSize(),
- RCAT->getSizeExpr(), ArraySizeModifier(), 0);
+ RCAT->getSizeExpr(), ArraySizeModifier(),
+ ArraySizeStar(), 0);
if (LVAT && getCanonicalType(LHSElem) == getCanonicalType(ResultType))
return LHS;
if (RVAT && getCanonicalType(RHSElem) == getCanonicalType(ResultType))
@@ -12233,7 +12253,8 @@ 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, ArraySizeModifier(), 0);
+ return getIncompleteArrayType(ResultType, ArraySizeModifier(),
+ ArraySizeStar(), 0);
}
case Type::FunctionNoProto:
return mergeFunctionTypes(LHS, RHS, OfBlockPointer, Unqualified,
@@ -13952,7 +13973,8 @@ 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,
- ArraySizeModifier::Normal, /*IndexTypeQuals*/ 0);
+ ArraySizeModifier::Normal, ArraySizeStar::Normal,
+ /*IndexTypeQuals*/ 0);
}
StringLiteral *
@@ -14373,6 +14395,11 @@ static auto getCommonSizeModifier(const ArrayType *X, const ArrayType *Y) {
return X->getSizeModifier();
}
+static auto getCommonSizeStar(const ArrayType *X, const ArrayType *Y) {
+ assert(X->getSizeStar() == Y->getSizeStar());
+ return X->getSizeStar();
+}
+
static auto getCommonIndexTypeCVRQualifiers(const ArrayType *X,
const ArrayType *Y) {
assert(X->getIndexTypeCVRQualifiers() == Y->getIndexTypeCVRQualifiers());
@@ -14526,7 +14553,8 @@ static QualType getCommonNonSugarTypeNode(const ASTContext &Ctx, const Type *X,
*AY = cast<IncompleteArrayType>(Y);
return Ctx.getIncompleteArrayType(
getCommonArrayElementType(Ctx, AX, QX, AY, QY),
- getCommonSizeModifier(AX, AY), getCommonIndexTypeCVRQualifiers(AX, AY));
+ getCommonSizeModifier(AX, AY), getCommonSizeStar(AX, AY),
+ getCommonIndexTypeCVRQualifiers(AX, AY));
}
case Type::DependentSizedArray: {
const auto *AX = cast<DependentSizedArrayType>(X),
@@ -14534,7 +14562,7 @@ static QualType getCommonNonSugarTypeNode(const ASTContext &Ctx, const Type *X,
return Ctx.getDependentSizedArrayType(
getCommonArrayElementType(Ctx, AX, QX, AY, QY),
getCommonSizeExpr(Ctx, AX, AY), getCommonSizeModifier(AX, AY),
- getCommonIndexTypeCVRQualifiers(AX, AY));
+ getCommonSizeStar(AX, AY), getCommonIndexTypeCVRQualifiers(AX, AY));
}
case Type::ConstantArray: {
const auto *AX = cast<ConstantArrayType>(X),
@@ -14545,7 +14573,8 @@ static QualType getCommonNonSugarTypeNode(const ASTContext &Ctx, const Type *X,
: nullptr;
return Ctx.getConstantArrayType(
getCommonArrayElementType(Ctx, AX, QX, AY, QY), AX->getSize(), SizeExpr,
- getCommonSizeModifier(AX, AY), getCommonIndexTypeCVRQualifiers(AX, AY));
+ getCommonSizeModifier(AX, AY), getCommonSizeStar(AX, AY),
+ getCommonIndexTypeCVRQualifiers(AX, AY));
}
case Type::ArrayParameter: {
const auto *AX = cast<ArrayParameterType>(X),
@@ -14556,7 +14585,8 @@ static QualType getCommonNonSugarTypeNode(const ASTContext &Ctx, const Type *X,
: nullptr;
auto ArrayTy = Ctx.getConstantArrayType(
getCommonArrayElementType(Ctx, AX, QX, AY, QY), AX->getSize(), SizeExpr,
- getCommonSizeModifier(AX, AY), getCommonIndexTypeCVRQualifiers(AX, AY));
+ getCommonSizeModifier(AX, AY), getCommonSizeStar(AX, AY),
+ getCommonIndexTypeCVRQualifiers(AX, AY));
return Ctx.getArrayParameterType(ArrayTy);
}
case Type::Atomic: {
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index 0925fbdcbaeb7a..989838d5ccbba7 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -138,17 +138,20 @@ QualType clang::desugarForDiagnostic(ASTContext &Context, QualType QT,
if (const auto *CAT = dyn_cast<ConstantArrayType>(AT))
QT = Context.getConstantArrayType(
ElementTy, CAT->getSize(), CAT->getSizeExpr(),
- CAT->getSizeModifier(), CAT->getIndexTypeCVRQualifiers());
+ CAT->getSizeModifier(), CAT->getSizeStar(),
+ CAT->getIndexTypeCVRQualifiers());
else if (const auto *VAT = dyn_cast<VariableArrayType>(AT))
QT = Context.getVariableArrayType(ElementTy, VAT->getSizeExpr(),
VAT->getSizeModifier(),
+ VAT->getSizeStar(),
VAT->getIndexTypeCVRQualifiers());
else if (const auto *DSAT = dyn_cast<DependentSizedArrayType>(AT))
QT = Context.getDependentSizedArrayType(
ElementTy, DSAT->getSizeExpr(), DSAT->getSizeModifier(),
- DSAT->getIndexTypeCVRQualifiers());
+ DSAT->getSizeStar(), DSAT->getIndexTypeCVRQualifiers());
else if (const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
QT = Context.getIncompleteArrayType(ElementTy, IAT->getSizeModifier(),
+ IAT->getSizeStar(),
IAT->getIndexTypeCVRQualifiers());
else
llvm_unreachable("Unhandled array type");
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index a9e45c2b8c56b5..581344af419351 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1500,7 +1500,7 @@ ASTNodeImporter::VisitConstantArrayType(const ConstantArrayType *T) {
return Importer.getToContext().getConstantArrayType(
ToElementType, T->getSize(), ToSizeExpr, T->getSizeModifier(),
- T->getIndexTypeCVRQualifiers());
+ T->getSizeStar(), T->getIndexTypeCVRQualifiers());
}
ExpectedType
@@ -1520,6 +1520,7 @@ ASTNodeImporter::VisitIncompleteArrayType(const IncompleteArrayType *T) {
return Importer.getToContext().getIncompleteArrayType(*ToElementTypeOrErr,
T->getSizeModifier(),
+ T->getSizeStar(),
T->getIndexTypeCVRQualifiers());
}
@@ -1531,7 +1532,7 @@ ASTNodeImporter::VisitVariableArrayType(const VariableArrayType *T) {
if (Err)
return std::move(Err);
return Importer.getToContext().getVariableArrayType(
- ToElementType, ToSizeExpr, T->getSizeModifier(),
+ ToElementType, ToSizeExpr, T->getSizeModifier(), T->getSizeStar(),
T->getIndexTypeCVRQualifiers());
}
@@ -1546,7 +1547,7 @@ ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
// For example, 'int a[]'.
return Importer.getToContext().getDependentSizedArrayType(
- ToElementType, ToSizeExpr, T->getSizeModifier(),
+ ToElementType, ToSizeExpr, T->getSizeModifier(), T->getSizeStar(),
T->getIndexTypeCVRQualifiers());
}
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index ad786154db8cbf..ef0ef9e34bdea2 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -3281,7 +3281,8 @@ bool Compiler<Emitter>::VisitSYCLUniqueStableNameExpr(
QualType CharTy = A.CharTy.withConst();
APInt Size(A.getTypeSize(A.getSizeType()), ResultStr.size() + 1);
QualType ArrayTy = A.getConstantArrayType(CharTy, Size, nullptr,
- ArraySizeModifier::Normal, 0);
+ ArraySizeModifier::Normal,
+ ArraySizeStar::Star, 0);
StringLiteral *SL =
StringLiteral::Create(A, ResultStr, StringLiteralKind::Ordinary,
diff --git a/clang/lib/AST/ByteCode/Descriptor.cpp b/clang/lib/AST/ByteCode/Descriptor.cpp
index 67e09cb004a88a..49c14c60adb26b 100644
--- a/clang/lib/AST/ByteCode/Descriptor.cpp
+++ b/clang/lib/AST/ByteCode/Descriptor.cpp
@@ -451,7 +451,7 @@ QualType Descriptor::getDataType(const ASTContext &Ctx) const {
if (IsArray)
return Ctx.getConstantArrayType(
ElemType, APInt(64, static_cast<uint64_t>(getNumElems()), false),
- nullptr, ArraySizeModifier::Normal, 0);
+ nullptr, ArraySizeModifier::Normal, ArraySizeStar::Normal, 0);
return ElemType;
};
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 0377dbe6c130fc..d9d938c7e2bd06 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -2894,7 +2894,7 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E,
AllocType = ASTCtx.getConstantArrayType(
NewExpr->getAllocatedType(),
APInt(64, static_cast<uint64_t>(*ArraySize), false), nullptr,
- ArraySizeModifier::Normal, 0);
+ ArraySizeModifier::Normal, ArraySizeStar::Normal, 0);
} else {
AllocType = NewExpr->getAllocatedType();
}
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index f43c6c9227200d..dc7d939fe1a04d 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2784,7 +2784,8 @@ inline bool SubPtr(InterpState &S, CodePtr OpPC, uint32_t ElemSize) {
if (ElemSize == 0) {
QualType PtrT = S.getASTContext().getBaseElementType(LHS.getType());
QualType ArrayTy = S.getASTContext().getConstantArrayType(
- PtrT, APInt::getZero(1), nullptr, ArraySizeModifier::Normal, 0);
+ PtrT, APInt::getZero(1), nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
S.FFDiag(S.Current->getSource(OpPC),
diag::note_constexpr_pointer_subtraction_zero_size)
<< ArrayTy;
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index ff7a8a7c098276..83eb9b932f128c 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1733,7 +1733,8 @@ static bool interp__builtin_operator_new(InterpState &S, CodePtr OpPC,
// Records. Still allocate them as single-element arrays.
QualType AllocType = S.getASTContext().getConstantArrayType(
- ElemType, NumElems, nullptr, ArraySizeModifier::Normal, 0);
+ ElemType, NumElems, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
const Descriptor *Desc =
S.P.createDescriptor(NewCall, AllocType.getTypePtr());
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 647bb9c45f871a..083742686d6b19 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -7912,7 +7912,8 @@ static bool HandleOperatorNewCall(EvalInfo &Info, const CallExpr *E,
}
QualType AllocType = Info.Ctx.getConstantArrayType(
- ElemType, Size, nullptr, ArraySizeModifier::Normal, 0);
+ ElemType, Size, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
APValue *Val = Info.createHeapAlloc(Caller.Call, AllocType, Result);
*Val = APValue(APValue::UninitArray(), 0, Size.getZExtValue());
Result.addArray(Info, E, cast<ConstantArrayType>(AllocType));
@@ -10366,7 +10367,8 @@ class PointerExprEvaluator
APInt Size(Info.Ctx.getTypeSize(Info.Ctx.getSizeType()),
ResultStr.size() + 1);
QualType ArrayTy = Info.Ctx.getConstantArrayType(
- CharTy, Size, nullptr, ArraySizeModifier::Normal, 0);
+ CharTy, Size, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
StringLiteral *SL =
StringLiteral::Create(Info.Ctx, ResultStr, StringLiteralKind::Ordinary,
@@ -11298,7 +11300,8 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
}
AllocType = Info.Ctx.getConstantArrayType(AllocType, ArrayBound, nullptr,
- ArraySizeModifier::Normal, 0);
+ ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
} else if (E->isArray()) {
// We have an array new-expression whose array size could not be
// determined, e.g. 'new int[]()', where the bound is neither given nor
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index 97d67914e02ddd..101050f93aad3e 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -695,16 +695,11 @@ void JSONNodeDumper::VisitRValueReferenceType(const ReferenceType *RT) {
}
void JSONNodeDumper::VisitArrayType(const ArrayType *AT) {
- switch (AT->getSizeModifier()) {
- case ArraySizeModifier::Star:
- JOS.attribute("sizeModifier", "*");
- break;
- case ArraySizeModifier::Static:
+ if (AT->getSizeModifier() == ArraySizeModifier::Static)
JOS.attribute("sizeModifier", "static");
- break;
- case ArraySizeModifier::Normal:
- break;
- }
+
+ if (AT->getSizeStar() == ArraySizeStar::Star)
+ JOS.attribute("sizeModifier", "*");
std::string Str = AT->getIndexTypeQualifiers().getAsString();
if (!Str.empty())
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index 74edee531e48a0..7713b5756a9259 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -2397,7 +2397,7 @@ void MicrosoftCXXNameMangler::mangleFunctionArgumentType(QualType T,
// a decayed IncompleteArrayType.
if (const auto *AT = getASTContext().getAsArrayType(OriginalType))
OriginalType = getASTContext().getIncompleteArrayType(
- AT->getElementType(), AT->getSizeModifier(),
+ AT->getElementType(), AT->getSizeModifier(), AT->getSizeStar(),
AT->getIndexTypeCVRQualifiers());
TypePtr = OriginalType.getCanonicalType().getAsOpaquePtr();
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 24af510ece2ad9..e47727b09bc722 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -2110,16 +2110,11 @@ void TextNodeDumper::VisitRValueReferenceType(const ReferenceType *T) {
}
void TextNodeDumper::VisitArrayType(const ArrayType *T) {
- switch (T->getSizeModifier()) {
- case ArraySizeModifier::Normal:
- break;
- case ArraySizeModifier::Static:
+ if (T->getSizeModifier() == ArraySizeModifier::Static)
OS << " static";
- break;
- case ArraySizeModifier::Star:
+ if (T->getSizeStar() == ArraySizeStar::Star)
OS << " *";
- break;
- }
+
OS << " " << T->getIndexTypeQualifiers().getAsString();
}
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 7eafa13962e793..30c793298e24f2 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -292,7 +292,8 @@ QualType::isNonConstantStorage(const ASTContext &Ctx, bool ExcludeCtor,
// size is specified by a constant expression that is
// value-dependent,
ArrayType::ArrayType(TypeClass tc, QualType et, QualType can,
- ArraySizeModifier sm, unsigned tq, const Expr *sz)
+ ArraySizeModifier sm, ArraySizeStar st, unsigned tq,
+ const Expr *sz)
// Note, we need to check for DependentSizedArrayType explicitly here
// because we use a DependentSizedArrayType with no size expression as the
// type of a dependent array of unknown bound with a dependent braced
@@ -314,22 +315,24 @@ ArrayType::ArrayType(TypeClass tc, QualType et, QualType can,
"only CVR index qualifiers are stored");
ArrayTypeBits.IndexTypeQuals = tq;
ArrayTypeBits.SizeModifier = llvm::to_underlying(sm);
+ ArrayTypeBits.SizeStar = llvm::to_underlying(st);
}
ConstantArrayType *
ConstantArrayType::Create(const ASTContext &Ctx, QualType ET, QualType Can,
const llvm::APInt &Sz, const Expr *SzExpr,
- ArraySizeModifier SzMod, unsigned Qual) {
+ ArraySizeModifier SzMod, ArraySizeStar St,
+ unsigned Qual) {
bool NeedsExternalSize = SzExpr != nullptr || Sz.ugt(0x0FFFFFFFFFFFFFFF) ||
Sz.getBitWidth() > 0xFF;
if (!NeedsExternalSize)
return new (Ctx, alignof(ConstantArrayType)) ConstantArrayType(
- ET, Can, Sz.getBitWidth(), Sz.getZExtValue(), SzMod, Qual);
+ ET, Can, Sz.getBitWidth(), Sz.getZExtValue(), SzMod, St, Qual);
auto *SzPtr = new (Ctx, alignof(ConstantArrayType::ExternalSize))
ConstantArrayType::ExternalSize(Sz, SzExpr);
return new (Ctx, alignof(ConstantArrayType))
- ConstantArrayType(ET, Can, SzPtr, SzMod, Qual);
+ ConstantArrayType(ET, Can, SzPtr, SzMod, St, Qual);
}
unsigned
@@ -400,21 +403,24 @@ void ConstantArrayType::Profile(llvm::FoldingSetNodeID &ID,
QualType ArrayParameterType::getConstantArrayType(const ASTContext &Ctx) const {
return Ctx.getConstantArrayType(getElementType(), getSize(), getSizeExpr(),
- getSizeModifier(),
+ getSizeModifier(), getSizeStar(),
getIndexTypeQualifiers().getAsOpaqueValue());
}
DependentSizedArrayType::DependentSizedArrayType(QualType et, QualType can,
Expr *e, ArraySizeModifier sm,
- unsigned tq)
- : ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((Stmt *)e) {}
+ ArraySizeStar st, unsigned tq)
+ : ArrayType(DependentSizedArray, et, can, sm, st, tq, e),
+ SizeExpr((Stmt *)e) {}
void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context, QualType ET,
ArraySizeModifier SizeMod,
+ ArraySizeStar Star,
unsigned TypeQuals, Expr *E) {
ID.AddPointer(ET.getAsOpaquePtr());
ID.AddInteger(llvm::to_underlying(SizeMod));
+ ID.AddInteger(llvm::to_underlying(Star));
ID.AddInteger(TypeQuals);
if (E)
E->Profile(ID, Context, true);
@@ -1223,7 +1229,7 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
return QualType(T, 0);
return Ctx.getConstantArrayType(elementType, T->getSize(), T->getSizeExpr(),
- T->getSizeModifier(),
+ T->getSizeModifier(), T->getSizeStar(),
T->getIndexTypeCVRQualifiers());
}
@@ -1236,7 +1242,7 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
return QualType(T, 0);
return Ctx.getVariableArrayType(elementType, T->getSizeExpr(),
- T->getSizeModifier(),
+ T->getSizeModifier(), T->getSizeStar(),
T->getIndexTypeCVRQualifiers());
}
@@ -1249,6 +1255,7 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
return QualType(T, 0);
return Ctx.getIncompleteArrayType(elementType, T->getSizeModifier(),
+ T->getSizeStar(),
T->getIndexTypeCVRQualifiers());
}
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index a90b2d2c0cb94d..bb5d137296b73e 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -568,7 +568,7 @@ void TypePrinter::printVariableArrayAfter(const VariableArrayType *T,
if (T->getSizeModifier() == ArraySizeModifier::Static)
OS << "static ";
- else if (T->getSizeModifier() == ArraySizeModifier::Star)
+ if (T->getSizeStar() == ArraySizeStar::Star)
OS << '*';
if (T->getSizeExpr())
diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index cd7b278eab15d9..838c4801d49922 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -102,6 +102,7 @@ namespace {
C.toCharUnitsFromBits(AtomicSizeInBits).getQuantity());
AtomicTy = C.getConstantArrayType(C.CharTy, Size, nullptr,
ArraySizeModifier::Normal,
+ ArraySizeStar::Normal,
/*IndexTypeQuals=*/0);
}
AtomicAlign = ValueAlign = lvalue.getAlignment();
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7b78abdb71c390..1157d4235b3cc4 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6549,7 +6549,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
llvm::APInt ArraySize(32, NumArgs - First);
QualType SizeArrayTy = getContext().getConstantArrayType(
getContext().getSizeType(), ArraySize, nullptr,
- ArraySizeModifier::Normal,
+ ArraySizeModifier::Normal, ArraySizeStar::Normal,
/*IndexTypeQuals=*/0);
auto Tmp = CreateMemTempWithoutCast(SizeArrayTy, "block_sizes");
llvm::Value *Alloca = Tmp.getPointer();
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 279a7beceeba1f..09f3140e1333c9 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4797,7 +4797,8 @@ void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
QualType ET = CGM.getContext().getAsArrayType(T)->getElementType();
T = CGM.getContext().getConstantArrayType(ET, ConstVal, nullptr,
- ArraySizeModifier::Normal, 0);
+ ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
}
Name = VD->getName();
@@ -5533,7 +5534,8 @@ CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
if (NumPaddingBytes.isPositive()) {
llvm::APInt pad(32, NumPaddingBytes.getQuantity());
FType = CGM.getContext().getConstantArrayType(
- CGM.getContext().CharTy, pad, nullptr, ArraySizeModifier::Normal, 0);
+ CGM.getContext().CharTy, pad, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
EltTys.push_back(CreateMemberType(Unit, FType, "", &FieldOffset));
}
}
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index cb738d060c24a9..42c2594f998288 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -168,7 +168,7 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E,
QualType ElementType = Context.getObjCIdType().withConst();
QualType ElementArrayType = Context.getConstantArrayType(
ElementType, APNumElements, nullptr, ArraySizeModifier::Normal,
- /*IndexTypeQuals=*/0);
+ ArraySizeStar::Normal, /*IndexTypeQuals=*/0);
// Allocate the temporary array(s).
Address Objects = CreateMemTemp(ElementArrayType, "objects");
@@ -1861,7 +1861,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
QualType ItemsTy = getContext().getConstantArrayType(
getContext().getObjCIdType(), llvm::APInt(32, NumItems), nullptr,
- ArraySizeModifier::Normal, 0);
+ ArraySizeModifier::Normal, ArraySizeStar::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 ea4ccf71f6569b..bb2ea035e377fb 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2418,7 +2418,7 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF,
llvm::APInt ArraySize(/*unsigned int numBits=*/32, CopyprivateVars.size());
QualType CopyprivateArrayTy = C.getConstantArrayType(
C.VoidPtrTy, ArraySize, nullptr, ArraySizeModifier::Normal,
- /*IndexTypeQuals=*/0);
+ ArraySizeStar::Normal, /*IndexTypeQuals=*/0);
// Create a list of all private variables for copyprivate.
Address CopyprivateList = CGF.CreateMemTempWithoutCast(
CopyprivateArrayTy, ".omp.copyprivate.cpr_list");
@@ -4193,7 +4193,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
RValue::get(NumOfElements));
KmpTaskAffinityInfoArrayTy = C.getVariableArrayType(
KmpTaskAffinityInfoTy, OVE, ArraySizeModifier::Normal,
- /*IndexTypeQuals=*/0);
+ ArraySizeStar::Normal, /*IndexTypeQuals=*/0);
// Properly emit variable-sized array.
auto *PD = ImplicitParamDecl::Create(C, KmpTaskAffinityInfoArrayTy,
ImplicitParamKind::Other);
@@ -4205,7 +4205,8 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
KmpTaskAffinityInfoArrayTy = C.getConstantArrayType(
KmpTaskAffinityInfoTy,
llvm::APInt(C.getTypeSize(C.getSizeType()), NumAffinities), nullptr,
- ArraySizeModifier::Normal, /*IndexTypeQuals=*/0);
+ ArraySizeModifier::Normal, ArraySizeStar::Normal,
+ /*IndexTypeQuals=*/0);
AffinitiesArray = CGF.CreateMemTempWithoutCast(KmpTaskAffinityInfoArrayTy,
".affs.arr.addr");
AffinitiesArray = CGF.Builder.CreateConstArrayGEP(AffinitiesArray, 0);
@@ -4653,7 +4654,7 @@ std::pair<llvm::Value *, Address> CGOpenMPRuntime::emitDependClause(
RValue::get(NumOfElements));
KmpDependInfoArrayTy =
C.getVariableArrayType(KmpDependInfoTy, OVE, ArraySizeModifier::Normal,
- /*IndexTypeQuals=*/0);
+ ArraySizeStar::Normal, /*IndexTypeQuals=*/0);
// CGF.EmitVariablyModifiedType(KmpDependInfoArrayTy);
// Properly emit variable-sized array.
auto *PD = ImplicitParamDecl::Create(C, KmpDependInfoArrayTy,
@@ -4665,7 +4666,7 @@ std::pair<llvm::Value *, Address> CGOpenMPRuntime::emitDependClause(
} else {
KmpDependInfoArrayTy = C.getConstantArrayType(
KmpDependInfoTy, llvm::APInt(/*numBits=*/64, NumDependencies), nullptr,
- ArraySizeModifier::Normal, /*IndexTypeQuals=*/0);
+ ArraySizeModifier::Normal, ArraySizeStar::Normal, /*IndexTypeQuals=*/0);
DependenciesArray =
CGF.CreateMemTempWithoutCast(KmpDependInfoArrayTy, ".dep.arr.addr");
DependenciesArray = CGF.Builder.CreateConstArrayGEP(DependenciesArray, 0);
@@ -4740,7 +4741,8 @@ Address CGOpenMPRuntime::emitDepobjDependClause(
} else {
QualType KmpDependInfoArrayTy = C.getConstantArrayType(
KmpDependInfoTy, llvm::APInt(/*numBits=*/64, NumDependencies + 1),
- nullptr, ArraySizeModifier::Normal, /*IndexTypeQuals=*/0);
+ nullptr, ArraySizeModifier::Normal, ArraySizeStar::Normal,
+ /*IndexTypeQuals=*/0);
CharUnits Sz = C.getTypeSizeInChars(KmpDependInfoArrayTy);
Size = CGM.getSize(Sz.alignTo(Align));
NumDepsVal = llvm::ConstantInt::get(CGF.IntPtrTy, NumDependencies);
@@ -5626,7 +5628,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
llvm::APInt ArraySize(/*unsigned int numBits=*/32, Size);
QualType ReductionArrayTy = C.getConstantArrayType(
C.VoidPtrTy, ArraySize, nullptr, ArraySizeModifier::Normal,
- /*IndexTypeQuals=*/0);
+ ArraySizeStar::Normal, /*IndexTypeQuals=*/0);
RawAddress ReductionList =
CGF.CreateMemTemp(ReductionArrayTy, ".omp.reduction.red_list");
const auto *IPriv = Privates.begin();
@@ -6123,7 +6125,8 @@ llvm::Value *CGOpenMPRuntime::emitTaskReductionInit(
llvm::APInt ArraySize(/*numBits=*/64, Size);
QualType ArrayRDType =
C.getConstantArrayType(RDType, ArraySize, nullptr,
- ArraySizeModifier::Normal, /*IndexTypeQuals=*/0);
+ ArraySizeModifier::Normal, ArraySizeStar::Normal,
+ /*IndexTypeQuals=*/0);
// kmp_task_red_input_t .rd_input.[Size];
RawAddress TaskRedInput = CGF.CreateMemTemp(ArrayRDType, ".rd_input.");
ReductionCodeGen RCG(Data.ReductionVars, Data.ReductionOrigs,
@@ -12698,7 +12701,8 @@ void CGOpenMPRuntime::emitDoacrossInit(CodeGenFunction &CGF,
}
llvm::APInt Size(/*numBits=*/32, NumIterations.size());
QualType ArrayTy = C.getConstantArrayType(KmpDimTy, Size, nullptr,
- ArraySizeModifier::Normal, 0);
+ ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
Address DimsAddr = CGF.CreateMemTemp(ArrayTy, "dims");
CGF.EmitNullInitialization(DimsAddr, ArrayTy);
@@ -12750,7 +12754,8 @@ 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, ArraySizeModifier::Normal, 0);
+ Int64Ty, Size, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::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 bf8cd97e10166f..5f4488ae1bba03 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -160,7 +160,8 @@ static RecordDecl *buildRecordForGlobalizedVars(
if (BufSize > 1) {
llvm::APInt ArraySize(32, BufSize);
Type = C.getConstantArrayType(Type, ArraySize, nullptr,
- ArraySizeModifier::Normal, 0);
+ ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
}
Field = FieldDecl::Create(
C, GlobalizedRD, Loc, Loc, VD->getIdentifier(), Type,
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 35880f66fe6f84..476a321b8e1613 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -5969,14 +5969,14 @@ void CodeGenFunction::EmitOMPTargetTaskBasedDirective(
llvm::APInt ArrSize(/*numBits=*/32, InputInfo.NumberOfTargetItems);
QualType BaseAndPointerAndMapperType = getContext().getConstantArrayType(
getContext().VoidPtrTy, ArrSize, nullptr, ArraySizeModifier::Normal,
- /*IndexTypeQuals=*/0);
+ ArraySizeStar::Normal, /*IndexTypeQuals=*/0);
BPVD = createImplicitFirstprivateForType(
getContext(), Data, BaseAndPointerAndMapperType, CD, S.getBeginLoc());
PVD = createImplicitFirstprivateForType(
getContext(), Data, BaseAndPointerAndMapperType, CD, S.getBeginLoc());
QualType SizesType = getContext().getConstantArrayType(
getContext().getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/1),
- ArrSize, nullptr, ArraySizeModifier::Normal,
+ ArrSize, nullptr, ArraySizeModifier::Normal, ArraySizeStar::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 f0ea493e172229..dda493caace70b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -7601,7 +7601,8 @@ QualType CodeGenModule::getObjCFastEnumerationStateType() {
Context.UnsignedLongTy, Context.getPointerType(Context.getObjCIdType()),
Context.getPointerType(Context.UnsignedLongTy),
Context.getConstantArrayType(Context.UnsignedLongTy, llvm::APInt(32, 5),
- nullptr, ArraySizeModifier::Normal, 0)};
+ nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0)};
for (size_t i = 0; i < 4; ++i) {
FieldDecl *Field = FieldDecl::Create(Context,
diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index 150a05afb396f0..921bdc3ec3705b 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -359,16 +359,11 @@ DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForType(
// Push the array size part first to make sure they are in the right order.
After.append("[", DeclarationFragments::FragmentKind::Text);
- switch (AT->getSizeModifier()) {
- case ArraySizeModifier::Normal:
- break;
- case ArraySizeModifier::Static:
+ if (AT->getSizeModifier() == ArraySizeModifier::Static)
Fragments.append("static", DeclarationFragments::FragmentKind::Keyword);
- break;
- case ArraySizeModifier::Star:
- Fragments.append("*", DeclarationFragments::FragmentKind::Text);
- break;
- }
+
+ if (AT->getSizeStar() == ArraySizeStar::Star)
+ Fragments.append(" *", DeclarationFragments::FragmentKind::Text);
if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT)) {
// FIXME: right now this would evaluate any expressions/macros written in
diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index 40d78b5d3d2a68..9e61cc78c3b6cb 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -396,7 +396,8 @@ ExprResult Parser::createEmbedExpr() {
llvm::APSInt ArraySize =
Context.MakeIntValue(Str.size(), Context.getSizeType());
QualType ArrayTy = Context.getConstantArrayType(
- Ty, ArraySize, nullptr, ArraySizeModifier::Normal, 0);
+ Ty, ArraySize, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
return StringLiteral::Create(Context, Str, StringLiteralKind::Binary,
false, ArrayTy, StartLoc);
};
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index ebc8b85cf8a628..47da37dec33ae1 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1521,7 +1521,8 @@ void Sema::ActOnEndOfTranslationUnit() {
Diag(VD->getLocation(), diag::warn_tentative_incomplete_array);
llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true);
QualType T = Context.getConstantArrayType(
- ArrayT->getElementType(), One, nullptr, ArraySizeModifier::Normal, 0);
+ ArrayT->getElementType(), One, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::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 86a66c0cbd3147..a1f0b4adacdc2b 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -15796,7 +15796,7 @@ static void diagnoseArrayStarInParamType(Sema &S, QualType PType,
if (!AT)
return;
- if (AT->getSizeModifier() != ArraySizeModifier::Star) {
+ if (AT->getSizeStar() != ArraySizeStar::Star) {
diagnoseArrayStarInParamType(S, AT->getElementType(), Loc);
return;
}
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index a0bd7f524db1c8..6d34f5c442d426 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3538,7 +3538,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() == ArraySizeModifier::Star;
+ return VAT->getSizeStar() == ArraySizeStar::Star;
return false;
};
@@ -3550,8 +3550,7 @@ 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() == ArraySizeModifier::Star) ^
- (NewVAT->getSizeModifier() == ArraySizeModifier::Star))
+ if (OldVAT->getSizeStar() != NewVAT->getSizeStar())
return false;
return true;
}
@@ -6861,7 +6860,8 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T,
}
QualType FoldedArrayType = Context.getConstantArrayType(
- ElemTy, Res, VLATy->getSizeExpr(), ArraySizeModifier::Normal, 0);
+ ElemTy, Res, VLATy->getSizeExpr(), ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
return Qs.apply(Context, FoldedArrayType);
}
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 571ef6ea6b19eb..3f21e28c6864eb 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3733,6 +3733,7 @@ ExprResult Sema::BuildPredefinedExpr(SourceLocation Loc,
Str, RawChars);
ResTy = Context.getConstantArrayType(ResTy, LengthI, nullptr,
ArraySizeModifier::Normal,
+ ArraySizeStar::Normal,
/*IndexTypeQuals*/ 0);
SL = StringLiteral::Create(Context, RawChars, StringLiteralKind::Wide,
/*Pascal*/ false, ResTy, Loc);
@@ -3740,6 +3741,7 @@ ExprResult Sema::BuildPredefinedExpr(SourceLocation Loc,
ResTy = Context.adjustStringLiteralBaseType(Context.CharTy.withConst());
ResTy = Context.getConstantArrayType(ResTy, LengthI, nullptr,
ArraySizeModifier::Normal,
+ ArraySizeStar::Normal,
/*IndexTypeQuals*/ 0);
SL = StringLiteral::Create(Context, Str, StringLiteralKind::Ordinary,
/*Pascal*/ false, ResTy, Loc);
@@ -3994,7 +3996,8 @@ 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, ArraySizeModifier::Normal, 0);
+ llvm::APInt(32, Length + 1), nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
Expr *Lit =
StringLiteral::Create(Context, StringRef(TokSpelling.data(), Length),
StringLiteralKind::Ordinary,
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index e708de6981a54c..84b9e6c68e5538 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2593,10 +2593,11 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
AllocType,
llvm::APInt(Context.getTypeSize(Context.getSizeType()),
*KnownArraySize),
- *ArraySize, ArraySizeModifier::Normal, 0);
+ *ArraySize, ArraySizeModifier::Normal, ArraySizeStar::Normal, 0);
else if (ArraySize)
InitType = Context.getIncompleteArrayType(AllocType,
- ArraySizeModifier::Normal, 0);
+ ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
else
InitType = AllocType;
@@ -6392,9 +6393,11 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc,
case Array:
if (auto *CAT = cast_or_null<ConstantArrayType>(ClassOrBound))
return Ctx.getConstantArrayType(T, CAT->getSize(), nullptr,
- ArraySizeModifier::Normal, 0);
+ ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
else
- return Ctx.getIncompleteArrayType(T, ArraySizeModifier::Normal, 0);
+ return Ctx.getIncompleteArrayType(T, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
}
llvm_unreachable("unknown step kind");
}
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 611ad1ba453515..afd8f64c74a280 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -73,7 +73,8 @@ ExprResult SemaObjC::ParseObjCStringLiteral(SourceLocation *AtLocs,
assert(CAT && "String literal not of constant array type!");
QualType StrTy = Context.getConstantArrayType(
CAT->getElementType(), llvm::APInt(32, StrBuf.size() + 1), nullptr,
- CAT->getSizeModifier(), CAT->getIndexTypeCVRQualifiers());
+ CAT->getSizeModifier(), CAT->getSizeStar(),
+ CAT->getIndexTypeCVRQualifiers());
S = StringLiteral::Create(Context, StrBuf, StringLiteralKind::Ordinary,
/*Pascal=*/false, StrTy, StrLocs);
}
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 12ed7f47bedb64..73bf014e74a90a 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -534,6 +534,7 @@ static const Type *createHostLayoutType(Sema &S, const Type *Ty) {
return AST
.getConstantArrayType(QualType(ElementTy, 0), CAT->getSize(), nullptr,
CAT->getSizeModifier(),
+ CAT->getSizeStar(),
CAT->getIndexTypeCVRQualifiers())
.getTypePtr();
}
@@ -7132,7 +7133,8 @@ class InitListTransformer {
Inits.back()->getEndLoc(), /*isExplicit=*/false);
llvm::APInt ArySize(64, Inits.size());
NewInit->setType(Ctx.getConstantArrayType(InitTy, ArySize, nullptr,
- ArraySizeModifier::Normal, 0));
+ ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0));
return NewInit;
}
};
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ac1e67ed6d5af3..acaa92d55f6a94 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -230,7 +230,8 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT,
llvm::APInt ConstVal(32, StrLength);
// Return a new array type (C99 6.7.8p22).
DeclT = S.Context.getConstantArrayType(
- IAT->getElementType(), ConstVal, nullptr, ArraySizeModifier::Normal, 0);
+ IAT->getElementType(), ConstVal, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
updateStringLiteralType(Str, DeclT);
return;
}
@@ -2305,7 +2306,8 @@ void InitListChecker::CheckArrayType(const InitializedEntity &Entity,
}
DeclType = SemaRef.Context.getConstantArrayType(
- elementType, maxElements, nullptr, ArraySizeModifier::Normal, 0);
+ elementType, maxElements, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
}
if (!hadError) {
// If there are any members of the array that get value-initialized, check
@@ -4472,7 +4474,8 @@ static bool TryInitializerListConstruction(Sema &S,
E.withConst(),
llvm::APInt(S.Context.getTypeSize(S.Context.getSizeType()),
List->getNumInitsWithEmbedExpanded()),
- nullptr, clang::ArraySizeModifier::Normal, 0);
+ nullptr, clang::ArraySizeModifier::Normal,
+ clang::ArraySizeStar::Normal, 0);
InitializedEntity HiddenArray =
InitializedEntity::InitializeTemporary(ArrayType);
InitializationKind Kind = InitializationKind::CreateDirectList(
@@ -6083,7 +6086,8 @@ static void TryOrBuildParenListInitialization(
if (ResultType.isNull()) {
ResultType = S.Context.getConstantArrayType(
AT->getElementType(), llvm::APInt(/*numBits=*/32, ArrayLength),
- /*SizeExpr=*/nullptr, ArraySizeModifier::Normal, 0);
+ /*SizeExpr=*/nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
}
} else if (auto *RD = Entity.getType()->getAsCXXRecordDecl()) {
bool IsUnion = RD->isUnion();
@@ -8018,7 +8022,7 @@ ExprResult InitializationSequence::Perform(Sema &S,
*ResultType = S.Context.getDependentSizedArrayType(
ArrayT->getElementType(),
/*NumElts=*/nullptr, ArrayT->getSizeModifier(),
- ArrayT->getIndexTypeCVRQualifiers());
+ ArrayT->getSizeStar(), ArrayT->getIndexTypeCVRQualifiers());
}
}
if (Kind.getKind() == InitializationKind::IK_Direct &&
@@ -8707,7 +8711,8 @@ ExprResult InitializationSequence::Perform(Sema &S,
= S.Context.getAsConstantArrayType(CurInit.get()->getType())) {
*ResultType = S.Context.getConstantArrayType(
IncompleteDest->getElementType(), ConstantSource->getSize(),
- ConstantSource->getSizeExpr(), ArraySizeModifier::Normal, 0);
+ ConstantSource->getSizeExpr(), ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
}
}
}
@@ -9032,7 +9037,8 @@ static void diagnoseListInit(Sema &S, const InitializedEntity &Entity,
E.withConst(),
llvm::APInt(S.Context.getTypeSize(S.Context.getSizeType()),
InitList->getNumInitsWithEmbedExpanded()),
- nullptr, clang::ArraySizeModifier::Normal, 0);
+ nullptr, clang::ArraySizeModifier::Normal,
+ clang::ArraySizeStar::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 b81d94dd3436f2..178e39f3c1bccd 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -22827,6 +22827,7 @@ static bool actOnOMPReductionKindClause(
for (llvm::APSInt &Size : ArraySizes)
PrivateTy = Context.getConstantArrayType(PrivateTy, Size, nullptr,
ArraySizeModifier::Normal,
+ ArraySizeStar::Normal,
/*IndexTypeQuals=*/0);
}
}
@@ -22853,7 +22854,8 @@ static bool actOnOMPReductionKindClause(
Type,
new (Context)
OpaqueValueExpr(ELoc, Context.getSizeType(), VK_PRValue),
- ArraySizeModifier::Normal, /*IndexTypeQuals=*/0);
+ ArraySizeModifier::Normal, ArraySizeStar::Normal,
+ /*IndexTypeQuals=*/0);
} else if (!ASE && !OASE &&
Context.getAsArrayType(D->getType().getNonReferenceType())) {
PrivateTy = D->getType().getNonReferenceType();
@@ -23120,7 +23122,7 @@ static bool actOnOMPReductionKindClause(
auto *Dim = new (S.Context)
OpaqueValueExpr(ELoc, S.Context.getSizeType(), VK_PRValue);
QualType ArrayTy = S.Context.getVariableArrayType(
- PrivateTy, Dim, ArraySizeModifier::Normal,
+ PrivateTy, Dim, ArraySizeModifier::Normal, ArraySizeStar::Normal,
/*IndexTypeQuals=*/0);
VarDecl *TempArrayVD =
buildVarDecl(S, ELoc, ArrayTy, D->getName(),
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a015a6b2052763..49f81dcfd77453 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -5952,7 +5952,8 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
}
llvm::APInt Size(S.Context.getTypeSize(S.Context.getSizeType()), e);
ContTy = S.Context.getConstantArrayType(InitTy, Size, nullptr,
- ArraySizeModifier::Normal, 0);
+ ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
}
}
diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp
index 56675ee9f2d107..ab4222ff8f5df6 100644
--- a/clang/lib/Sema/SemaSYCL.cpp
+++ b/clang/lib/Sema/SemaSYCL.cpp
@@ -527,7 +527,8 @@ bool BuildSYCLKernelLaunchCallArgs(Sema &SemaRef, FunctionDecl *FD,
llvm::APInt KernelNameSize(Ctx.getTypeSize(Ctx.getSizeType()),
KernelName.size() + 1);
QualType KernelNameArrayTy = Ctx.getConstantArrayType(
- KernelNameCharTy, KernelNameSize, nullptr, ArraySizeModifier::Normal, 0);
+ KernelNameCharTy, KernelNameSize, nullptr, ArraySizeModifier::Normal,
+ ArraySizeStar::Normal, 0);
Expr *KernelNameExpr =
StringLiteral::Create(Ctx, KernelName, StringLiteralKind::Ordinary,
/*Pascal*/ false, KernelNameArrayTy, Loc);
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 0e49975e4bed04..edc5b4328c888a 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -2132,6 +2132,7 @@ bool Sema::checkArrayTooLarge(QualType ElementType,
}
QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM,
+ ArraySizeStar Star,
Expr *ArraySize, unsigned Quals,
SourceRange Brackets, DeclarationName Entity) {
// ArrayType stores only the CVR qualifiers; __unaligned and _Atomic are
@@ -2294,17 +2295,18 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM,
llvm::APSInt ConstVal(Context.getTypeSize(Context.getSizeType()));
if (!ArraySize) {
- if (ASM == ArraySizeModifier::Star) {
+ if (Star == ArraySizeStar::Star) {
Diag(Loc, VLADiag);
if (VLAIsError)
return QualType();
- T = Context.getVariableArrayType(T, nullptr, ASM, IndexTypeQuals);
+ T = Context.getVariableArrayType(T, nullptr, ASM, Star, IndexTypeQuals);
} else {
- T = Context.getIncompleteArrayType(T, ASM, IndexTypeQuals);
+ T = Context.getIncompleteArrayType(T, ASM, Star, IndexTypeQuals);
}
} else if (ArraySize->isTypeDependent() || ArraySize->isValueDependent()) {
- T = Context.getDependentSizedArrayType(T, ArraySize, ASM, IndexTypeQuals);
+ T = Context.getDependentSizedArrayType(T, ArraySize, ASM, Star,
+ IndexTypeQuals);
} else {
ExprResult R =
checkArraySize(*this, ArraySize, ConstVal, VLADiag, VLAIsError);
@@ -2315,7 +2317,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, IndexTypeQuals);
+ T = Context.getVariableArrayType(T, ArraySize, ASM, Star, IndexTypeQuals);
} else if (!T->isDependentType() && !T->isIncompleteType() &&
!T->isConstantSizeType()) {
// C99: an array with an element type that has a non-constant-size is a
@@ -2324,7 +2326,7 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM,
Diag(Loc, VLADiag);
if (VLAIsError)
return QualType();
- T = Context.getVariableArrayType(T, ArraySize, ASM, IndexTypeQuals);
+ T = Context.getVariableArrayType(T, ArraySize, ASM, Star, IndexTypeQuals);
} else {
// C99 6.7.5.2p1: If the expression is a constant expression, it shall
// have a value greater than zero.
@@ -2361,7 +2363,7 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM,
ArraySize->getSourceRange()))
return QualType();
- T = Context.getConstantArrayType(T, ConstVal, ArraySize, ASM,
+ T = Context.getConstantArrayType(T, ConstVal, ArraySize, ASM, Star,
IndexTypeQuals);
}
}
@@ -2382,10 +2384,11 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM,
// If this is not C99, diagnose array size modifiers on non-VLAs.
if (!getLangOpts().C99 && !T->isVariableArrayType() &&
- (ASM != ArraySizeModifier::Normal || Quals != 0)) {
+ (ASM != ArraySizeModifier::Normal || Star != ArraySizeStar::Normal ||
+ Quals != 0)) {
Diag(Loc, getLangOpts().CPlusPlus ? diag::err_c99_array_usage_cxx
: diag::ext_c99_array_usage)
- << ASM;
+ << ASM; // XXX: (How?) should I print 'Star'?
}
// OpenCL v2.0 s6.12.5 - Arrays of blocks are not supported.
@@ -4876,6 +4879,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
DeclaratorChunk::ArrayTypeInfo &ATI = DeclType.Arr;
Expr *ArraySize = ATI.NumElts;
ArraySizeModifier ASM;
+ ArraySizeStar Star;
// Microsoft property fields can have multiple sizeless array chunks
// (i.e. int x[][][]). Skip all of these except one to avoid creating
@@ -4890,12 +4894,14 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
}
if (ATI.isStar)
- ASM = ArraySizeModifier::Star;
- else if (ATI.hasStatic)
+ Star = ArraySizeStar::Star;
+ else
+ Star = ArraySizeStar::Normal;
+ if (ATI.hasStatic)
ASM = ArraySizeModifier::Static;
else
ASM = ArraySizeModifier::Normal;
- if (ASM == ArraySizeModifier::Star && !D.isPrototypeContext()) {
+ if (Star == ArraySizeStar::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
@@ -4942,7 +4948,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
checkNullabilityConsistency(S, SimplePointerKind::Array, DeclType.Loc);
}
- T = S.BuildArrayType(T, ASM, ArraySize, ATI.TypeQuals,
+ T = S.BuildArrayType(T, ASM, Star, ArraySize, ATI.TypeQuals,
SourceRange(DeclType.Loc, DeclType.EndLoc), Name);
break;
}
@@ -7269,6 +7275,7 @@ namespace {
QualType New = wrap(C, CAT->getElementType(), I);
return C.getConstantArrayType(New, CAT->getSize(), CAT->getSizeExpr(),
CAT->getSizeModifier(),
+ CAT->getSizeStar(),
CAT->getIndexTypeCVRQualifiers());
}
@@ -7276,12 +7283,14 @@ namespace {
QualType New = wrap(C, VAT->getElementType(), I);
return C.getVariableArrayType(New, VAT->getSizeExpr(),
VAT->getSizeModifier(),
+ VAT->getSizeStar(),
VAT->getIndexTypeCVRQualifiers());
}
const auto *IAT = cast<IncompleteArrayType>(Old);
QualType New = wrap(C, IAT->getElementType(), I);
return C.getIncompleteArrayType(New, IAT->getSizeModifier(),
+ IAT->getSizeStar(),
IAT->getIndexTypeCVRQualifiers());
}
@@ -9541,7 +9550,7 @@ void Sema::completeExprArrayBound(Expr *E) {
IAT->getElementType(),
llvm::APInt(Context.getTypeSize(Context.getSizeType()), 1),
/*SizeExpr=*/nullptr, ArraySizeModifier::Normal,
- /*IndexTypeQuals=*/0);
+ ArraySizeStar::Normal, /*IndexTypeQuals=*/0);
E->setType(ResultType);
}
}
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 87a0f40584384e..b91e52d531d239 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -965,6 +965,7 @@ class TreeTransform {
/// Subclasses may override this routine to provide different behavior.
/// Also by default, all of the other Rebuild*Array
QualType RebuildArrayType(QualType ElementType, ArraySizeModifier SizeMod,
+ ArraySizeStar Star,
const llvm::APInt *Size, Expr *SizeExpr,
unsigned IndexTypeQuals, SourceRange BracketsRange);
@@ -975,6 +976,7 @@ class TreeTransform {
/// Subclasses may override this routine to provide different behavior.
QualType RebuildConstantArrayType(QualType ElementType,
ArraySizeModifier SizeMod,
+ ArraySizeStar Star,
const llvm::APInt &Size, Expr *SizeExpr,
unsigned IndexTypeQuals,
SourceRange BracketsRange);
@@ -986,6 +988,7 @@ class TreeTransform {
/// Subclasses may override this routine to provide different behavior.
QualType RebuildIncompleteArrayType(QualType ElementType,
ArraySizeModifier SizeMod,
+ ArraySizeStar Star,
unsigned IndexTypeQuals,
SourceRange BracketsRange);
@@ -995,7 +998,8 @@ class TreeTransform {
/// By default, performs semantic analysis when building the array type.
/// Subclasses may override this routine to provide different behavior.
QualType RebuildVariableArrayType(QualType ElementType,
- ArraySizeModifier SizeMod, Expr *SizeExpr,
+ ArraySizeModifier SizeMod,
+ ArraySizeStar Star, Expr *SizeExpr,
unsigned IndexTypeQuals,
SourceRange BracketsRange);
@@ -1006,7 +1010,7 @@ class TreeTransform {
/// Subclasses may override this routine to provide different behavior.
QualType RebuildDependentSizedArrayType(QualType ElementType,
ArraySizeModifier SizeMod,
- Expr *SizeExpr,
+ ArraySizeStar Star, Expr *SizeExpr,
unsigned IndexTypeQuals,
SourceRange BracketsRange);
@@ -6068,6 +6072,7 @@ TreeTransform<Derived>::TransformConstantArrayType(TypeLocBuilder &TLB,
(T->getSizeExpr() && NewSize != OldSize)) {
Result = getDerived().RebuildConstantArrayType(ElementType,
T->getSizeModifier(),
+ T->getSizeStar(),
T->getSize(), NewSize,
T->getIndexTypeCVRQualifiers(),
TL.getBracketsRange());
@@ -6101,6 +6106,7 @@ QualType TreeTransform<Derived>::TransformIncompleteArrayType(
ElementType != T->getElementType()) {
Result = getDerived().RebuildIncompleteArrayType(ElementType,
T->getSizeModifier(),
+ T->getSizeStar(),
T->getIndexTypeCVRQualifiers(),
TL.getBracketsRange());
if (Result.isNull())
@@ -6145,6 +6151,7 @@ TreeTransform<Derived>::TransformVariableArrayType(TypeLocBuilder &TLB,
Size != T->getSizeExpr()) {
Result = getDerived().RebuildVariableArrayType(ElementType,
T->getSizeModifier(),
+ T->getSizeStar(),
Size,
T->getIndexTypeCVRQualifiers(),
TL.getBracketsRange());
@@ -6196,6 +6203,7 @@ TreeTransform<Derived>::TransformDependentSizedArrayType(TypeLocBuilder &TLB,
size != origSize) {
Result = getDerived().RebuildDependentSizedArrayType(ElementType,
T->getSizeModifier(),
+ T->getSizeStar(),
size,
T->getIndexTypeCVRQualifiers(),
TL.getBracketsRange());
@@ -18182,10 +18190,11 @@ QualType TreeTransform<Derived>::RebuildObjCObjectPointerType(
template <typename Derived>
QualType TreeTransform<Derived>::RebuildArrayType(
- QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
+ QualType ElementType, ArraySizeModifier SizeMod, ArraySizeStar Star,
+ const llvm::APInt *Size,
Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
if (SizeExpr || !Size)
- return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
+ return SemaRef.BuildArrayType(ElementType, SizeMod, Star, SizeExpr,
IndexTypeQuals, BracketsRange,
getDerived().getBaseEntity());
@@ -18206,41 +18215,43 @@ QualType TreeTransform<Derived>::RebuildArrayType(
IntegerLiteral *ArraySize
= IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
/*FIXME*/BracketsRange.getBegin());
- return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
+ return SemaRef.BuildArrayType(ElementType, SizeMod, Star, ArraySize,
IndexTypeQuals, BracketsRange,
getDerived().getBaseEntity());
}
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);
+ QualType ElementType, ArraySizeModifier SizeMod, ArraySizeStar Star,
+ const llvm::APInt &Size, Expr *SizeExpr, unsigned IndexTypeQuals,
+ SourceRange BracketsRange) {
+ return getDerived().RebuildArrayType(ElementType, SizeMod, Star,
+ &Size, SizeExpr, IndexTypeQuals,
+ 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);
+ QualType ElementType, ArraySizeModifier SizeMod, ArraySizeStar Star,
+ unsigned IndexTypeQuals, SourceRange BracketsRange) {
+ return getDerived().RebuildArrayType(ElementType, SizeMod, Star, nullptr,
+ nullptr, IndexTypeQuals, BracketsRange);
}
template <typename Derived>
QualType TreeTransform<Derived>::RebuildVariableArrayType(
- QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
- unsigned IndexTypeQuals, SourceRange BracketsRange) {
- return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
+ QualType ElementType, ArraySizeModifier SizeMod, ArraySizeStar Star,
+ Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
+ return getDerived().RebuildArrayType(ElementType, SizeMod, Star, nullptr,
SizeExpr,
IndexTypeQuals, BracketsRange);
}
template <typename Derived>
QualType TreeTransform<Derived>::RebuildDependentSizedArrayType(
- QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
- unsigned IndexTypeQuals, SourceRange BracketsRange) {
- return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
+ QualType ElementType, ArraySizeModifier SizeMod, ArraySizeStar Star,
+ Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
+ return getDerived().RebuildArrayType(ElementType, SizeMod, Star, nullptr,
SizeExpr,
IndexTypeQuals, BracketsRange);
}
diff --git a/clang/lib/UnifiedSymbolResolution/USRGeneration.cpp b/clang/lib/UnifiedSymbolResolution/USRGeneration.cpp
index 4481480069830f..1a1a89a7cc7ee4 100644
--- a/clang/lib/UnifiedSymbolResolution/USRGeneration.cpp
+++ b/clang/lib/UnifiedSymbolResolution/USRGeneration.cpp
@@ -1075,13 +1075,12 @@ void USRGenerator::VisitType(QualType T) {
case ArraySizeModifier::Static:
Out << 's';
break;
- case ArraySizeModifier::Star:
- Out << '*';
- break;
case ArraySizeModifier::Normal:
Out << 'n';
break;
}
+ if (AT->getSizeStar() == ArraySizeStar::Star)
+ Out << '*';
if (const auto *const CAT = dyn_cast<ConstantArrayType>(T))
Out << CAT->getSize();
diff --git a/libcxxabi/test/DemangleTestCases.inc b/libcxxabi/test/DemangleTestCases.inc
index ea40fdce31836e..20ca3439d014df 100644
--- a/libcxxabi/test/DemangleTestCases.inc
+++ b/libcxxabi/test/DemangleTestCases.inc
@@ -8849,7 +8849,7 @@
{"_ZNK5clang10ASTContext20getConstantArrayTypeENS_8QualTypeERKN4llvm5APIntENS_9ArrayType17ArraySizeModifierEj", "clang::ASTContext::getConstantArrayType(clang::QualType, llvm::APInt const&, clang::ArrayType::ArraySizeModifier, unsigned int) const"},
{"_ZNK5clang10ASTContext27getVariableArrayDecayedTypeENS_8QualTypeE", "clang::ASTContext::getVariableArrayDecayedType(clang::QualType) const"},
{"_ZNK5clang10ASTContext26getDependentSizedArrayTypeENS_8QualTypeEPNS_4ExprENS_9ArrayType17ArraySizeModifierEjNS_11SourceRangeE", "clang::ASTContext::getDependentSizedArrayType(clang::QualType, clang::Expr*, clang::ArrayType::ArraySizeModifier, unsigned int, clang::SourceRange) const"},
-{"_ZNK5clang10ASTContext20getVariableArrayTypeENS_8QualTypeEPNS_4ExprENS_9ArrayType17ArraySizeModifierEjNS_11SourceRangeE", "clang::ASTContext::getVariableArrayType(clang::QualType, clang::Expr*, clang::ArrayType::ArraySizeModifier, unsigned int, clang::SourceRange) const"},
+{"_ZNK5clang10ASTContext20getVariableArrayTypeENS_8QualTypeEPNS_4ExprENS_9ArrayType17ArraySizeModifierEjNS_11SourceRangeE", "clang::ASTContext::getVariableArrayType(clang::QualType, clang::Expr*, clang::ArrayType::ArraySizeModifier, bool, unsigned int, clang::SourceRange) const"},
{"_ZNK5clang10ASTContext22getIncompleteArrayTypeENS_8QualTypeENS_9ArrayType17ArraySizeModifierEj", "clang::ASTContext::getIncompleteArrayType(clang::QualType, clang::ArrayType::ArraySizeModifier, unsigned int) const"},
{"_ZNK5clang10ASTContext13getVectorTypeENS_8QualTypeEjNS_10VectorType10VectorKindE", "clang::ASTContext::getVectorType(clang::QualType, unsigned int, clang::VectorType::VectorKind) const"},
{"_ZNK5clang10ASTContext16getExtVectorTypeENS_8QualTypeEj", "clang::ASTContext::getExtVectorType(clang::QualType, unsigned int) const"},
diff --git a/llvm/include/llvm/Testing/Demangle/DemangleTestCases.inc b/llvm/include/llvm/Testing/Demangle/DemangleTestCases.inc
index ea40fdce31836e..20ca3439d014df 100644
--- a/llvm/include/llvm/Testing/Demangle/DemangleTestCases.inc
+++ b/llvm/include/llvm/Testing/Demangle/DemangleTestCases.inc
@@ -8849,7 +8849,7 @@
{"_ZNK5clang10ASTContext20getConstantArrayTypeENS_8QualTypeERKN4llvm5APIntENS_9ArrayType17ArraySizeModifierEj", "clang::ASTContext::getConstantArrayType(clang::QualType, llvm::APInt const&, clang::ArrayType::ArraySizeModifier, unsigned int) const"},
{"_ZNK5clang10ASTContext27getVariableArrayDecayedTypeENS_8QualTypeE", "clang::ASTContext::getVariableArrayDecayedType(clang::QualType) const"},
{"_ZNK5clang10ASTContext26getDependentSizedArrayTypeENS_8QualTypeEPNS_4ExprENS_9ArrayType17ArraySizeModifierEjNS_11SourceRangeE", "clang::ASTContext::getDependentSizedArrayType(clang::QualType, clang::Expr*, clang::ArrayType::ArraySizeModifier, unsigned int, clang::SourceRange) const"},
-{"_ZNK5clang10ASTContext20getVariableArrayTypeENS_8QualTypeEPNS_4ExprENS_9ArrayType17ArraySizeModifierEjNS_11SourceRangeE", "clang::ASTContext::getVariableArrayType(clang::QualType, clang::Expr*, clang::ArrayType::ArraySizeModifier, unsigned int, clang::SourceRange) const"},
+{"_ZNK5clang10ASTContext20getVariableArrayTypeENS_8QualTypeEPNS_4ExprENS_9ArrayType17ArraySizeModifierEjNS_11SourceRangeE", "clang::ASTContext::getVariableArrayType(clang::QualType, clang::Expr*, clang::ArrayType::ArraySizeModifier, bool, unsigned int, clang::SourceRange) const"},
{"_ZNK5clang10ASTContext22getIncompleteArrayTypeENS_8QualTypeENS_9ArrayType17ArraySizeModifierEj", "clang::ASTContext::getIncompleteArrayType(clang::QualType, clang::ArrayType::ArraySizeModifier, unsigned int) const"},
{"_ZNK5clang10ASTContext13getVectorTypeENS_8QualTypeEjNS_10VectorType10VectorKindE", "clang::ASTContext::getVectorType(clang::QualType, unsigned int, clang::VectorType::VectorKind) const"},
{"_ZNK5clang10ASTContext16getExtVectorTypeENS_8QualTypeEj", "clang::ASTContext::getExtVectorType(clang::QualType, unsigned int) const"},
More information about the cfe-commits
mailing list