diff options
author | Christian Kandeler <[email protected]> | 2015-03-03 15:09:27 +0100 |
---|---|---|
committer | Christian Kandeler <[email protected]> | 2015-03-09 16:55:53 +0200 |
commit | 10acf6af840153b5b69e9dc32fa9ad671d8f8290 (patch) | |
tree | e3c0810c14ea44356c43d0aea9dffb74b3af3b21 | |
parent | 26abab90ca8cf599421636b2292e801cba9759a1 (diff) |
Create a dummy run configuration to create our run control from.csa-v3.4.0-rc1
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
conceptually.
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: Nikolai Kosjar <[email protected]>
-rw-r--r-- | plugins/clangstaticanalyzer/clangstaticanalyzertool.cpp | 35 | ||||
-rw-r--r-- | plugins/clangstaticanalyzer/clangstaticanalyzertool.h | 5 |
2 files changed, 39 insertions, 1 deletions
diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzertool.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzertool.cpp index 37447c5f664..4e98a28ddd7 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzertool.cpp +++ b/plugins/clangstaticanalyzer/clangstaticanalyzertool.cpp @@ -48,6 +48,22 @@ using namespace ProjectExplorer; namespace ClangStaticAnalyzer { namespace Internal { +class DummyRunConfiguration : public RunConfiguration +{ + Q_OBJECT + +public: + DummyRunConfiguration(Target *parent) + : RunConfiguration(parent, "ClangStaticAnalyzer.DummyRunConfig") + { + setDefaultDisplayName(tr("Clang Static Analyzer")); + addExtraAspects(); + } + +private: + 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; handleStateUpdate(); - 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()) + m_runConfigs.remove(t); + }; + 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" diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzertool.h b/plugins/clangstaticanalyzer/clangstaticanalyzertool.h index 2f9b18efa7b..4334884c7e7 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzertool.h +++ b/plugins/clangstaticanalyzer/clangstaticanalyzertool.h @@ -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; }; |