[cfe-commits] r144269 - in /cfe/trunk: include/clang-c/ include/clang/Frontend/ lib/Frontend/ tools/c-index-test/ tools/libclang/

Argyrios Kyrtzidis kyrtzidis at apple.com
Thu Nov 10 10:48:34 PST 2011


On Nov 10, 2011, at 10:41 AM, Ted Kremenek wrote:

> 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?

Not a big deal, you just adjust the location/column locally; FYI getLocWithOffset is just an addition to an unsigned.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111110/22e36703/attachment.html>


More information about the cfe-commits mailing list