Commit 10acf6af authored by Christian Kandeler's avatar Christian Kandeler

Create a dummy run configuration to create our run control from.

The Clang Static Analyzer differs from other analyzers in that it does
not run a binary produced by the build process, but looks at source
files instead. It is therefore completely unrelated to any run
configurations that may or may not exist for the project. This has been
ignored so far, with these two main consequences:
    - When running the analyzer, the name of some random run
      configuration appears in the application output pane, which makes
      it look to the user as if the corresponding executable has been
      run, which it has not.
    - For projects without run configurations (e.g. libraries),
      analyzing does not work out of the box, which makes no sense
So we now create our own run special run configuration (not visible in
the UI) and run it directly via runRunConfiguration() instead of using
the currently active run configuration via runProject().
This fixes both issues listed above.

Change-Id: Icc839816f4a1e6f02a0eb2328c536b44f7304807
Reviewed-by: default avatarNikolai Kosjar <>
parent 26abab90
......@@ -48,6 +48,22 @@ using namespace ProjectExplorer;
namespace ClangStaticAnalyzer {
namespace Internal {
class DummyRunConfiguration : public RunConfiguration
DummyRunConfiguration(Target *parent)
: RunConfiguration(parent, "ClangStaticAnalyzer.DummyRunConfig")
setDefaultDisplayName(tr("Clang Static Analyzer"));
QWidget *createConfigurationWidget() { return 0; }
ClangStaticAnalyzerTool::ClangStaticAnalyzerTool(QObject *parent)
: QObject(parent)
, m_diagnosticModel(0)
......@@ -218,7 +234,22 @@ void ClangStaticAnalyzerTool::startTool()
QTC_ASSERT(m_projectInfoBeforeBuild.isValid(), return);
m_running = true;
ProjectExplorerPlugin::runProject(project, ProjectExplorer::ClangStaticAnalyzerMode);
Target * const target = project->activeTarget();
QTC_ASSERT(target, return);
DummyRunConfiguration *& rc = m_runConfigs[target];
if (!rc) {
rc = new DummyRunConfiguration(target);
connect(project, &Project::aboutToRemoveTarget, this,
[this](Target *t) { m_runConfigs.remove(t); });
const auto onProjectRemoved = [this](Project *p) {
foreach (Target * const t, p->targets())
connect(SessionManager::instance(), &SessionManager::aboutToRemoveProject, this,
onProjectRemoved, Qt::UniqueConnection);
ProjectExplorerPlugin::runRunConfiguration(rc, ProjectExplorer::ClangStaticAnalyzerMode);
CppTools::ProjectInfo ClangStaticAnalyzerTool::projectInfoBeforeBuild() const
......@@ -289,3 +320,5 @@ void ClangStaticAnalyzerTool::handleStateUpdate()
} // namespace Internal
} // namespace ClangStaticAnalyzer
#include "clangstaticanalyzertool.moc"
......@@ -22,7 +22,10 @@
#include <analyzerbase/ianalyzertool.h>
#include <cpptools/cppprojects.h>
#include <QHash>
namespace Analyzer { class DetailedErrorView; }
namespace ProjectExplorer { class Target; }
namespace ClangStaticAnalyzer {
namespace Internal {
......@@ -31,6 +34,7 @@ class ClangStaticAnalyzerDiagnosticFilterModel;
class ClangStaticAnalyzerDiagnosticModel;
class ClangStaticAnalyzerDiagnosticView;
class Diagnostic;
class DummyRunConfiguration;
const char ClangStaticAnalyzerToolId[] = "ClangStaticAnalyzer";
......@@ -72,6 +76,7 @@ private:
QAction *m_goBack;
QAction *m_goNext;
QHash<ProjectExplorer::Target *, DummyRunConfiguration *> m_runConfigs;
bool m_running;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment