Author: amaiorano Date: Mon Jan 16 18:13:32 2017 New Revision: 292175 URL: http://llvm.org/viewvc/llvm-project?rev=292175&view=rev Log: Update tools to use new getStyle API
Depends on https://reviews.llvm.org/D28081 Differential Revision: https://reviews.llvm.org/D28315 Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=292175&r1=292174&r2=292175&view=diff ============================================================================== --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original) +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Mon Jan 16 18:13:32 2017 @@ -883,11 +883,14 @@ void ChangeNamespaceTool::onEndOfTransla // 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; Modified: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp?rev=292175&r1=292174&r2=292175&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp (original) +++ clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp Mon Jan 16 18:13:32 2017 @@ -208,8 +208,15 @@ int main(int argc, char **argv) { // 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; Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=292175&r1=292174&r2=292175&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original) +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Mon Jan 16 18:13:32 2017 @@ -742,10 +742,13 @@ void ClangMoveTool::removeDeclsInOldFile // 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"; Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=292175&r1=292174&r2=292175&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Mon Jan 16 18:13:32 2017 @@ -197,10 +197,14 @@ public: 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<Replacements> CleanReplacements = format::cleanupAroundReplacements(Code, FileAndReplacements.second, - Style); + *Style); if (!CleanReplacements) { llvm::errs() << llvm::toString(CleanReplacements.takeError()) << "\n"; continue; Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=292175&r1=292174&r2=292175&view=diff ============================================================================== --- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Mon Jan 16 18:13:32 2017 @@ -303,10 +303,13 @@ int includeFixerMain(int argc, const cha 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 @@ int includeFixerMain(int argc, const cha std::vector<tooling::Replacements> 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 @@ int includeFixerMain(int argc, const cha } 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"; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits