From: Chris Lattner Date: Wed, 12 Nov 2008 19:48:13 +0000 (+0000) Subject: Restructure code to encourage fallthrough, no functionality change. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=57d5788b45b677463f3132410d6f530ae5a2cf87;p=clang Restructure code to encourage fallthrough, no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59157 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 3484849161..bab55bf829 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2482,16 +2482,19 @@ QualType Sema::TryFixInvalidVariablyModifiedType(QualType T) { // array even when the size isn't an ICE. This is necessary // for compatibility with code that depends on gcc's buggy // constant expression folding, like struct {char x[(int)(char*)2];} - if (const VariableArrayType* VLATy = dyn_cast(T)) { - APValue Result; - if (VLATy->getSizeExpr() && - VLATy->getSizeExpr()->tryEvaluate(Result, Context) && Result.isInt()) { - llvm::APSInt &Res = Result.getInt(); - if (Res > llvm::APSInt(Res.getBitWidth(), Res.isUnsigned())) - return Context.getConstantArrayType(VLATy->getElementType(), - Res, ArrayType::Normal, 0); - } - } + const VariableArrayType* VLATy = dyn_cast(T); + if (!VLATy) return QualType(); + + APValue Result; + if (!VLATy->getSizeExpr() || + !VLATy->getSizeExpr()->tryEvaluate(Result, Context)) + return QualType(); + + assert(Result.isInt() && "Size expressions must be integers!"); + llvm::APSInt &Res = Result.getInt(); + if (Res > llvm::APSInt(Res.getBitWidth(), Res.isUnsigned())) + return Context.getConstantArrayType(VLATy->getElementType(), + Res, ArrayType::Normal, 0); return QualType(); }