diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index a48a7b273e4f..0b73f82639e8 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -4400,16 +4400,10 @@ Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType, CheckReturnStackAddr(*this, RetValExp, lhsType, ReturnLoc); // Check if the return value is null but should not be. - if (Attrs) - for (specific_attr_iterator - I = specific_attr_iterator(Attrs->begin()), - E = specific_attr_iterator(Attrs->end()); - I != E; ++I) { - if (CheckNonNullExpr(*this, RetValExp)) - Diag(ReturnLoc, diag::warn_null_ret) - << (isObjCMethod ? 1 : 0) << RetValExp->getSourceRange(); - break; - } + if (Attrs && hasSpecificAttr(*Attrs) && + CheckNonNullExpr(*this, RetValExp)) + Diag(ReturnLoc, diag::warn_null_ret) + << (isObjCMethod ? 1 : 0) << RetValExp->getSourceRange(); // C++11 [basic.stc.dynamic.allocation]p4: // If an allocation function declared with a non-throwing @@ -7381,10 +7375,7 @@ bool GetMatchingCType( return false; if (VD) { - for (specific_attr_iterator - I = VD->specific_attr_begin(), - E = VD->specific_attr_end(); - I != E; ++I) { + if (TypeTagForDatatypeAttr *I = VD->getAttr()) { if (I->getArgumentKind() != ArgumentKind) { FoundWrongKind = true; return false;