From eae0678a8c08cb62f7572188f4ebeac47161c06c Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 10 Apr 2015 11:37:55 +0000 Subject: [PATCH] Reduce dyn_cast<> to isa<> or cast<> where possible. Clang edition. No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234587 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclObjC.cpp | 5 ++--- lib/Sema/SemaExprMember.cpp | 5 ++--- .../Checkers/MallocOverflowSecurityChecker.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index a12f2b1b3b..800abd13e0 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2580,10 +2580,9 @@ Sema::ObjCContainerKind Sema::getObjCContainerKind() const { case Decl::ObjCProtocol: return Sema::OCK_Protocol; case Decl::ObjCCategory: - if (dyn_cast(CurContext)->IsClassExtension()) + if (cast(CurContext)->IsClassExtension()) return Sema::OCK_ClassExtension; - else - return Sema::OCK_Category; + return Sema::OCK_Category; case Decl::ObjCImplementation: return Sema::OCK_Implementation; case Decl::ObjCCategoryImpl: diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp index 212c554715..e421349338 100644 --- a/lib/Sema/SemaExprMember.cpp +++ b/lib/Sema/SemaExprMember.cpp @@ -109,9 +109,8 @@ static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef, NamedDecl *D = *I; if (D->isCXXInstanceMember()) { - if (dyn_cast(D) || dyn_cast(D) - || dyn_cast(D)) - isField = true; + isField |= isa(D) || isa(D) || + isa(D); CXXRecordDecl *R = cast(D->getDeclContext()); Classes.insert(R->getCanonicalDecl()); diff --git a/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp index f38ce77dc6..e91347999d 100644 --- a/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp @@ -142,13 +142,13 @@ private: } } } - else if (isa(E)) { + else if (const auto *ME = dyn_cast(E)) { // No points-to analysis, just look at the member - const Decl * EmeMD = dyn_cast(E)->getMemberDecl(); + const Decl *EmeMD = ME->getMemberDecl(); while (i != e) { --i; - if (isa(i->variable)) { - if (dyn_cast(i->variable)->getMemberDecl() == EmeMD) + if (const auto *ME_i = dyn_cast(i->variable)) { + if (ME_i->getMemberDecl() == EmeMD) i = toScanFor.erase (i); } } -- 2.40.0