This is an archive of the discontinued LLVM Phabricator instance.

[clangd][NFC] Make use of TagDecl inside type for hover on auto
ClosedPublic

Authored by kadircet on Dec 17 2019, 4:01 AM.

Details

Summary

We were traversing AST twice to get the Decl in case of sugared
types(auto, decltype). They seem to be same in practice, so this patch gets rid
of the second traversal and makes use of TagDecl inside QualType instead.

Diff Detail

Event Timeline

kadircet created this revision.Dec 17 2019, 4:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 17 2019, 4:01 AM

Unit tests: pass. 60932 tests passed, 0 failed and 726 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

ilya-biryukov added inline comments.Dec 17 2019, 6:41 AM
clang-tools-extra/clangd/Hover.cpp
353

This might be a functional change in case of typedefs.

Could you check on these cases (not sure if we already have those in the tests):

typedef int int_type;
^auto x = int_type();

struct cls {};
typedef cls cls_type;
^auto y = cls_type();

template <class>
struct templ {};
^auto z = templ<int>();

Note that I don't necessarily think they will change behavior, but they might.

Also happy to LGTM as is if you remove "NFC" from the description. It seems we're potentially changing behvior, but it's not tested currently and we can land this, discover and fix any regreessions later.

kadircet updated this revision to Diff 234291.Dec 17 2019, 6:51 AM
kadircet marked an inline comment as done.
  • Added alias tests, behavior stayed the same.
This revision is now accepted and ready to land.Dec 17 2019, 6:59 AM

Unit tests: pass. 60932 tests passed, 0 failed and 726 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 was automatically updated to reflect the committed changes.