lebedev.ri added a comment.

In D57787#1387406 <https://reviews.llvm.org/D57787#1387406>, @aaron.ballman 
wrote:

> LGTM aside from a nit.


Thank you for the review.



================
Comment at: clang-tidy/modernize/AvoidCArraysCheck.cpp:35
+  const clang::DeclContext *DC = Node.getDeclContext();
+  const clang::FunctionDecl *FD = llvm::dyn_cast<clang::FunctionDecl>(DC);
+  if (!FD)
----------------
aaron.ballman wrote:
> JonasToth wrote:
> > lebedev.ri wrote:
> > > lebedev.ri wrote:
> > > > JonasToth wrote:
> > > > > There is `FunctionDecl->castToDeclContext()` which is probably a 
> > > > > better fit here.
> > > > I'm guessing you meant `cast*From*DeclContext()`.
> > > > Interesting, that function is never once used.
> > > > And it uses `static_cast<>()`..
> > > I'm not too sure about this.
> > > Given `ParmVarDecl`, are we sure it's `DeclContext` is *always* 
> > > `FunctionDecl`?
> > From Doc "Represents a parameter to a function. " so i think it has always 
> > a `FunctionDecl` (or subclass) as DeclContext.
> > 
> > Maybe that function is a relict? I just saw it in the docs too and thought 
> > it makes sense to use it. No opinion on that, @aaron.ballman do you know 
> > more on that?
> > From Doc "Represents a parameter to a function. " so i think it has always 
> > a FunctionDecl (or subclass) as DeclContext.
> 
> `ObjCMethodDecl` is not a subclass of `FunctionDecl`, yet it contains 
> `ParmVarDecl` objects and is a `DeclContext`.
> 
> I would use `dyn_cast` here instead.
Aha!


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57787/new/

https://reviews.llvm.org/D57787



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to