VitaNuo added inline comments.

================
Comment at: clang-tools-extra/clangd/Hover.cpp:663
+  const auto *Var = dyn_cast<VarDecl>(D);
+  if (Var && !llvm::isa<ParmVarDecl>(Var)) {
     if (const Expr *Init = Var->getInit())
----------------
VitaNuo wrote:
> hokein wrote:
> > We're ignoring all `ParmVarDecl` cases, 
> > 
> > The crash here is for broken code. For the crash case, the AST node looks 
> > like 
> > 
> > ```
> > `-ParmVarDecl 0x563b7cc853c0 <col:10, col:20> col:14 invalid param 
> > 'Foo':'Foo' cinit
> >     `-OpaqueValueExpr 0x563b7cc854a0 <col:20> 'Foo':'Foo'
> > ```
> > 
> > One alternative is to exclude invalid `VarDecl`, then the Hover feature 
> > still keep working on valid `ParmVarDecl`.
> > 
> > ```
> > if (const auto* Var = dyn_cast<VarDecl>(D); Var && !Var->isInvalidDecl()) {
> >    ...
> > }
> > ```
> Why would you do that?
Sorry this was an unintended comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153015

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

Reply via email to