https://github.com/Decodetalkers updated https://github.com/llvm/llvm-project/pull/200001
>From 99c6d4935b6ced1dab691d2a115698efcea1b511 Mon Sep 17 00:00:00 2001 From: ShootingStarDragons <[email protected]> Date: Thu, 28 May 2026 00:16:49 +0900 Subject: [PATCH] feat: allow modules work for gcc Remove the command options which is for gcc, and this will erase the wrong error when using gcc, and make modules work --- clang-tools-extra/clangd/CompileCommands.cpp | 10 ++++++++++ clang-tools-extra/clangd/ProjectModules.cpp | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp index 4eda330716f21..80b9cb24a5f00 100644 --- a/clang-tools-extra/clangd/CompileCommands.cpp +++ b/clang-tools-extra/clangd/CompileCommands.cpp @@ -327,6 +327,16 @@ void CommandMangler::operator()(tooling::CompileCommand &Command, return Elem.starts_with("--save-temps") || Elem.starts_with("-save-temps"); }); + llvm::erase_if(Cmd, [](llvm::StringRef FModuleTs) { + return FModuleTs == "-fmodules-ts"; + }); + llvm::erase_if(Cmd, [](llvm::StringRef FDepFormat) { + return FDepFormat.starts_with("-fdeps-format"); + }); + llvm::erase_if(Cmd, [](llvm::StringRef Elm) { + return Elm.starts_with("-fmodule-mapper="); + }); + std::vector<std::string> ToAppend; if (ResourceDir && !HasExact("-resource-dir") && !HasPrefix("-resource-dir=")) ToAppend.push_back(("-resource-dir=" + *ResourceDir)); diff --git a/clang-tools-extra/clangd/ProjectModules.cpp b/clang-tools-extra/clangd/ProjectModules.cpp index 33cbc715e9659..5a9729f088531 100644 --- a/clang-tools-extra/clangd/ProjectModules.cpp +++ b/clang-tools-extra/clangd/ProjectModules.cpp @@ -12,11 +12,16 @@ #include "clang/DependencyScanning/DependencyScanningService.h" #include "clang/Tooling/DependencyScanningTool.h" #include "clang/Tooling/Tooling.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringSet.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/FileUtilities.h" #include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" +#include "llvm/Support/Regex.h" #include "llvm/TargetParser/Host.h" namespace clang::clangd { @@ -213,6 +218,7 @@ std::optional<ModuleDependencyScanner::ModuleDependencyInfo> ModuleDependencyScanner::scan(PathRef FilePath, const ProjectModules::CommandMangler &Mangler) { auto Cmd = getCompileCommandForFile(*CDB, FilePath, Mangler); + if (!Cmd) return std::nullopt; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
