From fe4715c47f9c02a83b339c12067f1d27a3115fe4 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Fri, 9 Oct 2020 00:56:00 +0200 Subject: [PATCH] Remove old create(MainFile)?IncludeInsertion overloads Reviewed By: hokein Differential Revision: https://reviews.llvm.org/D89117 --- .../clang-tidy/utils/IncludeInserter.cpp | 22 ++++------------------ .../clang-tidy/utils/IncludeInserter.h | 18 +----------------- .../clang-tidy/utils/TransformerClangTidyCheck.cpp | 9 ++------- 3 files changed, 7 insertions(+), 42 deletions(-) diff --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp index fdb93a8..5fc6020 100644 --- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp +++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp @@ -67,8 +67,10 @@ IncludeSorter &IncludeInserter::getOrCreate(FileID FileID) { } llvm::Optional -IncludeInserter::createIncludeInsertion(FileID FileID, StringRef Header, - bool IsAngled) { +IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) { + bool IsAngled = Header.consume_front("<"); + if (IsAngled != Header.consume_back(">")) + return llvm::None; // We assume the same Header will never be included both angled and not // angled. if (!InsertedHeaders[FileID].insert(Header).second) @@ -78,22 +80,6 @@ IncludeInserter::createIncludeInsertion(FileID FileID, StringRef Header, } llvm::Optional -IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) { - bool IsAngled = Header.consume_front("<"); - if (IsAngled != Header.consume_back(">")) - return llvm::None; - return createIncludeInsertion(FileID, Header, IsAngled); -} - -llvm::Optional -IncludeInserter::createMainFileIncludeInsertion(StringRef Header, - bool IsAngled) { - assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call " - "registerPreprocessor()?"); - return createIncludeInsertion(SourceMgr->getMainFileID(), Header, IsAngled); -} - -llvm::Optional IncludeInserter::createMainFileIncludeInsertion(StringRef Header) { assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call " "registerPreprocessor()?"); diff --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.h b/clang-tools-extra/clang-tidy/utils/IncludeInserter.h index ba45a1c..95236c7 100644 --- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.h +++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.h @@ -67,14 +67,6 @@ public: void registerPreprocessor(Preprocessor *PP); /// Creates a \p Header inclusion directive fixit in the File \p FileID. - /// Returns ``llvm::None`` on error or if the inclusion directive already - /// exists. - /// FIXME: This should be removed once the clients are migrated to the - /// overload without the ``IsAngled`` parameter. - llvm::Optional - createIncludeInsertion(FileID FileID, llvm::StringRef Header, bool IsAngled); - - /// Creates a \p Header inclusion directive fixit in the File \p FileID. /// When \p Header is enclosed in angle brackets, uses angle brackets in the /// inclusion directive, otherwise uses quotes. /// Returns ``llvm::None`` on error or if the inclusion directive already @@ -83,17 +75,9 @@ public: llvm::StringRef Header); /// Creates a \p Header inclusion directive fixit in the main file. - /// Returns``llvm::None`` on error or if the inclusion directive already - /// exists. - /// FIXME: This should be removed once the clients are migrated to the - /// overload without the ``IsAngled`` parameter. - llvm::Optional - createMainFileIncludeInsertion(llvm::StringRef Header, bool IsAngled); - - /// Creates a \p Header inclusion directive fixit in the main file. /// When \p Header is enclosed in angle brackets, uses angle brackets in the /// inclusion directive, otherwise uses quotes. - /// Returns``llvm::None`` on error or if the inclusion directive already + /// Returns ``llvm::None`` on error or if the inclusion directive already /// exists. llvm::Optional createMainFileIncludeInsertion(llvm::StringRef Header); diff --git a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp index 6ea757a..ae2ae86 100644 --- a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp @@ -95,15 +95,10 @@ void TransformerClangTidyCheck::check( case transformer::EditKind::Range: Diag << FixItHint::CreateReplacement(T.Range, T.Replacement); break; - case transformer::EditKind::AddInclude: { - StringRef FileName = T.Replacement; - bool IsAngled = FileName.startswith("<") && FileName.endswith(">"); - Diag << Inserter.createMainFileIncludeInsertion( - IsAngled ? FileName.substr(1, FileName.size() - 2) : FileName, - IsAngled); + case transformer::EditKind::AddInclude: + Diag << Inserter.createMainFileIncludeInsertion(T.Replacement); break; } - } } void TransformerClangTidyCheck::storeOptions( -- 2.7.4