C++: Fix line number information after multiline comments.

Task-number: QTCREATORBUG-7702
Change-Id: I0ec2e1eb9bf1c556b0a426d4405df1c48b5653ed
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
This commit is contained in:
Christian Kamm
2012-08-07 10:47:38 +02:00
parent 336511dd99
commit 41e140da04
2 changed files with 130 additions and 4 deletions

View File

@@ -1137,10 +1137,17 @@ void Preprocessor::trackExpansionCycles(PPToken *tk)
}
}
static void adjustForCommentNewlines(unsigned *currentLine, const PPToken &tk)
{
if (tk.is(T_COMMENT) || tk.is(T_DOXY_COMMENT))
(*currentLine) += tk.asByteArrayRef().count('\n');
}
void Preprocessor::synchronizeOutputLines(const PPToken &tk, bool forceLine)
{
if (m_state.m_expansionStatus != NotExpanding
|| (!forceLine && m_env->currentLine == tk.lineno)) {
adjustForCommentNewlines(&m_env->currentLine, tk);
return;
}
@@ -1157,8 +1164,7 @@ void Preprocessor::synchronizeOutputLines(const PPToken &tk, bool forceLine)
}
m_env->currentLine = tk.lineno;
if (tk.is(T_COMMENT) || tk.is(T_DOXY_COMMENT))
m_env->currentLine += tk.asByteArrayRef().count('\n');
adjustForCommentNewlines(&m_env->currentLine, tk);
}
void Preprocessor::removeTrailingOutputLines()