[llvm-commits] [llvm] r81046 - in /llvm/trunk: include/llvm/MC/MCAsmLexer.h tools/llvm-mc/AsmLexer.cpp tools/llvm-mc/AsmLexer.h tools/llvm-mc/AsmParser.h tools/llvm-mc/llvm-mc.cpp

Kevin Enderby enderby at apple.com
Wed Sep 16 11:12:49 PDT 2009


On Sep 16, 2009, at 12:36 AM, Daniel Dunbar wrote:

> Hi Kevin,
>
> On Fri, Sep 4, 2009 at 2:45 PM, Kevin Enderby <enderby at apple.com>  
> wrote:
>> Author: enderby
>> Date: Fri Sep  4 16:45:34 2009
>> New Revision: 81046
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=81046&view=rev
>> Log:
>> Added the AsmToken::Hash enum constant to MCAsmLexer.h in  
>> preparation of
>> supporting other targets.  Changed the code to pass MCAsmInfo to  
>> the parser
>> and the lexer.  Then changed the lexer to use CommentString from  
>> MCAsmInfo
>> instead of a literal '#' character.
>
>>
>> -  while (*CurPtr != '#' &&  // Start of line comment.
>> -         *CurPtr != ';' &&  // End of statement marker.
>> +  while (*CurPtr != ';' &&  // End of statement marker.
>>          *CurPtr != '\n' &&
>>          *CurPtr != '\r' &&
>> -         (*CurPtr != 0 || CurPtr != CurBuf->getBufferEnd()))
>> +         (*CurPtr != 0 || CurPtr != CurBuf->getBufferEnd())) {
>> +    // check for start of line comment.
>> +    for (const char *p = MAI.getCommentString(); *p != 0; ++p)
>> +      if (*CurPtr == *p)
>> +        break;
>>     ++CurPtr;
>> +  }
>
> I don't think this does the right thing, this will never break out of
> the enclosing while loop based on the comment string?
>
>> @@ -244,6 +250,10 @@
>>   // This always consumes at least one character.
>>   int CurChar = getNextChar();
>>
>> +  for (const char *p = MAI.getCommentString(); *p != 0; ++p)
>> +    if (CurChar == *p)
>> +      return LexLineComment();
>
> Similarly this I think only works for single character comment
> strings? It may make sense to have a lexer "isAtStartOfComment"
> method, which both of these two places call.

Done in r82059.

>
>  - Daniel




More information about the llvm-commits mailing list