From da844b3483669c64d02082ff2a9e68d46bd00c1f Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 3 Jan 2013 04:05:19 +0000 Subject: [PATCH] Use early returns to reduce indentation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171457 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 65 ++++++++++++++++++++++--------------------- 1 file 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(ThisDecl); + if (!VD) + return; + // Now we have parsed the initializer and can update the table of magic // tag values. - if (ThisDecl && ThisDecl->hasAttr()) { - const VarDecl *VD = dyn_cast(ThisDecl); - if (VD && VD->getType()->isIntegralOrEnumerationType()) { - for (specific_attr_iterator - I = ThisDecl->specific_attr_begin(), - E = ThisDecl->specific_attr_end(); - 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() || + !VD->getType()->isIntegralOrEnumerationType()) + return; + + for (specific_attr_iterator + I = ThisDecl->specific_attr_begin(), + E = ThisDecl->specific_attr_end(); + 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()); } } -- 2.40.0