FilePath: Return optional bytearray for file contents

For differentiating between "error" and "empty file".

Change-Id: I2c019ceac625e7be3180afa4d47ae3a24df91c1d
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2022-09-09 13:48:08 +02:00
parent 28349c1b08
commit 2c51e4bc17
22 changed files with 84 additions and 49 deletions

View File

@@ -754,9 +754,10 @@ clang::format::FormatStyle ClangFormatBaseIndenter::styleForFile() const
clang::format::FormatStyle currentSettingsStyle;
currentSettingsStyle.Language = clang::format::FormatStyle::LK_Cpp;
const std::error_code error
= clang::format::parseConfiguration(filePath.fileContents().toStdString(),
&currentSettingsStyle);
const std::error_code error = clang::format::parseConfiguration(filePath.fileContents()
.value_or(QByteArray())
.toStdString(),
&currentSettingsStyle);
QTC_ASSERT(error.value() == static_cast<int>(clang::format::ParseError::Success),
return qtcStyle());