Commit 998e4ae1 authored by Andre Hartmann's avatar Andre Hartmann Committed by Roberto Raggi
Browse files

Fix C++ Macro Usages definition line in Search Results.

Add the complete line to the Search Results window,
including '#', "define", macro and macro value and
all possible white spaces between them.
Also covers the case of line continuation in macro
definitions from commit 3dec4855


Task-number: QTCREATORBUG-7217

Change-Id: I8b9d0c23d31ef76244833a9b9d67469c5c4a5635
Reviewed-by: default avatarRoberto Raggi <>
parent 4f0170e5
......@@ -646,14 +646,13 @@ void CppFindReferences::findMacroUses(const Macro &macro)
// ### FIXME: Encoding?
const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1();
QByteArray line = source.mid(macro.offset(), macro.length());
const int macroNameOffset = line.indexOf(;
const int macroNameLength =;
const int possibleNewLine = line.indexOf('\n', macroNameOffset + macroNameLength);
if (possibleNewLine != -1)
line.truncate(possibleNewLine); // truncate line at first '\n' after macro name
int lineBegin = source.lastIndexOf('\n', macro.offset()) + 1;
int lineEnd = source.indexOf('\n', macro.offset());
if (lineEnd == -1)
lineEnd = source.length();
const QByteArray line = source.mid(lineBegin, lineEnd - lineBegin);
search->addResult(macro.fileName(), macro.line(), line,
macroNameOffset, macroNameLength);
QFuture<Usage> result;
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