[PATCH] D68682: Clang-tidy fix removals removing all non-blank text from a line should remove the line

Conrad Poelman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 9 14:41:39 PDT 2019


poelmanc marked an inline comment as done.
poelmanc added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:27
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/CharInfo.h" // for isWhiteSpace(char), isVerticalWhitespace(char)
 #include "clang/Config/config.h"
----------------
MyDeveloperDay wrote:
> Nit: I'm guessing you'd drop these comments later
Thanks, will do!


================
Comment at: clang-tools-extra/clang-tidy/ClangTidy.cpp:143
+                     ReplacementText.empty();
+    LineCheckedThroughPos = R.getOffset() + R.getLength();
+  }
----------------
MyDeveloperDay wrote:
> so If I understand correctly, if the ReplcementText is empty we are assuming we've removed it, as opposed to if someone was adding a blank line the ReplacementText would be all whitespace as we might remove it by mistake.. sound reasonable
Exactly. A check's check() function can create a clang::FixItHint as an Insertion, Removal, or Replacement. Later FixItHints get processed, sorted, and merged into an ordered set of clang::tooling::Replacement. Each Replacement has a file Offset, Length, and ReplacementText. So a Removal FixItHint generally ends up as a Replacement whose ReplacementText is the empty string.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68682/new/

https://reviews.llvm.org/D68682





More information about the cfe-commits mailing list