diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 9709e39e0b6eea11dc1b4278468ca93e3514e6ef..d080f6e141b4a8c6801e32dab081b69977a9d8dd 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -1901,7 +1901,9 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
         snapshot = m_lastSemanticInfo.snapshot;
         doc = m_lastSemanticInfo.doc;
         m_mutex.unlock();
-    } else {
+    }
+
+    if (!doc) {
         const QByteArray preprocessedCode = source.snapshot.preprocessedCode(source.code, source.fileName);
 
         doc = source.snapshot.documentFromSource(preprocessedCode, source.fileName);