[cfe-commits] r155869 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/ARCMigrate/TransGCAttrs.cpp lib/Sema/IdentifierResolver.cpp lib/Sema/SemaLookup.cpp

Chandler Carruth chandlerc at google.com
Mon Apr 30 19:09:31 PDT 2012


On Mon, Apr 30, 2012 at 5:48 PM, David Blaikie <dblaikie at gmail.com> wrote:

> Author: dblaikie
> Date: Mon Apr 30 19:48:43 2012
> New Revision: 155869
>
> URL: http://llvm.org/viewvc/llvm-project?rev=155869&view=rev
> Log:
> Remove ref/value inconsistency in redecl_iterator.
>
> Similar to r155808 - this mistake has been made in a few iterators.
>
> Based on Chandler Carruth's feedback to r155808 I added an implicit
> conversion
> to Decl* to ease adoption/usage. Useful for the pointer comparison, but
> not the
> dyn_cast (due to template argument deduction causing the conversion not to
> be
> used)


If you look at the LLVM iterators that do this, they also specialize a
class template that allows isa and dyn_cast to work transparently.
simplify_type IIRC, but I've not gone and checked.


> - there for future convenience, though. This idiom (op T* for iterators)
> seems to be fairly idiomatic within the LLVM codebase & I'll likely add it
> as I
> fix up the other iterators here.
>
> Modified:
>    cfe/trunk/include/clang/AST/DeclBase.h
>    cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
>    cfe/trunk/lib/Sema/IdentifierResolver.cpp
>    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=155869&r1=155868&r2=155869&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Apr 30 19:48:43 2012
> @@ -692,17 +692,18 @@
>     Decl *Starter;
>
>   public:
> -    typedef Decl*                     value_type;
> -    typedef Decl*                     reference;
> -    typedef Decl*                     pointer;
> +    typedef Decl                     value_type;
> +    typedef value_type&              reference;
> +    typedef value_type*              pointer;
>     typedef std::forward_iterator_tag iterator_category;
>     typedef std::ptrdiff_t            difference_type;
>
>     redecl_iterator() : Current(0) { }
>     explicit redecl_iterator(Decl *C) : Current(C), Starter(C) { }
>
> -    reference operator*() const { return Current; }
> +    reference operator*() const { return *Current; }
>     pointer operator->() const { return Current; }
> +    operator pointer() const { return Current; }
>
>     redecl_iterator& operator++() {
>       assert(Current && "Advancing while iterator has reached end");
> @@ -1320,7 +1321,7 @@
>
>     filtered_decl_iterator() : Current() { }
>
> -    /// specific_decl_iterator - Construct a new iterator over a
> +    /// filtered_decl_iterator - Construct a new iterator over a
>     /// subset of the declarations the range [C,
>     /// end-of-declarations). If A is non-NULL, it is a pointer to a
>     /// member function of SpecificDecl that should return true for
>
> Modified: cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp?rev=155869&r1=155868&r2=155869&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp (original)
> +++ cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp Mon Apr 30 19:48:43 2012
> @@ -166,7 +166,7 @@
>
>     for (Decl::redecl_iterator
>            I = D->redecls_begin(), E = D->redecls_end(); I != E; ++I)
> -      if (!isInMainFile((*I)->getLocation()))
> +      if (!isInMainFile(I->getLocation()))
>         return false;
>
>     return true;
>
> Modified: cfe/trunk/lib/Sema/IdentifierResolver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.cpp?rev=155869&r1=155868&r2=155869&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
> +++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Mon Apr 30 19:48:43 2012
> @@ -304,7 +304,7 @@
>     for (Decl::redecl_iterator RD = New->redecls_begin(),
>                             RDEnd = New->redecls_end();
>          RD != RDEnd; ++RD) {
> -      if (*RD == Existing)
> +      if (RD == Existing)
>         return DMK_Replace;
>
>       if (RD->isCanonicalDecl())
>
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=155869&r1=155868&r2=155869&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Apr 30 19:48:43 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;
>     }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120430/8bdd44f5/attachment.html>


More information about the cfe-commits mailing list