aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-mc/AsmLexer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-mc/AsmLexer.cpp')
-rw-r--r--tools/llvm-mc/AsmLexer.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp
index 2016f935c5..be8f60d2dd 100644
--- a/tools/llvm-mc/AsmLexer.cpp
+++ b/tools/llvm-mc/AsmLexer.cpp
@@ -232,27 +232,30 @@ AsmToken AsmLexer::LexQuote() {
StringRef AsmLexer::LexUntilEndOfStatement() {
TokStart = CurPtr;
- while (*CurPtr != ';' && // End of statement marker.
+ while (!isAtStartOfComment(*CurPtr) && // Start of line comment.
+ *CurPtr != ';' && // End of statement marker.
*CurPtr != '\n' &&
*CurPtr != '\r' &&
(*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;
}
return StringRef(TokStart, CurPtr-TokStart);
}
+bool AsmLexer::isAtStartOfComment(char Char) {
+ for (const char *p = MAI.getCommentString(); *p != 0; ++p)
+ if (Char == *p)
+ return true;
+ return false;
+}
+
AsmToken AsmLexer::LexToken() {
TokStart = CurPtr;
// This always consumes at least one character.
int CurChar = getNextChar();
- for (const char *p = MAI.getCommentString(); *p != 0; ++p)
- if (CurChar == *p)
- return LexLineComment();
+ if (isAtStartOfComment(CurChar))
+ return LexLineComment();
switch (CurChar) {
default: