[cfe-dev] RewriteRope.cpp assertion: Assertion `getPiece(StartPiece).size() > NumBytes' failed.

Peeter Joot peeter.joot at gmail.com
Fri Apr 26 15:42:28 PDT 2013


It looks like the code that's blowing up here is:

// FIXME: This should go into the Lexer, but we need to figure out how
// to handle ranges for refactoring in general first - there is no obvious
// good way how to integrate this into the Lexer yet.
static int getRangeSize(SourceManager &Sources, const CharSourceRange
&Range) {
  SourceLocation SpellingBegin = Sources.getSpellingLoc(Range.getBegin());
  SourceLocation SpellingEnd = Sources.getSpellingLoc(Range.getEnd());
  std::pair<FileID, unsigned> Start =
Sources.getDecomposedLoc(SpellingBegin);
  std::pair<FileID, unsigned> End = Sources.getDecomposedLoc(SpellingEnd);
  if (Start.first != End.first) return -1;
  if (Range.isTokenRange())
    End.second += Lexer::MeasureTokenLength(SpellingEnd, Sources,
                                            LangOptions());
  return End.second - Start.second;
}

(gdb) c
Continuing.
r: &g_pOSResourceTracked

Breakpoint 2, clang::tooling::getRangeSize (Sources=..., Range=...)
    at
/home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Tooling/Refactoring.cpp:111
111       if (Range.isTokenRange())
(gdb) p Start
$16 = {first = {ID = 102780}, second = 50501}
(gdb) p End
$17 = {first = {ID = 102780}, second = 34606}
(gdb) n
113                                                 LangOptions());
(gdb) n
114       return End.second - Start.second;
(gdb) p End
$18 = {first = {ID = 102780}, second = 34626}
(gdb) p End.second - Start.second
$19 = 4294951421

The Lexer:: addition added 20 bytes, but something is out of sync with this
method of getting the source location range:

SourceLocation start = v->getLocStart() ;
SourceLocation end = v->getLocEnd() ;

Here v is a CStyleCastExpr object.

-- 
Peeter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130426/e30c00a7/attachment.html>


More information about the cfe-dev mailing list