[cfe-commits] r155929 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/Sema/SemaLookup.cpp

David Blaikie dblaikie at gmail.com
Tue May 1 12:49:42 PDT 2012


Author: dblaikie
Date: Tue May  1 14:49:42 2012
New Revision: 155929

URL: http://llvm.org/viewvc/llvm-project?rev=155929&view=rev
Log:
Implement simplify_type traits for redecl_iterator.

Based on Chandler Carruth's feedback on r155869.

Modified:
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=155929&r1=155928&r2=155929&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Tue May  1 14:49:42 2012
@@ -1632,6 +1632,23 @@
   }
 };
 
+// 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<const ::clang::Decl::redecl_iterator> {
+  typedef ::clang::Decl *SimpleType;
+  static SimpleType getSimplifiedValue(const ::clang::Decl::redecl_iterator
+      &Val) {
+    return Val;
+  }
+};
+
 } // end namespace llvm
 
 #endif

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=155929&r1=155928&r2=155929&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue May  1 14:49:42 2012
@@ -1069,7 +1069,7 @@
   
   for (Decl::redecl_iterator RD = D->redecls_begin(), RDEnd = D->redecls_end();
        RD != RDEnd; ++RD) {
-    if (NamedDecl *ND = dyn_cast<NamedDecl>(&*RD)) {
+    if (NamedDecl *ND = dyn_cast<NamedDecl>(RD)) {
       if (LookupResult::isVisible(ND))
         return ND;
     }





More information about the cfe-commits mailing list