forked from OSchip/llvm-project
Improve type printing of size-dependent const arrays to normalize array-of-const and const-array
Follow-on from 2bd8493847
based on
postcommit feedback from Richard Smith.
The VariableArray case I couldn't figure out how to test/provoke - you
can't write/form a variable array in any context other than a local
variable that I know of, and in that case `const int x[n]` is the
normalized form already (array-of-const) and you can't use typedefs
(since you can't typedef int[n] with variable 'n') to force the
const-array AST that would produce the undesirable type printing "int
const [n]".
This commit is contained in:
parent
4ac4e52189
commit
40acc0adad
|
@ -242,13 +242,16 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
|
||||||
T->isObjCQualifiedIdType() || T->isObjCQualifiedClassType();
|
T->isObjCQualifiedIdType() || T->isObjCQualifiedClassType();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Type::DependentSizedArray:
|
||||||
|
NeedARCStrongQualifier = true;
|
||||||
|
LLVM_FALLTHROUGH;
|
||||||
|
|
||||||
case Type::ConstantArray:
|
case Type::ConstantArray:
|
||||||
case Type::IncompleteArray:
|
case Type::IncompleteArray:
|
||||||
return canPrefixQualifiers(
|
return canPrefixQualifiers(
|
||||||
cast<ArrayType>(UnderlyingType)->getElementType().getTypePtr(),
|
cast<ArrayType>(UnderlyingType)->getElementType().getTypePtr(),
|
||||||
NeedARCStrongQualifier);
|
NeedARCStrongQualifier);
|
||||||
case Type::VariableArray:
|
case Type::VariableArray:
|
||||||
case Type::DependentSizedArray:
|
|
||||||
NeedARCStrongQualifier = true;
|
NeedARCStrongQualifier = true;
|
||||||
LLVM_FALLTHROUGH;
|
LLVM_FALLTHROUGH;
|
||||||
|
|
||||||
|
|
|
@ -23,5 +23,6 @@ class array {
|
||||||
|
|
||||||
using array_T_size = T[Size];
|
using array_T_size = T[Size];
|
||||||
// CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'T [Size]' dependent <col:25, col:30>
|
// CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'T [Size]' dependent <col:25, col:30>
|
||||||
|
using const_array_T_size = const T[Size];
|
||||||
|
// CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'const T [Size]' dependent <col:37, col:42>
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue