diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-01-03 04:05:19 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-01-03 04:05:19 +0000 |
commit | da844b3483669c64d02082ff2a9e68d46bd00c1f (patch) | |
tree | e8e1ac3c362d0b78eb68698f49754783322efe9f /lib/Sema | |
parent | 5d2faa41bc63a2a29535ae3dbbc99daabf14ea2f (diff) |
Use early returns to reduce indentation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171457 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 26aa5de009..624f40582b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -7344,40 +7344,43 @@ Sema::FinalizeDeclaration(Decl *ThisDecl) { // Note that we are no longer parsing the initializer for this declaration. ParsingInitForAutoVars.erase(ThisDecl); + const VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl); + if (!VD) + return; + // Now we have parsed the initializer and can update the table of magic // tag values. - if (ThisDecl && ThisDecl->hasAttr<TypeTagForDatatypeAttr>()) { - const VarDecl *VD = dyn_cast<VarDecl>(ThisDecl); - if (VD && VD->getType()->isIntegralOrEnumerationType()) { - for (specific_attr_iterator<TypeTagForDatatypeAttr> - I = ThisDecl->specific_attr_begin<TypeTagForDatatypeAttr>(), - E = ThisDecl->specific_attr_end<TypeTagForDatatypeAttr>(); - I != E; ++I) { - const Expr *MagicValueExpr = VD->getInit(); - if (!MagicValueExpr) { - continue; - } - llvm::APSInt MagicValueInt; - if (!MagicValueExpr->isIntegerConstantExpr(MagicValueInt, Context)) { - Diag(I->getRange().getBegin(), - diag::err_type_tag_for_datatype_not_ice) - << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange(); - continue; - } - if (MagicValueInt.getActiveBits() > 64) { - Diag(I->getRange().getBegin(), - diag::err_type_tag_for_datatype_too_large) - << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange(); - continue; - } - uint64_t MagicValue = MagicValueInt.getZExtValue(); - RegisterTypeTagForDatatype(I->getArgumentKind(), - MagicValue, - I->getMatchingCType(), - I->getLayoutCompatible(), - I->getMustBeNull()); - } + if (!VD->hasAttr<TypeTagForDatatypeAttr>() || + !VD->getType()->isIntegralOrEnumerationType()) + return; + + for (specific_attr_iterator<TypeTagForDatatypeAttr> + I = ThisDecl->specific_attr_begin<TypeTagForDatatypeAttr>(), + E = ThisDecl->specific_attr_end<TypeTagForDatatypeAttr>(); + I != E; ++I) { + const Expr *MagicValueExpr = VD->getInit(); + if (!MagicValueExpr) { + continue; + } + llvm::APSInt MagicValueInt; + if (!MagicValueExpr->isIntegerConstantExpr(MagicValueInt, Context)) { + Diag(I->getRange().getBegin(), + diag::err_type_tag_for_datatype_not_ice) + << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange(); + continue; + } + if (MagicValueInt.getActiveBits() > 64) { + Diag(I->getRange().getBegin(), + diag::err_type_tag_for_datatype_too_large) + << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange(); + continue; } + uint64_t MagicValue = MagicValueInt.getZExtValue(); + RegisterTypeTagForDatatype(I->getArgumentKind(), + MagicValue, + I->getMatchingCType(), + I->getLayoutCompatible(), + I->getMustBeNull()); } } |