This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Simplify "preferred" vs "definition" logic a bit in XRefs AST code.
ClosedPublic

Authored by sammccall on Jan 24 2020, 9:31 AM.

Details

Summary

Now Preferred is always the canonical (first) decl, Definition is always the def
if available.

In practice the index was already forcing this behaviour anyway, so there's no
change. (Unless you weren't using this index, in which case this patch makes
textDocument/declaration and toggling work as expected).

Diff Detail

Event Timeline

sammccall created this revision.Jan 24 2020, 9:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 24 2020, 9:31 AM

Unit tests: fail. 62173 tests passed, 5 failed and 815 were skipped.

failed: libc++.std/language_support/cmp/cmp_partialord/partialord.pass.cpp
failed: libc++.std/language_support/cmp/cmp_strongeq/cmp.strongeq.pass.cpp
failed: libc++.std/language_support/cmp/cmp_strongord/strongord.pass.cpp
failed: libc++.std/language_support/cmp/cmp_weakeq/cmp.weakeq.pass.cpp
failed: libc++.std/language_support/cmp/cmp_weakord/weakord.pass.cpp

clang-tidy: fail. clang-tidy found 0 errors and 1 warnings. 1 of them are added as review comments below (why?).

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

kadircet added inline comments.Jan 27 2020, 6:54 AM
clang-tools-extra/clangd/XRefs.cpp
257

Is it possible for this check to ever fail? I think it is safe to just perform a llvm::cast instead of dyn_cast.
also why not perform this before getting definition?

278

maybe inline getDefinition to here

also please fix clang-tidy and format warnings

sammccall updated this revision to Diff 252689.Mar 25 2020, 3:17 PM
sammccall marked 3 inline comments as done.

address comments, rebase

clang-tools-extra/clangd/XRefs.cpp
257

Done. (I thought there was such a case, but I was thinking about D vs OrigD in IndexDataConusmer, and this happens in one of the rare cases where D isn't the canonical decl of OrigD)

sammccall updated this revision to Diff 252690.Mar 25 2020, 3:18 PM

clang-format

kadircet accepted this revision.Mar 26 2020, 12:45 AM
This revision is now accepted and ready to land.Mar 26 2020, 12:45 AM
This revision was automatically updated to reflect the committed changes.