Skip to content

Commit 53afee7

Browse files
authoredJan 27, 2025··
Fix CUDA HTML code printing bug. (#8558)
* Fix CUDA HTML code printing bug.
1 parent bf65d52 commit 53afee7

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed
 

‎src/StmtToHTML.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -807,10 +807,16 @@ class HTMLCodePrinter : public IRVisitor {
807807
std::istringstream ss(str);
808808

809809
for (std::string line; std::getline(ss, line);) {
810-
if (line.empty()) {
810+
if (line.empty() || line == "\t") {
811811
stream << "<span class='line'></span>\n";
812812
continue;
813813
}
814+
bool indent = false;
815+
if (line[0] == '\t') {
816+
// Replace first tab with four spaces.
817+
line = line.substr(1);
818+
indent = true;
819+
}
814820
line = escape_html(line);
815821

816822
bool should_print_open_indent = false;
@@ -844,14 +850,6 @@ class HTMLCodePrinter : public IRVisitor {
844850
scope.pop(current_kernel);
845851
}
846852

847-
bool indent = false;
848-
849-
if (line[0] == '\t') {
850-
// Replace first tab with four spaces.
851-
line = line.substr(1);
852-
indent = true;
853-
}
854-
855853
line = replace_all(line, ".f32", ".<span class='OpF32'>f32</span>");
856854
line = replace_all(line, ".f64", ".<span class='OpF64'>f64</span>");
857855

@@ -883,7 +881,7 @@ class HTMLCodePrinter : public IRVisitor {
883881
}
884882

885883
// Predicated instructions
886-
if (line.front() == '@' && indent) {
884+
if (!line.empty() && line.front() == '@' && indent) {
887885
idx = line.find(' ');
888886
std::string pred = line.substr(1, idx - 1);
889887
line = "<span class='Pred'>@" + variable(pred, Bool()) + "</span>" + line.substr(idx);

0 commit comments

Comments
 (0)
Please sign in to comment.