Author: Timm Bäder Date: 2023-09-22T11:23:18+02:00 New Revision: b2bbf6947cae64934ff35a6a467bad34c1096155
URL: https://github.com/llvm/llvm-project/commit/b2bbf6947cae64934ff35a6a467bad34c1096155 DIFF: https://github.com/llvm/llvm-project/commit/b2bbf6947cae64934ff35a6a467bad34c1096155.diff LOG: [clang][Sema][NFC] _or_null -> _if_present Added: Modified: clang/lib/Sema/SemaDeclAttr.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index cc98713241395ec..090a54eedaa07d0 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1050,10 +1050,10 @@ static void handleDiagnoseAsBuiltinAttr(Sema &S, Decl *D, FunctionDecl *AttrFD = [&]() -> FunctionDecl * { if (!AL.isArgExpr(0)) return nullptr; - auto *F = dyn_cast_or_null<DeclRefExpr>(AL.getArgAsExpr(0)); + auto *F = dyn_cast_if_present<DeclRefExpr>(AL.getArgAsExpr(0)); if (!F) return nullptr; - return dyn_cast_or_null<FunctionDecl>(F->getFoundDecl()); + return dyn_cast_if_present<FunctionDecl>(F->getFoundDecl()); }(); if (!AttrFD || !AttrFD->getBuiltinID(true)) { @@ -1452,7 +1452,7 @@ static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) { if (!T.hasQualifiers() && T->isTypedefNameType()) { // Find the template name, if this type names a template specialization. const TemplateDecl *Template = nullptr; - if (const auto *CTSD = dyn_cast_or_null<ClassTemplateSpecializationDecl>( + if (const auto *CTSD = dyn_cast_if_present<ClassTemplateSpecializationDecl>( T->getAsCXXRecordDecl())) { Template = CTSD->getSpecializedTemplate(); } else if (const auto *TST = T->getAs<TemplateSpecializationType>()) { @@ -2643,10 +2643,11 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { bool IsUnavailable = AL.getUnavailableLoc().isValid(); bool IsStrict = AL.getStrictLoc().isValid(); StringRef Str; - if (const auto *SE = dyn_cast_or_null<StringLiteral>(AL.getMessageExpr())) + if (const auto *SE = dyn_cast_if_present<StringLiteral>(AL.getMessageExpr())) Str = SE->getString(); StringRef Replacement; - if (const auto *SE = dyn_cast_or_null<StringLiteral>(AL.getReplacementExpr())) + if (const auto *SE = + dyn_cast_if_present<StringLiteral>(AL.getReplacementExpr())) Replacement = SE->getString(); if (II->isStr("swift")) { @@ -2863,14 +2864,14 @@ static void handleExternalSourceSymbolAttr(Sema &S, Decl *D, return; StringRef Language; - if (const auto *SE = dyn_cast_or_null<StringLiteral>(AL.getArgAsExpr(0))) + if (const auto *SE = dyn_cast_if_present<StringLiteral>(AL.getArgAsExpr(0))) Language = SE->getString(); StringRef DefinedIn; - if (const auto *SE = dyn_cast_or_null<StringLiteral>(AL.getArgAsExpr(1))) + if (const auto *SE = dyn_cast_if_present<StringLiteral>(AL.getArgAsExpr(1))) DefinedIn = SE->getString(); bool IsGeneratedDeclaration = AL.getArgAsIdent(2) != nullptr; StringRef USR; - if (const auto *SE = dyn_cast_or_null<StringLiteral>(AL.getArgAsExpr(3))) + if (const auto *SE = dyn_cast_if_present<StringLiteral>(AL.getArgAsExpr(3))) USR = SE->getString(); D->addAttr(::new (S.Context) ExternalSourceSymbolAttr( @@ -6148,7 +6149,7 @@ static void handleObjCRequiresSuperAttr(Sema &S, Decl *D, const auto *Method = cast<ObjCMethodDecl>(D); const DeclContext *DC = Method->getDeclContext(); - if (const auto *PDecl = dyn_cast_or_null<ObjCProtocolDecl>(DC)) { + if (const auto *PDecl = dyn_cast_if_present<ObjCProtocolDecl>(DC)) { S.Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs << 0; S.Diag(PDecl->getLocation(), diag::note_protocol_decl); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits