[PATCH] Clang-format: added -fromline and -toline options to specify ranges in line numbers instead of byte offsets.

Daniel Jasper djasper at google.com
Thu Jul 18 12:44:38 PDT 2013



================
Comment at: tools/clang-format/ClangFormat.cpp:175
@@ +174,3 @@
+    if (!Offsets.empty() || !Lengths.empty()) {
+      llvm::errs() << "error: can not use -lines with -offset/-length\n";
+      return true;
----------------
nit: cannot

================
Comment at: tools/clang-format/ClangFormat.cpp:190
@@ +189,3 @@
+      SourceLocation Start = Sources.translateLineCol(ID, FromLine, 1);
+      SourceLocation End = Sources.translateLineCol(ID, ToLine, (unsigned)-1);
+      if (Start.isInvalid() || End.isInvalid())
----------------
(unsigned)-1?????

I think just using Sources.translateLineCol(ID, ToLine, 1) should almost always lead to the same result (but I am not 100% sure).

How about:
Sources.translateLineCol(ID, ToLine + 1, 1).getLocWithOffset(-1)?


http://llvm-reviews.chandlerc.com/D1160

BRANCH
  svn

ARCANIST PROJECT
  clang



More information about the cfe-commits mailing list