Put a symbols value information which is deduced from initializer
expression into HoverInfo struct.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
clang-tools-extra/clangd/XRefs.cpp | ||
---|---|---|
722 ↗ | (On Diff #204750) | do we want the initializer both here and in Definition? I suspect we'd like to turn off one or the other when both are present. Looking at the examples, I think it's clearer to keep a non-evaluated initializer as part of the Definition (which is mostly as-written), and only include Value if it's evaluated. |
733 ↗ | (On Diff #204750) | why not print the non-evaluated init if it's dependent? |
clang-tools-extra/clangd/unittests/XRefsTests.cpp | ||
920 ↗ | (On Diff #204750) | constexpr may not be required here, I think? |
956 ↗ | (On Diff #204750) | Hmm, actually I'm not sure whether this is TypeLoc vs Decl here. Rather this should be a DeclRefExpr to the VarDecl (result) in the *expanded* CXXRecordDecl. This suggests that maybe the isValueDependent check isn't quite right - the initializer expression is value dependent as spelled, but in the instantiation it's resolved. Not sure if this is fixable. What happens if you comment out the check? |
981 ↗ | (On Diff #204750) | whoa, that's... weird. But fine, I think. (It would be nice to elide the &[] if the index is zero, or maybe print as "1234" + 2 etc) |
- Address comments
clang-tools-extra/clangd/XRefs.cpp | ||
---|---|---|
733 ↗ | (On Diff #204750) | not-necessary anymore, since we only generate value if it can be evaluated. |
clang-tools-extra/clangd/unittests/XRefsTests.cpp | ||
956 ↗ | (On Diff #204750) | yes, and the problem lies in the IndexingAPI, inside handleDeclOccurence implicit instantiations are resolved into templated decls. therefore we lose the template params :/ we can't call expression evaluator on value dependent expressions, there is an assertion in the beginning of EvaluateAsRvalue. |
981 ↗ | (On Diff #204750) | do you think it is worth changing that in printpretty (either the defaults or via some PrintingPolicy option)? |
Implementation LG though please do check that the new test results look useful and not too duplicative
clang-tools-extra/clangd/XRefs.cpp | ||
---|---|---|
723 ↗ | (On Diff #205530) | Maybe add a FIXME about doing this for arbitrary expressions (like sizeof and function calls), not just VarDecl? |
clang-tools-extra/clangd/XRefs.h | ||
106 ↗ | (On Diff #205530) | if exists -> if available? |
clang-tools-extra/clangd/unittests/XRefsTests.cpp | ||
673 ↗ | (On Diff #205530) | are these actually still emitted, or tests not updated? Some of them (e.g. the lambda below!) don't seem useful |
956 ↗ | (On Diff #204750) | OK, let's leave this to later. Can you change the FIXME comment? I think it's misleading as it stands |
981 ↗ | (On Diff #204750) | Let's leave it for now and see if it actually proves annoying. |