Commit 2f649be1 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Disable macro expansion when preprocessing in fast-mode.

parent 93cdff18
......@@ -38,14 +38,14 @@ FastPreprocessor::FastPreprocessor(const Snapshot &snapshot)
QByteArray FastPreprocessor::run(QString fileName, const QString &source)
{
#ifdef QTCREATOR_WITH_MERGED_ENVIRONMENT
_preproc.setExpandMacros(false);
if (Document::Ptr doc = _snapshot.value(fileName)) {
_merged.insert(fileName);
foreach (const Document::Include &i, doc->includes())
mergeEnvironment(i.fileName());
}
#endif
const QByteArray preprocessed = _preproc(fileName, source);
return preprocessed;
......
......@@ -533,7 +533,8 @@ Preprocessor::Preprocessor(Client *client, Environment *env)
env(env),
_expand(env),
_result(0),
_markGeneratedTokens(false)
_markGeneratedTokens(false),
_expandMacros(true)
{
resetIfLevel ();
}
......@@ -620,6 +621,16 @@ void Preprocessor::out(const char *s)
_result->append(s);
}
bool Preprocessor::expandMacros() const
{
return _expandMacros;
}
void Preprocessor::setExpandMacros(bool expandMacros)
{
_expandMacros = expandMacros;
}
Preprocessor::State Preprocessor::createStateFromSource(const QByteArray &source) const
{
State state;
......@@ -806,8 +817,12 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
++_dot; // skip T_IDENTIFIER
const QByteArray spell = tokenSpell(*identifierToken);
if (! _expandMacros) {
out(spell);
continue;
}
if (env->isBuiltinMacro(spell))
else if (env->isBuiltinMacro(spell))
expandBuiltinMacro(identifierToken, spell);
else {
......
......@@ -72,6 +72,9 @@ public:
const QByteArray &source,
QByteArray *result);
bool expandMacros() const;
void setExpandMacros(bool expandMacros);
private:
enum { MAX_LEVEL = 512 };
......@@ -188,6 +191,7 @@ private:
bool _markGeneratedTokens;
QString _originalSource;
bool _expandMacros;
};
} // namespace CPlusPlus
......
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