Closed i-ky closed 1 year ago
Also in the following code:
enum class Foo {Bar, Baz};
void test() {
using enum Foo;
Bar;
}
hovering over Bar;
(line 5) gives the following tip:
Note the hex value (pointer address?) instead of enum
name.
Also in the following code [...] hovering over Bar; (line 5) gives the following tip
For tracking purposes, could you please file this as a separate issue?
For tracking purposes, could you please file this as a separate issue?
Seems you have already done so (#1283). Thanks!
For tracking purposes, could you please file this as a separate issue?
Seems you have already done so (#1283). Thanks!
No, that one is yet another issue about the color of the Foo
token in using enum Foo
OK, created #1284.
The problem seems to be that DS.getTypeSpecType()
returns DeclSpec::TST_unspecified
which is not handled in the switch
.
The following patch fixes the crash and provides the correct completion candidate (Foo
), but to me it looks like it only fixes the symptom rather than the underlying issue.
But maybe this is a good starting point for someone with more knowledge in that area. According to git blame
, @urnathan wrote most of this code.
diff --git c/clang/lib/Sema/SemaDeclCXX.cpp i/clang/lib/Sema/SemaDeclCXX.cpp
index bad298c8c8..94c57ae74a 100644
--- c/clang/lib/Sema/SemaDeclCXX.cpp
+++ i/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11855,6 +11855,9 @@ Decl *Sema::ActOnUsingEnumDeclaration(Scope *S, AccessSpecifier AS,
case DeclSpec::TST_enum:
break;
+ case DeclSpec::TST_unspecified:
+ return nullptr;
+
case DeclSpec::TST_typename:
Diag(DS.getTypeSpecTypeLoc(), diag::err_using_enum_is_dependent);
return nullptr;
--------------------------------------------------
That patch is tempting, it's not obvious what the right pattern is.
Sent https://reviews.llvm.org/D134243, which is a maybe-slightly-clearer way to get the same thing.
On 9/19/22 07:00, Tom Praschan wrote:
The problem seems to be that |DS.getTypeSpecType()| returns |DeclSpec::TST_unspecified| which is not handled in the |switch|.
The following patch fixes the crash and provides the correct completion candidate (|Foo|), but to me it looks like it only fixes the symptom rather than the underlying issue.
this may well be mooted by fixing #57659, which I'm working on
nathan
-- Nathan Sidwell
Crash occurs when user types
using enum ...
.Can be reproduced with the following code (
test.cpp
):and the following configuration (
.clangd
):Jump to function body using VS Code (but the crash can be observed with other editors too):
Start typing
using enum Foo;
, after typingF
clangd crashes.I am using clangd compiled from source (updated every morning) with a little patch of mine (which should not affect this behaviour).
Logs
Logs obtained from VS Code, but the same crash can be experienced with Kate editor and it's built-in LSP Client plugin. To shorten the logs I've actually pastedCtrl +Space
using enum F
from clipboard and triggered autocomplete withSystem information
Output of
clangd --version
:Editor/LSP plugin:
Operating system: Ubuntu 22.04