diff options
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/MCParser/AsmLexer.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/MC/MCParser/MCAsmLexer.cpp | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp index 0fa7fbdc7b6..87ecf9e0227 100644 --- a/llvm/lib/MC/MCParser/AsmLexer.cpp +++ b/llvm/lib/MC/MCParser/AsmLexer.cpp @@ -181,12 +181,19 @@ AsmToken AsmLexer::LexSlash() { // C Style comment. ++CurPtr; // skip the star. + const char *CommentTextStart = CurPtr; while (CurPtr != CurBuf.end()) { switch (*CurPtr++) { case '*': // End of the comment? if (*CurPtr != '/') break; + // If we have a CommentConsumer, notify it about the comment. + if (CommentConsumer) { + CommentConsumer->HandleComment( + SMLoc::getFromPointer(CommentTextStart), + StringRef(CommentTextStart, CurPtr - 1 - CommentTextStart)); + } ++CurPtr; // End the */. return AsmToken(AsmToken::Comment, StringRef(TokStart, CurPtr - TokStart)); @@ -202,10 +209,18 @@ AsmToken AsmLexer::LexLineComment() { // comment. While it would be nicer to leave this two tokens, // backwards compatability with TargetParsers makes keeping this in this form // better. + const char *CommentTextStart = CurPtr; int CurChar = getNextChar(); while (CurChar != '\n' && CurChar != '\r' && CurChar != EOF) CurChar = getNextChar(); + // If we have a CommentConsumer, notify it about the comment. + if (CommentConsumer) { + CommentConsumer->HandleComment( + SMLoc::getFromPointer(CommentTextStart), + StringRef(CommentTextStart, CurPtr - 1 - CommentTextStart)); + } + IsAtStartOfLine = true; // This is a whole line comment. leave newline if (IsAtStartOfStatement) diff --git a/llvm/lib/MC/MCParser/MCAsmLexer.cpp b/llvm/lib/MC/MCParser/MCAsmLexer.cpp index 336e6413e38..63c0daba09a 100644 --- a/llvm/lib/MC/MCParser/MCAsmLexer.cpp +++ b/llvm/lib/MC/MCParser/MCAsmLexer.cpp @@ -13,7 +13,8 @@ using namespace llvm; MCAsmLexer::MCAsmLexer() - : TokStart(nullptr), SkipSpace(true), IsAtStartOfStatement(true) { + : TokStart(nullptr), SkipSpace(true), IsAtStartOfStatement(true), + CommentConsumer(nullptr) { CurTok.emplace_back(AsmToken::Space, StringRef()); } |