<div dir="ltr">It looks like the code that's blowing up here is:<div><br></div><div><div>// FIXME: This should go into the Lexer, but we need to figure out how</div><div>// to handle ranges for refactoring in general first - there is no obvious</div>
<div>// good way how to integrate this into the Lexer yet.</div><div>static int getRangeSize(SourceManager &Sources, const CharSourceRange &Range) {</div><div>  SourceLocation SpellingBegin = Sources.getSpellingLoc(Range.getBegin());</div>
<div>  SourceLocation SpellingEnd = Sources.getSpellingLoc(Range.getEnd());</div><div>  std::pair<FileID, unsigned> Start = Sources.getDecomposedLoc(SpellingBegin);</div><div>  std::pair<FileID, unsigned> End = Sources.getDecomposedLoc(SpellingEnd);</div>
<div>  if (Start.first != End.first) return -1;</div><div>  if (Range.isTokenRange())</div><div>    End.second += Lexer::MeasureTokenLength(SpellingEnd, Sources,</div><div>                                            LangOptions());</div>
<div>  return End.second - Start.second;</div><div>}</div><div><br></div><div style><div>(gdb) c</div><div>Continuing.</div><div>r: &g_pOSResourceTracked</div><div><br></div><div>Breakpoint 2, clang::tooling::getRangeSize (Sources=..., Range=...)</div>
<div>    at /home/hotellnx94/peeterj/clang/sources/llvm/tools/clang/lib/Tooling/Refactoring.cpp:111</div><div>111       if (Range.isTokenRange())</div><div>(gdb) p Start</div><div>$16 = {first = {ID = 102780}, second = 50501}</div>
<div>(gdb) p End</div><div>$17 = {first = {ID = 102780}, second = 34606}</div><div>(gdb) n</div><div>113                                                 LangOptions());</div><div>(gdb) n</div><div>114       return End.second - Start.second;</div>
<div>(gdb) p End</div><div>$18 = {first = {ID = 102780}, second = 34626}</div><div>(gdb) p End.second - Start.second</div><div>$19 = 4294951421</div><div><br></div><div style>The Lexer:: addition added 20 bytes, but something is out of sync with this method of getting the source location range:<br>
<br><div style="font-family:arial,sans-serif;font-size:13px">SourceLocation start = v->getLocStart() ;</div><div style="font-family:arial,sans-serif;font-size:13px">SourceLocation end = v->getLocEnd() ;</div></div></div>
<div><br></div><div style>Here v is a <span style="font-family:arial,sans-serif;font-size:13px">CStyleCastExpr</span><span style="font-family:arial,sans-serif;font-size:13px"> object.</span></div><div><br></div><div class="gmail_extra">
-- <br>Peeter
</div></div></div>