[cfe-commits] r46231 - in /cfe/trunk: AST/Type.cpp include/clang/AST/Type.h
Steve Naroff
snaroff at apple.com
Mon Jan 21 14:59:18 PST 2008
Author: snaroff
Date: Mon Jan 21 16:59:18 2008
New Revision: 46231
URL: http://llvm.org/viewvc/llvm-project?rev=46231&view=rev
Log:
Add a predicate/getter when checking for incomplete array types ("[]").
Modified:
cfe/trunk/AST/Type.cpp
cfe/trunk/include/clang/AST/Type.h
Modified: cfe/trunk/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Type.cpp?rev=46231&r1=46230&r2=46231&view=diff
==============================================================================
--- cfe/trunk/AST/Type.cpp (original)
+++ cfe/trunk/AST/Type.cpp Mon Jan 21 16:59:18 2008
@@ -235,6 +235,22 @@
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))
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=46231&r1=46230&r2=46231&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Jan 21 16:59:18 2008
@@ -263,6 +263,10 @@
/// 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 @@
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;
More information about the cfe-commits
mailing list