@@ -1050,10 +1050,10 @@ static void handleDiagnoseAsBuiltinAttr(Sema &S, Decl *D,
1050
1050
FunctionDecl *AttrFD = [&]() -> FunctionDecl * {
1051
1051
if (!AL.isArgExpr (0 ))
1052
1052
return nullptr ;
1053
- auto *F = dyn_cast_or_null <DeclRefExpr>(AL.getArgAsExpr (0 ));
1053
+ auto *F = dyn_cast_if_present <DeclRefExpr>(AL.getArgAsExpr (0 ));
1054
1054
if (!F)
1055
1055
return nullptr ;
1056
- return dyn_cast_or_null <FunctionDecl>(F->getFoundDecl ());
1056
+ return dyn_cast_if_present <FunctionDecl>(F->getFoundDecl ());
1057
1057
}();
1058
1058
1059
1059
if (!AttrFD || !AttrFD->getBuiltinID (true )) {
@@ -1452,7 +1452,7 @@ static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) {
1452
1452
if (!T.hasQualifiers () && T->isTypedefNameType ()) {
1453
1453
// Find the template name, if this type names a template specialization.
1454
1454
const TemplateDecl *Template = nullptr ;
1455
- if (const auto *CTSD = dyn_cast_or_null <ClassTemplateSpecializationDecl>(
1455
+ if (const auto *CTSD = dyn_cast_if_present <ClassTemplateSpecializationDecl>(
1456
1456
T->getAsCXXRecordDecl ())) {
1457
1457
Template = CTSD->getSpecializedTemplate ();
1458
1458
} else if (const auto *TST = T->getAs <TemplateSpecializationType>()) {
@@ -2643,10 +2643,11 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
2643
2643
bool IsUnavailable = AL.getUnavailableLoc ().isValid ();
2644
2644
bool IsStrict = AL.getStrictLoc ().isValid ();
2645
2645
StringRef Str;
2646
- if (const auto *SE = dyn_cast_or_null <StringLiteral>(AL.getMessageExpr ()))
2646
+ if (const auto *SE = dyn_cast_if_present <StringLiteral>(AL.getMessageExpr ()))
2647
2647
Str = SE->getString ();
2648
2648
StringRef Replacement;
2649
- if (const auto *SE = dyn_cast_or_null<StringLiteral>(AL.getReplacementExpr ()))
2649
+ if (const auto *SE =
2650
+ dyn_cast_if_present<StringLiteral>(AL.getReplacementExpr ()))
2650
2651
Replacement = SE->getString ();
2651
2652
2652
2653
if (II->isStr (" swift" )) {
@@ -2863,14 +2864,14 @@ static void handleExternalSourceSymbolAttr(Sema &S, Decl *D,
2863
2864
return ;
2864
2865
2865
2866
StringRef Language;
2866
- if (const auto *SE = dyn_cast_or_null <StringLiteral>(AL.getArgAsExpr (0 )))
2867
+ if (const auto *SE = dyn_cast_if_present <StringLiteral>(AL.getArgAsExpr (0 )))
2867
2868
Language = SE->getString ();
2868
2869
StringRef DefinedIn;
2869
- if (const auto *SE = dyn_cast_or_null <StringLiteral>(AL.getArgAsExpr (1 )))
2870
+ if (const auto *SE = dyn_cast_if_present <StringLiteral>(AL.getArgAsExpr (1 )))
2870
2871
DefinedIn = SE->getString ();
2871
2872
bool IsGeneratedDeclaration = AL.getArgAsIdent (2 ) != nullptr ;
2872
2873
StringRef USR;
2873
- if (const auto *SE = dyn_cast_or_null <StringLiteral>(AL.getArgAsExpr (3 )))
2874
+ if (const auto *SE = dyn_cast_if_present <StringLiteral>(AL.getArgAsExpr (3 )))
2874
2875
USR = SE->getString ();
2875
2876
2876
2877
D->addAttr (::new (S.Context ) ExternalSourceSymbolAttr (
@@ -6148,7 +6149,7 @@ static void handleObjCRequiresSuperAttr(Sema &S, Decl *D,
6148
6149
const auto *Method = cast<ObjCMethodDecl>(D);
6149
6150
6150
6151
const DeclContext *DC = Method->getDeclContext ();
6151
- if (const auto *PDecl = dyn_cast_or_null <ObjCProtocolDecl>(DC)) {
6152
+ if (const auto *PDecl = dyn_cast_if_present <ObjCProtocolDecl>(DC)) {
6152
6153
S.Diag (D->getBeginLoc (), diag::warn_objc_requires_super_protocol) << Attrs
6153
6154
<< 0 ;
6154
6155
S.Diag (PDecl->getLocation (), diag::note_protocol_decl);
0 commit comments