forked from qt-creator/qt-creator
ClangFormat: Fix empty warning message
Change-Id: Id08afdea266c018fe6b2756cf7d3bbe8677aaae9 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -396,27 +396,30 @@ Utils::FilePath filePathToCurrentSettings(const TextEditor::ICodeStylePreference
|
|||||||
/ QLatin1String(Constants::SETTINGS_FILE_NAME);
|
/ QLatin1String(Constants::SETTINGS_FILE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString s_errorMessage;
|
|
||||||
Utils::expected_str<void> parseConfigurationContent(const std::string &fileContent,
|
Utils::expected_str<void> parseConfigurationContent(const std::string &fileContent,
|
||||||
clang::format::FormatStyle &style,
|
clang::format::FormatStyle &style,
|
||||||
bool allowUnknownOptions)
|
bool allowUnknownOptions)
|
||||||
{
|
{
|
||||||
auto diagHandler = [](const llvm::SMDiagnostic &diag, void * /*context*/) {
|
llvm::SourceMgr::DiagHandlerTy diagHandler = [](const llvm::SMDiagnostic &diag, void *context) {
|
||||||
s_errorMessage = QString::fromStdString(diag.getMessage().str()) + " "
|
QString *errorMessage = reinterpret_cast<QString *>(context);
|
||||||
+ QString::number(diag.getLineNo()) + ":"
|
*errorMessage = QString::fromStdString(diag.getMessage().str()) + " "
|
||||||
+ QString::number(diag.getColumnNo());
|
+ QString::number(diag.getLineNo()) + ":"
|
||||||
|
+ QString::number(diag.getColumnNo());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QString errorMessage;
|
||||||
style.Language = clang::format::FormatStyle::LK_Cpp;
|
style.Language = clang::format::FormatStyle::LK_Cpp;
|
||||||
const std::error_code error = parseConfiguration(
|
const std::error_code error = parseConfiguration(
|
||||||
llvm::MemoryBufferRef(fileContent, "YAML"),
|
llvm::MemoryBufferRef(fileContent, "YAML"),
|
||||||
&style,
|
&style,
|
||||||
allowUnknownOptions,
|
allowUnknownOptions,
|
||||||
diagHandler,
|
diagHandler,
|
||||||
nullptr);
|
&errorMessage);
|
||||||
|
|
||||||
|
errorMessage = errorMessage.trimmed().isEmpty() ? QString::fromStdString(error.message())
|
||||||
|
: errorMessage;
|
||||||
if (error)
|
if (error)
|
||||||
return make_unexpected(s_errorMessage);
|
return make_unexpected(errorMessage);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user