forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/3.4'
This commit is contained in:
@@ -64,7 +64,13 @@ QtcPlugin {
|
|||||||
"clangstaticanalyzerunittests.cpp",
|
"clangstaticanalyzerunittests.cpp",
|
||||||
"clangstaticanalyzerunittests.h",
|
"clangstaticanalyzerunittests.h",
|
||||||
"clangstaticanalyzerunittests.qrc",
|
"clangstaticanalyzerunittests.qrc",
|
||||||
"unit-tests/**/*",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Group {
|
||||||
|
name: "Unit test resources"
|
||||||
|
prefix: "unit-tests/"
|
||||||
|
fileTags: []
|
||||||
|
files: ["**/*"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,8 +35,10 @@
|
|||||||
#include <cpptools/cppprojects.h>
|
#include <cpptools/cppprojects.h>
|
||||||
#include <cpptools/cppprojectfile.h>
|
#include <cpptools/cppprojectfile.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/abi.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/runconfiguration.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/taskhub.h>
|
#include <projectexplorer/taskhub.h>
|
||||||
|
|
||||||
@@ -61,14 +63,32 @@ ClangStaticAnalyzerRunControl::ClangStaticAnalyzerRunControl(
|
|||||||
, m_projectInfo(projectInfo)
|
, m_projectInfo(projectInfo)
|
||||||
, m_toolchainType(ProjectExplorer::ToolChainKitInformation
|
, m_toolchainType(ProjectExplorer::ToolChainKitInformation
|
||||||
::toolChain(runConfiguration->target()->kit())->type())
|
::toolChain(runConfiguration->target()->kit())->type())
|
||||||
|
, m_wordWidth(runConfiguration->abi().wordWidth())
|
||||||
, m_initialFilesToProcessSize(0)
|
, m_initialFilesToProcessSize(0)
|
||||||
, m_filesAnalyzed(0)
|
, m_filesAnalyzed(0)
|
||||||
, m_filesNotAnalyzed(0)
|
, m_filesNotAnalyzed(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes (1) filePath (2) -o <somePath>
|
static void prependWordWidthArgumentIfNotIncluded(QStringList *arguments, unsigned char wordWidth)
|
||||||
static QStringList tweakedArguments(const QString &filePath, const QStringList &arguments)
|
{
|
||||||
|
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;
|
QStringList newArguments;
|
||||||
|
|
||||||
@@ -88,12 +108,15 @@ static QStringList tweakedArguments(const QString &filePath, const QStringList &
|
|||||||
}
|
}
|
||||||
QTC_CHECK(skip == false);
|
QTC_CHECK(skip == false);
|
||||||
|
|
||||||
|
prependWordWidthArgumentIfNotIncluded(&newArguments, wordWidth);
|
||||||
|
|
||||||
return newArguments;
|
return newArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QStringList argumentsFromProjectPart(const CppTools::ProjectPart::Ptr &projectPart,
|
static QStringList argumentsFromProjectPart(const CppTools::ProjectPart::Ptr &projectPart,
|
||||||
CppTools::ProjectFile::Kind fileKind,
|
CppTools::ProjectFile::Kind fileKind,
|
||||||
const QString &toolchainType)
|
const QString &toolchainType,
|
||||||
|
unsigned char wordWidth)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
||||||
@@ -112,16 +135,20 @@ static QStringList argumentsFromProjectPart(const CppTools::ProjectPart::Ptr &pr
|
|||||||
projectPart->headerPaths,
|
projectPart->headerPaths,
|
||||||
CompilerOptionsBuilder::IsBlackListed(),
|
CompilerOptionsBuilder::IsBlackListed(),
|
||||||
toolchainType);
|
toolchainType);
|
||||||
|
|
||||||
if (toolchainType == QLatin1String("msvc"))
|
if (toolchainType == QLatin1String("msvc"))
|
||||||
result += QLatin1String("/EHsc"); // clang-cl does not understand exceptions
|
result += QLatin1String("/EHsc"); // clang-cl does not understand exceptions
|
||||||
else
|
else
|
||||||
result += QLatin1String("-fPIC"); // TODO: Remove?
|
result += QLatin1String("-fPIC"); // TODO: Remove?
|
||||||
|
|
||||||
|
prependWordWidthArgumentIfNotIncluded(&result, wordWidth);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompilerCallData(
|
static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompilerCallData(
|
||||||
const ProjectInfo::CompilerCallData &compilerCallData)
|
const ProjectInfo::CompilerCallData &compilerCallData,
|
||||||
|
unsigned char wordWidth)
|
||||||
{
|
{
|
||||||
typedef ClangStaticAnalyzerRunControl::AnalyzeUnit AnalyzeUnit;
|
typedef ClangStaticAnalyzerRunControl::AnalyzeUnit AnalyzeUnit;
|
||||||
qCDebug(LOG) << "Taking arguments for analyzing from CompilerCallData.";
|
qCDebug(LOG) << "Taking arguments for analyzing from CompilerCallData.";
|
||||||
@@ -134,7 +161,7 @@ static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompi
|
|||||||
const QString file = it.key();
|
const QString file = it.key();
|
||||||
const QList<QStringList> compilerCalls = it.value();
|
const QList<QStringList> compilerCalls = it.value();
|
||||||
foreach (const QStringList &options, compilerCalls) {
|
foreach (const QStringList &options, compilerCalls) {
|
||||||
const QStringList arguments = tweakedArguments(file, options);
|
const QStringList arguments = tweakedArguments(file, options, wordWidth);
|
||||||
unitsToAnalyze << AnalyzeUnit(file, arguments);
|
unitsToAnalyze << AnalyzeUnit(file, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +170,9 @@ static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromCompi
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromProjectParts(
|
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;
|
typedef ClangStaticAnalyzerRunControl::AnalyzeUnit AnalyzeUnit;
|
||||||
qCDebug(LOG) << "Taking arguments for analyzing from ProjectParts.";
|
qCDebug(LOG) << "Taking arguments for analyzing from ProjectParts.";
|
||||||
@@ -159,8 +188,10 @@ static QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> unitsToAnalyzeFromProje
|
|||||||
continue;
|
continue;
|
||||||
QTC_CHECK(file.kind != ProjectFile::Unclassified);
|
QTC_CHECK(file.kind != ProjectFile::Unclassified);
|
||||||
if (ProjectFile::isSource(file.kind)) {
|
if (ProjectFile::isSource(file.kind)) {
|
||||||
const QStringList arguments
|
const QStringList arguments = argumentsFromProjectPart(projectPart,
|
||||||
= argumentsFromProjectPart(projectPart, file.kind, toolchainType);
|
file.kind,
|
||||||
|
toolchainType,
|
||||||
|
wordWidth);
|
||||||
unitsToAnalyze << AnalyzeUnit(file.path, arguments);
|
unitsToAnalyze << AnalyzeUnit(file.path, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,8 +206,10 @@ QList<ClangStaticAnalyzerRunControl::AnalyzeUnit> ClangStaticAnalyzerRunControl:
|
|||||||
|
|
||||||
const ProjectInfo::CompilerCallData compilerCallData = m_projectInfo.compilerCallData();
|
const ProjectInfo::CompilerCallData compilerCallData = m_projectInfo.compilerCallData();
|
||||||
if (!compilerCallData.isEmpty())
|
if (!compilerCallData.isEmpty())
|
||||||
return unitsToAnalyzeFromCompilerCallData(compilerCallData);
|
return unitsToAnalyzeFromCompilerCallData(compilerCallData, m_wordWidth);
|
||||||
return unitsToAnalyzeFromProjectParts(m_projectInfo.projectParts(), m_toolchainType);
|
return unitsToAnalyzeFromProjectParts(m_projectInfo.projectParts(),
|
||||||
|
m_toolchainType,
|
||||||
|
m_wordWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClangStaticAnalyzerRunControl::startEngine()
|
bool ClangStaticAnalyzerRunControl::startEngine()
|
||||||
|
@@ -70,6 +70,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
const CppTools::ProjectInfo m_projectInfo;
|
const CppTools::ProjectInfo m_projectInfo;
|
||||||
const QString m_toolchainType;
|
const QString m_toolchainType;
|
||||||
|
const unsigned char m_wordWidth;
|
||||||
|
|
||||||
QString m_clangExecutable;
|
QString m_clangExecutable;
|
||||||
QString m_clangLogFileDir;
|
QString m_clangLogFileDir;
|
||||||
|
@@ -70,8 +70,6 @@ RunControl *ClangStaticAnalyzerRunControlFactory::create(RunConfiguration *runCo
|
|||||||
RunMode runMode,
|
RunMode runMode,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
Q_UNUSED(runMode);
|
|
||||||
|
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
const ProjectInfo projectInfoBeforeBuild = m_tool->projectInfoBeforeBuild();
|
const ProjectInfo projectInfoBeforeBuild = m_tool->projectInfoBeforeBuild();
|
||||||
QTC_ASSERT(projectInfoBeforeBuild.isValid(), return 0);
|
QTC_ASSERT(projectInfoBeforeBuild.isValid(), return 0);
|
||||||
|
@@ -94,10 +94,16 @@ void ClangStaticAnalyzerUnitTests::testProject_data()
|
|||||||
{
|
{
|
||||||
QTest::addColumn<QString>("projectFilePath");
|
QTest::addColumn<QString>("projectFilePath");
|
||||||
QTest::addColumn<int>("expectedDiagCount");
|
QTest::addColumn<int>("expectedDiagCount");
|
||||||
QTest::newRow("qbs project")
|
|
||||||
|
QTest::newRow("simple qbs project")
|
||||||
<< QString(m_tmpDir->path() + QLatin1String("/simple/simple.qbs")) << 1;
|
<< 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;
|
<< 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
|
} // namespace Internal
|
||||||
|
@@ -3,5 +3,11 @@
|
|||||||
<file>unit-tests/simple/main.cpp</file>
|
<file>unit-tests/simple/main.cpp</file>
|
||||||
<file>unit-tests/simple/simple.qbs</file>
|
<file>unit-tests/simple/simple.qbs</file>
|
||||||
<file>unit-tests/simple/simple.pro</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>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@@ -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();
|
||||||
|
}
|
@@ -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;
|
||||||
|
}
|
@@ -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
|
@@ -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>
|
@@ -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
|
@@ -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"
|
||||||
|
]
|
||||||
|
}
|
Reference in New Issue
Block a user