]> granicus.if.org Git - clang/commitdiff
Add a predicate/getter when checking for incomplete array types ("[]").
authorSteve Naroff <snaroff@apple.com>
Mon, 21 Jan 2008 22:59:18 +0000 (22:59 +0000)
committerSteve Naroff <snaroff@apple.com>
Mon, 21 Jan 2008 22:59:18 +0000 (22:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46231 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Type.cpp
include/clang/AST/Type.h

index bb031cb656671464294e7ce2bd1c80549ca3d67a..c078bee909143a128f6562bed51e8e9cca32fa67 100644 (file)
@@ -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))
index ce35c4c3f08f685c358a37549dcca7a1ca76a6ee..bdcef4a575d7fafd120d6886162bb3fd87b7149e 100644 (file)
@@ -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;