Determine the access method to a referenced symbol.#172462
Conversation
The access method helps to know in a quick way, what is happening with the referenced symbol somewhere in the code, i.e. is the referenced symbol used as a rvalue object to read a value from or as lvalue object to write some value into. The basic access methods to a referenced symbol can be write and/or read.
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
fe531ed to
d556a72
Compare
- Fix lit tests - Fix unit tests.
d556a72 to
98e1167
Compare
Try to get the function definition before calling analyseParameterUsage. Visit member expressions.
…in_call_hierarchy_item
Honor the client's referenceTags capability for callHierarchy/\nincomingCalls, recover target decls for header symbols when AST\nlookup falls back to the index, and treat compound assignments\nas both read and write accesses.
… items Extend call hierarchy outgoing results to annotate variable/field references with read/write `referenceTags` when supported by the client. - keep function calls untagged (no [clangd] Add outgoing call reference tags with fast-path and stable ordering Compute read/write reference tags for outgoing call hierarchy entries on variables and fields, while keeping function calls untagged. - preserve index-only outgoing call resolution when reference tags are not needed - keep outgoing results deterministically ordered - compute variable/field usage in a single AST traversal - add and update unit/LSP tests for tagged outgoing calls read/write classification) - preserve existing incomingCalls behavior (no functional changes) - update/adjust outgoing-focused tests to cover variable/field tagging
c238a58 to
914239f
Compare
Implement support for the LSP 3.18 PR llvm#2226 textDocument/references Reference item response type. When the client announces textDocument.references.referenceItemsSupport=true, clangd returns Reference[] objects (with nested 'location' and optional 'referenceTags') instead of the legacy flat Location[] array. Changes: - Protocol.h/cpp: Add 'Reference' struct and JSON serializer; parse 'textDocument.references.referenceItemsSupport' client capability. - XRefs.h/cpp: Add 'ReferenceTags' field to ReferencesResult::Reference; introduce 6-arg findReferences() overload with ComputeReferenceTags flag; keep 5-arg overload for backward compatibility. - ClangdServer.h/cpp: Thread ComputeReferenceTags flag through to XRefs. - ClangdLSPServer.h/cpp: Store SupportsReferenceItems capability flag; in onReference() emit Reference[] or legacy ReferenceLocation[] depending on client capability. - Tests: Add LSPTest.ReferencesReturnReferenceItemsWithTags and LSPTest.ReferencesReturnLegacyLocationWithoutReferenceItemsSupport.
71e8b5b to
d041feb
Compare
Update references.test lit to verify the new LSP 3.18 reference items response format. Enable referenceItemsSupport capability in the initialize request, and verify that the response includes: - nested 'location' field instead of flat uri/range - 'referenceTags' array marking the reference as Read (tag value 1) This validates that clangd correctly returns Reference items with semantic information when the client supports it.
… cases Add two new textDocument/references lit tests to cover: - Write reference (referenceTags: [2]): variable assigned via 'w = 5' confirms tag value 2 (ReferenceTag::Write) is emitted. - Function call reference (no referenceTags): calling 'func()' produces a Reference item with only 'location'; function calls carry neither Read nor Write access semantics, so 'referenceTags' is absent.
The access method helps to know in a quick way, what is happening with the referenced symbol somewhere in the code, i.e. is the referenced symbol used as a rvalue object to read a value from or as lvalue object to write some value into.
The basic access methods to a referenced symbol can be write and/or read.
Implementation of the LSP issue microsoft/language-server-protocol#2207 and microsoft/language-server-protocol#2226