[PATCH] D155392: [clangd] add a config knob to disable modules

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 15 23:54:27 PDT 2023


sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

We don't yet have any intentional modules support:
https://github.com/clangd/clangd/issues/1293

However if the user has modules-related flags in their CDB, modules will still
be enabled inside clang.

- for some configurations this works well enough, apparently. We should allow them to keep using this config if they wish, though unsupported.
- for other configurations this is crashy/buggy. We can't really control the behavior/stability, so long-term this should not be the default.
- there is no flag to disable modules if when using `-std=c++20`. Since clangd does not support modules, we should provide a mechanism.
- in future we're likely to explicitly add modules support. This will not be a simple passthrough of flags to clang, so we'll need another mode.

This patch adds a config option:

  CompileFlags:
    NaiveModules: false

For now, the default is true, and modules are internally enabled/disabled
according to compile flags. When set to false, we force Modules/CPlusPlusModules
lang opts off.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155392

Files:
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/ModulesTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155392.540762.patch
Type: text/x-patch
Size: 8137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230716/88b60ef3/attachment.bin>


More information about the cfe-commits mailing list