Fix MSVC warnings

* Missing `this` captures
* Implicit size_t -> int conversion
* Unused argument
* Suppress warnings in clang headers

Change-Id: I7083ce6ab22ee22ecc1258539e77c790acc78df1
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2019-09-11 08:22:53 +03:00
committed by Orgad Shaneh
parent 75a0340a53
commit 2aca0c1b28
11 changed files with 22 additions and 18 deletions

View File

@@ -90,8 +90,8 @@ QJsonDocument ProjectPartArtefact::createJsonDocument(Utils::SmallStringView jso
const char *whatError) const char *whatError)
{ {
QJsonParseError error; QJsonParseError error;
QJsonDocument document = QJsonDocument::fromJson(QByteArray::fromRawData(jsonText.data(), QJsonDocument document = QJsonDocument::fromJson(
jsonText.size()), QByteArray::fromRawData(jsonText.data(), int(jsonText.size())),
&error); &error);
checkError(whatError, error); checkError(whatError, error);

View File

@@ -137,9 +137,8 @@ ClangFormatConfigWidget::ClangFormatConfigWidget(ProjectExplorer::Project *proje
tr("Override Clang Format configuration file with the fallback configuration.")); tr("Override Clang Format configuration file with the fallback configuration."));
} }
connect(m_ui->overrideDefault, &QCheckBox::toggled, this, [this](bool checked) { connect(m_ui->overrideDefault, &QCheckBox::toggled,
showOrHideWidgets(); this, &ClangFormatConfigWidget::showOrHideWidgets);
});
showOrHideWidgets(); showOrHideWidgets();
fillTable(); fillTable();

View File

