C++: Preserve comments after preprocessor directives

Task-number: QTCREATORBUG-11216
Change-Id: Iac10e75f0f5c504b79e8466607dc1f478e578f99
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Orgad Shaneh
2014-01-10 09:08:39 +02:00
committed by Orgad Shaneh
parent 6133920bfe
commit dabdb60299
2 changed files with 81 additions and 2 deletions

View File

@@ -898,6 +898,11 @@ void Preprocessor::skipPreprocesorDirective(PPToken *tk)
ScopedBoolSwap s(m_state.m_inPreprocessorDirective, true);
while (isContinuationToken(*tk)) {
if (tk->isComment()) {
synchronizeOutputLines(*tk);
enforceSpacing(*tk, true);
currentOutputBuffer().append(tk->tokenStart(), tk->length());
}
lex(tk);
}
}
@@ -1703,8 +1708,13 @@ void Preprocessor::handleDefineDirective(PPToken *tk)
previousLine = tk->lineno;
// Discard comments in macro definitions (keep comments flag doesn't apply here).
if (!tk->isComment())
if (tk->isComment()) {
synchronizeOutputLines(*tk);
enforceSpacing(*tk, true);
currentOutputBuffer().append(tk->tokenStart(), tk->length());
} else {
bodyTokens.push_back(*tk);
}
lex(tk);
}