[cfe-dev] Line and Column from clang-tidy

Marek Kurdej curdeius at gmail.com
Thu Oct 30 01:09:01 PDT 2014


Hi Daniel,


> I have been calling runClangTidy directly, and I finally am (mostly)
> getting the results that I expect.
> ClangTidyMessage has the position as an offset into the file.  Is there a
> function in Clang/LLVM that will convert this to a line and column?

Take a look at SourceManager methods like getSpellingLineNumber

In a clang-tidy check, you can write something along the lines:
  const SourceManager &SM = *Result.SourceManager;
  SourceLocation Loc = ...;
  bool Invalid = false;
  unsigned LineNo = SM.getSpellingLineNumber(Loc, &Invalid);
  unsigned ColNo = SM.getSpellingColumnNumber(Loc, &Invalid);

Cheers,

Marek Kurdej
--
Ph.D. candidate
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141030/02c33754/attachment.html>


More information about the cfe-commits mailing list