aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/3rdparty/cplusplus/TranslationUnit.cpp14
-rw-r--r--src/libs/3rdparty/cplusplus/TranslationUnit.h16
-rw-r--r--tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp21
3 files changed, 36 insertions, 15 deletions
diff --git a/src/libs/3rdparty/cplusplus/TranslationUnit.cpp b/src/libs/3rdparty/cplusplus/TranslationUnit.cpp
index 9bc8edecfda..df9c2151a45 100644
--- a/src/libs/3rdparty/cplusplus/TranslationUnit.cpp
+++ b/src/libs/3rdparty/cplusplus/TranslationUnit.cpp
@@ -164,7 +164,7 @@ void TranslationUnit::tokenize()
_Lrecognize:
if (tk.is(T_POUND) && tk.newline()) {
- unsigned offset = tk.byteOffset;
+ const unsigned utf16CharOffset = tk.utf16charOffset;
lex(&tk);
if (! tk.newline() && tk.is(T_IDENTIFIER) && tk.identifier == expansionId) {
@@ -237,7 +237,7 @@ void TranslationUnit::tokenize()
if (! tk.newline() && tk.is(T_STRING_LITERAL)) {
const StringLiteral *fileName =
control()->stringLiteral(tk.string->chars(), tk.string->size());
- pushPreprocessorLine(offset, line, fileName);
+ pushPreprocessorLine(utf16CharOffset, line, fileName);
lex(&tk);
}
}
@@ -343,10 +343,10 @@ bool TranslationUnit::parse(ParseMode mode)
void TranslationUnit::pushLineOffset(unsigned offset)
{ _lineOffsets.push_back(offset); }
-void TranslationUnit::pushPreprocessorLine(unsigned offset,
+void TranslationUnit::pushPreprocessorLine(unsigned utf16charOffset,
unsigned line,
const StringLiteral *fileName)
-{ _ppLines.push_back(PPLine(offset, line, fileName)); }
+{ _ppLines.push_back(PPLine(utf16charOffset, line, fileName)); }
unsigned TranslationUnit::findLineNumber(unsigned utf16charOffset) const
{
@@ -359,10 +359,10 @@ unsigned TranslationUnit::findLineNumber(unsigned utf16charOffset) const
return it - _lineOffsets.begin();
}
-TranslationUnit::PPLine TranslationUnit::findPreprocessorLine(unsigned offset) const
+TranslationUnit::PPLine TranslationUnit::findPreprocessorLine(unsigned utf16charOffset) const
{
std::vector<PPLine>::const_iterator it =
- std::lower_bound(_ppLines.begin(), _ppLines.end(), PPLine(offset));
+ std::lower_bound(_ppLines.begin(), _ppLines.end(), PPLine(utf16charOffset));
if (it != _ppLines.begin())
--it;
@@ -419,7 +419,7 @@ void TranslationUnit::getPosition(unsigned utf16charOffset,
// Adjust the line in regards to the preprocessing markers.
const PPLine ppLine = findPreprocessorLine(utf16charOffset);
- lineNumber -= findLineNumber(ppLine.offset) + 1;
+ lineNumber -= findLineNumber(ppLine.utf16charOffset) + 1;
lineNumber += ppLine.line;
file = ppLine.fileName;
diff --git a/src/libs/3rdparty/cplusplus/TranslationUnit.h b/src/libs/3rdparty/cplusplus/TranslationUnit.h
index 83213703c59..c42e25f958e 100644
--- a/src/libs/3rdparty/cplusplus/TranslationUnit.h
+++ b/src/libs/3rdparty/cplusplus/TranslationUnit.h
@@ -138,7 +138,7 @@ public:
const StringLiteral **fileName = 0) const;
void pushLineOffset(unsigned offset);
- void pushPreprocessorLine(unsigned offset,
+ void pushPreprocessorLine(unsigned utf16charOffset,
unsigned line,
const StringLiteral *fileName);
@@ -151,30 +151,30 @@ public:
private:
struct PPLine {
- unsigned offset;
+ unsigned utf16charOffset;
unsigned line;
const StringLiteral *fileName;
- PPLine(unsigned offset = 0,
+ PPLine(unsigned utf16charOffset = 0,
unsigned line = 0,
const StringLiteral *fileName = 0)
- : offset(offset), line(line), fileName(fileName)
+ : utf16charOffset(utf16charOffset), line(line), fileName(fileName)
{ }
bool operator == (const PPLine &other) const
- { return offset == other.offset; }
+ { return utf16charOffset == other.utf16charOffset; }
bool operator != (const PPLine &other) const
- { return offset != other.offset; }
+ { return utf16charOffset != other.utf16charOffset; }
bool operator < (const PPLine &other) const
- { return offset < other.offset; }
+ { return utf16charOffset < other.utf16charOffset; }
};
void releaseTokensAndComments();
unsigned findLineNumber(unsigned utf16charOffset) const;
unsigned findColumnNumber(unsigned utf16CharOffset, unsigned lineNumber) const;
- PPLine findPreprocessorLine(unsigned offset) const;
+ PPLine findPreprocessorLine(unsigned utf16charOffset) const;
void showErrorLine(unsigned index, unsigned column, FILE *out);
static const Token nullToken;
diff --git a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp
index c31c69178f4..07cd07eb42e 100644
--- a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp
+++ b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp
@@ -125,6 +125,7 @@ public:
// Preprocess source
Environment env;
Preprocessor preprocess(0, &env);
+ preprocess.setKeepComments(true);
const QByteArray preprocessedSource = preprocess.run(filePath, source);
document->setUtf8Source(preprocessedSource);
@@ -1687,6 +1688,26 @@ void tst_CheckSymbols::test_checksymbols_data()
<< Use(9, 1, 5, Highlighting::TypeUse)
<< Use(9, 1, 5, Highlighting::TypeUse)
<< Use(9, 9, 5, Highlighting::TypeUse));
+
+#define UC_U10302_4TIMES UC_U10302 UC_U10302 UC_U10302 UC_U10302
+#define UC_U10302_12TIMES UC_U10302_4TIMES UC_U10302_4TIMES UC_U10302_4TIMES
+ QTest::newRow("unicodeComments1")
+ << _("#define NULL 0\n"
+ "\n"
+ "// " UC_U10302_12TIMES "\n"
+ "// " UC_U10302_12TIMES "\n"
+ "\n"
+ "class Foo {\n"
+ "double f(bool b = NULL);\n"
+ "Foo *x;\n"
+ "};\n")
+ << (UseList()
+ << Use(6, 7, 3, CppHighlightingSupport::TypeUse)
+ << Use(7, 8, 1, CppHighlightingSupport::FunctionUse)
+ << Use(8, 1, 3, CppHighlightingSupport::TypeUse)
+ << Use(8, 6, 1, CppHighlightingSupport::FieldUse));
+#undef UC_U10302_12TIMES
+#undef UC_U10302_4TIMES
}
void tst_CheckSymbols::test_checksymbols_macroUses()