[cfe-commits] r39289 - in /cfe/cfe/trunk: AST/Type.cpp include/clang/AST/Type.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:42:32 PDT 2007
Author: sabre
Date: Wed Jul 11 11:42:32 2007
New Revision: 39289
URL: http://llvm.org/viewvc/llvm-project?rev=39289&view=rev
Log:
Add Type::isIncompleteType, which implements the algorithm described in
C99 6.2.5.
Modified:
cfe/cfe/trunk/AST/Type.cpp
cfe/cfe/trunk/include/clang/AST/Type.h
Modified: cfe/cfe/trunk/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Type.cpp?rev=39289&r1=39288&r2=39289&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Type.cpp (original)
+++ cfe/cfe/trunk/AST/Type.cpp Wed Jul 11 11:42:32 2007
@@ -27,6 +27,29 @@
return false;
}
+/// isIncompleteType - Return true if this is an incomplete type (C99 6.2.5p1)
+/// - a type that can describe objects, but which lacks information needed to
+/// determine its size.
+bool Type::isIncompleteType() const {
+ switch (getTypeClass()) {
+ default: return false;
+ case Builtin:
+ // Void is the only incomplete builtin type. Per C99 6.2.5p19, it can never
+ // be completed.
+ return isVoidType();
+ case Tagged:
+ // A tagged type (struct/union/enum/class) is incomplete if the decl is a
+ // forward declaration, but not a full definition (C99 6.2.5p22).
+ return !cast<TaggedType>(this)->getDecl()->isDefinition();
+
+ case Array:
+ // An array of unknown size is an incomplete type (C99 6.2.5p22).
+ // FIXME: Implement this.
+ return true; // cast<ArrayType>(this)-> blah.
+ }
+}
+
+
const char *BuiltinType::getName() const {
switch (getKind()) {
default: assert(0 && "Unknown builtin type!");
Modified: cfe/cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Type.h?rev=39289&r1=39288&r2=39289&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Type.h Wed Jul 11 11:42:32 2007
@@ -185,6 +185,10 @@
/// isVoidType - Helper method to determine if this is the 'void' type.
bool isVoidType() const;
+ /// isIncompleteType - Return true if this is an incomplete type (C99 6.2.5p1)
+ /// - a type that can describe objects, but which lacks information needed to
+ /// determine its size (e.g. void, or a fwd declared struct).
+ bool isIncompleteType() const;
virtual void getAsString(std::string &InnerString) const = 0;
@@ -256,6 +260,7 @@
TypeRef ElementType;
/// FIXME: Capture size for VLA or constant size.
+ /// Use this to implement Type::isIncompleteType.
ArrayType(TypeRef et, ArraySizeModifier sm, unsigned tq, Type *can)
: Type(Array, can), SizeModifier(sm), IndexTypeQuals(tq), ElementType(et) {}
More information about the cfe-commits
mailing list