This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Handle the missing constructor initializers in findExplicitReferences.
ClosedPublic

Authored by hokein on Oct 21 2019, 1:14 AM.

Diff Detail

Event Timeline

hokein created this revision.Oct 21 2019, 1:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2019, 1:14 AM
ilya-biryukov accepted this revision.Oct 21 2019, 1:36 AM

LGTM, thanks!

clang-tools-extra/clangd/FindTarget.cpp
646

This looks misindented. Could you clang-format?

This revision is now accepted and ready to land.Oct 21 2019, 1:36 AM
ilya-biryukov added inline comments.Oct 21 2019, 1:37 AM
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
844

Could you also add a test with the initializer containing a base class? It produces a different kind of CXXConstructorInitializer

Build result: fail - 33623 tests passed, 1 failed and 462 were skipped.

failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt

NIT: there's a typo in the revision title: should be constructor, not consturctor

hokein updated this revision to Diff 226013.Oct 22 2019, 3:11 AM
hokein marked 2 inline comments as done.
  • fix some issues in the existing implementation;
  • add tests for base/delegating initializer;
hokein retitled this revision from [clangd] Handle the missing consturctor initializers in findExplicitReferences. to [clangd] Handle the missing constructor initializers in findExplicitReferences..Oct 22 2019, 3:12 AM

NIT: there's a typo in the revision title: should be constructor, not consturctor

Done.

clang-tools-extra/clangd/unittests/FindTargetTests.cpp
844

Done.

While adding more tests, I discover some issues in the implementation, also fixed them in this patch, please review the patch again.

Build result: fail - 59521 tests passed, 1 failed and 805 were skipped.

failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt

ilya-biryukov added inline comments.Oct 22 2019, 6:03 AM
clang-tools-extra/clangd/FindTarget.cpp
677–684

I believe base initializers are the only ones left, but the comment suggests there are more cases. Maybe change to:

// Base initializers are handled by visting the type loc.

Or am I missing something?

hokein marked an inline comment as done.Oct 22 2019, 6:13 AM
hokein added inline comments.
clang-tools-extra/clangd/FindTarget.cpp
677–684

there are others, delegating initializers.

ilya-biryukov added inline comments.Oct 22 2019, 6:20 AM
clang-tools-extra/clangd/FindTarget.cpp
677–684

Ah, interesting... Could we add them to the tests too?

hokein marked an inline comment as done.Oct 22 2019, 6:26 AM
hokein added inline comments.
clang-tools-extra/clangd/FindTarget.cpp
677–684

it has been added in the tests already, without the change here, the test will trigger the assert(CCI->isAnyMemberInitializer());.

// delegating initializer
class $10^Foo {
  $11^Foo(int$12^);
  $13^Foo(): $14^Foo(111) {}
};

Build result: fail - 59521 tests passed, 1 failed and 805 were skipped.

failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt

This revision was automatically updated to reflect the committed changes.