Skip to content

Commit b39895b

Browse files
committed
Fix incorrect format specifiers passed to snprintf in Sema
1 parent 3c77e01 commit b39895b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Diff for: lib/Sema/PCMacro.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,10 @@ class Instrumenter : InstrumenterBase {
539539
char *start_column_buf = (char *)Context.Allocate(buf_size, 1);
540540
char *end_column_buf = (char *)Context.Allocate(buf_size, 1);
541541

542-
::snprintf(start_line_buf, buf_size, "%d", StartLC.first);
543-
::snprintf(start_column_buf, buf_size, "%d", StartLC.second);
544-
::snprintf(end_line_buf, buf_size, "%d", EndLC.first);
545-
::snprintf(end_column_buf, buf_size, "%d", EndLC.second);
542+
::snprintf(start_line_buf, buf_size, "%u", StartLC.first);
543+
::snprintf(start_column_buf, buf_size, "%u", StartLC.second);
544+
::snprintf(end_line_buf, buf_size, "%u", EndLC.first);
545+
::snprintf(end_column_buf, buf_size, "%u", EndLC.second);
546546

547547
Expr *StartLine =
548548
new (Context) IntegerLiteralExpr(start_line_buf, SR.End, true);
@@ -622,10 +622,10 @@ class Instrumenter : InstrumenterBase {
622622
char *start_column_buf = (char *)Context.Allocate(buf_size, 1);
623623
char *end_column_buf = (char *)Context.Allocate(buf_size, 1);
624624

625-
::snprintf(start_line_buf, buf_size, "%d", StartLC.first);
626-
::snprintf(start_column_buf, buf_size, "%d", StartLC.second);
627-
::snprintf(end_line_buf, buf_size, "%d", EndLC.first);
628-
::snprintf(end_column_buf, buf_size, "%d", EndLC.second);
625+
::snprintf(start_line_buf, buf_size, "%u", StartLC.first);
626+
::snprintf(start_column_buf, buf_size, "%u", StartLC.second);
627+
::snprintf(end_line_buf, buf_size, "%u", EndLC.first);
628+
::snprintf(end_column_buf, buf_size, "%u", EndLC.second);
629629

630630
Expr *StartLine =
631631
new (Context) IntegerLiteralExpr(start_line_buf, SR.End, true);

Diff for: lib/Sema/PlaygroundTransform.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -818,10 +818,10 @@ class Instrumenter : InstrumenterBase {
818818
char *start_column_buf = (char *)Context.Allocate(buf_size, 1);
819819
char *end_column_buf = (char *)Context.Allocate(buf_size, 1);
820820

821-
::snprintf(start_line_buf, buf_size, "%d", StartLC.first);
822-
::snprintf(start_column_buf, buf_size, "%d", StartLC.second);
823-
::snprintf(end_line_buf, buf_size, "%d", EndLC.first);
824-
::snprintf(end_column_buf, buf_size, "%d", EndLC.second);
821+
::snprintf(start_line_buf, buf_size, "%u", StartLC.first);
822+
::snprintf(start_column_buf, buf_size, "%u", StartLC.second);
823+
::snprintf(end_line_buf, buf_size, "%u", EndLC.first);
824+
::snprintf(end_column_buf, buf_size, "%u", EndLC.second);
825825

826826
Expr *StartLine =
827827
new (Context) IntegerLiteralExpr(start_line_buf, SR.End, true);

0 commit comments

Comments
 (0)