C++: fix the quick-exit for already parsed files.

When the preprocessor is asked to process a file which it has already
seen before, it can skip it, but it still has to add the file to the
list of included files for the current document.

Task-number: QTCREATORBUG-9107
Change-Id: I30cac61c1da20da7fe925168ecccb429584e9746
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Erik Verbruggen
2013-04-11 11:40:07 +02:00
committed by Nikolai Kosjar
parent 8ba344a556
commit c388c05b86

View File

@@ -511,17 +511,17 @@ void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, Inclu
return;
QString absoluteFileName = resolveFile(fileName, type);
absoluteFileName = QDir::cleanPath(absoluteFileName);
if (m_currentDoc && !absoluteFileName.isEmpty())
m_currentDoc->addIncludeFile(absoluteFileName, line);
if (m_included.contains(absoluteFileName))
return; // we've already seen this file.
m_included.insert(absoluteFileName);
absoluteFileName = QDir::cleanPath(absoluteFileName);
unsigned editorRevision = 0;
QString contents;
getFileContents(absoluteFileName, &contents, &editorRevision);
if (m_currentDoc) {
m_currentDoc->addIncludeFile(absoluteFileName, line);
if (contents.isEmpty() && ! QFileInfo(absoluteFileName).isAbsolute()) {
QString msg = QCoreApplication::translate(
"CppPreprocessor", "%1: No such file or directory").arg(fileName);