diff --git a/src/libs/cplusplus/BackwardsScanner.cpp b/src/libs/cplusplus/BackwardsScanner.cpp
index eb0e5c280335c9af1637b3733976819cda027b25..32efdf158ee2e0f9a53ca375d934545873655136 100644
--- a/src/libs/cplusplus/BackwardsScanner.cpp
+++ b/src/libs/cplusplus/BackwardsScanner.cpp
@@ -76,21 +76,9 @@ const SimpleToken &BackwardsScanner::fetchToken(int i)
             QList<SimpleToken> adaptedTokens;
             for (int i = 0; i < _tokens.size(); ++i) {
                 SimpleToken t = _tokens.at(i);
-                if (i == 0) {
-                    Q_ASSERT(t.followsNewline());
-                }
                 t.setPosition(t.position() + blockText.length());
                 t.setText(_text.midRef(t.position(), t.length()));
-
-                if (i == 0) {
-                    Q_ASSERT(t.followsNewline());
-                }
-
                 adaptedTokens.append(t);
-
-                if (i == 0) {
-                    Q_ASSERT(adaptedTokens.last().followsNewline());
-                }
             }
 
             _tokens = _tokenize(blockText, previousBlockState(_block));
@@ -111,18 +99,16 @@ int BackwardsScanner::startPosition() const
 QString BackwardsScanner::text() const
 { return _text; }
 
-QString BackwardsScanner::text(int begin, int end) const
+QString BackwardsScanner::text(int index) const
 {
-    const SimpleToken &firstToken = _tokens.at(begin + _offset);
-    const SimpleToken &lastToken = _tokens.at(end + _offset - 1);
-    return _text.mid(firstToken.begin(), lastToken.end() - firstToken.begin());
+    const SimpleToken &firstToken = _tokens.at(index + _offset);
+    return _text.mid(firstToken.begin(), firstToken.length());
 }
 
-QStringRef BackwardsScanner::textRef(int begin, int end) const
+QStringRef BackwardsScanner::textRef(int index) const
 {
-    const SimpleToken &firstToken = _tokens.at(begin + _offset);
-    const SimpleToken &lastToken = _tokens.at(end + _offset - 1);
-    return _text.midRef(firstToken.begin(), lastToken.end() - firstToken.begin());
+    const SimpleToken &firstToken = _tokens.at(index + _offset);
+    return _text.midRef(firstToken.begin(), firstToken.length());
 }
 
 int BackwardsScanner::previousBlockState(const QTextBlock &block) const
diff --git a/src/libs/cplusplus/BackwardsScanner.h b/src/libs/cplusplus/BackwardsScanner.h
index 1ce6d3f85c20866c08ba6d965a55a5bf5e1d5738..a109d2cab31f59edb8d4597f0d3219763ed2578e 100644
--- a/src/libs/cplusplus/BackwardsScanner.h
+++ b/src/libs/cplusplus/BackwardsScanner.h
@@ -51,8 +51,8 @@ public:
     int startPosition() const;
 
     QString text() const;
-    QString text(int begin, int end) const;
-    QStringRef textRef(int begin, int end) const;
+    QString text(int index) const;
+    QStringRef textRef(int index) const;
 
     // 1-based
     SimpleToken LA(int index) const;
diff --git a/src/libs/cplusplus/ExpressionUnderCursor.cpp b/src/libs/cplusplus/ExpressionUnderCursor.cpp
index 106e3040b1bd8abe923f865103afad8beffccee5..e64444190254c832ea15e726ca72fd677f6d2541 100644
--- a/src/libs/cplusplus/ExpressionUnderCursor.cpp
+++ b/src/libs/cplusplus/ExpressionUnderCursor.cpp
@@ -150,7 +150,7 @@ QString ExpressionUnderCursor::operator()(const QTextCursor &cursor)
     if (i == initialSize)
         return QString();
 
-    return scanner.text(i, initialSize);
+    return scanner.text(i);
 }
 
 int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) const
diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp
index 8813e890bee8dfd4cb9c7d35c10bb9d87f047917..877145d886a35b1c235553ec12f9acdd5e3af407 100644
--- a/src/libs/cplusplus/MatchingText.cpp
+++ b/src/libs/cplusplus/MatchingText.cpp
@@ -49,9 +49,9 @@ static bool shouldOverrideChar(const QChar &ch)
     }
 }
 
