diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-02-15 18:16:39 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-02-15 18:16:39 +0000 |
commit | c5773c4b8ce1ed6ed5c7112c9020c954a47dce96 (patch) | |
tree | ec33b36044e41db2658a41cd1a9e6353cd06ccba /CodeGen/CodeGenTypes.cpp | |
parent | 3e5849ecfc02e362beb195d35100f868b1699176 (diff) |
Split out incomplete arrays from VariableArrayType into
IncompleteArrayType. This should make code dealing with both incomplete
and variable length arrays much more readable, plus it allows properly
making the distinction between isVariableArrayType() and
isVariablyModifiedType(). The patch is a little big, but it's
strightforward. so I don't think there should be any issues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47165 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CodeGenTypes.cpp')
-rw-r--r-- | CodeGen/CodeGenTypes.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/CodeGen/CodeGenTypes.cpp b/CodeGen/CodeGenTypes.cpp index d293b4f081..96bccfc6ec 100644 --- a/CodeGen/CodeGenTypes.cpp +++ b/CodeGen/CodeGenTypes.cpp @@ -207,15 +207,18 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { case Type::VariableArray: { const VariableArrayType &A = cast<VariableArrayType>(Ty); - assert(A.getSizeModifier() == ArrayType::Normal && - A.getIndexTypeQualifier() == 0 && + assert(A.getIndexTypeQualifier() == 0 && "FIXME: We only handle trivial array types so far!"); - if (A.getSizeExpr() == 0) { - // int X[] -> [0 x int] - return llvm::ArrayType::get(ConvertType(A.getElementType()), 0); - } else { - assert(0 && "FIXME: VLAs not implemented yet!"); - } + // VLAs resolve to the innermost element type; this matches + // the return of alloca, and there isn't any obviously better choice. + return ConvertType(A.getElementType()); + } + case Type::IncompleteArray: { + const IncompleteArrayType &A = cast<IncompleteArrayType>(Ty); + assert(A.getIndexTypeQualifier() == 0 && + "FIXME: We only handle trivial array types so far!"); + // int X[] -> [0 x int] + return llvm::ArrayType::get(ConvertType(A.getElementType()), 0); } case Type::ConstantArray: { const ConstantArrayType &A = cast<ConstantArrayType>(Ty); |