summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-12 19:48:13 +0000
committerChris Lattner <sabre@nondot.org>2008-11-12 19:48:13 +0000
commitb5da7a342c82b7be23bf07804bd395c4a1ac5f47 (patch)
tree25263dd9aa34c6bcecb25cb79b641cb427756c50 /clang/lib/Sema
parente7d1cdb6fd67397d3c3649b259ef43b0d2deb61d (diff)
downloadbcm5719-llvm-b5da7a342c82b7be23bf07804bd395c4a1ac5f47.tar.gz
bcm5719-llvm-b5da7a342c82b7be23bf07804bd395c4a1ac5f47.zip
Restructure code to encourage fallthrough, no functionality change.
llvm-svn: 59157
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3484849161f..bab55bf8293 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/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<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();
}
OpenPOWER on IntegriCloud