Preprocessor Enginge: fix bug in pp-engine.cpp

Preprocessor variables __LINE__,__FILE__,__TIME__,__DATE__ where destroying
the following systems when affected variables were standing  within the
same line with those variables:
* highlighting
* refactoring
* local renaming

Task-number: QTCREATORBUG-8036
Change-Id: I1a4b919d15812872ca5a8e63b1031ec1ab144c22
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Simon Schäfer
2013-11-26 21:56:30 +01:00
committed by Nikolai Kosjar
parent e4d800ad4a
commit 1d834c1126
2 changed files with 1 additions and 61 deletions

View File

@@ -906,49 +906,7 @@ bool Preprocessor::handleIdentifier(PPToken *tk)
{
ScopedBoolSwap s(m_state.m_inPreprocessorDirective, true);
static const QByteArray ppLine("__LINE__");
static const QByteArray ppFile("__FILE__");
static const QByteArray ppDate("__DATE__");
static const QByteArray ppTime("__TIME__");
ByteArrayRef macroNameRef = tk->asByteArrayRef();
if (macroNameRef.size() == 8
&& macroNameRef[0] == '_'
&& macroNameRef[1] == '_') {
PPToken newTk;
if (macroNameRef == ppLine) {
QByteArray txt = QByteArray::number(tk->lineno);
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
} else if (macroNameRef == ppFile) {
QByteArray txt;
txt.append('"');
txt.append(m_env->currentFileUtf8);
txt.append('"');
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
} else if (macroNameRef == ppDate) {
QByteArray txt;
txt.append('"');
txt.append(QDate::currentDate().toString().toUtf8());
txt.append('"');
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
} else if (macroNameRef == ppTime) {
QByteArray txt;
txt.append('"');
txt.append(QTime::currentTime().toString().toUtf8());
txt.append('"');
newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false);
}
if (newTk.hasSource()) {
newTk.f.newline = tk->newline();
newTk.f.whitespace = tk->whitespace();
*tk = newTk;
return false;
}
}
Macro *macro = m_env->resolve(macroNameRef);
Macro *macro = m_env->resolve(tk->asByteArrayRef());
if (!macro
|| (tk->expanded()
&& m_state.m_tokenBuffer