[cfe-commits] r59157 - /cfe/trunk/lib/Sema/SemaDecl.cpp
Chris Lattner
sabre at nondot.org
Wed Nov 12 11:48:22 PST 2008
Author: lattner
Date: Wed Nov 12 13:48:13 2008
New Revision: 59157
URL: http://llvm.org/viewvc/llvm-project?rev=59157&view=rev
Log:
Restructure code to encourage fallthrough, no functionality change.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=59157&r1=59156&r2=59157&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov 12 13:48:13 2008
@@ -2482,16 +2482,19 @@
// 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<VariableArrayType>(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<VariableArrayType>(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();
}
More information about the cfe-commits
mailing list