Page MenuHomePhabricator

[clangd] targetDecl() returns only NamedDecls.
ClosedPublic

Authored by sammccall on Fri, Jan 3, 8:34 AM.

Details

Summary

While it's perfectly reasonable for non-named decls such as
static_assert to resolve to themselves:

  • nothing else ever resolves to them
  • features based on references (hover, highlight, find refs etc) tend to be uninteresting where only trivial references are possible
  • returning NamedDecl is a more convenient API (we cast to it in many places)
  • this aligns closer to findExplicitReferences/explicitReferenceTargets

This fixes a crash in explicitReferenceTargets: if the target is a
non-named decl then there's an invalid unchecked cast to NamedDecl.

In practice this means when hovering over e.g. a static_assert:

  • before ac3f9e4842, we would show a (boring) hover card
  • after ac3f9e4842, we would crash
  • after this patch, we will show nothing

Diff Detail

Event Timeline

sammccall created this revision.Fri, Jan 3, 8:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptFri, Jan 3, 8:34 AM

Unit tests: pass. 61180 tests passed, 0 failed and 729 were skipped.

clang-tidy: pass.

clang-format: pass.

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

This revision is now accepted and ready to land.Fri, Jan 3, 8:52 AM
This revision was automatically updated to reflect the committed changes.