From d44ed56106f185a053283e39401e6bf904ca925f Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Wed, 13 Dec 2023 11:52:51 +0100 Subject: [PATCH 01/22] Compiler Default Include Paths --- src/lib/Lib/AbsoluteCompilationDatabase.cpp | 21 +++++- src/lib/Lib/AbsoluteCompilationDatabase.hpp | 3 +- src/tool/GenerateAction.cpp | 84 ++++++++++++++++++++- 3 files changed, 101 insertions(+), 7 deletions(-) diff --git a/src/lib/Lib/AbsoluteCompilationDatabase.cpp b/src/lib/Lib/AbsoluteCompilationDatabase.cpp index b23b02482..6a3a99719 100644 --- a/src/lib/Lib/AbsoluteCompilationDatabase.cpp +++ b/src/lib/Lib/AbsoluteCompilationDatabase.cpp @@ -51,14 +51,22 @@ static std::vector adjustCommandLine( const std::vector& cmdline, - const std::vector& additional_defines) + const std::vector& additional_defines, + std::unordered_map> const& includePathsByCompiler) { std::vector new_cmdline; std::vector discarded_cmdline; llvm::opt::InputArgList args; StringRef driver_mode; - if(! cmdline.empty()) + + std::vector systemIncludePaths; + + if( ! cmdline.empty()) { + if (auto it = includePathsByCompiler.find(cmdline[0]); it != includePathsByCompiler.end()) { + systemIncludePaths = it->second; + } + std::vector raw_cmdline; raw_cmdline.reserve(cmdline.size()); for(const auto& s : cmdline) @@ -85,6 +93,9 @@ adjustCommandLine( for(const auto& def : additional_defines) new_cmdline.emplace_back(fmt::format("-D{}", def)); + for (auto const& inc : systemIncludePaths) + new_cmdline.emplace_back(fmt::format("-I{}", inc)); + for(unsigned idx = 1; idx < cmdline.size();) { const unsigned old_idx = idx; @@ -168,7 +179,8 @@ AbsoluteCompilationDatabase:: AbsoluteCompilationDatabase( llvm::StringRef workingDir, CompilationDatabase const& inner, - std::shared_ptr config) + std::shared_ptr config, + std::unordered_map> const& includePathsByCompiler) { namespace fs = llvm::sys::fs; namespace path = llvm::sys::path; @@ -187,7 +199,8 @@ AbsoluteCompilationDatabase( cmd.Output = cmd0.Output; cmd.CommandLine = adjustCommandLine( cmd0.CommandLine, - (*config_impl)->defines); + (*config_impl)->defines, + includePathsByCompiler); if(path::is_absolute(cmd0.Directory)) { diff --git a/src/lib/Lib/AbsoluteCompilationDatabase.hpp b/src/lib/Lib/AbsoluteCompilationDatabase.hpp index afb65e876..160e0f084 100644 --- a/src/lib/Lib/AbsoluteCompilationDatabase.hpp +++ b/src/lib/Lib/AbsoluteCompilationDatabase.hpp @@ -43,7 +43,8 @@ class AbsoluteCompilationDatabase AbsoluteCompilationDatabase( llvm::StringRef workingDir, CompilationDatabase const& inner, - std::shared_ptr config); + std::shared_ptr config, + std::unordered_map> const& includePathsByCompiler); std::vector getCompileCommands( diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index edfc8a061..cb4264370 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -18,10 +18,87 @@ #include #include #include +#include namespace clang { namespace mrdocs { +Expected +getCompilerInfo(std::string const& compiler) +{ + std::string const command = compiler + " -v -E -x c++ - < /dev/null 2>&1"; + std::array buffer; + std::string result; + std::unique_ptr pipe(popen(command.c_str(), "r"), pclose); + + if ( ! pipe) + { + return Unexpected(formatError("popen() failed for command \"{}\"", command)); + } + + while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) + { + result += buffer.data(); + } + + return result; +} + +std::vector +parseIncludePaths(std::string const& compilerOutput) +{ + std::vector includePaths; + std::istringstream stream(compilerOutput); + std::string line; + bool capture = false; + + while (std::getline(stream, line)) + { + if (line.find("#include <...> search starts here:") != std::string::npos) + { + capture = true; + continue; + } + if (line.find("End of search list.") != std::string::npos) + { + break; + } + if (capture) + { + line.erase(0, line.find_first_not_of(" ")); + includePaths.push_back(line); + } + } + + return includePaths; +} + +std::unordered_map> +getCompilersDefaultIncludeDir(clang::tooling::CompilationDatabase const& compDb) +{ + std::unordered_map> res; + auto const allCommands = compDb.getAllCompileCommands(); + + for (auto const& cmd : allCommands) { + if ( ! cmd.CommandLine.empty()) { + auto const& compilerPath = cmd.CommandLine[0]; + if (res.contains(compilerPath)) { + continue; + } + + auto const compilerOutput = getCompilerInfo(compilerPath); + if ( ! compilerOutput) { + report::warn("Warning: ", compilerOutput.error()); + continue; + } + std::vector includePaths = parseIncludePaths(*compilerOutput); + res.emplace(compilerPath, std::move(includePaths)); + } + } + + return res; +} + Expected DoGenerateAction() { @@ -65,7 +142,7 @@ DoGenerateAction() toolArgs.inputPaths.size())); auto compilationsPath = files::normalizePath(toolArgs.inputPaths.front()); std::string errorMessage; - MRDOCS_TRY_MSG( + MRDOCS_TRY_MSG( auto& jsonCompilations, tooling::JSONCompilationDatabase::loadFromFile( compilationsPath, @@ -83,9 +160,12 @@ DoGenerateAction() files::makeAbsolute(toolArgs.outputPath, (*config)->workingDir)); + // Get the default include paths for each compiler + auto const defaultIncludePaths = getCompilersDefaultIncludeDir(jsonCompilations); + // Convert relative paths to absolute AbsoluteCompilationDatabase compilations( - workingDir, jsonCompilations, config); + workingDir, jsonCompilations, config, defaultIncludePaths); // Run the tool: this can take a while MRDOCS_TRY( From 4b9f9854dea294b72181e7df33fecd9165395937 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Wed, 13 Dec 2023 14:38:43 +0100 Subject: [PATCH 02/22] fix test runner --- src/test/TestRunner.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/TestRunner.cpp b/src/test/TestRunner.cpp index ab3e6ac0c..6c6aecb23 100644 --- a/src/test/TestRunner.cpp +++ b/src/test/TestRunner.cpp @@ -105,9 +105,12 @@ handleFile( path::replace_extension(expectedPath, xmlGen_->fileExtension()); auto workingDir = files::getParentDir(filePath); + + std::unordered_map> defaultIncludePaths; + // Convert relative paths to absolute AbsoluteCompilationDatabase compilations( - llvm::StringRef(workingDir), SingleFileDB(filePath), config); + llvm::StringRef(workingDir), SingleFileDB(filePath), config, defaultIncludePaths); // Build Corpus auto corpus = CorpusImpl::build( report::Level::debug, config, compilations); From 59d2d7afc5d053638ac32a97c5f5b3909eb201cb Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Wed, 13 Dec 2023 16:27:54 +0100 Subject: [PATCH 03/22] Portable compiler execution --- src/tool/GenerateAction.cpp | 42 +++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index cb4264370..dad837c29 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -13,35 +13,51 @@ #include "lib/Lib/AbsoluteCompilationDatabase.hpp" #include "lib/Lib/ConfigImpl.hpp" #include "lib/Lib/CorpusImpl.hpp" +#include "llvm/Support/Program.h" #include #include #include #include + #include #include namespace clang { namespace mrdocs { -Expected -getCompilerInfo(std::string const& compiler) +std::optional +getCompilerInfo(llvm::StringRef compiler) { - std::string const command = compiler + " -v -E -x c++ - < /dev/null 2>&1"; - std::array buffer; - std::string result; - std::unique_ptr pipe(popen(command.c_str(), "r"), pclose); - - if ( ! pipe) + llvm::SmallString<128> outputPath; + if (auto EC = llvm::sys::fs::createTemporaryFile("compiler-info", "txt", outputPath)) + { + return std::nullopt; + } + + std::optional redirects[] = {llvm::StringRef(), llvm::StringRef(), outputPath.str()}; + std::vector args = {compiler, "-v", "-E", "-x", "c++", "-"}; + + llvm::ErrorOr compilerPath = llvm::sys::findProgramByName(compiler); + if ( ! compilerPath) + { + return std::nullopt; + } + + int result = llvm::sys::ExecuteAndWait(*compilerPath, args, std::nullopt, redirects); + if (result != 0) { - return Unexpected(formatError("popen() failed for command \"{}\"", command)); + llvm::sys::fs::remove(outputPath); + return std::nullopt; } - while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) + auto bufferOrError = llvm::MemoryBuffer::getFile(outputPath); + llvm::sys::fs::remove(outputPath); + if ( ! bufferOrError) { - result += buffer.data(); + return std::nullopt; } - return result; + return bufferOrError.get()->getBuffer().str(); } std::vector @@ -88,7 +104,7 @@ getCompilersDefaultIncludeDir(clang::tooling::CompilationDatabase const& compDb) auto const compilerOutput = getCompilerInfo(compilerPath); if ( ! compilerOutput) { - report::warn("Warning: ", compilerOutput.error()); + report::warn("Warning: could not get compiler info for \"{}\"", compilerPath); continue; } std::vector includePaths = parseIncludePaths(*compilerOutput); From 7b105bd64651f7c8d21debe1dbbf4d1b1b60e1c6 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 15:19:01 +0100 Subject: [PATCH 04/22] class renaming --- ...ionDatabase.cpp => MrDocsCompilationDatabase.cpp} | 12 ++++++------ ...ionDatabase.hpp => MrDocsCompilationDatabase.hpp} | 10 +++++----- src/test/TestRunner.cpp | 4 ++-- src/tool/GenerateAction.cpp | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) rename src/lib/Lib/{AbsoluteCompilationDatabase.cpp => MrDocsCompilationDatabase.cpp} (97%) rename src/lib/Lib/{AbsoluteCompilationDatabase.hpp => MrDocsCompilationDatabase.hpp} (87%) diff --git a/src/lib/Lib/AbsoluteCompilationDatabase.cpp b/src/lib/Lib/MrDocsCompilationDatabase.cpp similarity index 97% rename from src/lib/Lib/AbsoluteCompilationDatabase.cpp rename to src/lib/Lib/MrDocsCompilationDatabase.cpp index 6a3a99719..e344c804c 100644 --- a/src/lib/Lib/AbsoluteCompilationDatabase.cpp +++ b/src/lib/Lib/MrDocsCompilationDatabase.cpp @@ -12,7 +12,7 @@ #include "lib/Support/Debug.hpp" #include "lib/Support/Path.hpp" #include "lib/Lib/ConfigImpl.hpp" -#include "lib/Lib/AbsoluteCompilationDatabase.hpp" +#include "lib/Lib/MrDocsCompilationDatabase.hpp" #include #include #include @@ -175,8 +175,8 @@ adjustCommandLine( return new_cmdline; } -AbsoluteCompilationDatabase:: -AbsoluteCompilationDatabase( +MrDocsCompilationDatabase:: +MrDocsCompilationDatabase( llvm::StringRef workingDir, CompilationDatabase const& inner, std::shared_ptr config, @@ -240,7 +240,7 @@ AbsoluteCompilationDatabase( } std::vector -AbsoluteCompilationDatabase:: +MrDocsCompilationDatabase:: getCompileCommands( llvm::StringRef FilePath) const { @@ -256,7 +256,7 @@ getCompileCommands( } std::vector -AbsoluteCompilationDatabase:: +MrDocsCompilationDatabase:: getAllFiles() const { std::vector allFiles; @@ -267,7 +267,7 @@ getAllFiles() const } std::vector -AbsoluteCompilationDatabase:: +MrDocsCompilationDatabase:: getAllCompileCommands() const { return AllCommands_; diff --git a/src/lib/Lib/AbsoluteCompilationDatabase.hpp b/src/lib/Lib/MrDocsCompilationDatabase.hpp similarity index 87% rename from src/lib/Lib/AbsoluteCompilationDatabase.hpp rename to src/lib/Lib/MrDocsCompilationDatabase.hpp index 160e0f084..f480d95b9 100644 --- a/src/lib/Lib/AbsoluteCompilationDatabase.hpp +++ b/src/lib/Lib/MrDocsCompilationDatabase.hpp @@ -8,8 +8,8 @@ // Official repository: https://github.com/cppalliance/mrdocs // -#ifndef MRDOCS_LIB_TOOL_ABSOLUTECOMPILATIONDATABASE_HPP -#define MRDOCS_LIB_TOOL_ABSOLUTECOMPILATIONDATABASE_HPP +#ifndef MRDOCS_LIB_TOOL_MR_DOCS_COMPILATION_DATABASE_HPP +#define MRDOCS_LIB_TOOL_MR_DOCS_COMPILATION_DATABASE_HPP #include #include @@ -26,7 +26,7 @@ namespace mrdocs { them according to the working directory specified at construction. */ -class AbsoluteCompilationDatabase +class MrDocsCompilationDatabase : public tooling::CompilationDatabase { std::vector AllCommands_; @@ -40,7 +40,7 @@ class AbsoluteCompilationDatabase absolute path by resolving against the specified working directory. */ - AbsoluteCompilationDatabase( + MrDocsCompilationDatabase( llvm::StringRef workingDir, CompilationDatabase const& inner, std::shared_ptr config, @@ -60,5 +60,5 @@ class AbsoluteCompilationDatabase } // mrdocs } // clang -#endif +#endif // MRDOCS_LIB_TOOL_MR_DOCS_COMPILATION_DATABASE_HPP diff --git a/src/test/TestRunner.cpp b/src/test/TestRunner.cpp index 6c6aecb23..1d5224c15 100644 --- a/src/test/TestRunner.cpp +++ b/src/test/TestRunner.cpp @@ -12,9 +12,9 @@ #include "TestArgs.hpp" #include "lib/Support/Error.hpp" #include "lib/Support/Path.hpp" -#include "lib/Lib/AbsoluteCompilationDatabase.hpp" #include "lib/Lib/ConfigImpl.hpp" #include "lib/Lib/CorpusImpl.hpp" +#include "lib/Lib/MrDocsCompilationDatabase.hpp" #include "lib/Lib/SingleFileDB.hpp" #include #include @@ -109,7 +109,7 @@ handleFile( std::unordered_map> defaultIncludePaths; // Convert relative paths to absolute - AbsoluteCompilationDatabase compilations( + MrDocsCompilationDatabase compilations( llvm::StringRef(workingDir), SingleFileDB(filePath), config, defaultIncludePaths); // Build Corpus auto corpus = CorpusImpl::build( diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index dad837c29..f1a09d8d2 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -10,9 +10,9 @@ // #include "ToolArgs.hpp" -#include "lib/Lib/AbsoluteCompilationDatabase.hpp" #include "lib/Lib/ConfigImpl.hpp" #include "lib/Lib/CorpusImpl.hpp" +#include "lib/Lib/MrDocsCompilationDatabase.hpp" #include "llvm/Support/Program.h" #include #include @@ -180,7 +180,7 @@ DoGenerateAction() auto const defaultIncludePaths = getCompilersDefaultIncludeDir(jsonCompilations); // Convert relative paths to absolute - AbsoluteCompilationDatabase compilations( + MrDocsCompilationDatabase compilations( workingDir, jsonCompilations, config, defaultIncludePaths); // Run the tool: this can take a while From 482ba916c71a9e352e1997ba3c88f377dac5fbea Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 15:27:23 +0100 Subject: [PATCH 05/22] better comments --- src/lib/Lib/MrDocsCompilationDatabase.cpp | 8 ++++---- src/lib/Lib/MrDocsCompilationDatabase.hpp | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/lib/Lib/MrDocsCompilationDatabase.cpp b/src/lib/Lib/MrDocsCompilationDatabase.cpp index e344c804c..fc01a7018 100644 --- a/src/lib/Lib/MrDocsCompilationDatabase.cpp +++ b/src/lib/Lib/MrDocsCompilationDatabase.cpp @@ -52,7 +52,7 @@ std::vector adjustCommandLine( const std::vector& cmdline, const std::vector& additional_defines, - std::unordered_map> const& includePathsByCompiler) + std::unordered_map> const& implicitIncludeDirectories) { std::vector new_cmdline; std::vector discarded_cmdline; @@ -63,7 +63,7 @@ adjustCommandLine( if( ! cmdline.empty()) { - if (auto it = includePathsByCompiler.find(cmdline[0]); it != includePathsByCompiler.end()) { + if (auto it = implicitIncludeDirectories.find(cmdline[0]); it != implicitIncludeDirectories.end()) { systemIncludePaths = it->second; } @@ -180,7 +180,7 @@ MrDocsCompilationDatabase( llvm::StringRef workingDir, CompilationDatabase const& inner, std::shared_ptr config, - std::unordered_map> const& includePathsByCompiler) + std::unordered_map> const& implicitIncludeDirectories) { namespace fs = llvm::sys::fs; namespace path = llvm::sys::path; @@ -200,7 +200,7 @@ MrDocsCompilationDatabase( cmd.CommandLine = adjustCommandLine( cmd0.CommandLine, (*config_impl)->defines, - includePathsByCompiler); + implicitIncludeDirectories); if(path::is_absolute(cmd0.Directory)) { diff --git a/src/lib/Lib/MrDocsCompilationDatabase.hpp b/src/lib/Lib/MrDocsCompilationDatabase.hpp index f480d95b9..e2d5f8dad 100644 --- a/src/lib/Lib/MrDocsCompilationDatabase.hpp +++ b/src/lib/Lib/MrDocsCompilationDatabase.hpp @@ -33,18 +33,25 @@ class MrDocsCompilationDatabase llvm::StringMap IndexByFile_; public: - /** Constructor. - - This copies the contents of the source compilation - database. Every relative path is converted into an - absolute path by resolving against the specified - working directory. - */ + /** + * Constructor. + * + * This copies the contents of the source compilation + * database. Every relative path is converted into an + * absolute path by resolving against the specified + * working directory. + * + * @param workingDir The working directory against which relative paths will be resolved. + * @param inner The source compilation database to copy. + * @param config The shared configuration object. + * @param implicitIncludeDirectories A map from compiler executable paths to their respective + * implicit include directories, as determined by the system's compiler. + */ MrDocsCompilationDatabase( llvm::StringRef workingDir, CompilationDatabase const& inner, std::shared_ptr config, - std::unordered_map> const& includePathsByCompiler); + std::unordered_map> const& implicitIncludeDirectories); std::vector getCompileCommands( From 8790ae5e6858cc5280f045bcbc59290273deb4d3 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 15:30:09 +0100 Subject: [PATCH 06/22] just code style --- src/lib/Lib/MrDocsCompilationDatabase.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/Lib/MrDocsCompilationDatabase.cpp b/src/lib/Lib/MrDocsCompilationDatabase.cpp index fc01a7018..76565b916 100644 --- a/src/lib/Lib/MrDocsCompilationDatabase.cpp +++ b/src/lib/Lib/MrDocsCompilationDatabase.cpp @@ -58,7 +58,6 @@ adjustCommandLine( std::vector discarded_cmdline; llvm::opt::InputArgList args; StringRef driver_mode; - std::vector systemIncludePaths; if( ! cmdline.empty()) From 5f58c8d257714c7d81d986ef85081b9cf80c2cea Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 15:32:37 +0100 Subject: [PATCH 07/22] style --- src/lib/Lib/MrDocsCompilationDatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Lib/MrDocsCompilationDatabase.cpp b/src/lib/Lib/MrDocsCompilationDatabase.cpp index 76565b916..3ec5683a3 100644 --- a/src/lib/Lib/MrDocsCompilationDatabase.cpp +++ b/src/lib/Lib/MrDocsCompilationDatabase.cpp @@ -60,7 +60,7 @@ adjustCommandLine( StringRef driver_mode; std::vector systemIncludePaths; - if( ! cmdline.empty()) + if(! cmdline.empty()) { if (auto it = implicitIncludeDirectories.find(cmdline[0]); it != implicitIncludeDirectories.end()) { systemIncludePaths = it->second; From fb67df34e0f48feae683a7dc5d0c3cc164ecbbfe Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 15:36:03 +0100 Subject: [PATCH 08/22] remove unused code --- src/lib/Lib/MrDocsCompilationDatabase.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/lib/Lib/MrDocsCompilationDatabase.cpp b/src/lib/Lib/MrDocsCompilationDatabase.cpp index 3ec5683a3..c7173f985 100644 --- a/src/lib/Lib/MrDocsCompilationDatabase.cpp +++ b/src/lib/Lib/MrDocsCompilationDatabase.cpp @@ -55,7 +55,6 @@ adjustCommandLine( std::unordered_map> const& implicitIncludeDirectories) { std::vector new_cmdline; - std::vector discarded_cmdline; llvm::opt::InputArgList args; StringRef driver_mode; std::vector systemIncludePaths; @@ -103,10 +102,6 @@ adjustCommandLine( if(! arg) { - discarded_cmdline.insert( - discarded_cmdline.end(), - cmdline.begin() + old_idx, - cmdline.begin() + idx); continue; } @@ -158,10 +153,6 @@ adjustCommandLine( // driver::options::OPT__SLASH_Tc )) { - discarded_cmdline.insert( - discarded_cmdline.end(), - cmdline.begin() + old_idx, - cmdline.begin() + idx); continue; } From 0b0848e20741914f2067e15fa14517f85fcd1df2 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 15:42:53 +0100 Subject: [PATCH 09/22] do not find compiler in system paths --- src/tool/GenerateAction.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index f1a09d8d2..03a0e1c2a 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -26,24 +26,21 @@ namespace clang { namespace mrdocs { std::optional -getCompilerInfo(llvm::StringRef compiler) +getCompilerInfo(llvm::StringRef compilerPath) { - llvm::SmallString<128> outputPath; - if (auto EC = llvm::sys::fs::createTemporaryFile("compiler-info", "txt", outputPath)) - { + if ( ! llvm::sys::fs::exists(compilerPath)) { return std::nullopt; } - std::optional redirects[] = {llvm::StringRef(), llvm::StringRef(), outputPath.str()}; - std::vector args = {compiler, "-v", "-E", "-x", "c++", "-"}; - - llvm::ErrorOr compilerPath = llvm::sys::findProgramByName(compiler); - if ( ! compilerPath) + llvm::SmallString<128> outputPath; + if (auto EC = llvm::sys::fs::createTemporaryFile("compiler-info", "txt", outputPath)) { return std::nullopt; } - int result = llvm::sys::ExecuteAndWait(*compilerPath, args, std::nullopt, redirects); + std::optional const redirects[] = {llvm::StringRef(), llvm::StringRef(), outputPath.str()}; + std::vector const args = {compilerPath, "-v", "-E", "-x", "c++", "-"}; + int const result = llvm::sys::ExecuteAndWait(compilerPath, args, std::nullopt, redirects); if (result != 0) { llvm::sys::fs::remove(outputPath); From 12b8d56b48c17cf0538e52fad6fe400932d09de0 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 16:00:09 +0100 Subject: [PATCH 10/22] do not inherit environment from parent process --- src/tool/GenerateAction.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index 03a0e1c2a..6e04e5475 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -39,8 +39,9 @@ getCompilerInfo(llvm::StringRef compilerPath) } std::optional const redirects[] = {llvm::StringRef(), llvm::StringRef(), outputPath.str()}; - std::vector const args = {compilerPath, "-v", "-E", "-x", "c++", "-"}; - int const result = llvm::sys::ExecuteAndWait(compilerPath, args, std::nullopt, redirects); + llvm::ArrayRef const args = {compilerPath, "-v", "-E", "-x", "c++", "-"}; + llvm::ArrayRef emptyEnv; + int const result = llvm::sys::ExecuteAndWait(compilerPath, args, emptyEnv, redirects); if (result != 0) { llvm::sys::fs::remove(outputPath); From c93a4f9f397c0d781087b95b5f4fc34c5a10ecf4 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 23:17:43 +0100 Subject: [PATCH 11/22] skip calling MSVC --- src/tool/GenerateAction.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index 6e04e5475..b729601c9 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -26,20 +26,20 @@ namespace clang { namespace mrdocs { std::optional -getCompilerInfo(llvm::StringRef compilerPath) +getCompilerVerboseOutput(llvm::StringRef compilerPath) { if ( ! llvm::sys::fs::exists(compilerPath)) { return std::nullopt; } llvm::SmallString<128> outputPath; - if (auto EC = llvm::sys::fs::createTemporaryFile("compiler-info", "txt", outputPath)) + if (auto ec = llvm::sys::fs::createTemporaryFile("compiler-info", "txt", outputPath)) { return std::nullopt; } std::optional const redirects[] = {llvm::StringRef(), llvm::StringRef(), outputPath.str()}; - llvm::ArrayRef const args = {compilerPath, "-v", "-E", "-x", "c++", "-"}; + std::vector const args = {compilerPath, "-v", "-E", "-x", "c++", "-"}; llvm::ArrayRef emptyEnv; int const result = llvm::sys::ExecuteAndWait(compilerPath, args, emptyEnv, redirects); if (result != 0) @@ -100,7 +100,12 @@ getCompilersDefaultIncludeDir(clang::tooling::CompilationDatabase const& compDb) continue; } - auto const compilerOutput = getCompilerInfo(compilerPath); + // Skip MSVC compiler + if (compilerPath.find("cl.exe") != std::string::npos) { + continue; + } + + auto const compilerOutput = getCompilerVerboseOutput(compilerPath); if ( ! compilerOutput) { report::warn("Warning: could not get compiler info for \"{}\"", compilerPath); continue; From 86cc512cc8fdf65c67d85ac6ec931ee1c58d5dda Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 23:21:13 +0100 Subject: [PATCH 12/22] remove CI workaround --- .github/workflows/ci.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70df67f03..f6eeb1b3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -325,19 +325,7 @@ jobs: rm -rf __build__ fi mkdir __build__ - cd __build__ - mkdir __include_dirs__ - cd __include_dirs__ - output_file="include_dirs.txt" - echo "cmake_minimum_required(VERSION 3.22)" > CMakeLists.txt - echo "project(get_implicit_dirs)" >> CMakeLists.txt - echo "file(WRITE \"${output_file}\" \"\${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}\")" >> CMakeLists.txt - mkdir __build__ - cd __build__ - cmake -D CMAKE_CXX_COMPILER=${{ steps.setup-cpp.outputs.cxx }} -D CMAKE_C_COMPILER=${{ steps.setup-cpp.outputs.cc }} .. - cd .. - default_includes=$(cat "$output_file") - cd .. + cd __build__ cmake -D BOOST_URL_BUILD_TESTS=OFF -D BOOST_URL_BUILD_EXAMPLES=OFF -D CMAKE_EXPORT_COMPILE_COMMANDS=ON -D CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES="$default_includes" -D CMAKE_CXX_COMPILER=${{ steps.setup-cpp.outputs.cxx }} -D CMAKE_C_COMPILER=${{ steps.setup-cpp.outputs.cc }} .. - name: Generate demos From a86306b5ad3540598118a34480604cadb7b856df Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 23:26:52 +0100 Subject: [PATCH 13/22] fix name --- src/tool/GenerateAction.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index b729601c9..9116309ec 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -162,7 +162,7 @@ DoGenerateAction() auto compilationsPath = files::normalizePath(toolArgs.inputPaths.front()); std::string errorMessage; MRDOCS_TRY_MSG( - auto& jsonCompilations, + auto& compileCommands, tooling::JSONCompilationDatabase::loadFromFile( compilationsPath, errorMessage, @@ -180,11 +180,11 @@ DoGenerateAction() (*config)->workingDir)); // Get the default include paths for each compiler - auto const defaultIncludePaths = getCompilersDefaultIncludeDir(jsonCompilations); + auto const defaultIncludePaths = getCompilersDefaultIncludeDir(compileCommands); // Convert relative paths to absolute MrDocsCompilationDatabase compilations( - workingDir, jsonCompilations, config, defaultIncludePaths); + workingDir, compileCommands, config, defaultIncludePaths); // Run the tool: this can take a while MRDOCS_TRY( From 20f1db5acea29b70f56d5e3408243d7a3d968d6a Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 23:28:00 +0100 Subject: [PATCH 14/22] fix style --- src/tool/GenerateAction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index 9116309ec..b7b081824 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -161,7 +161,7 @@ DoGenerateAction() toolArgs.inputPaths.size())); auto compilationsPath = files::normalizePath(toolArgs.inputPaths.front()); std::string errorMessage; - MRDOCS_TRY_MSG( + MRDOCS_TRY_MSG( auto& compileCommands, tooling::JSONCompilationDatabase::loadFromFile( compilationsPath, From 3413a5c5d5eed5f81910b3d08a45463388a16792 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 23:28:43 +0100 Subject: [PATCH 15/22] comment --- src/tool/GenerateAction.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index b7b081824..d83b55378 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -186,7 +186,11 @@ DoGenerateAction() MrDocsCompilationDatabase compilations( workingDir, compileCommands, config, defaultIncludePaths); - // Run the tool: this can take a while + // -------------------------------------------------------------- + // + // Build corpus + // + // -------------------------------------------------------------- MRDOCS_TRY( auto corpus, CorpusImpl::build( From 8a0e866bd82cc631f340c0407ae5bdb423f4c534 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 23:35:54 +0100 Subject: [PATCH 16/22] fix --- src/tool/GenerateAction.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index f4155d8df..f19f3c4ad 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -183,10 +183,13 @@ DoGenerateAction() tooling::JSONCommandLineSyntax::AutoDetect), std::move(errorMessage)); + // Get the default include paths for each compiler + auto const defaultIncludePaths = getCompilersDefaultIncludeDir(compileCommands); + // Custom compilation database that converts relative paths to absolute auto compileCommandsDir = files::getParentDir(compilationsPath); - AbsoluteCompilationDatabase absCompileCommands( - compileCommandsDir, compileCommands, config); + MrDocsCompilationDatabase compilationDatabase( + compileCommandsDir, compileCommands, config, defaultIncludePaths); // Normalize outputPath path MRDOCS_CHECK(toolArgs.outputPath, "The output path argument is missing"); @@ -194,13 +197,6 @@ DoGenerateAction() files::makeAbsolute(toolArgs.outputPath, (*config)->workingDir)); - // Get the default include paths for each compiler - auto const defaultIncludePaths = getCompilersDefaultIncludeDir(compileCommands); - - // Convert relative paths to absolute - MrDocsCompilationDatabase compilations( - workingDir, compileCommands, config, defaultIncludePaths); - // -------------------------------------------------------------- // // Build corpus @@ -209,7 +205,7 @@ DoGenerateAction() MRDOCS_TRY( auto corpus, CorpusImpl::build( - report::Level::info, config, absCompileCommands)); + report::Level::info, config, compilationDatabase)); // -------------------------------------------------------------- // From aaf1caf35a35085d0a408db31101ca53f6e3245f Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 23:41:26 +0100 Subject: [PATCH 17/22] refactoring --- src/tool/Compiler.cpp | 111 ++++++++++++++++++++++++++++++++++++ src/tool/Compiler.hpp | 51 +++++++++++++++++ src/tool/GenerateAction.cpp | 95 +----------------------------- 3 files changed, 163 insertions(+), 94 deletions(-) create mode 100644 src/tool/Compiler.cpp create mode 100644 src/tool/Compiler.hpp diff --git a/src/tool/Compiler.cpp b/src/tool/Compiler.cpp new file mode 100644 index 000000000..dc3a26e07 --- /dev/null +++ b/src/tool/Compiler.cpp @@ -0,0 +1,111 @@ +// +// This is a derivative work. originally part of the LLVM Project. +// Licensed under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com) +// +// Official repository: https://github.com/cppalliance/mrdocs +// + +#include + +namespace clang { +namespace mrdocs { + +std::optional +getCompilerVerboseOutput(llvm::StringRef compilerPath) +{ + if ( ! llvm::sys::fs::exists(compilerPath)) { + return std::nullopt; + } + + llvm::SmallString<128> outputPath; + if (auto ec = llvm::sys::fs::createTemporaryFile("compiler-info", "txt", outputPath)) + { + return std::nullopt; + } + + std::optional const redirects[] = {llvm::StringRef(), llvm::StringRef(), outputPath.str()}; + std::vector const args = {compilerPath, "-v", "-E", "-x", "c++", "-"}; + llvm::ArrayRef emptyEnv; + int const result = llvm::sys::ExecuteAndWait(compilerPath, args, emptyEnv, redirects); + if (result != 0) + { + llvm::sys::fs::remove(outputPath); + return std::nullopt; + } + + auto bufferOrError = llvm::MemoryBuffer::getFile(outputPath); + llvm::sys::fs::remove(outputPath); + if ( ! bufferOrError) + { + return std::nullopt; + } + + return bufferOrError.get()->getBuffer().str(); +} + +std::vector +parseIncludePaths(std::string const& compilerOutput) +{ + std::vector includePaths; + std::istringstream stream(compilerOutput); + std::string line; + bool capture = false; + + while (std::getline(stream, line)) + { + if (line.find("#include <...> search starts here:") != std::string::npos) + { + capture = true; + continue; + } + if (line.find("End of search list.") != std::string::npos) + { + break; + } + if (capture) + { + line.erase(0, line.find_first_not_of(" ")); + includePaths.push_back(line); + } + } + + return includePaths; +} + +std::unordered_map> +getCompilersDefaultIncludeDir(clang::tooling::CompilationDatabase const& compDb) +{ + std::unordered_map> res; + auto const allCommands = compDb.getAllCompileCommands(); + + for (auto const& cmd : allCommands) { + if ( ! cmd.CommandLine.empty()) { + auto const& compilerPath = cmd.CommandLine[0]; + if (res.contains(compilerPath)) { + continue; + } + + // Skip MSVC compiler + if (compilerPath.find("cl.exe") != std::string::npos) { + continue; + } + + auto const compilerOutput = getCompilerVerboseOutput(compilerPath); + if ( ! compilerOutput) { + report::warn("Warning: could not get compiler info for \"{}\"", compilerPath); + continue; + } + std::vector includePaths = parseIncludePaths(*compilerOutput); + res.emplace(compilerPath, std::move(includePaths)); + } + } + + return res; +} + +} // mrdocs +} // clang diff --git a/src/tool/Compiler.hpp b/src/tool/Compiler.hpp new file mode 100644 index 000000000..9cad98a3a --- /dev/null +++ b/src/tool/Compiler.hpp @@ -0,0 +1,51 @@ +// +// Licensed under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com) +// +// Official repository: https://github.com/cppalliance/mrdocs +// + +#ifndef MRDOCS_TOOL_COMPILER_HPP +#define MRDOCS_TOOL_COMPILER_HPP + +#include +#include +#include + +namespace clang { +namespace mrdocs { + +/** + * @brief Get the compiler verbose output. + * + * @param compilerPath The compiler path. + * @return std::optional The compiler verbose output. +*/ +std::optional +getCompilerVerboseOutput(llvm::StringRef compilerPath); + +/** + * @brief Parse the include paths. + * + * @param compilerOutput The compiler output. + * @return std::vector The include paths. +*/ +std::vector +parseIncludePaths(std::string const& compilerOutput); + +/** + * @brief Get the compiler default include dir. + * + * @param compDb The compilation database. + * @return std::unordered_map> The compiler default include dir. +*/ +std::unordered_map> +getCompilersDefaultIncludeDir(clang::tooling::CompilationDatabase const& compDb); + +} // mrdocs +} // clang + +#endif diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index f19f3c4ad..a27481445 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -9,6 +9,7 @@ // Official repository: https://github.com/cppalliance/mrdocs // +#include "Compiler.hpp" #include "ToolArgs.hpp" #include "lib/Lib/ConfigImpl.hpp" #include "lib/Lib/CorpusImpl.hpp" @@ -20,104 +21,10 @@ #include #include -#include namespace clang { namespace mrdocs { -std::optional -getCompilerVerboseOutput(llvm::StringRef compilerPath) -{ - if ( ! llvm::sys::fs::exists(compilerPath)) { - return std::nullopt; - } - - llvm::SmallString<128> outputPath; - if (auto ec = llvm::sys::fs::createTemporaryFile("compiler-info", "txt", outputPath)) - { - return std::nullopt; - } - - std::optional const redirects[] = {llvm::StringRef(), llvm::StringRef(), outputPath.str()}; - std::vector const args = {compilerPath, "-v", "-E", "-x", "c++", "-"}; - llvm::ArrayRef emptyEnv; - int const result = llvm::sys::ExecuteAndWait(compilerPath, args, emptyEnv, redirects); - if (result != 0) - { - llvm::sys::fs::remove(outputPath); - return std::nullopt; - } - - auto bufferOrError = llvm::MemoryBuffer::getFile(outputPath); - llvm::sys::fs::remove(outputPath); - if ( ! bufferOrError) - { - return std::nullopt; - } - - return bufferOrError.get()->getBuffer().str(); -} - -std::vector -parseIncludePaths(std::string const& compilerOutput) -{ - std::vector includePaths; - std::istringstream stream(compilerOutput); - std::string line; - bool capture = false; - - while (std::getline(stream, line)) - { - if (line.find("#include <...> search starts here:") != std::string::npos) - { - capture = true; - continue; - } - if (line.find("End of search list.") != std::string::npos) - { - break; - } - if (capture) - { - line.erase(0, line.find_first_not_of(" ")); - includePaths.push_back(line); - } - } - - return includePaths; -} - -std::unordered_map> -getCompilersDefaultIncludeDir(clang::tooling::CompilationDatabase const& compDb) -{ - std::unordered_map> res; - auto const allCommands = compDb.getAllCompileCommands(); - - for (auto const& cmd : allCommands) { - if ( ! cmd.CommandLine.empty()) { - auto const& compilerPath = cmd.CommandLine[0]; - if (res.contains(compilerPath)) { - continue; - } - - // Skip MSVC compiler - if (compilerPath.find("cl.exe") != std::string::npos) { - continue; - } - - auto const compilerOutput = getCompilerVerboseOutput(compilerPath); - if ( ! compilerOutput) { - report::warn("Warning: could not get compiler info for \"{}\"", compilerPath); - continue; - } - std::vector includePaths = parseIncludePaths(*compilerOutput); - res.emplace(compilerPath, std::move(includePaths)); - } - } - - return res; -} - Expected DoGenerateAction() { From f20a8b6b552c0c582f59674823abff178003cf73 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 23:42:35 +0100 Subject: [PATCH 18/22] proper includes --- src/tool/Compiler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tool/Compiler.cpp b/src/tool/Compiler.cpp index dc3a26e07..2b4fd3826 100644 --- a/src/tool/Compiler.cpp +++ b/src/tool/Compiler.cpp @@ -9,6 +9,9 @@ // Official repository: https://github.com/cppalliance/mrdocs // +#include +#include +#include #include namespace clang { From 9fde756897ddceb3731358d229095d9428089f5a Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 23:44:53 +0100 Subject: [PATCH 19/22] proper includes --- src/tool/Compiler.cpp | 5 +---- src/tool/Compiler.hpp | 7 +++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tool/Compiler.cpp b/src/tool/Compiler.cpp index 2b4fd3826..fd343573f 100644 --- a/src/tool/Compiler.cpp +++ b/src/tool/Compiler.cpp @@ -9,10 +9,7 @@ // Official repository: https://github.com/cppalliance/mrdocs // -#include -#include -#include -#include +#include "Compiler.hpp" namespace clang { namespace mrdocs { diff --git a/src/tool/Compiler.hpp b/src/tool/Compiler.hpp index 9cad98a3a..5a3cdee82 100644 --- a/src/tool/Compiler.hpp +++ b/src/tool/Compiler.hpp @@ -11,9 +11,12 @@ #ifndef MRDOCS_TOOL_COMPILER_HPP #define MRDOCS_TOOL_COMPILER_HPP -#include -#include +#include #include +#include +#include + +#include namespace clang { namespace mrdocs { From 9525130e182f16e46c32c66f97a9d410c0a17cf5 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Mon, 18 Dec 2023 23:56:00 +0100 Subject: [PATCH 20/22] proper includes --- src/tool/Compiler.cpp | 4 ++++ src/tool/Compiler.hpp | 1 + 2 files changed, 5 insertions(+) diff --git a/src/tool/Compiler.cpp b/src/tool/Compiler.cpp index fd343573f..63236bdba 100644 --- a/src/tool/Compiler.cpp +++ b/src/tool/Compiler.cpp @@ -11,6 +11,10 @@ #include "Compiler.hpp" +#include + +#include + namespace clang { namespace mrdocs { diff --git a/src/tool/Compiler.hpp b/src/tool/Compiler.hpp index 5a3cdee82..aa9d112ed 100644 --- a/src/tool/Compiler.hpp +++ b/src/tool/Compiler.hpp @@ -16,6 +16,7 @@ #include #include +#include #include namespace clang { From dfd8a89a9102f2a46ea8e46c21dd41150465468f Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Tue, 19 Dec 2023 14:53:12 +0100 Subject: [PATCH 21/22] file rename --- src/tool/{Compiler.cpp => CompilerInfo.cpp} | 2 +- src/tool/{Compiler.hpp => CompilerInfo.hpp} | 0 src/tool/GenerateAction.cpp | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/tool/{Compiler.cpp => CompilerInfo.cpp} (99%) rename src/tool/{Compiler.hpp => CompilerInfo.hpp} (100%) diff --git a/src/tool/Compiler.cpp b/src/tool/CompilerInfo.cpp similarity index 99% rename from src/tool/Compiler.cpp rename to src/tool/CompilerInfo.cpp index 63236bdba..0633360a8 100644 --- a/src/tool/Compiler.cpp +++ b/src/tool/CompilerInfo.cpp @@ -9,7 +9,7 @@ // Official repository: https://github.com/cppalliance/mrdocs // -#include "Compiler.hpp" +#include "CompilerInfo.hpp" #include diff --git a/src/tool/Compiler.hpp b/src/tool/CompilerInfo.hpp similarity index 100% rename from src/tool/Compiler.hpp rename to src/tool/CompilerInfo.hpp diff --git a/src/tool/GenerateAction.cpp b/src/tool/GenerateAction.cpp index a27481445..b4e10df03 100644 --- a/src/tool/GenerateAction.cpp +++ b/src/tool/GenerateAction.cpp @@ -9,7 +9,7 @@ // Official repository: https://github.com/cppalliance/mrdocs // -#include "Compiler.hpp" +#include "CompilerInfo.hpp" #include "ToolArgs.hpp" #include "lib/Lib/ConfigImpl.hpp" #include "lib/Lib/CorpusImpl.hpp" From a06ccea245c6917c7ed5c080956bc13d040fce8e Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Tue, 19 Dec 2023 14:55:54 +0100 Subject: [PATCH 22/22] MSVC detection is not necessary --- src/tool/CompilerInfo.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/tool/CompilerInfo.cpp b/src/tool/CompilerInfo.cpp index 0633360a8..41ac80bea 100644 --- a/src/tool/CompilerInfo.cpp +++ b/src/tool/CompilerInfo.cpp @@ -93,11 +93,6 @@ getCompilersDefaultIncludeDir(clang::tooling::CompilationDatabase const& compDb) continue; } - // Skip MSVC compiler - if (compilerPath.find("cl.exe") != std::string::npos) { - continue; - } - auto const compilerOutput = getCompilerVerboseOutput(compilerPath); if ( ! compilerOutput) { report::warn("Warning: could not get compiler info for \"{}\"", compilerPath);