From 71b914b82865adeb562aa48d5d1011498627d94c Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 13 Jun 2022 16:52:52 +0200 Subject: [PATCH] ClangCodeModel: Do not dump compile_commands.json into project dir We can't know if it's safe to put there; e.g. we might overwrite an existing one. Fixes: QTCREATORBUG-27573 Change-Id: I928408996759aaccb84332fcf95cf43d7f3bf083 Reviewed-by: Qt CI Bot Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/clangcodemodel/clangcodemodelplugin.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/clangcodemodel/clangcodemodelplugin.cpp b/src/plugins/clangcodemodel/clangcodemodelplugin.cpp index 3b26d7b82c7..675ee4e0e93 100644 --- a/src/plugins/clangcodemodel/clangcodemodelplugin.cpp +++ b/src/plugins/clangcodemodel/clangcodemodelplugin.cpp @@ -34,8 +34,6 @@ # include "test/clangfixittest.h" #endif -#include - #include #include #include @@ -45,6 +43,7 @@ #include #include +#include #include #include #include @@ -53,6 +52,9 @@ #include +#include +#include + using namespace Utils; namespace ClangCodeModel { @@ -69,10 +71,13 @@ void ClangCodeModelPlugin::generateCompilationDB() const auto projectInfo = CppModelManager::instance()->projectInfo(target->project()); if (!projectInfo) return; + FilePath baseDir = projectInfo->buildRoot(); + if (baseDir == target->project()->projectDirectory()) + baseDir = TemporaryDirectory::masterDirectoryFilePath(); QFuture task = Utils::runAsync(&Internal::generateCompilationDB, projectInfo, - projectInfo->buildRoot(), CompilationDbPurpose::Project, + baseDir, CompilationDbPurpose::Project, warningsConfigForProject(target->project()), globalClangOptions(), FilePath());