[clang-tools-extra] [clangd] Support .clangd command line modifications for C++ modules (PR #122606)
kadir çetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 17 06:02:03 PST 2025
================
@@ -39,7 +40,25 @@ class MockDirectoryCompilationDatabase : public MockCompilationDatabase {
void addFile(llvm::StringRef Path, llvm::StringRef Contents);
std::unique_ptr<ProjectModules> getProjectModules(PathRef) const override {
- return scanningProjectModules(MockedCDBPtr, TFS);
+ auto Modules = scanningProjectModules(MockedCDBPtr, TFS);
+ Modules->setCommandProvider(
+ [this](tooling::CompileCommand &Command, PathRef) {
+ for (auto &Flag : ExcludeFlags) {
+ auto const It = std::find(Command.CommandLine.begin(),
+ Command.CommandLine.end(), Flag);
+ if (It != Command.CommandLine.end())
+ Command.CommandLine.erase(It);
+ }
+ });
+ return Modules;
+ }
+
+ void addExtraClangFlag(std::string Flag) {
+ this->ExtraClangFlags.push_back(std::move(Flag));
----------------
kadircet wrote:
`ExtraClangFlags` are already public, you can directly update them un the relevant tests.
https://github.com/llvm/llvm-project/pull/122606
More information about the cfe-commits
mailing list