forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/2.6'
Conflicts: src/plugins/qt4projectmanager/qt4buildconfiguration.cpp src/plugins/qtsupport/baseqtversion.cpp Change-Id: Id870f70aa35c232dbbd455f83429bab80f266c2d
This commit is contained in:
@@ -676,10 +676,20 @@ void Snapshot::insert(Document::Ptr doc)
|
||||
_documents.insert(doc->fileName(), doc);
|
||||
}
|
||||
|
||||
QByteArray Snapshot::preprocessedCode(const QString &source, const QString &fileName) const
|
||||
Document::Ptr Snapshot::preprocessedDocument(const QString &source, const QString &fileName) const
|
||||
{
|
||||
Document::Ptr newDoc = Document::create(fileName);
|
||||
if (Document::Ptr thisDocument = document(fileName)) {
|
||||
newDoc->_revision = thisDocument->_revision;
|
||||
newDoc->_editorRevision = thisDocument->_editorRevision;
|
||||
newDoc->_lastModified = thisDocument->_lastModified;
|
||||
newDoc->_includes = thisDocument->_includes;
|
||||
}
|
||||
|
||||
FastPreprocessor pp(*this);
|
||||
return pp.run(fileName, source);
|
||||
const QByteArray preprocessedCode = pp.run(newDoc, source);
|
||||
newDoc->setUtf8Source(preprocessedCode);
|
||||
return newDoc;
|
||||
}
|
||||
|
||||
Document::Ptr Snapshot::documentFromSource(const QByteArray &preprocessedCode,
|
||||
|
||||
@@ -79,7 +79,8 @@ public:
|
||||
|
||||
void appendMacro(const Macro ¯o);
|
||||
void addMacroUse(const Macro ¯o, unsigned offset, unsigned length,
|
||||
unsigned beginLine, const QVector<MacroArgumentReference> &range);
|
||||
unsigned beginLine,
|
||||
const QVector<MacroArgumentReference> &range);
|
||||
void addUndefinedMacroUse(const QByteArray &name, unsigned offset);
|
||||
|
||||
Control *control() const;
|
||||
@@ -254,8 +255,7 @@ public:
|
||||
unsigned _beginLine;
|
||||
|
||||
public:
|
||||
inline MacroUse(const Macro ¯o,
|
||||
unsigned begin, unsigned end, unsigned beginLine)
|
||||
inline MacroUse(const Macro ¯o, unsigned begin, unsigned end, unsigned beginLine)
|
||||
: Block(begin, end),
|
||||
_macro(macro),
|
||||
_beginLine(beginLine)
|
||||
@@ -371,10 +371,10 @@ public:
|
||||
|
||||
Snapshot simplified(Document::Ptr doc) const;
|
||||
|
||||
QByteArray preprocessedCode(const QString &source,
|
||||
const QString &fileName) const;
|
||||
Document::Ptr preprocessedDocument(const QString &source,
|
||||
const QString &fileName) const;
|
||||
|
||||
Document::Ptr documentFromSource(const QByteArray &preprocessedCode,
|
||||
Document::Ptr documentFromSource(const QByteArray &preprocessedDocument,
|
||||
const QString &fileName) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -39,8 +39,10 @@ FastPreprocessor::FastPreprocessor(const Snapshot &snapshot)
|
||||
_preproc(this, &_env)
|
||||
{ }
|
||||
|
||||
QByteArray FastPreprocessor::run(QString fileName, const QString &source)
|
||||
QByteArray FastPreprocessor::run(Document::Ptr newDoc, const QString &source)
|
||||
{
|
||||
std::swap(newDoc, _currentDoc);
|
||||
const QString fileName = _currentDoc->fileName();
|
||||
_preproc.setExpandFunctionlikeMacros(false);
|
||||
_preproc.setKeepComments(true);
|
||||
|
||||
@@ -54,11 +56,17 @@ QByteArray FastPreprocessor::run(QString fileName, const QString &source)
|
||||
|
||||
const QByteArray preprocessed = _preproc.run(fileName, source);
|
||||
// qDebug("FastPreprocessor::run for %s produced [[%s]]", fileName.toUtf8().constData(), preprocessed.constData());
|
||||
std::swap(newDoc, _currentDoc);
|
||||
return preprocessed;
|
||||
}
|
||||
|
||||
void FastPreprocessor::sourceNeeded(unsigned, QString &fileName, IncludeType)
|
||||
{ mergeEnvironment(fileName); }
|
||||
void FastPreprocessor::sourceNeeded(unsigned line, QString &fileName, IncludeType)
|
||||
{
|
||||
Q_ASSERT(_currentDoc);
|
||||
_currentDoc->addIncludeFile(fileName, line);
|
||||
|
||||
mergeEnvironment(fileName);
|
||||
}
|
||||
|
||||
void FastPreprocessor::mergeEnvironment(const QString &fileName)
|
||||
{
|
||||
@@ -73,3 +81,56 @@ void FastPreprocessor::mergeEnvironment(const QString &fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FastPreprocessor::macroAdded(const Macro ¯o)
|
||||
{
|
||||
Q_ASSERT(_currentDoc);
|
||||
|
||||
_currentDoc->appendMacro(macro);
|
||||
}
|
||||
|
||||
static const Macro revision(const Snapshot &s, const Macro &m)
|
||||
{
|
||||
if (Document::Ptr d = s.document(m.fileName())) {
|
||||
Macro newMacro(m);
|
||||
newMacro.setFileRevision(d->revision());
|
||||
return newMacro;
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
void FastPreprocessor::passedMacroDefinitionCheck(unsigned offset, unsigned line, const Macro ¯o)
|
||||
{
|
||||
Q_ASSERT(_currentDoc);
|
||||
|
||||
_currentDoc->addMacroUse(revision(_snapshot, macro),
|
||||
offset, macro.name().length(), line,
|
||||
QVector<MacroArgumentReference>());
|
||||
}
|
||||
|
||||
void FastPreprocessor::failedMacroDefinitionCheck(unsigned offset, const ByteArrayRef &name)
|
||||
{
|
||||
Q_ASSERT(_currentDoc);
|
||||
|
||||
_currentDoc->addUndefinedMacroUse(QByteArray(name.start(), name.size()), offset);
|
||||
}
|
||||
|
||||
void FastPreprocessor::notifyMacroReference(unsigned offset, unsigned line, const Macro ¯o)
|
||||
{
|
||||
Q_ASSERT(_currentDoc);
|
||||
|
||||
_currentDoc->addMacroUse(revision(_snapshot, macro),
|
||||
offset, macro.name().length(), line,
|
||||
QVector<MacroArgumentReference>());
|
||||
}
|
||||
|
||||
void FastPreprocessor::startExpandingMacro(unsigned offset, unsigned line,
|
||||
const Macro ¯o,
|
||||
const QVector<MacroArgumentReference> &actuals)
|
||||
{
|
||||
Q_ASSERT(_currentDoc);
|
||||
|
||||
_currentDoc->addMacroUse(revision(_snapshot, macro),
|
||||
offset, macro.name().length(), line, actuals);
|
||||
}
|
||||
|
||||
@@ -47,28 +47,29 @@ class CPLUSPLUS_EXPORT FastPreprocessor: public Client
|
||||
Snapshot _snapshot;
|
||||
Preprocessor _preproc;
|
||||
QSet<QString> _merged;
|
||||
Document::Ptr _currentDoc;
|
||||
|
||||
void mergeEnvironment(const QString &fileName);
|
||||
|
||||
public:
|
||||
FastPreprocessor(const Snapshot &snapshot);
|
||||
|
||||
QByteArray run(QString fileName, const QString &source);
|
||||
QByteArray run(Document::Ptr newDoc, const QString &source);
|
||||
|
||||
// CPlusPlus::Client
|
||||
virtual void sourceNeeded(unsigned, QString &fileName, IncludeType);
|
||||
virtual void sourceNeeded(unsigned line, QString &fileName, IncludeType);
|
||||
|
||||
virtual void macroAdded(const Macro &) {}
|
||||
virtual void macroAdded(const Macro &);
|
||||
|
||||
virtual void passedMacroDefinitionCheck(unsigned, unsigned, const Macro &) {}
|
||||
virtual void failedMacroDefinitionCheck(unsigned, const ByteArrayRef &) {}
|
||||
virtual void passedMacroDefinitionCheck(unsigned, unsigned, const Macro &);
|
||||
virtual void failedMacroDefinitionCheck(unsigned, const ByteArrayRef &);
|
||||
|
||||
virtual void notifyMacroReference(unsigned, unsigned, const Macro &) {}
|
||||
virtual void notifyMacroReference(unsigned, unsigned, const Macro &);
|
||||
|
||||
virtual void startExpandingMacro(unsigned,
|
||||
unsigned,
|
||||
const Macro &,
|
||||
const QVector<MacroArgumentReference> &) {}
|
||||
const QVector<MacroArgumentReference> &);
|
||||
virtual void stopExpandingMacro(unsigned, const Macro &) {}
|
||||
|
||||
virtual void startSkippingBlocks(unsigned) {}
|
||||
|
||||
@@ -53,6 +53,7 @@ using namespace CPlusPlus;
|
||||
Macro::Macro()
|
||||
: _next(0),
|
||||
_hashcode(0),
|
||||
_fileRevision(0),
|
||||
_line(0),
|
||||
_offset(0),
|
||||
_length(0),
|
||||
|
||||
@@ -95,6 +95,12 @@ public:
|
||||
void setFileName(const QString &fileName)
|
||||
{ _fileName = fileName; }
|
||||
|
||||
unsigned fileRevision() const
|
||||
{ return _fileRevision; }
|
||||
|
||||
void setFileRevision(unsigned fileRevision)
|
||||
{ _fileRevision = fileRevision; }
|
||||
|
||||
unsigned line() const
|
||||
{ return _line; }
|
||||
|
||||
@@ -154,6 +160,7 @@ private:
|
||||
QVector<PPToken> _definitionTokens;
|
||||
QVector<QByteArray> _formals;
|
||||
QString _fileName;
|
||||
unsigned _fileRevision;
|
||||
unsigned _line;
|
||||
unsigned _offset;
|
||||
unsigned _length;
|
||||
|
||||
@@ -52,15 +52,6 @@ static bool shouldOverrideChar(QChar ch)
|
||||
}
|
||||
}
|
||||
|
||||
// disable gcc warning:
|
||||
//
|
||||
// qstring.h:1175:39: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false
|
||||
//
|
||||
// caused by Q_ASSERT in QStringRef::at()
|
||||
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
|
||||
# pragma GCC diagnostic ignored "-Wstrict-overflow"
|
||||
#endif
|
||||
|
||||
static bool isCompleteStringLiteral(const BackwardsScanner &tk, int index)
|
||||
{
|
||||
const QStringRef text = tk.textRef(index);
|
||||
|
||||
@@ -812,6 +812,9 @@ bool Preprocessor::handleIdentifier(PPToken *tk)
|
||||
if (!expandFunctionlikeMacros()
|
||||
// Still expand if this originally started with an object-like macro.
|
||||
&& m_state.m_expansionStatus != Expanding) {
|
||||
m_client->notifyMacroReference(m_state.m_offsetRef + idTk.offset,
|
||||
idTk.lineno,
|
||||
*macro);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user