Fix AsmParser lines to correctly handle end-of-line pre-processor
comments parsing when '#' is not the assembly line comment prefix.
Details
Diff Detail
- Build Status
Buildable 478 Build 478: arc lint + arc unit
Event Timeline
lib/MC/MCParser/AsmParser.cpp | ||
---|---|---|
2970–2974 | HasComma | |
lib/MC/MCParser/MCAsmParser.cpp | ||
70–71 | I see a lot of usage of this that looks like: bool HasComma; parseOptionalToken(Comma, HasComma); if (HasComma && ...) Right now, this always returns false. Either the token is there and its not an error, or we consume it and its not an error. In that case, do you think we should indicate presence with the return type? It might be confusing because a boolean parse method return type usually indicates an error. WDYT? Usage would look like: if (parseOptionalToken(AsmToken::Comma)) { if (parseIdentifier(...) || parseThing(...) || ...)) return true / error / etc; } | |
76–77 | This feels like it's below parseToken. Any reason to not keep using Lex? |
lib/MC/MCParser/MCAsmParser.cpp | ||
---|---|---|
70–71 | I had a similar thought myself but I was unhappy with the fact that the clean way to write this involves multiple conditional statements which duplicates the error suffix additions so I was pushing it off to another cleanup patch while I pondered a cleaner solution. In any case there's no real issue doing it here so I've folded it in. | |
76–77 | This is to correctly handle # preprocessor line comments as EndOfStatement for those cases that the lexer doesn't have the context. |
lgtm
include/llvm/MC/MCParser/MCAsmParser.h | ||
---|---|---|
183 | Please document the convention here, since it's not "return true on error". |
Please document the convention here, since it's not "return true on error".