From dabdb60299d01d12857f45baa2b04f10077c27cc Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 10 Jan 2014 09:08:39 +0200 Subject: C++: Preserve comments after preprocessor directives Task-number: QTCREATORBUG-11216 Change-Id: Iac10e75f0f5c504b79e8466607dc1f478e578f99 Reviewed-by: Erik Verbruggen --- src/libs/cplusplus/pp-engine.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/libs/cplusplus/pp-engine.cpp') diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index c17d36555d2..9c86b7e35d2 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -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); } -- cgit v1.2.3