diff options
-rw-r--r-- | AST/Type.cpp | 16 | ||||
-rw-r--r-- | include/clang/AST/Type.h | 5 |
2 files changed, 21 insertions, 0 deletions
diff --git a/AST/Type.cpp b/AST/Type.cpp index bb031cb656..c078bee909 100644 --- a/AST/Type.cpp +++ b/AST/Type.cpp @@ -235,6 +235,22 @@ const VariableArrayType *Type::getAsVariablyModifiedType() const { return 0; } +bool Type::isIncompleteArrayType() const { + if (const VariableArrayType *VAT = getAsVariableArrayType()) { + if (!VAT->getSizeExpr()) + return true; + } + return false; +} + +const VariableArrayType *Type::getAsIncompleteArrayType() const { + if (const VariableArrayType *VAT = getAsVariableArrayType()) { + if (!VAT->getSizeExpr()) + return VAT; + } + return 0; +} + const RecordType *Type::getAsRecordType() const { // If this is directly a reference type, return it. if (const RecordType *RTy = dyn_cast<RecordType>(this)) diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index ce35c4c3f0..bdcef4a575 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -263,6 +263,10 @@ public: /// types that have a non-constant expression. This does not include "[]". bool isVariablyModifiedType() const; + /// isIncompleteArrayType (C99 6.2.5p22) - Return true for variable array + /// types that don't have any expression ("[]"). + bool isIncompleteArrayType() const; + /// Helper methods to distinguish type categories. All type predicates /// operate on the canonical type, ignoring typedefs. @@ -313,6 +317,7 @@ public: const ArrayType *getAsArrayType() const; const ConstantArrayType *getAsConstantArrayType() const; const VariableArrayType *getAsVariableArrayType() const; + const VariableArrayType *getAsIncompleteArrayType() const; const VariableArrayType *getAsVariablyModifiedType() const; const RecordType *getAsRecordType() const; const RecordType *getAsStructureType() const; |