forked from qt-creator/qt-creator
Track more macro uses.
In particular macros that are only checked for definition or are expanded during the evaluation of an #if or #elif directive are now also added to the list available through Document::macroUses(). The names of undefined macros that are interesting (because they're used in an #ifdef or a defined(...)) are now available through Document::undefinedMacroUses(). Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
@@ -196,9 +196,12 @@ protected:
|
||||
void mergeEnvironment(CPlusPlus::Document::Ptr doc);
|
||||
|
||||
virtual void macroAdded(const Macro ¯o);
|
||||
virtual void passedMacroDefinitionCheck(unsigned offset, const Macro ¯o);
|
||||
virtual void failedMacroDefinitionCheck(unsigned offset, const QByteArray &name);
|
||||
virtual void startExpandingMacro(unsigned offset,
|
||||
const Macro ¯o,
|
||||
const QByteArray &originalText,
|
||||
bool inCondition,
|
||||
const QVector<MacroArgumentReference> &actuals);
|
||||
virtual void stopExpandingMacro(unsigned offset, const Macro ¯o);
|
||||
virtual void startSkippingBlocks(unsigned offset);
|
||||
@@ -446,16 +449,34 @@ void CppPreprocessor::macroAdded(const Macro ¯o)
|
||||
m_currentDoc->appendMacro(macro);
|
||||
}
|
||||
|
||||
void CppPreprocessor::passedMacroDefinitionCheck(unsigned offset, const Macro ¯o)
|
||||
{
|
||||
if (! m_currentDoc)
|
||||
return;
|
||||
|
||||
m_currentDoc->addMacroUse(macro, offset, macro.name().length(),
|
||||
QVector<MacroArgumentReference>(), true);
|
||||
}
|
||||
|
||||
void CppPreprocessor::failedMacroDefinitionCheck(unsigned offset, const QByteArray &name)
|
||||
{
|
||||
if (! m_currentDoc)
|
||||
return;
|
||||
|
||||
m_currentDoc->addUndefinedMacroUse(name, offset);
|
||||
}
|
||||
|
||||
void CppPreprocessor::startExpandingMacro(unsigned offset,
|
||||
const Macro ¯o,
|
||||
const QByteArray &originalText,
|
||||
bool inCondition,
|
||||
const QVector<MacroArgumentReference> &actuals)
|
||||
{
|
||||
if (! m_currentDoc)
|
||||
return;
|
||||
|
||||
//qDebug() << "start expanding:" << macro.name << "text:" << originalText;
|
||||
m_currentDoc->addMacroUse(macro, offset, originalText.length(), actuals);
|
||||
//qDebug() << "start expanding:" << macro.name() << "text:" << originalText;
|
||||
m_currentDoc->addMacroUse(macro, offset, originalText.length(), actuals, inCondition);
|
||||
}
|
||||
|
||||
void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &)
|
||||
|
||||
Reference in New Issue
Block a user