Skip to content
Snippets Groups Projects
Commit 2f649be1 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Disable macro expansion when preprocessing in fast-mode.

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