From 0b9ce52904139bb8cb2229e602d8b232671af41b Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Sun, 21 Oct 2012 20:16:58 +0200 Subject: C++ Macro Usages: Refactoring Change-Id: I959e0aeeec3164fdd997c08b6d4ed4e95a39009f Reviewed-by: Erik Verbruggen --- src/plugins/cpptools/cppfindreferences.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/plugins/cpptools/cppfindreferences.cpp') diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 63e3edabdb..faafde01da 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -573,22 +573,21 @@ _Lrestart: const Macro &useMacro = use.macro(); if (useMacro.fileName() == macro.fileName()) { // Check if this is a match, but possibly against an outdated document. + if (source.isEmpty()) + source = getSource(fileName, workingCopy); + if (macro.fileRevision() > useMacro.fileRevision()) { // yes, it is outdated, so re-preprocess and start from scratch for this file. - source = getSource(fileName, workingCopy).toLatin1(); doc = snapshot.preprocessedDocument(source, fileName); goto _Lrestart; } - } - if (useMacro.fileName() == macro.fileName() && macro.name() == useMacro.name()) { - if (source.isEmpty()) - source = getSource(fileName, workingCopy); - - unsigned lineStart; - const QString &lineSource = matchingLine(use.begin(), source, &lineStart); - usages.append(Usage(fileName, lineSource, use.beginLine(), - use.begin() - lineStart, useMacro.name().length())); + if (macro.name() == useMacro.name()) { + unsigned lineStart; + const QString &lineSource = matchingLine(use.begin(), source, &lineStart); + usages.append(Usage(fileName, lineSource, use.beginLine(), + use.begin() - lineStart, useMacro.name().length())); + } } } -- cgit v1.2.1