Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp =================================================================== --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp @@ -883,11 +883,14 @@ // Add replacements referring to the changed code to existing replacements, // which refers to the original code. Replaces = Replaces.merge(NewReplacements); - format::FormatStyle Style = - format::getStyle("file", FilePath, FallbackStyle); + auto Style = format::getStyle("file", FilePath, FallbackStyle); + if (!Style) { + llvm::errs() << llvm::toString(Style.takeError()) << "\n"; + continue; + } // Clean up old namespaces if there is nothing in it after moving. auto CleanReplacements = - format::cleanupAroundReplacements(Code, Replaces, Style); + format::cleanupAroundReplacements(Code, Replaces, *Style); if (!CleanReplacements) { llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n"; continue; Index: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp =================================================================== --- clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp +++ clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp @@ -208,8 +208,15 @@ // Determine a formatting style from options. format::FormatStyle FormatStyle; - if (DoFormat) - FormatStyle = format::getStyle(FormatStyleOpt, FormatStyleConfig, "LLVM"); + if (DoFormat) { + auto FormatStyleOrError = + format::getStyle(FormatStyleOpt, FormatStyleConfig, "LLVM"); + if (!FormatStyleOrError) { + llvm::errs() << llvm::toString(FormatStyleOrError.takeError()) << "\n"; + return 1; + } + FormatStyle = *FormatStyleOrError; + } TUReplacements TURs; TUReplacementFiles TUFiles; Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp =================================================================== --- clang-tools-extra/trunk/clang-move/ClangMove.cpp +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp @@ -742,10 +742,13 @@ // Ignore replacements for new.h/cc. if (SI == FilePathToFileID.end()) continue; llvm::StringRef Code = SM.getBufferData(SI->second); - format::FormatStyle Style = - format::getStyle("file", FilePath, Context->FallbackStyle); + auto Style = format::getStyle("file", FilePath, Context->FallbackStyle); + if (!Style) { + llvm::errs() << llvm::toString(Style.takeError()) << "\n"; + continue; + } auto CleanReplacements = format::cleanupAroundReplacements( - Code, Context->FileToReplacements[FilePath], Style); + Code, Context->FileToReplacements[FilePath], *Style); if (!CleanReplacements) { llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n"; Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp @@ -197,10 +197,14 @@ continue; } StringRef Code = Buffer.get()->getBuffer(); - format::FormatStyle Style = format::getStyle("file", File, FormatStyle); + auto Style = format::getStyle("file", File, FormatStyle); + if (!Style) { + llvm::errs() << llvm::toString(Style.takeError()) << "\n"; + continue; + } llvm::Expected CleanReplacements = format::cleanupAroundReplacements(Code, FileAndReplacements.second, - Style); + *Style); if (!CleanReplacements) { llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n"; continue; Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp =================================================================== --- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp +++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp @@ -303,10 +303,13 @@ const IncludeFixerContext::HeaderInfo &RHS) { return LHS.QualifiedName == RHS.QualifiedName; }); - format::FormatStyle InsertStyle = - format::getStyle("file", Context.getFilePath(), Style); + auto InsertStyle = format::getStyle("file", Context.getFilePath(), Style); + if (!InsertStyle) { + llvm::errs() << llvm::toString(InsertStyle.takeError()) << "\n"; + return 1; + } auto Replacements = clang::include_fixer::createIncludeFixerReplacements( - Code->getBuffer(), Context, InsertStyle, + Code->getBuffer(), Context, *InsertStyle, /*AddQualifiers=*/IsUniqueQualifiedName); if (!Replacements) { errs() << "Failed to create replacements: " @@ -378,7 +381,11 @@ std::vector FixerReplacements; for (const auto &Context : Contexts) { StringRef FilePath = Context.getFilePath(); - format::FormatStyle InsertStyle = format::getStyle("file", FilePath, Style); + auto InsertStyle = format::getStyle("file", FilePath, Style); + if (!InsertStyle) { + llvm::errs() << llvm::toString(InsertStyle.takeError()) << "\n"; + return 1; + } auto Buffer = llvm::MemoryBuffer::getFile(FilePath); if (!Buffer) { errs() << "Couldn't open file: " + FilePath.str() + ": " @@ -387,7 +394,7 @@ } auto Replacements = clang::include_fixer::createIncludeFixerReplacements( - Buffer.get()->getBuffer(), Context, InsertStyle); + Buffer.get()->getBuffer(), Context, *InsertStyle); if (!Replacements) { errs() << "Failed to create replacement: " << llvm::toString(Replacements.takeError()) << "\n";