diff options
author | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-04-23 09:38:36 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@theqtcompany.com> | 2015-04-23 09:38:36 +0200 |
commit | da3379549623e5ca7ce67724c661c9166fbcf445 (patch) | |
tree | bc6aa3c110e7c52208dc52f6636f67f18cd713cf | |
parent | 462f4054fe69f270d6a7ca61dda522e63e8b41e2 (diff) | |
parent | 5a493ae38fa74b27b0f7bfb1f7c7a00bd299b9cf (diff) |
Merge remote-tracking branch 'origin/3.4'
12 files changed, 163 insertions, 15 deletions
diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzer.qbs b/plugins/clangstaticanalyzer/clangstaticanalyzer.qbs index 4179000d76..2ccc31337c 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzer.qbs +++ b/plugins/clangstaticanalyzer/clangstaticanalyzer.qbs @@ -64,7 +64,13 @@ QtcPlugin { "clangstaticanalyzerunittests.cpp", "clangstaticanalyzerunittests.h", "clangstaticanalyzerunittests.qrc", - "unit-tests/**/*", ] } + + Group { + name: "Unit test resources" + prefix: "unit-tests/" + fileTags: [] + files: ["**/*"] + } } diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index c99060d13c..4ef7cacfa9 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -35,8 +35,10 @@ #include <cpptools/cppprojects.h> #include <cpptools/cppprojectfile.h> +#include <projectexplorer/abi.h> #include <projectexplorer/kitinformation.h> #include <projectexplorer/project.h> +#include <projectexplorer/runconfiguration.h> #include <projectexplorer/target.h> #include <projectexplorer/taskhub.h> @@ -61,14 +63,32 @@ ClangStaticAnalyzerRunControl::ClangStaticAnalyzerRunControl( , m_projectInfo(projectInfo) , m_toolchainType(ProjectExplorer::ToolChainKitInformation ::toolChain(runConfiguration->target()->kit())->type()) + , m_wordWidth(runConfiguration->abi().wordWidth()) , m_initialFilesToProcessSize(0) , m_filesAnalyzed(0) , m_filesNotAnalyzed(0) { } -// Removes (1) filePath (2) -o <somePath> -static QStringList tweakedArguments(const QString &filePath, const QStringList &arguments) +static void prependWordWidthArgumentIfNotIncluded(QStringList *arguments, unsigned char wordWidth) +{ + QTC_ASSERT(arguments, return); + + const QString m64Argument = QLatin1String("-m64"); + const QString m32Argument = QLatin1String("-m32"); + + const QString argument = wordWidth == 64 ? m64Argument : m32Argument; + if (!arguments->contains(argument)) + arguments->prepend(argument); + + QTC_CHECK(!arguments->contains(m32Argument) || !arguments->contains(m64Argument)); +} + +// Removes (1) filePath (2) -o <somePath>. +// Adds -m64/-m32 argument if not already included. +static QStringList tweakedArguments(const QString &filePath, + const QStringList &arguments, + unsigned char wordWidth) { QStringList newArguments; @@ -88,12 +108,15 @@ static QStringList tweakedArguments(const QString &filePath, const QStringList & } QTC_CHECK(skip == false); + prependWordWidthArgumentIfNotIncluded(&newArguments, wordWidth); + return newArguments; } static QStringList argumentsFromProjectPart(const CppTools::ProjectPart::Ptr &projectPart, CppTools::ProjectFile::Kind fileKind, - const QString &toolchainType) + const QString &toolchainType, + unsigned char wordWidth) { QStringList result; @@ -112,16 +135,20 @@ static QStringList argumentsFromProjectPart(const CppTools::ProjectPart::Ptr &pr projectPart->headerPaths, CompilerOptionsBuilder::IsBlackListed(), toolchainType); + if (toolchainType == QLatin1String("msvc")) result += QLatin1String("/EHsc"); // clang-cl does not understand exceptions else result += QLatin1String("-fPIC"); // TODO: Remove? + prependWordWidthArgumentIfNotIncluded(&result, wordWidth); + return result; } static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompilerCallData( - const ProjectInfo::CompilerCallData &compilerCallData) + const ProjectInfo::CompilerCallData &compilerCallData, + unsigned char wordWidth) { typedef ClangStaticAnalyzerRunControl::AnalyzeUnit AnalyzeUnit; qCDebug(LOG) << "Taking arguments for analyzing from CompilerCallData."; @@ -134,7 +161,7 @@ static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompi const QString file = it.key(); const QList<QStringList> compilerCalls = it.value(); foreach (const QStringList &options, compilerCalls) { - const QStringList arguments = tweakedArguments(file, options); + const QStringList arguments = tweakedArguments(file, options, wordWidth); unitsToAnalyze << AnalyzeUnit(file, arguments); } } @@ -143,7 +170,9 @@ static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompi } static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromProjectParts( - const QList<ProjectPart::Ptr> projectParts, const QString &toolchainType) + const QList<ProjectPart::Ptr> projectParts, + const QString &toolchainType, + unsigned char wordWidth) { typedef ClangStaticAnalyzerRunControl::AnalyzeUnit AnalyzeUnit; qCDebug(LOG) << "Taking arguments for analyzing from ProjectParts."; @@ -159,8 +188,10 @@ static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromProje continue; QTC_CHECK(file.kind != ProjectFile::Unclassified); if (ProjectFile::isSource(file.kind)) { - const QStringList arguments - = argumentsFromProjectPart(projectPart, file.kind, toolchainType); + const QStringList arguments = argumentsFromProjectPart(projectPart, + file.kind, + toolchainType, + wordWidth); unitsToAnalyze << AnalyzeUnit(file.path, arguments); } } @@ -175,8 +206,10 @@ QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> ClangStaticAnalyzerRunControl: const ProjectInfo::CompilerCallData compilerCallData = m_projectInfo.compilerCallData(); if (!compilerCallData.isEmpty()) - return unitsToAnalyzeFromCompilerCallData(compilerCallData); - return unitsToAnalyzeFromProjectParts(m_projectInfo.projectParts(), m_toolchainType); + return unitsToAnalyzeFromCompilerCallData(compilerCallData, m_wordWidth); + return unitsToAnalyzeFromProjectParts(m_projectInfo.projectParts(), + m_toolchainType, + m_wordWidth); } bool ClangStaticAnalyzerRunControl::startEngine() diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h index ff74644619..1da8598ffb 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h @@ -70,6 +70,7 @@ private: private: const CppTools::ProjectInfo m_projectInfo; const QString m_toolchainType; + const unsigned char m_wordWidth; QString m_clangExecutable; QString m_clangLogFileDir; diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp index 03b7355cd6..9e8d69a4df 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp @@ -70,8 +70,6 @@ RunControl *ClangStaticAnalyzerRunControlFactory::create(RunConfiguration *runCo RunMode runMode, QString *errorMessage) { - Q_UNUSED(runMode); - using namespace CppTools; const ProjectInfo projectInfoBeforeBuild = m_tool->projectInfoBeforeBuild(); QTC_ASSERT(projectInfoBeforeBuild.isValid(), return 0); diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerunittests.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerunittests.cpp index 21b086858e..4eed420574 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerunittests.cpp +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerunittests.cpp @@ -94,10 +94,16 @@ void ClangStaticAnalyzerUnitTests::testProject_data() { QTest::addColumn<QString>("projectFilePath"); QTest::addColumn<int>("expectedDiagCount"); - QTest::newRow("qbs project") + + QTest::newRow("simple qbs project") << QString(m_tmpDir->path() + QLatin1String("/simple/simple.qbs")) << 1; - QTest::newRow("qmake project") + QTest::newRow("simple qmake project") << QString(m_tmpDir->path() + QLatin1String("/simple/simple.pro")) << 1; + + QTest::newRow("qt-widgets-app qbs project") + << QString(m_tmpDir->path() + QLatin1String("/qt-widgets-app/qt-widgets-app.qbs")) << 0; + QTest::newRow("qt-widgets-app qmake project") + << QString(m_tmpDir->path() + QLatin1String("/qt-widgets-app/qt-widgets-app.pro")) << 0; } } // namespace Internal diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerunittests.qrc b/plugins/clangstaticanalyzer/clangstaticanalyzerunittests.qrc index 0de4936d20..d8a1a8674e 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerunittests.qrc +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerunittests.qrc @@ -3,5 +3,11 @@ <file>unit-tests/simple/main.cpp</file> <file>unit-tests/simple/simple.qbs</file> <file>unit-tests/simple/simple.pro</file> + <file>unit-tests/qt-widgets-app/main.cpp</file> + <file>unit-tests/qt-widgets-app/mainwindow.cpp</file> + <file>unit-tests/qt-widgets-app/mainwindow.h</file> + <file>unit-tests/qt-widgets-app/mainwindow.ui</file> + <file>unit-tests/qt-widgets-app/qt-widgets-app.pro</file> + <file>unit-tests/qt-widgets-app/qt-widgets-app.qbs</file> </qresource> </RCC> diff --git a/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/main.cpp b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/main.cpp new file mode 100644 index 0000000000..b48f94ec82 --- /dev/null +++ b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include <QApplication> + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/mainwindow.cpp b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/mainwindow.cpp new file mode 100644 index 0000000000..49d64fce7c --- /dev/null +++ b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/mainwindow.h b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/mainwindow.h new file mode 100644 index 0000000000..ce76956bad --- /dev/null +++ b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/mainwindow.h @@ -0,0 +1,24 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> + +QT_BEGIN_NAMESPACE +namespace Ui { +class MainWindow; +} +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/mainwindow.ui b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/mainwindow.ui new file mode 100644 index 0000000000..6050363fa7 --- /dev/null +++ b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/mainwindow.ui @@ -0,0 +1,24 @@ +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle" > + <string>MainWindow</string> + </property> + <widget class="QMenuBar" name="menuBar" /> + <widget class="QToolBar" name="mainToolBar" /> + <widget class="QWidget" name="centralWidget" /> + <widget class="QStatusBar" name="statusBar" /> + </widget> + <layoutDefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> diff --git a/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/qt-widgets-app.pro b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/qt-widgets-app.pro new file mode 100644 index 0000000000..d9e1f2590b --- /dev/null +++ b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/qt-widgets-app.pro @@ -0,0 +1,8 @@ +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = qt-widgets-app +TEMPLATE = app +SOURCES += main.cpp mainwindow.cpp +HEADERS += mainwindow.h +FORMS += mainwindow.ui diff --git a/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/qt-widgets-app.qbs b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/qt-widgets-app.qbs new file mode 100644 index 0000000000..e641f9bd54 --- /dev/null +++ b/plugins/clangstaticanalyzer/unit-tests/qt-widgets-app/qt-widgets-app.qbs @@ -0,0 +1,17 @@ +import qbs 1.0 + +QtApplication { + name : "Qt Widgets Application" + + Depends { + name: "Qt" + submodules: [ "widgets" ] + } + + files : [ + "main.cpp", + "mainwindow.cpp", + "mainwindow.h", + "mainwindow.ui" + ] +} |