summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus/pp-engine.cpp
diff options
context:
space:
mode:
authorLeandro Melo <leandro.melo@nokia.com>2012-08-15 16:06:22 +0200
committerhjk <qthjk@ovi.com>2012-08-23 15:00:53 +0200
commit009d6b1e2ffd9fc617c2bfe135daf2eb107fc5b6 (patch)
tree1c59822be0597ea607563acba20082241c8150c9 /src/libs/cplusplus/pp-engine.cpp
parent08cc1e7d6a5924584878c8ea383c72dafa5e4c79 (diff)
downloadqt-creator-009d6b1e2ffd9fc617c2bfe135daf2eb107fc5b6.tar.gz
C++: Handle C++ style comments in macro expansion
Notice that a similar problem still exists for which we need to fix the lexer when there's a C style commend which ends with a backslash-newline. Task-number: QTCREATORBUG-7713 Change-Id: I0f6d561703984f917fa5ed29de020ad0bdc5aaf0 Reviewed-by: David Schulz <david.schulz@nokia.com> Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/libs/cplusplus/pp-engine.cpp')
-rw-r--r--src/libs/cplusplus/pp-engine.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp
index 45cf36f588..f71ba47c14 100644
--- a/src/libs/cplusplus/pp-engine.cpp
+++ b/src/libs/cplusplus/pp-engine.cpp
@@ -1349,7 +1349,21 @@ void Preprocessor::scanActualArgument(PPToken *tk, QVector<PPToken> *tokens)
break;
}
- tokens->append(*tk);
+ if (m_keepComments
+ && (tk->is(T_CPP_COMMENT) || tk->is(T_CPP_DOXY_COMMENT))) {
+ // Even in keep comments mode, we cannot preserve C++ style comments inside the
+ // expansion. We stick with GCC's approach which is to replace them by C style
+ // comments (currently clang just gets rid of them) and transform internals */
+ // into *|.
+ QByteArray text = m_state.m_source.mid(tk->begin() + 2, tk->end() - tk->begin() - 2);
+ const QByteArray &comment = "/*" + text.replace("*/", "*|") + "*/";
+ tokens->append(generateToken(T_COMMENT,
+ comment.constData(), comment.size(),
+ tk->lineno, false));
+ } else {
+ tokens->append(*tk);
+ }
+
lex(tk);
}
}