Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
thanks.
| clang-tools-extra/clangd/unittests/HoverTests.cpp | ||
|---|---|---|
| 3727 | I believe this case should trigger a crash, but I don't see the crash with a trunk-built clangd, do we miss something here? | |
thanks!
| clang-tools-extra/clangd/unittests/HoverTests.cpp | ||
|---|---|---|
| 3727 | It crashes on invalid code. I've inspected two user workspaces: class Foo{};
void foo(Foo param = nullptr);void foo(ClassName param = functionReturningObjectOfSimilarSoundingButUnrelatedClass()); I guess clangd is not even expected to act soundly in the face of non-compiling code. | |
| clang-tools-extra/clangd/Hover.cpp | ||
|---|---|---|
| 663 | 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()) {
...
} | |
| clang-tools-extra/clangd/unittests/HoverTests.cpp | ||
| 3727 | thanks for the clarification. That makes sense. We can still use these broken code (the first one should be good enough) in the HoverTest, we need to add a magic comment /* error-ok */. | |
Thanks, looks good, just one nit to simplify the unittest.
| clang-tools-extra/clangd/unittests/HoverTests.cpp | ||
|---|---|---|
| 3726 | nit: instead of creating a completely-new TEST, it seems simpler to just add a testcase in the existing TEST(Hover, All). {R"cpp(// Should not crash on an invalid param decl.
class Foo {};
// error-ok
void foo(Foo [[fo^o]] = nullptr);
)cpp",
[](HoverInfo &HI) {
HI.Name = "foo";
HI.Type = "Foo";
HI.Kind = index::SymbolKind::Parameter;
HI.NamespaceScope = "";
HI.LocalScope = "foo::";
HI.Definition = "Foo foo = <null expr>";
}}, | |
Thanks!
| clang-tools-extra/clangd/unittests/HoverTests.cpp | ||
|---|---|---|
| 3726 | I'm not sure I agree. The Hover, All test takes already about 5 seconds to scroll through on the screen :) On top of that, other test cases that are a result of crash fixes seem to be separate too. | |
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()) { ... }