forked from qt-creator/qt-creator
C++: Fix handling of #undef
* If the macro is defined before, track its reference * Synchronize environment line before calling remove, which currently sets incorrect line * Set macro offset Task-number: QTCREATORBUG-10454 Change-Id: I480d16423a976a025bb8c71046610a46f9d7b0fd Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
8ff63de728
commit
5d2cd2e56d
@@ -1951,10 +1951,19 @@ void Preprocessor::handleUndefDirective(PPToken *tk)
|
||||
lex(tk); // consume "undef" token
|
||||
if (tk->is(T_IDENTIFIER)) {
|
||||
const ByteArrayRef macroName = tk->asByteArrayRef();
|
||||
const Macro *macro = m_env->remove(macroName);
|
||||
const unsigned offset = tk->offset + m_state.m_offsetRef;
|
||||
// Track macro use if previously defined
|
||||
if (m_client) {
|
||||
if (const Macro *existingMacro = m_env->resolve(macroName))
|
||||
m_client->notifyMacroReference(offset, tk->lineno, *existingMacro);
|
||||
}
|
||||
synchronizeOutputLines(*tk);
|
||||
Macro *macro = m_env->remove(macroName);
|
||||
|
||||
if (m_client && macro)
|
||||
if (m_client && macro) {
|
||||
macro->setOffset(offset);
|
||||
m_client->macroAdded(*macro);
|
||||
}
|
||||
lex(tk); // consume macro name
|
||||
#ifndef NO_DEBUG
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user