This is an archive of the discontinued LLVM Phabricator instance.

[NFC] [C++20] [Modules] [clangd] Add test for code completion for C++20 Named Modules
Changes PlannedPublic

Authored by ChuanqiXu on Nov 9 2022, 12:06 AM.

Details

Reviewers
nridge
sammccall
Summary

For issue https://github.com/llvm/llvm-project/issues/58723. Although we can't say the current status is good (enough), it should be good to add some tests to prevent the current status become worse.

Diff Detail

Event Timeline

ChuanqiXu created this revision.Nov 9 2022, 12:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 9 2022, 12:06 AM
ChuanqiXu requested review of this revision.Nov 9 2022, 12:06 AM
ChuanqiXu added inline comments.Nov 9 2022, 12:12 AM
clang-tools-extra/clangd/test/completion-modules2.test
14

It looks redundant at the first sight. I know we can reduce the size by the following trick:

#ifdef USE_EXPORT
export
#endif
void printA()

...

But this style will become very complex soon as long as the the size increases. An example could be found at: https://github.com/llvm/llvm-project/blob/main/clang/test/CXX/module/module.interface/p2.cpp. It was pretty painful for me to understand and edit the test cases. So I don't like such styles. I prefer the psychology that the somebody's redundancy is another's clearness. And the redundant test cases looks not a problem to me.

ChuanqiXu updated this revision to Diff 474445.Nov 9 2022, 10:48 PM

Add dependency to clangd tests to make sure they can find the corresponding rules.

Set the path to clang correctly.

The failed tests in windows says:

Failed to find compilation database for \\C:\ws\w9\llvm-project\premerge-checks\build\tools\clang\tools\extra\clangd\test\Output\completion-modules.test.tmp\Use.cpp

I think at this point we specifically don't want to commit to preserving particular modules behavior, this is more or less what the unsupported state means (https://github.com/clangd/clangd/issues/1293).

In particular the pattern where modules are built externally by clang, clang must be version-locked to clangd, and module content is never indexed, doesn't seem to be a good foundation for most users, so having the freedom to tear it down later seems better than encouraging people to rely on it.

clang-tools-extra/clangd/test/CMakeLists.txt
2

A dependency on clang here probably isn't acceptable:

  • it's a *large* increase in what needs to be built for check-clangd, which we try quite hard to keep small
  • the conceptual reason is that clangd is consuming modules built by (version-locked) clang, for various reasons this shouldn't be required (not least: users likely don't have a version-locked clang installed)
clang-tools-extra/clangd/test/completion-modules.test
1

We generally find lit tests too hard to maintain for this sort of thing.

In particular:

  • lots of noise added to each test
  • failures are too hard to parse
  • too much redundant setup work duplicated in each testcase
  • substituting filenames tends to run into escaping issues with windows and backslashes, etc
  • test scope ends up being too large
  • use of real filesystem doesn't verify the implementation is VFS-clean

It's usually OK to have a single smoke test if needed, but generally these are written as unittests.

ChuanqiXu planned changes to this revision.Nov 10 2022, 5:25 AM

Thanks for the explanation. I got your point.