aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2017-05-18 12:46:19 +0200
committerEike Ziller <eike.ziller@qt.io>2017-05-19 13:50:42 +0000
commit4e35cc2ea80effe757ff0c81a739aa1eb761b7c4 (patch)
tree41b6d7f764f4c5a4678673a4d298f325ebc9ab6f
parenta37c8add58d43e37a96c5c49080cd0bf41205308 (diff)
Fix that raw string literals that close on same line were not terminated
With the built-in model, which affects basic highlighting. Task-number: QTCREATORBUG-17720 Change-Id: I7369d7288d9c2c8e5ef36fc27549121014527e58 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
-rw-r--r--src/libs/3rdparty/cplusplus/Lexer.cpp4
-rw-r--r--tests/auto/cplusplus/lexer/tst_lexer.cpp16
2 files changed, 19 insertions, 1 deletions
diff --git a/src/libs/3rdparty/cplusplus/Lexer.cpp b/src/libs/3rdparty/cplusplus/Lexer.cpp
index efaaaf9165..e62c9412a4 100644
--- a/src/libs/3rdparty/cplusplus/Lexer.cpp
+++ b/src/libs/3rdparty/cplusplus/Lexer.cpp
@@ -748,6 +748,7 @@ void Lexer::scanRawStringLiteral(Token *tok, unsigned char hint)
int delimLength = -1;
const char *closingDelimCandidate = 0;
+ bool closed = false;
while (_yychar) {
if (_yychar == '(' && delimLength == -1) {
delimLength = _currentChar - yytext;
@@ -769,6 +770,7 @@ void Lexer::scanRawStringLiteral(Token *tok, unsigned char hint)
if (_yychar == '"') {
if (delimLength == _currentChar - closingDelimCandidate) {
// Got a matching closing delimiter.
+ closed = true;
break;
}
}
@@ -802,7 +804,7 @@ void Lexer::scanRawStringLiteral(Token *tok, unsigned char hint)
else
tok->f.kind = T_RAW_STRING_LITERAL;
- if (!_yychar)
+ if (!closed)
s._tokenKind = tok->f.kind;
}
diff --git a/tests/auto/cplusplus/lexer/tst_lexer.cpp b/tests/auto/cplusplus/lexer/tst_lexer.cpp
index 23ddcc21b0..a2c415d33c 100644
--- a/tests/auto/cplusplus/lexer/tst_lexer.cpp
+++ b/tests/auto/cplusplus/lexer/tst_lexer.cpp
@@ -766,6 +766,22 @@ void tst_SimpleLexer::incremental_data()
<< _("bar\";")
<< (TokenKindList() << T_STRING_LITERAL << T_SEMICOLON);
+ QTest::newRow("multiline_raw_string_literal_1")
+ << _("R\"delim(foo")
+ << (TokenKindList() << T_RAW_STRING_LITERAL);
+
+ QTest::newRow("multiline_raw_string_literal_2")
+ << _("bar)delim\"")
+ << (TokenKindList() << T_RAW_STRING_LITERAL);
+
+ QTest::newRow("token_after_raw_string_literal_1")
+ << _("R\"delim( )delim\"")
+ << (TokenKindList() << T_RAW_STRING_LITERAL);
+
+ QTest::newRow("token_after_raw_string_literal_2")
+ << _(";")
+ << (TokenKindList() << T_SEMICOLON);
+
QTest::newRow("simple_cpp_comment")
<< _("//foo")
<< (TokenKindList() << T_CPP_COMMENT);