Skip to content

Commit aa99bfa

Browse files
committed
do not stringify AST nodes unless emitting comments
1 parent 15d6032 commit aa99bfa

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/comp/middle/trans.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4536,7 +4536,9 @@ fn zero_alloca(cx: @block_ctxt, llptr: ValueRef, t: ty::t)
45364536
fn trans_stmt(cx: @block_ctxt, s: ast::stmt) -> @block_ctxt {
45374537
// FIXME Fill in cx.sp
45384538

4539-
add_span_comment(cx, s.span, stmt_to_str(s));
4539+
if (!bcx_ccx(cx).sess.get_opts().no_asm_comments) {
4540+
add_span_comment(cx, s.span, stmt_to_str(s));
4541+
}
45404542

45414543
let bcx = cx;
45424544
alt s.node {

src/comp/middle/trans_build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,9 @@ fn add_span_comment(bcx: @block_ctxt, sp: span, text: str) {
515515
fn add_comment(bcx: @block_ctxt, text: str) {
516516
let ccx = bcx_ccx(bcx);
517517
if (!ccx.sess.get_opts().no_asm_comments) {
518-
let comment_text = "; " + text;
518+
check str::is_not_empty("$");
519+
let sanitized = str::replace(text, "$", "");
520+
let comment_text = "; " + sanitized;
519521
let asm = str::as_buf(comment_text, { |c|
520522
str::as_buf("", { |e|
521523
llvm::LLVMConstInlineAsm(T_fn([], T_void()), c, e, 0, 0)})});

0 commit comments

Comments
 (0)