C++: Pass on the byte offsets of macro arguments

...to the Document/Block.

Change-Id: I1a96dc70ac93254e6030326b36a5df9a2cdc2bd8
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-09-12 10:49:23 +02:00
committed by Christian Stenger
parent 25a8ee7344
commit c2e5f1c819
4 changed files with 95 additions and 4 deletions

View File

@@ -378,7 +378,9 @@ void Document::addMacroUse(const Macro &macro,
beginLine);
foreach (const MacroArgumentReference &actual, actuals) {
const Block arg(0, 0, actual.utf16charsOffset(),
const Block arg(actual.bytesOffset(),
actual.bytesOffset() + actual.bytesLength(),
actual.utf16charsOffset(),
actual.utf16charsOffset() + actual.utf16charsLength());
use.addArgument(arg);
}

View File

@@ -46,14 +46,26 @@ class Macro;
class CPLUSPLUS_EXPORT MacroArgumentReference
{
unsigned _bytesOffset;
unsigned _bytesLength;
unsigned _utf16charsOffset;
unsigned _utf16charsLength;
public:
explicit MacroArgumentReference(unsigned utf16charsOffset = 0, unsigned utf16charsLength = 0)
: _utf16charsOffset(utf16charsOffset), _utf16charsLength(utf16charsLength)
explicit MacroArgumentReference(unsigned bytesOffset = 0, unsigned bytesLength = 0,
unsigned utf16charsOffset = 0, unsigned utf16charsLength = 0)
: _bytesOffset(bytesOffset)
, _bytesLength(bytesLength)
, _utf16charsOffset(utf16charsOffset)
, _utf16charsLength(utf16charsLength)
{ }
unsigned bytesOffset() const
{ return _bytesOffset; }
unsigned bytesLength() const
{ return _bytesLength; }
unsigned utf16charsOffset() const
{ return _utf16charsOffset; }

View File

@@ -1034,6 +1034,9 @@ bool Preprocessor::handleIdentifier(PPToken *tk)
} else {
argRefs.push_back(MacroArgumentReference(
m_state.m_bytesOffsetRef + argTks.first().bytesBegin(),
argTks.last().bytesBegin() + argTks.last().bytes()
- argTks.first().bytesBegin(),
m_state.m_utf16charsOffsetRef + argTks.first().utf16charsBegin(),
argTks.last().utf16charsBegin() + argTks.last().utf16chars()
- argTks.first().utf16charsBegin()));