Clang: Add commentary about column convertion

... to/from utf8 byte offset used by Clang.

Change-Id: I294d6cd61b416e5f2d64206ee2f3f1b4a91fb1d3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-01-26 17:04:38 +01:00
parent 0c50d54da7
commit fbbdfd2444
6 changed files with 20 additions and 4 deletions

View File

@@ -100,6 +100,9 @@ SourceLocation::SourceLocation(CXTranslationUnit cxTranslationUnit,
const char *contents = clang_getFileContents(cxTranslationUnit, cxFile, nullptr);
if (!contents)
return;
// (1) column in SourceLocation is the actual column shown by CppEditor.
// (2) column in Clang is the utf8 byte offset from the beginning of the line.
// Here we convert column from (2) to (1).
column_ = static_cast<uint>(QString::fromUtf8(&contents[lineStart],
static_cast<int>(column_)).size());
}