Commit d57b405f authored by Erik Verbruggen's avatar Erik Verbruggen Committed by Nikolai Kosjar

CppTools: fix inclusion of "injected" defines.

Task-number: QTCREATORBUG-10280

Change-Id: Ibc6ffeedb97a31a35a2d1f00625506f844692e16
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 336644a7
......@@ -63,7 +63,11 @@ QByteArray FastPreprocessor::run(Document::Ptr newDoc, const QByteArray &source)
if (Document::Ptr doc = _snapshot.document(fileName)) {
_merged.insert(fileName);
mergeEnvironment(Preprocessor::configurationFileName);
for (Snapshot::const_iterator i = _snapshot.begin(), ei = _snapshot.end(); i != ei; ++i) {
if (isInjectedFile(i.key()))
mergeEnvironment(i.key());
}
foreach (const Document::Include &i, doc->resolvedIncludes())
mergeEnvironment(i.resolvedFileName());
}
......
......@@ -32,11 +32,11 @@
#include <cplusplus/CPlusPlusForwardDeclarations.h>
#include <QString>
#include <QVector>
QT_BEGIN_NAMESPACE
class QByteArray;
class QString;
QT_END_NAMESPACE
namespace CPlusPlus {
......@@ -99,6 +99,11 @@ public:
virtual void stopSkippingBlocks(unsigned offset) = 0;
virtual void sourceNeeded(unsigned line, const QString &fileName, IncludeType mode) = 0;
static inline bool isInjectedFile(const QString &fileName)
{
return fileName.startsWith(QLatin1Char('<')) && fileName.endsWith(QLatin1Char('>'));
}
};
} // namespace CPlusPlus
......
......@@ -416,7 +416,6 @@ void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, Inclu
if (m_dumpFileNameWhileParsing) {
qDebug() << "Parsing file:" << absoluteFileName
<< "contents:" << contents.size() << "bytes";
;
}
Document::Ptr doc = m_snapshot.document(absoluteFileName);
......
......@@ -153,15 +153,21 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
preproc.setIncludePaths(m_includePaths);
preproc.setFrameworkPaths(m_frameworkPaths);
preproc.run(configurationFileName);
if (m_usePrecompiledHeaders)
if (m_usePrecompiledHeaders) {
foreach (const QString &precompiledHeader, m_precompiledHeaders)
preproc.run(precompiledHeader);
}
if (!m_editorDefines.isEmpty())
preproc.run(editorDefinesFileName);
preproc.run(m_fileInEditor);
m_snapshot = preproc.snapshot();
m_snapshot = m_snapshot.simplified(document());
Snapshot newSnapshot = m_snapshot.simplified(document());
for (Snapshot::const_iterator i = m_snapshot.begin(), ei = m_snapshot.end(); i != ei; ++i) {
if (Client::isInjectedFile(i.key()))
newSnapshot.insert(i.value());
}
m_snapshot = newSnapshot;
m_deps.build(m_snapshot);
foreach (Document::Ptr doc, m_snapshot) {
......
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