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 <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2022-06-13 16:52:52 +02:00
parent 56e838da70
commit 71b914b828

View File

@@ -34,8 +34,6 @@
# include "test/clangfixittest.h"
#endif
#include <utils/runextensions.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/messagemanager.h>
@@ -45,6 +43,7 @@
#include <cppeditor/cppmodelmanager.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectpanelfactory.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
@@ -53,6 +52,9 @@
#include <texteditor/textmark.h>
#include <utils/temporarydirectory.h>
#include <utils/runextensions.h>
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<GenerateCompilationDbResult> task
= Utils::runAsync(&Internal::generateCompilationDB, projectInfo,
projectInfo->buildRoot(), CompilationDbPurpose::Project,
baseDir, CompilationDbPurpose::Project,
warningsConfigForProject(target->project()),
globalClangOptions(),
FilePath());