[clang-tools-extra] fe4715c - Remove old create(MainFile)?IncludeInsertion overloads

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 06:25:05 PDT 2020


Author: Alexander Kornienko
Date: 2020-10-09T15:24:57+02:00
New Revision: fe4715c47f9c02a83b339c12067f1d27a3115fe4

URL: https://github.com/llvm/llvm-project/commit/fe4715c47f9c02a83b339c12067f1d27a3115fe4
DIFF: https://github.com/llvm/llvm-project/commit/fe4715c47f9c02a83b339c12067f1d27a3115fe4.diff

LOG: Remove old create(MainFile)?IncludeInsertion overloads

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D89117

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
    clang-tools-extra/clang-tidy/utils/IncludeInserter.h
    clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
index fdb93a8f1a81..5fc6020d4265 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<FixItHint>
-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)
@@ -77,22 +79,6 @@ IncludeInserter::createIncludeInsertion(FileID FileID, StringRef Header,
   return getOrCreate(FileID).CreateIncludeInsertion(Header, IsAngled);
 }
 
-llvm::Optional<FixItHint>
-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<FixItHint>
-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<FixItHint>
 IncludeInserter::createMainFileIncludeInsertion(StringRef Header) {
   assert(SourceMgr && "SourceMgr shouldn't be null; did you remember to call "

diff  --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.h b/clang-tools-extra/clang-tidy/utils/IncludeInserter.h
index ba45a1c3fa76..95236c732f13 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.h
+++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.h
@@ -66,14 +66,6 @@ class IncludeInserter {
   /// class is used.
   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<FixItHint>
-  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.
@@ -82,18 +74,10 @@ class IncludeInserter {
   llvm::Optional<FixItHint> createIncludeInsertion(FileID FileID,
                                                    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<FixItHint>
-  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<FixItHint>
   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 6ea757a38f05..ae2ae86f4665 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(


        


More information about the cfe-commits mailing list