Add warning for c++ member variable shadowing

Jonathan Roelofs via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 7 18:46:15 PST 2017



On 2/7/17 7:30 PM, Saleem Abdulrasool wrote:
>
>
> On Tue, Feb 7, 2017 at 1:09 PM, Jonathan Roelofs 
> <jonathan at codesourcery.com <mailto:jonathan at codesourcery.com>> wrote:
>
>
>
>     On 1/24/17 8:10 PM, Saleem Abdulrasool via cfe-commits wrote:
>
>         Don't use the cast for the check, use isa.  Although, since
>         you use the
>         value later, it is probably better to write this as:
>
>             if (const auto *RD = cast<CXXRecordDecl>(CurContext))
>               CheckShadowInheritedVariabless(Loc, Name.getAsString(),
>         RD, RD);
>
>
>
>     @compnerd: s/cast/dyn_cast/ or s/cast/dyn_cast_or_null/, right?
>
>
> Only in that it looks weird.  There is an assert that CurContext is a 
> CXXRecordDecl, so the cast is perfectly fine.

Oh, I see. the branch is never expected to go the other way... yeah, 
that is a strange, non-idiomatic use of 'if'.


Jon
>
>
>     Jon
>
>
>     -- 
>     Jon Roelofs
>     jonathan at codesourcery.com <mailto:jonathan at codesourcery.com>
>     CodeSourcery / Mentor Embedded
>
>
>
>
> -- 
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170207/a8c25b4e/attachment-0001.html>


More information about the cfe-commits mailing list