diff options
| author | Kevin Enderby <enderby@apple.com> | 2009-09-16 18:08:00 +0000 |
|---|---|---|
| committer | Kevin Enderby <enderby@apple.com> | 2009-09-16 18:08:00 +0000 |
| commit | ecd879a2d537193bc53f5e05330fbf2d72df1b97 (patch) | |
| tree | e8dc6a287bfaf6691af4dbfe0063c53713a3038c /llvm/tools | |
| parent | c0edda3184afb681265c195a8b9e56a5bd45c8e4 (diff) | |
| download | bcm5719-llvm-ecd879a2d537193bc53f5e05330fbf2d72df1b97.tar.gz bcm5719-llvm-ecd879a2d537193bc53f5e05330fbf2d72df1b97.zip | |
Fixed some problems with the logic of parsing line comments by adding
isAtStartOfComment and using that instead in two places where a loop
to check if the char was in MAI.getCommentString().
llvm-svn: 82059
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/llvm-mc/AsmLexer.cpp | 19 | ||||
| -rw-r--r-- | llvm/tools/llvm-mc/AsmLexer.h | 3 |
2 files changed, 13 insertions, 9 deletions
diff --git a/llvm/tools/llvm-mc/AsmLexer.cpp b/llvm/tools/llvm-mc/AsmLexer.cpp index 2016f935c5b..be8f60d2dd7 100644 --- a/llvm/tools/llvm-mc/AsmLexer.cpp +++ b/llvm/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: diff --git a/llvm/tools/llvm-mc/AsmLexer.h b/llvm/tools/llvm-mc/AsmLexer.h index 32b0c5f5fb4..0c2ec138924 100644 --- a/llvm/tools/llvm-mc/AsmLexer.h +++ b/llvm/tools/llvm-mc/AsmLexer.h @@ -55,7 +55,8 @@ public: SMLoc getLoc() const; StringRef LexUntilEndOfStatement(); - + + bool isAtStartOfComment(char Char); /// EnterIncludeFile - Enter the specified file. This returns true on failure. bool EnterIncludeFile(const std::string &Filename); |

