diff options
author | Nirav Dave <niravd@google.com> | 2016-07-11 12:42:14 +0000 |
---|---|---|
committer | Nirav Dave <niravd@google.com> | 2016-07-11 12:42:14 +0000 |
commit | 53a72f4d3c644b0364126daa67fb823171f48781 (patch) | |
tree | 4d971584d3c227afcfaa4c2fc84e6f3f9a3282a7 /llvm/lib/MC/MCParser/AsmParser.cpp | |
parent | faef9a766745acf6938839a5d433f5b2b5d2863f (diff) | |
download | bcm5719-llvm-53a72f4d3c644b0364126daa67fb823171f48781.tar.gz bcm5719-llvm-53a72f4d3c644b0364126daa67fb823171f48781.zip |
Provide support for preserving assembly comments
Preserve assembly comments from input in output assembly and flags to
toggle property. This is on by default for inline assembly and off in
llvm-mc.
Parsed comments are emitted immediately before an EOL which generally
places them on the expected line.
Reviewers: rtrieu, dwmw2, rnk, majnemer
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D20020
llvm-svn: 275058
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmParser.cpp')
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 9a331ec4458..d16f2452e13 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -626,9 +626,20 @@ const AsmToken &AsmParser::Lex() { if (Lexer.getTok().is(AsmToken::Error)) Error(Lexer.getErrLoc(), Lexer.getErr()); + // if it's a end of statement with a comment in it + if (getTok().is(AsmToken::EndOfStatement)) { + // if this is a line comment output it. + if (getTok().getString().front() != '\n' && + getTok().getString().front() != '\r' && MAI.preserveAsmComments()) + Out.addExplicitComment(Twine(getTok().getString())); + } + const AsmToken *tok = &Lexer.Lex(); - // Drop comments here. + + // Parse comments here to be deferred until end of next statement. while (tok->is(AsmToken::Comment)) { + if (MAI.preserveAsmComments()) + Out.addExplicitComment(Twine(tok->getString())); tok = &Lexer.Lex(); } |