forked from qt-creator/qt-creator
Clang Format: Fix partially initialized style
"Always initialize an object". `clang::format::FormatStyle` does not have a default constructor, so the options that are not explicitly specified in the config had garbage values. Improved error reporting. Task-number: QTCREATORBUG-32051 Change-Id: Id5d5d1b8247b61725644e0aa5f774e35635fcb41 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -930,8 +930,14 @@ clang::format::FormatStyle ClangFormatBaseIndenterPrivate::customSettingsStyle(
|
||||
return currentQtStyle(preferences);
|
||||
|
||||
clang::format::FormatStyle currentSettingsStyle;
|
||||
const Utils::expected_str<void> success = parseConfigurationFile(filePath, currentSettingsStyle);
|
||||
QTC_ASSERT(success, return currentQtStyle(preferences));
|
||||
const Utils::expected_str<void> result = parseConfigurationFile(filePath, currentSettingsStyle);
|
||||
if (!result) {
|
||||
qCWarning(clangIndenterLog)
|
||||
<< QString{"Failed to parse config %1. Falling back to the Qt style."}.arg(
|
||||
filePath.toUserOutput())
|
||||
<< result.error();
|
||||
return currentQtStyle(preferences);
|
||||
};
|
||||
|
||||
return currentSettingsStyle;
|
||||
}
|
||||
|
@@ -201,7 +201,7 @@ void ClangFormatConfigWidget::initEditor()
|
||||
this);
|
||||
|
||||
connect(m_editor->document(), &TextEditor::TextDocument::contentsChanged, this, [this] {
|
||||
clang::format::FormatStyle currentSettingsStyle;
|
||||
clang::format::FormatStyle currentSettingsStyle{};
|
||||
const Utils::expected_str<void> success
|
||||
= parseConfigurationContent(m_editor->document()->contents().toStdString(),
|
||||
currentSettingsStyle);
|
||||
|
Reference in New Issue
Block a user