[cfe-commits] r144269 - in /cfe/trunk: include/clang-c/ include/clang/Frontend/ lib/Frontend/ tools/c-index-test/ tools/libclang/
Ted Kremenek
kremenek at apple.com
Thu Nov 10 10:41:32 PST 2011
On Nov 10, 2011, at 10:32 AM, Argyrios Kyrtzidis wrote:
>> void SDiagsWriter::AddCharSourceRangeToRecord(CharSourceRange Range,
>> RecordDataImpl &Record) {
>> AddLocToRecord(Range.getBegin(), Record);
>> - AddLocToRecord(Range.getEnd(), Record);
>> + unsigned TokSize = 0;
>> + if (Range.isTokenRange())
>> + TokSize = Lexer::MeasureTokenLength(Range.getEnd(),
>> + Diags.getSourceManager(),
>> + *LangOpts);
>> +
>> + AddLocToRecord(Range.getEnd(), Record, TokSize);
>> }
>
> Instead of passing the TokSize to AddLocToRecord you could adjust the source location, like:
>
> AddLocToRecord(Range.getBegin(), Record);
> SourceLocation CharEnd = Range.getEnd();
> if (Range.isTokenRange()) {
> unsigned TokSize = Lexer::MeasureTokenLength(CharEnd,
> Diags.getSourceManager(),
> *LangOpts);
> CharEnd = CharEnd.getLocWithOffset(TokSize);
> }
>
> AddLocToRecord(CharEnd, Record);
Seems like a reasonable simplification, although I don't think this really matters all that much. Why bother creating a new SourceLocation when all we care about is adjusting the column one function call away?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111110/a2e6e7be/attachment.html>
More information about the cfe-commits
mailing list