Commit 3dec4855 authored by Andre Hartmann's avatar Andre Hartmann Committed by Erik Verbruggen
Browse files

Fix C++ Macro Usages when Definition contains Newline.

Now truncates the displayed line at the first Newline character after
the Macro name.

Task-number: QTCREATORBUG-7113

Change-Id: Ifb13c01d10b97098b54ac4346a80f0dcff3a35f3
Reviewed-by: default avatarOrgad Shaneh <>
Reviewed-by: default avatarErik Verbruggen <>
parent 60db5736
......@@ -646,9 +646,14 @@ void CppFindReferences::findMacroUses(const Macro &macro)
// ### FIXME: Encoding?
const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1();
const QByteArray line = source.mid(macro.offset(), macro.length());
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
search->addResult(macro.fileName(), macro.line(), line,
macroNameOffset, macroNameLength);
QFuture<Usage> result;
Supports Markdown
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