[cfe-commits] r39586 - in /cfe/cfe/trunk: AST/Type.cpp include/clang/AST/Type.h
clattner at cs.uiuc.edu
clattner at cs.uiuc.edu
Wed Jul 11 09:45:58 PDT 2007
Author: clattner
Date: Wed Jul 11 11:45:57 2007
New Revision: 39586
URL: http://llvm.org/viewvc/llvm-project?rev=39586&view=rev
Log:
simplify Type::isConstantSizeType based on knowledge that it is only called
on complete types.
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=39586&r1=39585&r2=39586&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Type.cpp (original)
+++ cfe/cfe/trunk/AST/Type.cpp Wed Jul 11 11:45:57 2007
@@ -316,11 +316,9 @@
// cannot contain a VLA member. They can have a flexible array member, however
// the structure is still constant size (C99 6.7.2.1p16).
bool Type::isConstantSizeType(SourceLocation *loc) const {
- if (const ArrayType *ary = dyn_cast<ArrayType>(CanonicalType)) {
- if (Expr *size = ary->getSize()) {
- if (!size->isIntegerConstantExpr(loc))
- return false; // Variable Length Array
- }
+ if (const ArrayType *Ary = dyn_cast<ArrayType>(CanonicalType)) {
+ assert(Ary->getSize() && "Incomplete types don't have a size at all!");
+ return Ary->getSize()->isIntegerConstantExpr(loc); // Variable Length Array?
}
return true;
}
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=39586&r1=39585&r2=39586&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Type.h Wed Jul 11 11:45:57 2007
@@ -244,7 +244,8 @@
/// isConstantSizeType - Return true if this is not a variable sized type,
/// according to the rules of C99 6.7.5p3. If Loc is non-null, it is set to
- /// the location of the subexpression that makes it a vla type.
+ /// the location of the subexpression that makes it a vla type. It is not
+ /// legal to call this on incomplete types.
bool isConstantSizeType(SourceLocation *Loc = 0) const;
/// Compatibility predicates used to check assignment expressions.
More information about the cfe-commits
mailing list