From f8c12146fa2153a6d97b7c92d27d2ece0cd26e79 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Sun, 3 Feb 2013 16:10:26 +0000 Subject: [PATCH] Remove unneeded const_casts git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174287 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclTemplate.h | 6 ++---- include/clang/ASTMatchers/ASTMatchers.h | 8 +++----- lib/AST/Decl.cpp | 6 ++---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index e5e69af049..547490dea3 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -1464,8 +1464,7 @@ public: = SpecializedTemplate.dyn_cast()) return PartialSpec->PartialSpecialization; - return const_cast( - SpecializedTemplate.get()); + return SpecializedTemplate.get(); } /// \brief Retrieve the class template or class template partial @@ -1477,8 +1476,7 @@ public: = SpecializedTemplate.dyn_cast()) return PartialSpec->PartialSpecialization; - return const_cast( - SpecializedTemplate.get()); + return SpecializedTemplate.get(); } /// \brief Retrieve the set of template arguments that should be used diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index ffffe52c2c..9dbd5d18d9 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -1501,9 +1501,8 @@ inline internal::PolymorphicMatcherWithParam1< internal::HasDeclarationMatcher, /// FIXME: Overload to allow directly matching types? AST_MATCHER_P(CXXMemberCallExpr, on, internal::Matcher, InnerMatcher) { - const Expr *ExprNode = const_cast(Node) - .getImplicitObjectArgument() - ->IgnoreParenImpCasts(); + const Expr *ExprNode = Node.getImplicitObjectArgument() + ->IgnoreParenImpCasts(); return (ExprNode != NULL && InnerMatcher.matches(*ExprNode, Finder, Builder)); } @@ -1649,8 +1648,7 @@ inline internal::Matcher references( AST_MATCHER_P(CXXMemberCallExpr, onImplicitObjectArgument, internal::Matcher, InnerMatcher) { - const Expr *ExprNode = - const_cast(Node).getImplicitObjectArgument(); + const Expr *ExprNode = Node.getImplicitObjectArgument(); return (ExprNode != NULL && InnerMatcher.matches(*ExprNode, Finder, Builder)); } diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index ed2a0c36fd..cdf921de4a 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -587,8 +587,7 @@ void NamedDecl::ClearLinkageCache() { if (const CXXRecordDecl *record = dyn_cast(this)) clearLinkageForClass(record); - if (ClassTemplateDecl *temp = - dyn_cast(const_cast(this))) { + if (ClassTemplateDecl *temp = dyn_cast(this)) { // Clear linkage for the template pattern. CXXRecordDecl *record = temp->getTemplatedDecl(); record->HasCachedLinkage = 0; @@ -601,8 +600,7 @@ void NamedDecl::ClearLinkageCache() { } // Clear cached linkage for function template decls, too. - if (FunctionTemplateDecl *temp = - dyn_cast(const_cast(this))) { + if (FunctionTemplateDecl *temp = dyn_cast(this)) { temp->getTemplatedDecl()->ClearLinkageCache(); for (FunctionTemplateDecl::spec_iterator i = temp->spec_begin(), e = temp->spec_end(); i != e; ++i) -- 2.40.0