@@ -79,6 +79,7 @@ public:
TextEditor::CodeStyleEditorWidget *createCodeStyleEditor( TextEditor::CodeStyleEditorWidget *createCodeStyleEditor(
TextEditor::ICodeStylePreferences *preferences, QWidget *parent = nullptr) override TextEditor::ICodeStylePreferences *preferences, QWidget *parent = nullptr) override
{ {
Q_UNUSED(preferences);
if (!parent) if (!parent)
return new ClangFormatConfigWidget; return new ClangFormatConfigWidget;
return new ClangFormatConfigWidget(SessionManager::startupProject()); return new ClangFormatConfigWidget(SessionManager::startupProject());

View File

@@ -436,7 +436,7 @@ void QmlInspectorAgent::verifyAndInsertObjectInTree(const ObjectReference &objec
const auto it = m_debugIdToIname.find(objectDebugId); const auto it = m_debugIdToIname.find(objectDebugId);
if (it != m_debugIdToIname.end()) { if (it != m_debugIdToIname.end()) {
const QString iname = *it; const QString iname = *it;
const int firstIndex = strlen("inspect"); const int firstIndex = int(strlen("inspect"));
const int secondIndex = iname.indexOf('.', firstIndex + 1); const int secondIndex = iname.indexOf('.', firstIndex + 1);
if (secondIndex != -1) if (secondIndex != -1)
engineId = iname.midRef(firstIndex + 1, secondIndex - firstIndex - 1).toInt(); engineId = iname.midRef(firstIndex + 1, secondIndex - firstIndex - 1).toInt();

View File

@@ -495,7 +495,7 @@ void LanguageClientManager::findUsages(const Utils::FilePath &filePath, const QT
ReferenceParams params(TextDocumentPositionParams(document, pos)); ReferenceParams params(TextDocumentPositionParams(document, pos));
params.setContext(ReferenceParams::ReferenceContext(true)); params.setContext(ReferenceParams::ReferenceContext(true));
FindReferencesRequest request(params); FindReferencesRequest request(params);
auto callback = [wordUnderCursor = termCursor.selectedText()] auto callback = [this, wordUnderCursor = termCursor.selectedText()]
(const QString &clientName, const FindReferencesRequest::Response &response){ (const QString &clientName, const FindReferencesRequest::Response &response){
if (auto result = response.result()) { if (auto result = response.result()) {
Core::SearchResult *search = Core::SearchResultWindow::instance()->startNewSearch( Core::SearchResult *search = Core::SearchResultWindow::instance()->startNewSearch(

View File

@@ -610,7 +610,8 @@ ToolChain::BuiltInHeaderPathsRunner GccToolChain::createBuiltInHeaderPathsRunner
addToEnvironment(env); addToEnvironment(env);
// This runner must be thread-safe! // This runner must be thread-safe!
return [env, return [this,
env,
compilerCommand = m_compilerCommand, compilerCommand = m_compilerCommand,
platformCodeGenFlags = m_platformCodeGenFlags, platformCodeGenFlags = m_platformCodeGenFlags,
reinterpretOptions = m_optionsReinterpreter, reinterpretOptions = m_optionsReinterpreter,
@@ -1382,7 +1383,8 @@ ToolChain::BuiltInHeaderPathsRunner ClangToolChain::createBuiltInHeaderPathsRunn
addToEnvironment(env); addToEnvironment(env);
// This runner must be thread-safe! // This runner must be thread-safe!
return [env, return [this,
env,
compilerCommand = m_compilerCommand, compilerCommand = m_compilerCommand,
platformCodeGenFlags = m_platformCodeGenFlags, platformCodeGenFlags = m_platformCodeGenFlags,
reinterpretOptions = m_optionsReinterpreter, reinterpretOptions = m_optionsReinterpreter,

View File

@@ -123,7 +123,7 @@ bool TreeItem::compare(const std::vector<QString> &path) const
int TreeItem::row() const int TreeItem::row() const
{ {
if (m_parent) { if (m_parent) {
for (size_t i = 0; i < m_parent->m_children.size(); ++i) { for (int i = 0, total = int(m_parent->m_children.size()); i < total; ++i) {
if (m_parent->m_children[i] == this) if (m_parent->m_children[i] == this)
return i; return i;
} }
@@ -139,7 +139,7 @@ int TreeItem::column() const
int TreeItem::rowCount() const int TreeItem::rowCount() const
{ {
return m_children.size(); return int(m_children.size());
} }
int TreeItem::columnCount() const int TreeItem::columnCount() const

View File

@@ -184,7 +184,8 @@ void StatesEditorModel::renameState(int internalNodeId, const QString &newName)
if (newName.isEmpty() ||! m_statesEditorView->validStateName(newName)) { if (newName.isEmpty() ||! m_statesEditorView->validStateName(newName)) {
QTimer::singleShot(0, [newName]{ QTimer::singleShot(0, [newName]{
auto w = Core::AsynchronousMessageBox::warning(tr("Invalid state name"), Core::AsynchronousMessageBox::warning(
tr("Invalid state name"),
newName.isEmpty() ? newName.isEmpty() ?
tr("The empty string as a name is reserved for the base state.") : tr("The empty string as a name is reserved for the base state.") :
tr("Name already used in another state")); tr("Name already used in another state"));

View File

@@ -73,7 +73,7 @@ QmlPreviewRunner::QmlPreviewRunner(ProjectExplorer::RunControl *runControl,
}); });
connect(&m_connectionManager, &Internal::QmlPreviewConnectionManager::restart, connect(&m_connectionManager, &Internal::QmlPreviewConnectionManager::restart,
runControl, [runControl]() { runControl, [this, runControl]() {
if (!runControl->isRunning()) if (!runControl->isRunning())
return; return;

View File

@@ -243,7 +243,7 @@ void QtOutputFormatter::handleLink(const QString &href)
const QString filePath = qmlLineMatch.captured(1); const QString filePath = qmlLineMatch.captured(1);
QUrl fileUrl = QUrl(filePath); QUrl fileUrl = QUrl(filePath);
if (!fileUrl.isValid() && filePath.startsWith(scheme)) if (!fileUrl.isValid() && filePath.startsWith(scheme))
fileUrl = QUrl::fromLocalFile(filePath.mid(strlen(scheme))); fileUrl = QUrl::fromLocalFile(filePath.mid(int(strlen(scheme))));
const int line = qmlLineMatch.captured(2).toInt(); const int line = qmlLineMatch.captured(2).toInt();
openEditor(getFileToOpen(fileUrl), line); openEditor(getFileToOpen(fileUrl), line);
return; return;

View File

@@ -179,6 +179,7 @@ isEmpty(LLVM_VERSION) {
# clang/Format/Format.h has intentional multiline comments # clang/Format/Format.h has intentional multiline comments
QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-comment QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-comment
} }
msvc:QMAKE_CXXFLAGS_WARN_ON += -wd4100 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291
LLVM_LIBDIR = $$quote($$system($$llvm_config --libdir, lines)) LLVM_LIBDIR = $$quote($$system($$llvm_config --libdir, lines))
LLVM_BINDIR = $$quote($$system($$llvm_config --bindir, lines)) LLVM_BINDIR = $$quote($$system($$llvm_config --bindir, lines))