From fbbdfd24446c12eff7761d16c6acbf8e24985a5c Mon Sep 17 00:00:00 2001 From: Ivan Donchevskii Date: Fri, 26 Jan 2018 17:04:38 +0100 Subject: Clang: Add commentary about column convertion ... to/from utf8 byte offset used by Clang. Change-Id: I294d6cd61b416e5f2d64206ee2f3f1b4a91fb1d3 Reviewed-by: Nikolai Kosjar --- src/tools/clangbackend/source/sourcelocation.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/tools/clangbackend/source/sourcelocation.cpp') diff --git a/src/tools/clangbackend/source/sourcelocation.cpp b/src/tools/clangbackend/source/sourcelocation.cpp index 41f68a9ae6..77fd9e61da 100644 --- a/src/tools/clangbackend/source/sourcelocation.cpp +++ b/src/tools/clangbackend/source/sourcelocation.cpp @@ -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(QString::fromUtf8(&contents[lineStart], static_cast(column_)).size()); } -- cgit v1.2.1