From 8165605dfb926561bcbc64310bec4106a70dd1e1 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 1 May 2012 19:49:42 +0000 Subject: [PATCH] Implement simplify_type traits for redecl_iterator. Based on Chandler Carruth's feedback on r155869. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155929 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclBase.h | 17 +++++++++++++++++ lib/Sema/SemaLookup.cpp | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 555ce3c4b6..6382bf3694 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -1632,6 +1632,23 @@ struct cast_convert_val< const ::clang::DeclContext, FromTy*, FromTy*> { } }; +// simplify_type - Allow clients to treat redecl_iterators just like Decl +// pointers when using casting operators. +template<> struct simplify_type< ::clang::Decl::redecl_iterator> { + typedef ::clang::Decl *SimpleType; + static SimpleType getSimplifiedValue(const ::clang::Decl::redecl_iterator + &Val) { + return Val; + } +}; +template<> struct simplify_type { + typedef ::clang::Decl *SimpleType; + static SimpleType getSimplifiedValue(const ::clang::Decl::redecl_iterator + &Val) { + return Val; + } +}; + } // end namespace llvm #endif diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 3a6e290326..78a9905155 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -1069,7 +1069,7 @@ static NamedDecl *getVisibleDecl(NamedDecl *D) { for (Decl::redecl_iterator RD = D->redecls_begin(), RDEnd = D->redecls_end(); RD != RDEnd; ++RD) { - if (NamedDecl *ND = dyn_cast(&*RD)) { + if (NamedDecl *ND = dyn_cast(RD)) { if (LookupResult::isVisible(ND)) return ND; } -- 2.40.0