Commit f829ef89 authored by Roberto Raggi's avatar Roberto Raggi

Store in the document's macroUsages only the top-level macro expansions.

parent 48e7f20d
......@@ -444,12 +444,12 @@ QByteArray Snapshot::preprocessedCode(const QString &source, const QString &file
Document::Ptr Snapshot::documentFromSource(const QByteArray &preprocessedCode,
const QString &fileName) const
{
FastPreprocessor pp(*this);
Document::Ptr newDoc = Document::create(fileName);
if (Document::Ptr thisDocument = value(fileName)) {
newDoc->_includes = thisDocument->_includes;
newDoc->_definedMacros = thisDocument->_definedMacros;
newDoc->_macroUses = thisDocument->_macroUses;
}
newDoc->setSource(preprocessedCode);
......
......@@ -189,6 +189,15 @@ public:
: _begin(begin), _end(end)
{ }
inline bool isNull() const
{ return length() == 0; }
inline unsigned position() const
{ return _begin; }
inline unsigned length() const
{ return _end - _begin; }
inline unsigned begin() const
{ return _begin; }
......
......@@ -975,18 +975,9 @@ Macro *Preprocessor::processObjectLikeMacro(TokenIterator identifierToken,
void Preprocessor::expandBuiltinMacro(TokenIterator identifierToken,
const QByteArray &spell)
{
const Macro trivial;
if (client)
client->startExpandingMacro(identifierToken->offset,
trivial, spell);
const bool was = markGeneratedTokens(true, identifierToken);
expand(spell, _result);
(void) markGeneratedTokens(was);
if (client)
client->stopExpandingMacro(_dot->offset, trivial);
}
void Preprocessor::expandObjectLikeMacro(TokenIterator identifierToken,
......
......@@ -287,9 +287,6 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
if (! macro->definition().isEmpty())
{
if (client)
client->startExpandingMacro(start_offset + (name_begin-start), *macro, fast_name, true);
macro->setHidden(true);
QByteArray __tmp;
......@@ -316,9 +313,6 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
}
macro->setHidden(false);
if (client)
client->stopExpandingMacro(start_offset + (name_begin-start), *macro);
}
if (! m)
......@@ -375,17 +369,11 @@ const char *MacroExpander::expand(const char *__first, const char *__last,
++arg_it; // skip ')'
__first = arg_it;
if (client)
client->startExpandingMacro(start_offset + (name_begin-start), *macro, fast_name, true, actuals_ref);
pp_frame frame (macro, actuals);
MacroExpander expand_macro (env, &frame);
macro->setHidden(true);
expand_macro (macro->definition(), __result);
macro->setHidden(false);
if (client)
client->stopExpandingMacro(start_offset + (name_begin-start), *macro);
}
else
__result->append(*__first++);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment