Merge remote-tracking branch 'origin/2.6'

This commit is contained in:
Eike Ziller
2012-08-07 16:11:22 +02:00
30 changed files with 718 additions and 550 deletions

View File

@@ -42,7 +42,7 @@ FastPreprocessor::FastPreprocessor(const Snapshot &snapshot)
QByteArray FastPreprocessor::run(QString fileName, const QString &source)
{
_preproc.setExpandMacros(false);
_preproc.setExpandFunctionlikeMacros(false);
_preproc.setKeepComments(true);
if (Document::Ptr doc = _snapshot.document(fileName)) {

View File

@@ -593,7 +593,7 @@ void Preprocessor::State::popTokenBuffer()
Preprocessor::Preprocessor(Client *client, Environment *env)
: m_client(client)
, m_env(env)
, m_expandMacros(true)
, m_expandFunctionlikeMacros(true)
, m_keepComments(false)
{
}
@@ -615,14 +615,14 @@ QByteArray Preprocessor::run(const QString &fileName,
return preprocessed;
}
bool Preprocessor::expandMacros() const
bool Preprocessor::expandFunctionlikeMacros() const
{
return m_expandMacros;
return m_expandFunctionlikeMacros;
}
void Preprocessor::setExpandMacros(bool expandMacros)
void Preprocessor::setExpandFunctionlikeMacros(bool expandMacros)
{
m_expandMacros = expandMacros;
m_expandFunctionlikeMacros = expandMacros;
}
bool Preprocessor::keepComments() const
@@ -741,9 +741,6 @@ void Preprocessor::skipPreprocesorDirective(PPToken *tk)
bool Preprocessor::handleIdentifier(PPToken *tk)
{
if (!expandMacros())
return false;
ScopedBoolSwap s(m_state.m_inPreprocessorDirective, true);
static const QByteArray ppLine("__LINE__");
@@ -813,6 +810,9 @@ bool Preprocessor::handleIdentifier(PPToken *tk)
PPToken oldMarkerTk;
if (macro->isFunctionLike()) {
if (!expandFunctionlikeMacros())
return false;
// Collect individual tokens that form the macro arguments.
QVector<QVector<PPToken> > allArgTks;
bool hasArgs = collectActualArguments(tk, &allArgTks);
@@ -1137,10 +1137,17 @@ void Preprocessor::trackExpansionCycles(PPToken *tk)
}
}
static void adjustForCommentNewlines(unsigned *currentLine, const PPToken &tk)
{
if (tk.is(T_COMMENT) || tk.is(T_DOXY_COMMENT))
(*currentLine) += tk.asByteArrayRef().count('\n');
}
void Preprocessor::synchronizeOutputLines(const PPToken &tk, bool forceLine)
{
if (m_state.m_expansionStatus != NotExpanding
|| (!forceLine && m_env->currentLine == tk.lineno)) {
adjustForCommentNewlines(&m_env->currentLine, tk);
return;
}
@@ -1157,8 +1164,7 @@ void Preprocessor::synchronizeOutputLines(const PPToken &tk, bool forceLine)
}
m_env->currentLine = tk.lineno;
if (tk.is(T_COMMENT) || tk.is(T_DOXY_COMMENT))
m_env->currentLine += tk.asByteArrayRef().count('\n');
adjustForCommentNewlines(&m_env->currentLine, tk);
}
void Preprocessor::removeTrailingOutputLines()

View File

@@ -81,8 +81,8 @@ public:
QByteArray run(const QString &filename, const QString &source);
QByteArray run(const QString &filename, const QByteArray &source, bool noLines = false, bool markGeneratedTokens = true);
bool expandMacros() const;
void setExpandMacros(bool expandMacros);
bool expandFunctionlikeMacros() const;
void setExpandFunctionlikeMacros(bool expandFunctionlikeMacros);
bool keepComments() const;
void setKeepComments(bool keepComments);
@@ -197,7 +197,7 @@ private:
Environment *m_env;
QByteArray m_scratchBuffer;
bool m_expandMacros;
bool m_expandFunctionlikeMacros;
bool m_keepComments;
State m_state;