[PATCH] D24829: [clang-format] support header deletion in cleanupAroundReplacemnts.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 23 05:22:36 PDT 2016


djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


================
Comment at: lib/Format/Format.cpp:1557
@@ +1556,3 @@
+                     const std::set<llvm::StringRef> HeadersToDelete) {
+  if (HeadersToDelete.find(HeaderName) != HeadersToDelete.end())
+    return true;
----------------
  return HeaderToDelete.find(HeaderName) != HeadersToDelete.end() ||
         HeaderToDelete.find(HeaderName.trim("\"<>")) != HeadersToDelete.end()

================
Comment at: lib/Format/Format.cpp:1623
@@ -1607,2 +1622,3 @@
     if (IncludeRegex.match(Line, &Matches)) {
+      // The header name with quptos or angle brackets.
       StringRef IncludeName = Matches[2];
----------------
quotes.

================
Comment at: lib/Format/Format.cpp:1634
@@ +1633,3 @@
+        // sure we don't delete across the file boundary.
+        unsigned Length = (Offset + Line.size() < Code.size()) ? Line.size() + 1
+                                                               : Line.size();
----------------
Maybe:
  
  unsigned Length = std::min(Line.size(), Code.size() - Offset - 1);


https://reviews.llvm.org/D24829





More information about the cfe-commits mailing list