-static bool isCompleteStringLiteral(const BackwardsScanner &tk, int index, int startToken)
+static bool isCompleteStringLiteral(const BackwardsScanner &tk, int index)
 {
-    const QStringRef text = tk.textRef(index, startToken);
+    const QStringRef text = tk.textRef(index);
 
     if (text.length() < 2)
         return false;
@@ -62,9 +62,9 @@ static bool isCompleteStringLiteral(const BackwardsScanner &tk, int index, int s
     return false;
 }
 
-static bool isCompleteCharLiteral(const BackwardsScanner &tk, int index, int startToken)
+static bool isCompleteCharLiteral(const BackwardsScanner &tk, int index)
 {
-    const QStringRef text = tk.textRef(index, startToken);
+    const QStringRef text = tk.textRef(index);
 
     if (text.length() < 2)
         return false;
@@ -133,7 +133,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri
         if (text.length() != 1)
             qWarning() << Q_FUNC_INFO << "handle event compression";
 
-        if (isCompleteStringLiteral(tk, index - 1, startToken))
+        if (isCompleteStringLiteral(tk, index - 1))
             return QLatin1String("\"");
 
         return QString();
@@ -141,7 +141,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri
         if (text.length() != 1)
             qWarning() << Q_FUNC_INFO << "handle event compression";
 
-        if (isCompleteCharLiteral(tk, index - 1, startToken))
+        if (isCompleteCharLiteral(tk, index - 1))
             return QLatin1String("'");
 
         return QString();
diff --git a/src/libs/cplusplus/SimpleLexer.cpp b/src/libs/cplusplus/SimpleLexer.cpp
index 8c023d860366f35df73bd41d6fb40a192cc4b16f..59475bc4a4e78929fed5c0a4b2ec8eea602119f8 100644
--- a/src/libs/cplusplus/SimpleLexer.cpp
+++ b/src/libs/cplusplus/SimpleLexer.cpp
@@ -139,27 +139,14 @@ QList<SimpleToken> SimpleLexer::operator()(const QString &text, int state)
 
     bool inPreproc = false;
 
-    bool first = true;
-
     for (;;) {
         Token tk;
         lex(&tk);
         if (tk.is(T_EOF_SYMBOL))
             break;
 
-        Q_ASSERT(lex.tokenOffset() == tk.begin());
-        Q_ASSERT(lex.tokenLength() == tk.f.length);
-
         QStringRef spell = text.midRef(lex.tokenOffset(), lex.tokenLength());
         SimpleToken simpleTk(tk, spell);
-
-        if (first) {
-            first = false;
-
-            Q_ASSERT(tk.f.newline);
-            Q_ASSERT(simpleTk.followsNewline());
-        }
-
         lex.setScanAngleStringLiteralTokens(false);
 
         if (tk.f.newline && tk.is(T_POUND))
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 4a4c8dff1abe69d6432d8f25f39cedf7f7e8c7c0..22bb3672ff0606456653a510fac6121672223b6d 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -1472,9 +1472,6 @@ static void indentCPPBlock(const CPPEditor::TabSettings &ts,
 
 void CPPEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
 {
-    const TextEditor::TextBlockIterator begin(doc->begin());
-    const TextEditor::TextBlockIterator end(block.next());
-
     QTextCursor tc(block);
     tc.movePosition(QTextCursor::EndOfBlock);
 
@@ -1509,6 +1506,26 @@ void CPPEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedCha
         }
     }
 
+    if ((tokenCount == 0 || tk[0].isNot(T_POUND)) && typedChar.isNull() && (tk[-1].is(T_IDENTIFIER) || tk[-1].is(T_RPAREN))) {
+        int tokenIndex = -1;
+        if (tk[-1].is(T_RPAREN)) {
+            const int matchingBrace = tk.startOfMatchingBrace(0);
+            if (matchingBrace != 0 && tk[matchingBrace - 1].is(T_IDENTIFIER)) {
+                tokenIndex = matchingBrace - 1;
+            }
+        }
+
+        const QString spell = tk.text(tokenIndex);
+        if (tk[tokenIndex].followsNewline() && (spell.startsWith(QLatin1String("QT_")) ||
+                                                spell.startsWith(QLatin1String("Q_")))) {
+            const int indent = tk.indentation(tokenIndex);
+            tabSettings().indentLine(block, indent);
+            return;
+        }
+    }
+
+    const TextEditor::TextBlockIterator begin(doc->begin());
+    const TextEditor::TextBlockIterator end(block.next());
     indentCPPBlock(tabSettings(), block, begin, end, typedChar);
 }