[PATCH] D68969: [clang-format] Remove the dependency on frontend

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 02:21:05 PDT 2019


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


================
Comment at: clang/tools/clang-format/ClangFormat.cpp:351
+      SourceLocation LineBegin = Sources.translateFileLineCol(
+          FileEntryPtr.get(), PLoc.getLine() - 1, 0);
+      SourceLocation NextLineBegin =
----------------
MyDeveloperDay wrote:
> klimek wrote:
> > This is unexpected: I'd have expected this to be PLoc.getLine() here and PLoc.getLine() + 1 below. I'm probably missing something?
> This caught me out too, but it kept pulling the next line. So I think it must be a zero based line as opposed to PesumedLoc which uses line 1 to mean the first line..
> 
> but leet me double check.
OK this then perhaps is wrong, given the assert.. let me double check what is going on.

```
 SourceLocation SourceManager::translateFileLineCol(const FileEntry *SourceFile,
                                                   unsigned Line,
                                                   unsigned Col) const {
   assert(SourceFile && "Null source file!");
   assert(Line && Col && "Line and column should start from 1!");
 
   FileID FirstFID = translateFile(SourceFile);
   return translateLineCol(FirstFID, Line, Col);
 }
```


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

https://reviews.llvm.org/D68969





More information about the cfe-commits mailing list