[compiler-rt] 5b7dfa9 - [NFC][sanitizer] Rename InternalScopedString::append to AppendF (#66558)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 17:06:24 PDT 2023


Author: Vitaly Buka
Date: 2023-09-15T17:06:20-07:00
New Revision: 5b7dfa968fa49b51c850000350daf835b8652b3d

URL: https://github.com/llvm/llvm-project/commit/5b7dfa968fa49b51c850000350daf835b8652b3d
DIFF: https://github.com/llvm/llvm-project/commit/5b7dfa968fa49b51c850000350daf835b8652b3d.diff

LOG: [NFC][sanitizer] Rename InternalScopedString::append to AppendF (#66558)

Prepare to introduce trivial InternalScopedString::Append(const char*).

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_descriptions.cpp
    compiler-rt/lib/asan/asan_errors.cpp
    compiler-rt/lib/asan/asan_fake_stack.cpp
    compiler-rt/lib/asan/asan_globals.cpp
    compiler-rt/lib/asan/asan_report.cpp
    compiler-rt/lib/dfsan/dfsan.cpp
    compiler-rt/lib/hwasan/hwasan.cpp
    compiler-rt/lib/hwasan/hwasan_report.cpp
    compiler-rt/lib/lsan/lsan_common.cpp
    compiler-rt/lib/memprof/memprof_descriptions.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_common.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_common.h
    compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
    compiler-rt/lib/sanitizer_common/sanitizer_printf.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
    compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
    compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
    compiler-rt/lib/ubsan/ubsan_diag.cpp
    compiler-rt/lib/ubsan/ubsan_monitor.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_descriptions.cpp b/compiler-rt/lib/asan/asan_descriptions.cpp
index fbe92572b55b242..8bf070b36d0066b 100644
--- a/compiler-rt/lib/asan/asan_descriptions.cpp
+++ b/compiler-rt/lib/asan/asan_descriptions.cpp
@@ -49,14 +49,14 @@ void DescribeThread(AsanThreadContext *context) {
   }
   context->announced = true;
   InternalScopedString str;
-  str.append("Thread %s", AsanThreadIdAndName(context).c_str());
+  str.AppendF("Thread %s", AsanThreadIdAndName(context).c_str());
   if (context->parent_tid == kInvalidTid) {
-    str.append(" created by unknown thread\n");
+    str.AppendF(" created by unknown thread\n");
     Printf("%s", str.data());
     return;
   }
-  str.append(" created by %s here:\n",
-             AsanThreadIdAndName(context->parent_tid).c_str());
+  str.AppendF(" created by %s here:\n",
+              AsanThreadIdAndName(context->parent_tid).c_str());
   Printf("%s", str.data());
   StackDepotGet(context->stack_id).Print();
   // Recursively described parent thread if needed.
@@ -126,29 +126,29 @@ static void GetAccessToHeapChunkInformation(ChunkAccess *descr,
 static void PrintHeapChunkAccess(uptr addr, const ChunkAccess &descr) {
   Decorator d;
   InternalScopedString str;
-  str.append("%s", d.Location());
+  str.AppendF("%s", d.Location());
   switch (descr.access_type) {
     case kAccessTypeLeft:
-      str.append("%p is located %zd bytes before",
-                 (void *)descr.bad_addr, descr.offset);
+      str.AppendF("%p is located %zd bytes before", (void *)descr.bad_addr,
+                  descr.offset);
       break;
     case kAccessTypeRight:
-      str.append("%p is located %zd bytes after",
-                 (void *)descr.bad_addr, descr.offset);
+      str.AppendF("%p is located %zd bytes after", (void *)descr.bad_addr,
+                  descr.offset);
       break;
     case kAccessTypeInside:
-      str.append("%p is located %zd bytes inside of", (void *)descr.bad_addr,
-                 descr.offset);
+      str.AppendF("%p is located %zd bytes inside of", (void *)descr.bad_addr,
+                  descr.offset);
       break;
     case kAccessTypeUnknown:
-      str.append(
+      str.AppendF(
           "%p is located somewhere around (this is AddressSanitizer bug!)",
           (void *)descr.bad_addr);
   }
-  str.append(" %zu-byte region [%p,%p)\n", descr.chunk_size,
-             (void *)descr.chunk_begin,
-             (void *)(descr.chunk_begin + descr.chunk_size));
-  str.append("%s", d.Default());
+  str.AppendF(" %zu-byte region [%p,%p)\n", descr.chunk_size,
+              (void *)descr.chunk_begin,
+              (void *)(descr.chunk_begin + descr.chunk_size));
+  str.AppendF("%s", d.Default());
   Printf("%s", str.data());
 }
 
@@ -243,24 +243,24 @@ static void PrintAccessAndVarIntersection(const StackVarDescr &var, uptr addr,
       pos_descr = "underflows";
   }
   InternalScopedString str;
-  str.append("    [%zd, %zd)", var.beg, var_end);
+  str.AppendF("    [%zd, %zd)", var.beg, var_end);
   // Render variable name.
-  str.append(" '");
+  str.AppendF(" '");
   for (uptr i = 0; i < var.name_len; ++i) {
-    str.append("%c", var.name_pos[i]);
+    str.AppendF("%c", var.name_pos[i]);
   }
-  str.append("'");
+  str.AppendF("'");
   if (var.line > 0) {
-    str.append(" (line %zd)", var.line);
+    str.AppendF(" (line %zd)", var.line);
   }
   if (pos_descr) {
     Decorator d;
     // FIXME: we may want to also print the size of the access here,
     // but in case of accesses generated by memset it may be confusing.
-    str.append("%s <== Memory access at offset %zd %s this variable%s\n",
-               d.Location(), addr, pos_descr, d.Default());
+    str.AppendF("%s <== Memory access at offset %zd %s this variable%s\n",
+                d.Location(), addr, pos_descr, d.Default());
   } else {
-    str.append("\n");
+    str.AppendF("\n");
   }
   Printf("%s", str.data());
 }
@@ -277,23 +277,23 @@ static void DescribeAddressRelativeToGlobal(uptr addr, uptr access_size,
                                             const __asan_global &g) {
   InternalScopedString str;
   Decorator d;
-  str.append("%s", d.Location());
+  str.AppendF("%s", d.Location());
   if (addr < g.beg) {
-    str.append("%p is located %zd bytes before", (void *)addr,
-               g.beg - addr);
+    str.AppendF("%p is located %zd bytes before", (void *)addr, g.beg - addr);
   } else if (addr + access_size > g.beg + g.size) {
     if (addr < g.beg + g.size) addr = g.beg + g.size;
-    str.append("%p is located %zd bytes after", (void *)addr,
-               addr - (g.beg + g.size));
+    str.AppendF("%p is located %zd bytes after", (void *)addr,
+                addr - (g.beg + g.size));
   } else {
     // Can it happen?
-    str.append("%p is located %zd bytes inside of", (void *)addr, addr - g.beg);
+    str.AppendF("%p is located %zd bytes inside of", (void *)addr,
+                addr - g.beg);
   }
-  str.append(" global variable '%s' defined in '",
-             MaybeDemangleGlobalName(g.name));
+  str.AppendF(" global variable '%s' defined in '",
+              MaybeDemangleGlobalName(g.name));
   PrintGlobalLocation(&str, g);
-  str.append("' (0x%zx) of size %zu\n", g.beg, g.size);
-  str.append("%s", d.Default());
+  str.AppendF("' (0x%zx) of size %zu\n", g.beg, g.size);
+  str.AppendF("%s", d.Default());
   PrintGlobalNameIfASCII(&str, g);
   Printf("%s", str.data());
 }

diff  --git a/compiler-rt/lib/asan/asan_errors.cpp b/compiler-rt/lib/asan/asan_errors.cpp
index cc8dc26f5b7572e..49f5b38c3338f61 100644
--- a/compiler-rt/lib/asan/asan_errors.cpp
+++ b/compiler-rt/lib/asan/asan_errors.cpp
@@ -379,8 +379,8 @@ void ErrorODRViolation::Print() {
       "HINT: if you don't care about these errors you may set "
       "ASAN_OPTIONS=detect_odr_violation=0\n");
   InternalScopedString error_msg;
-  error_msg.append("%s: global '%s' at %s", scariness.GetDescription(),
-                   MaybeDemangleGlobalName(global1.name), g1_loc.data());
+  error_msg.AppendF("%s: global '%s' at %s", scariness.GetDescription(),
+                    MaybeDemangleGlobalName(global1.name), g1_loc.data());
   ReportErrorSummary(error_msg.data());
 }
 
@@ -517,15 +517,15 @@ static void PrintShadowByte(InternalScopedString *str, const char *before,
 }
 
 static void PrintLegend(InternalScopedString *str) {
-  str->append(
+  str->AppendF(
       "Shadow byte legend (one shadow byte represents %d "
       "application bytes):\n",
       (int)ASAN_SHADOW_GRANULARITY);
   PrintShadowByte(str, "  Addressable:           ", 0);
-  str->append("  Partially addressable: ");
+  str->AppendF("  Partially addressable: ");
   for (u8 i = 1; i < ASAN_SHADOW_GRANULARITY; i++)
     PrintShadowByte(str, "", i, " ");
-  str->append("\n");
+  str->AppendF("\n");
   PrintShadowByte(str, "  Heap left redzone:       ",
                   kAsanHeapLeftRedzoneMagic);
   PrintShadowByte(str, "  Freed heap region:       ", kAsanHeapFreeMagic);
@@ -559,8 +559,8 @@ static void PrintShadowBytes(InternalScopedString *str, const char *before,
                              u8 *bytes, u8 *guilty, uptr n) {
   Decorator d;
   if (before)
-    str->append("%s%p:", before,
-                (void *)ShadowToMem(reinterpret_cast<uptr>(bytes)));
+    str->AppendF("%s%p:", before,
+                 (void *)ShadowToMem(reinterpret_cast<uptr>(bytes)));
   for (uptr i = 0; i < n; i++) {
     u8 *p = bytes + i;
     const char *before =
@@ -568,7 +568,7 @@ static void PrintShadowBytes(InternalScopedString *str, const char *before,
     const char *after = p == guilty ? "]" : "";
     PrintShadowByte(str, before, *p, after);
   }
-  str->append("\n");
+  str->AppendF("\n");
 }
 
 static void PrintShadowMemoryForAddress(uptr addr) {
@@ -577,7 +577,7 @@ static void PrintShadowMemoryForAddress(uptr addr) {
   const uptr n_bytes_per_row = 16;
   uptr aligned_shadow = shadow_addr & ~(n_bytes_per_row - 1);
   InternalScopedString str;
-  str.append("Shadow bytes around the buggy address:\n");
+  str.AppendF("Shadow bytes around the buggy address:\n");
   for (int i = -5; i <= 5; i++) {
     uptr row_shadow_addr = aligned_shadow + i * n_bytes_per_row;
     // Skip rows that would be outside the shadow range. This can happen when

diff  --git a/compiler-rt/lib/asan/asan_fake_stack.cpp b/compiler-rt/lib/asan/asan_fake_stack.cpp
index 4273f178dc9f06d..7443ff166984d4e 100644
--- a/compiler-rt/lib/asan/asan_fake_stack.cpp
+++ b/compiler-rt/lib/asan/asan_fake_stack.cpp
@@ -68,8 +68,8 @@ void FakeStack::Destroy(int tid) {
   if (Verbosity() >= 2) {
     InternalScopedString str;
     for (uptr class_id = 0; class_id < kNumberOfSizeClasses; class_id++)
-      str.append("%zd: %zd/%zd; ", class_id, hint_position_[class_id],
-                 NumberOfFrames(stack_size_log(), class_id));
+      str.AppendF("%zd: %zd/%zd; ", class_id, hint_position_[class_id],
+                  NumberOfFrames(stack_size_log(), class_id));
     Report("T%d: FakeStack destroyed: %s\n", tid, str.data());
   }
   uptr size = RequiredSize(stack_size_log_);

diff  --git a/compiler-rt/lib/asan/asan_globals.cpp b/compiler-rt/lib/asan/asan_globals.cpp
index 7a72e91528e0739..5b9a335029edc11 100644
--- a/compiler-rt/lib/asan/asan_globals.cpp
+++ b/compiler-rt/lib/asan/asan_globals.cpp
@@ -295,8 +295,8 @@ void PrintGlobalNameIfASCII(InternalScopedString *str, const __asan_global &g) {
     if (c == '\0' || !IsASCII(c)) return;
   }
   if (*(char *)(g.beg + g.size - 1) != '\0') return;
-  str->append("  '%s' is ascii string '%s'\n", MaybeDemangleGlobalName(g.name),
-              (char *)g.beg);
+  str->AppendF("  '%s' is ascii string '%s'\n", MaybeDemangleGlobalName(g.name),
+               (char *)g.beg);
 }
 
 void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g) {
@@ -304,14 +304,17 @@ void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g) {
   Symbolizer::GetOrInit()->SymbolizeData(g.beg, &info);
 
   if (info.line != 0) {
-    str->append("%s:%d", info.file, static_cast<int>(info.line));
+    str->AppendF("%s:%d", info.file, static_cast<int>(info.line));
   } else if (g.gcc_location != 0) {
     // Fallback to Global::gcc_location
-    str->append("%s", g.gcc_location->filename ? g.gcc_location->filename : g.module_name);
-    if (g.gcc_location->line_no) str->append(":%d", g.gcc_location->line_no);
-    if (g.gcc_location->column_no) str->append(":%d", g.gcc_location->column_no);
+    str->AppendF("%s", g.gcc_location->filename ? g.gcc_location->filename
+                                                : g.module_name);
+    if (g.gcc_location->line_no)
+      str->AppendF(":%d", g.gcc_location->line_no);
+    if (g.gcc_location->column_no)
+      str->AppendF(":%d", g.gcc_location->column_no);
   } else {
-    str->append("%s", g.module_name);
+    str->AppendF("%s", g.module_name);
   }
 }
 

diff  --git a/compiler-rt/lib/asan/asan_report.cpp b/compiler-rt/lib/asan/asan_report.cpp
index f2c04342e778aca..7603e8131154bad 100644
--- a/compiler-rt/lib/asan/asan_report.cpp
+++ b/compiler-rt/lib/asan/asan_report.cpp
@@ -60,9 +60,9 @@ void AppendToErrorMessageBuffer(const char *buffer) {
 void PrintMemoryByte(InternalScopedString *str, const char *before, u8 byte,
                      bool in_shadow, const char *after) {
   Decorator d;
-  str->append("%s%s%x%x%s%s", before,
-              in_shadow ? d.ShadowByte(byte) : d.MemoryByte(), byte >> 4,
-              byte & 15, d.Default(), after);
+  str->AppendF("%s%s%x%x%s%s", before,
+               in_shadow ? d.ShadowByte(byte) : d.MemoryByte(), byte >> 4,
+               byte & 15, d.Default(), after);
 }
 
 static void PrintZoneForPointer(uptr ptr, uptr zone_ptr,

diff  --git a/compiler-rt/lib/dfsan/dfsan.cpp b/compiler-rt/lib/dfsan/dfsan.cpp
index a579c9e53444370..5e85c8fda3e230f 100644
--- a/compiler-rt/lib/dfsan/dfsan.cpp
+++ b/compiler-rt/lib/dfsan/dfsan.cpp
@@ -823,12 +823,12 @@ bool PrintOriginTraceFramesToStr(Origin o, InternalScopedString *out) {
     dfsan_origin origin_id = o.raw_id();
     o = o.getNextChainedOrigin(&stack);
     if (o.isChainedOrigin())
-      out->append(
+      out->AppendF(
           "  %sOrigin value: 0x%x, Taint value was stored to memory at%s\n",
           d.Origin(), origin_id, d.Default());
     else
-      out->append("  %sOrigin value: 0x%x, Taint value was created at%s\n",
-                  d.Origin(), origin_id, d.Default());
+      out->AppendF("  %sOrigin value: 0x%x, Taint value was created at%s\n",
+                   d.Origin(), origin_id, d.Default());
 
     // Includes a trailing newline, so no need to add it again.
     stack.PrintTo(out);
@@ -849,9 +849,9 @@ bool PrintOriginTraceToStr(const void *addr, const char *description,
 
   const dfsan_origin origin = *__dfsan::origin_for(addr);
 
-  out->append("  %sTaint value 0x%x (at %p) origin tracking (%s)%s\n",
-              d.Origin(), label, addr, description ? description : "",
-              d.Default());
+  out->AppendF("  %sTaint value 0x%x (at %p) origin tracking (%s)%s\n",
+               d.Origin(), label, addr, description ? description : "",
+               d.Default());
 
   Origin o = Origin::FromRawId(origin);
   return PrintOriginTraceFramesToStr(o, out);

diff  --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp
index 74aabc6c4f06b62..2f6cb10caf1be60 100644
--- a/compiler-rt/lib/hwasan/hwasan.cpp
+++ b/compiler-rt/lib/hwasan/hwasan.cpp
@@ -172,7 +172,7 @@ static void HwasanFormatMemoryUsage(InternalScopedString &s) {
   auto sds = StackDepotGetStats();
   AllocatorStatCounters asc;
   GetAllocatorStats(asc);
-  s.append(
+  s.AppendF(
       "HWASAN pid: %d rss: %zd threads: %zd stacks: %zd"
       " thr_aux: %zd stack_depot: %zd uniq_stacks: %zd"
       " heap: %zd",

diff  --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cpp
index efe6f57704919a4..8d81322c35554c1 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -243,8 +243,8 @@ static void PrintStackAllocations(StackAllocationsRingBuffer *sa,
       break;
     uptr pc_mask = (1ULL << 48) - 1;
     uptr pc = record & pc_mask;
-    frame_desc.append("  record_addr:0x%zx record:0x%zx",
-                      reinterpret_cast<uptr>(record_addr), record);
+    frame_desc.AppendF("  record_addr:0x%zx record:0x%zx",
+                       reinterpret_cast<uptr>(record_addr), record);
     if (SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc)) {
       RenderFrame(&frame_desc, " %F %L", 0, frame->info.address, &frame->info,
                   common_flags()->symbolize_vs_style,
@@ -528,14 +528,14 @@ static void PrintTagInfoAroundAddr(tag_t *tag_ptr, uptr num_rows,
   tag_t *end_row = center_row_beg + row_len * ((num_rows + 1) / 2);
   InternalScopedString s;
   for (tag_t *row = beg_row; row < end_row; row += row_len) {
-    s.append("%s", row == center_row_beg ? "=>" : "  ");
-    s.append("%p:", (void *)ShadowToMem(reinterpret_cast<uptr>(row)));
+    s.AppendF("%s", row == center_row_beg ? "=>" : "  ");
+    s.AppendF("%p:", (void *)ShadowToMem(reinterpret_cast<uptr>(row)));
     for (uptr i = 0; i < row_len; i++) {
-      s.append("%s", row + i == tag_ptr ? "[" : " ");
+      s.AppendF("%s", row + i == tag_ptr ? "[" : " ");
       print_tag(s, &row[i]);
-      s.append("%s", row + i == tag_ptr ? "]" : " ");
+      s.AppendF("%s", row + i == tag_ptr ? "]" : " ");
     }
-    s.append("\n");
+    s.AppendF("\n");
   }
   Printf("%s", s.data());
 }
@@ -545,7 +545,7 @@ static void PrintTagsAroundAddr(tag_t *tag_ptr) {
       "Memory tags around the buggy address (one tag corresponds to %zd "
       "bytes):\n", kShadowAlignment);
   PrintTagInfoAroundAddr(tag_ptr, 17, [](InternalScopedString &s, tag_t *tag) {
-    s.append("%02x", *tag);
+    s.AppendF("%02x", *tag);
   });
 
   Printf(
@@ -555,10 +555,10 @@ static void PrintTagsAroundAddr(tag_t *tag_ptr) {
   PrintTagInfoAroundAddr(tag_ptr, 3, [](InternalScopedString &s, tag_t *tag) {
     if (*tag >= 1 && *tag <= kShadowAlignment) {
       uptr granule_addr = ShadowToMem(reinterpret_cast<uptr>(tag));
-      s.append("%02x",
-               *reinterpret_cast<u8 *>(granule_addr + kShadowAlignment - 1));
+      s.AppendF("%02x",
+                *reinterpret_cast<u8 *>(granule_addr + kShadowAlignment - 1));
     } else {
-      s.append("..");
+      s.AppendF("..");
     }
   });
   Printf(
@@ -654,31 +654,29 @@ void ReportTailOverwritten(StackTrace *stack, uptr tagged_addr, uptr orig_size,
   CHECK_GT(tail_size, 0U);
   CHECK_LT(tail_size, kShadowAlignment);
   u8 *tail = reinterpret_cast<u8*>(untagged_addr + orig_size);
-  s.append("Tail contains: ");
-  for (uptr i = 0; i < kShadowAlignment - tail_size; i++)
-    s.append(".. ");
+  s.AppendF("Tail contains: ");
+  for (uptr i = 0; i < kShadowAlignment - tail_size; i++) s.AppendF(".. ");
+  for (uptr i = 0; i < tail_size; i++) s.AppendF("%02x ", tail[i]);
+  s.AppendF("\n");
+  s.AppendF("Expected:      ");
+  for (uptr i = 0; i < kShadowAlignment - tail_size; i++) s.AppendF(".. ");
+  for (uptr i = 0; i < tail_size; i++) s.AppendF("%02x ", actual_expected[i]);
+  s.AppendF("\n");
+  s.AppendF("               ");
+  for (uptr i = 0; i < kShadowAlignment - tail_size; i++) s.AppendF("   ");
   for (uptr i = 0; i < tail_size; i++)
-    s.append("%02x ", tail[i]);
-  s.append("\n");
-  s.append("Expected:      ");
-  for (uptr i = 0; i < kShadowAlignment - tail_size; i++)
-    s.append(".. ");
-  for (uptr i = 0; i < tail_size; i++) s.append("%02x ", actual_expected[i]);
-  s.append("\n");
-  s.append("               ");
-  for (uptr i = 0; i < kShadowAlignment - tail_size; i++)
-    s.append("   ");
-  for (uptr i = 0; i < tail_size; i++)
-    s.append("%s ", actual_expected[i] != tail[i] ? "^^" : "  ");
-
-  s.append("\nThis error occurs when a buffer overflow overwrites memory\n"
-    "after a heap object, but within the %zd-byte granule, e.g.\n"
-    "   char *x = new char[20];\n"
-    "   x[25] = 42;\n"
-    "%s does not detect such bugs in uninstrumented code at the time of write,"
-    "\nbut can detect them at the time of free/delete.\n"
-    "To disable this feature set HWASAN_OPTIONS=free_checks_tail_magic=0\n",
-    kShadowAlignment, SanitizerToolName);
+    s.AppendF("%s ", actual_expected[i] != tail[i] ? "^^" : "  ");
+
+  s.AppendF(
+      "\nThis error occurs when a buffer overflow overwrites memory\n"
+      "after a heap object, but within the %zd-byte granule, e.g.\n"
+      "   char *x = new char[20];\n"
+      "   x[25] = 42;\n"
+      "%s does not detect such bugs in uninstrumented code at the time of "
+      "write,"
+      "\nbut can detect them at the time of free/delete.\n"
+      "To disable this feature set HWASAN_OPTIONS=free_checks_tail_magic=0\n",
+      kShadowAlignment, SanitizerToolName);
   Printf("%s", s.data());
   GetCurrentThread()->Announce();
 

diff  --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp
index 9b73ddbdc756ffa..8b1af5b629fbce1 100644
--- a/compiler-rt/lib/lsan/lsan_common.cpp
+++ b/compiler-rt/lib/lsan/lsan_common.cpp
@@ -950,8 +950,8 @@ void LeakReport::PrintSummary() {
     allocations += leaks_[i].hit_count;
   }
   InternalScopedString summary;
-  summary.append("%zu byte(s) leaked in %zu allocation(s).", bytes,
-                 allocations);
+  summary.AppendF("%zu byte(s) leaked in %zu allocation(s).", bytes,
+                  allocations);
   ReportErrorSummary(summary.data());
 }
 

diff  --git a/compiler-rt/lib/memprof/memprof_descriptions.cpp b/compiler-rt/lib/memprof/memprof_descriptions.cpp
index 669b1acd8c71c38..48b74b6bc87fb53 100644
--- a/compiler-rt/lib/memprof/memprof_descriptions.cpp
+++ b/compiler-rt/lib/memprof/memprof_descriptions.cpp
@@ -49,14 +49,14 @@ void DescribeThread(MemprofThreadContext *context) {
   }
   context->announced = true;
   InternalScopedString str;
-  str.append("Thread %s", MemprofThreadIdAndName(context).c_str());
+  str.AppendF("Thread %s", MemprofThreadIdAndName(context).c_str());
   if (context->parent_tid == kInvalidTid) {
-    str.append(" created by unknown thread\n");
+    str.AppendF(" created by unknown thread\n");
     Printf("%s", str.data());
     return;
   }
-  str.append(" created by %s here:\n",
-             MemprofThreadIdAndName(context->parent_tid).c_str());
+  str.AppendF(" created by %s here:\n",
+              MemprofThreadIdAndName(context->parent_tid).c_str());
   Printf("%s", str.data());
   StackDepotGet(context->stack_id).Print();
   // Recursively described parent thread if needed.

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_common.cpp
index 79b7748b8f6e825..5efdd864295beca 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.cpp
@@ -115,8 +115,9 @@ void ReportErrorSummary(const char *error_message, const char *alt_tool_name) {
   if (!common_flags()->print_summary)
     return;
   InternalScopedString buff;
-  buff.append("SUMMARY: %s: %s",
-              alt_tool_name ? alt_tool_name : SanitizerToolName, error_message);
+  buff.AppendF("SUMMARY: %s: %s",
+               alt_tool_name ? alt_tool_name : SanitizerToolName,
+               error_message);
   __sanitizer_report_error_summary(buff.data());
 }
 

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index eda1ead664de8f5..26393d65c8e935e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -643,7 +643,7 @@ class InternalScopedString {
     buffer_.resize(1);
     buffer_[0] = '\0';
   }
-  void append(const char *format, ...) FORMAT(2, 3);
+  void AppendF(const char *format, ...) FORMAT(2, 3);
   const char *data() const { return buffer_.data(); }
   char *data() { return buffer_.data(); }
 

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
index 895763ac6b6f5ef..b9a3117b48473fe 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
@@ -120,7 +120,7 @@ void MaybeStartBackgroudThread() {}
 
 void WriteToSyslog(const char *msg) {
   InternalScopedString msg_copy;
-  msg_copy.append("%s", msg);
+  msg_copy.AppendF("%s", msg);
   const char *p = msg_copy.data();
 
   // Print one line at a time.

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 42013f471870520..e93aebf9542c14b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -700,7 +700,7 @@ static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) {
 
   if (info->dlpi_name) {
     InternalScopedString module_name;
-    module_name.append("%s", info->dlpi_name);
+    module_name.AppendF("%s", info->dlpi_name);
     return AddModuleSegments(module_name.data(), info, data->modules);
   }
 

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc b/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
index fe76b3f8aa05144..6343eb284afbf18 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
@@ -123,7 +123,7 @@ INTERCEPTOR(void, malloc_set_zone_name, malloc_zone_t *zone, const char *name) {
   COMMON_MALLOC_ENTER();
   InternalScopedString new_name;
   if (name && zone->introspect == sanitizer_zone.introspect) {
-    new_name.append(COMMON_MALLOC_ZONE_NAME "-%s", name);
+    new_name.AppendF(COMMON_MALLOC_ZONE_NAME "-%s", name);
     name = new_name.data();
   }
 

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_printf.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_printf.cpp
index 3a9e366d2df952a..33a226358f62eb6 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_printf.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_printf.cpp
@@ -337,7 +337,7 @@ int internal_snprintf(char *buffer, uptr length, const char *format, ...) {
   return needed_length;
 }
 
-void InternalScopedString::append(const char *format, ...) {
+void InternalScopedString::AppendF(const char *format, ...) {
   uptr prev_len = length();
 
   while (true) {

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp
index 47983ee7ec713f2..ef2c69c8a77af16 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp
@@ -46,7 +46,7 @@ class StackTraceTextPrinter {
                   common_flags()->strip_path_prefix);
 
       if (prev_len != output_->length())
-        output_->append("%c", frame_delimiter_);
+        output_->AppendF("%c", frame_delimiter_);
 
       ExtendDedupToken(cur);
     }
@@ -62,9 +62,9 @@ class StackTraceTextPrinter {
 
     if (dedup_frames_-- > 0) {
       if (dedup_token_->length())
-        dedup_token_->append("--");
+        dedup_token_->AppendF("--");
       if (stack->info.function != nullptr)
-        dedup_token_->append("%s", stack->info.function);
+        dedup_token_->AppendF("%s", stack->info.function);
     }
   }
 
@@ -98,7 +98,7 @@ void StackTrace::PrintTo(InternalScopedString *output) const {
                                 output, &dedup_token);
 
   if (trace == nullptr || size == 0) {
-    output->append("    <empty stack>\n\n");
+    output->AppendF("    <empty stack>\n\n");
     return;
   }
 
@@ -110,11 +110,11 @@ void StackTrace::PrintTo(InternalScopedString *output) const {
   }
 
   // Always add a trailing empty line after stack trace.
-  output->append("\n");
+  output->AppendF("\n");
 
   // Append deduplication token, if non-empty.
   if (dedup_token.length())
-    output->append("DEDUP_TOKEN: %s\n", dedup_token.data());
+    output->AppendF("DEDUP_TOKEN: %s\n", dedup_token.data());
 }
 
 uptr StackTrace::PrintTo(char *out_buf, uptr out_buf_size) const {
@@ -197,7 +197,7 @@ void __sanitizer_symbolize_pc(uptr pc, const char *fmt, char *out_buf,
   StackTraceTextPrinter printer(fmt, '\0', &output, nullptr);
   if (!printer.ProcessAddressFrames(pc)) {
     output.clear();
-    output.append("<can't symbolize>");
+    output.AppendF("<can't symbolize>");
   }
   CopyStringToBuffer(output, out_buf, out_buf_size);
 }

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
index 45c480d225c7f5a..2c7540d7cf134ec 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
@@ -130,12 +130,12 @@ static void MaybeBuildIdToBuffer(const AddressInfo &info, bool PrefixSpace,
                                  InternalScopedString *buffer) {
   if (info.uuid_size) {
     if (PrefixSpace)
-      buffer->append(" ");
-    buffer->append("(BuildId: ");
+      buffer->AppendF(" ");
+    buffer->AppendF("(BuildId: ");
     for (uptr i = 0; i < info.uuid_size; ++i) {
-      buffer->append("%02x", info.uuid[i]);
+      buffer->AppendF("%02x", info.uuid[i]);
     }
-    buffer->append(")");
+    buffer->AppendF(")");
   }
 }
 
@@ -154,56 +154,56 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
     format = kDefaultFormat;
   for (const char *p = format; *p != '\0'; p++) {
     if (*p != '%') {
-      buffer->append("%c", *p);
+      buffer->AppendF("%c", *p);
       continue;
     }
     p++;
     switch (*p) {
     case '%':
-      buffer->append("%%");
+      buffer->AppendF("%%");
       break;
     // Frame number and all fields of AddressInfo structure.
     case 'n':
-      buffer->append("%u", frame_no);
+      buffer->AppendF("%u", frame_no);
       break;
     case 'p':
-      buffer->append("0x%zx", address);
+      buffer->AppendF("0x%zx", address);
       break;
     case 'm':
-      buffer->append("%s", StripPathPrefix(info->module, strip_path_prefix));
+      buffer->AppendF("%s", StripPathPrefix(info->module, strip_path_prefix));
       break;
     case 'o':
-      buffer->append("0x%zx", info->module_offset);
+      buffer->AppendF("0x%zx", info->module_offset);
       break;
     case 'b':
       MaybeBuildIdToBuffer(*info, /*PrefixSpace=*/false, buffer);
       break;
     case 'f':
-      buffer->append("%s",
-                     DemangleFunctionName(StripFunctionName(info->function)));
+      buffer->AppendF("%s",
+                      DemangleFunctionName(StripFunctionName(info->function)));
       break;
     case 'q':
-      buffer->append("0x%zx", info->function_offset != AddressInfo::kUnknown
-                                  ? info->function_offset
-                                  : 0x0);
+      buffer->AppendF("0x%zx", info->function_offset != AddressInfo::kUnknown
+                                   ? info->function_offset
+                                   : 0x0);
       break;
     case 's':
-      buffer->append("%s", StripPathPrefix(info->file, strip_path_prefix));
+      buffer->AppendF("%s", StripPathPrefix(info->file, strip_path_prefix));
       break;
     case 'l':
-      buffer->append("%d", info->line);
+      buffer->AppendF("%d", info->line);
       break;
     case 'c':
-      buffer->append("%d", info->column);
+      buffer->AppendF("%d", info->column);
       break;
     // Smarter special cases.
     case 'F':
       // Function name and offset, if file is unknown.
       if (info->function) {
-        buffer->append("in %s",
-                       DemangleFunctionName(StripFunctionName(info->function)));
+        buffer->AppendF(
+            "in %s", DemangleFunctionName(StripFunctionName(info->function)));
         if (!info->file && info->function_offset != AddressInfo::kUnknown)
-          buffer->append("+0x%zx", info->function_offset);
+          buffer->AppendF("+0x%zx", info->function_offset);
       }
       break;
     case 'S':
@@ -224,7 +224,7 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
         MaybeBuildIdToBuffer(*info, /*PrefixSpace=*/true, buffer);
 #endif
       } else {
-        buffer->append("(<unknown module>)");
+        buffer->AppendF("(<unknown module>)");
       }
       break;
     case 'M':
@@ -239,7 +239,7 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
         MaybeBuildIdToBuffer(*info, /*PrefixSpace=*/true, buffer);
 #endif
       } else {
-        buffer->append("(%p)", (void *)address);
+        buffer->AppendF("(%p)", (void *)address);
       }
       break;
     default:
@@ -277,22 +277,22 @@ void RenderData(InternalScopedString *buffer, const char *format,
                 const DataInfo *DI, const char *strip_path_prefix) {
   for (const char *p = format; *p != '\0'; p++) {
     if (*p != '%') {
-      buffer->append("%c", *p);
+      buffer->AppendF("%c", *p);
       continue;
     }
     p++;
     switch (*p) {
       case '%':
-        buffer->append("%%");
+        buffer->AppendF("%%");
         break;
       case 's':
-        buffer->append("%s", StripPathPrefix(DI->file, strip_path_prefix));
+        buffer->AppendF("%s", StripPathPrefix(DI->file, strip_path_prefix));
         break;
       case 'l':
-        buffer->append("%zu", DI->line);
+        buffer->AppendF("%zu", DI->line);
         break;
       case 'g':
-        buffer->append("%s", DI->name);
+        buffer->AppendF("%s", DI->name);
         break;
       default:
         Report("Unsupported specifier in stack frame format: %c (%p)!\n", *p,
@@ -308,29 +308,29 @@ void RenderSourceLocation(InternalScopedString *buffer, const char *file,
                           int line, int column, bool vs_style,
                           const char *strip_path_prefix) {
   if (vs_style && line > 0) {
-    buffer->append("%s(%d", StripPathPrefix(file, strip_path_prefix), line);
+    buffer->AppendF("%s(%d", StripPathPrefix(file, strip_path_prefix), line);
     if (column > 0)
-      buffer->append(",%d", column);
-    buffer->append(")");
+      buffer->AppendF(",%d", column);
+    buffer->AppendF(")");
     return;
   }
 
-  buffer->append("%s", StripPathPrefix(file, strip_path_prefix));
+  buffer->AppendF("%s", StripPathPrefix(file, strip_path_prefix));
   if (line > 0) {
-    buffer->append(":%d", line);
+    buffer->AppendF(":%d", line);
     if (column > 0)
-      buffer->append(":%d", column);
+      buffer->AppendF(":%d", column);
   }
 }
 
 void RenderModuleLocation(InternalScopedString *buffer, const char *module,
                           uptr offset, ModuleArch arch,
                           const char *strip_path_prefix) {
-  buffer->append("(%s", StripPathPrefix(module, strip_path_prefix));
+  buffer->AppendF("(%s", StripPathPrefix(module, strip_path_prefix));
   if (arch != kModuleArchUnknown) {
-    buffer->append(":%s", ModuleArchToString(arch));
+    buffer->AppendF(":%s", ModuleArchToString(arch));
   }
-  buffer->append("+0x%zx)", offset);
+  buffer->AppendF("+0x%zx)", offset);
 }
 
 } // namespace __sanitizer

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
index 13b90ce9bf51613..25c4af70856084f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
@@ -565,7 +565,7 @@ PtraceRegistersStatus SuspendedThreadsListLinux::GetRegistersAndSP(
   constexpr uptr uptr_sz = sizeof(uptr);
   int pterrno;
 #ifdef ARCH_IOVEC_FOR_GETREGSET
-  auto append = [&](uptr regset) {
+  auto AppendF = [&](uptr regset) {
     uptr size = buffer->size();
     // NT_X86_XSTATE requires 64bit alignment.
     uptr size_up = RoundUpTo(size, 8 / uptr_sz);
@@ -596,11 +596,11 @@ PtraceRegistersStatus SuspendedThreadsListLinux::GetRegistersAndSP(
   };
 
   buffer->clear();
-  bool fail = !append(NT_PRSTATUS);
+  bool fail = !AppendF(NT_PRSTATUS);
   if (!fail) {
     // Accept the first available and do not report errors.
     for (uptr regs : kExtraRegs)
-      if (regs && append(regs))
+      if (regs && AppendF(regs))
         break;
   }
 #else

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
index c8c10de10d03a24..e56af63a4397056 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
@@ -83,7 +83,7 @@ bool Symbolizer::SymbolizeData(uptr addr, DataInfo *info) {
 // We ignore the format argument to __sanitizer_symbolize_global.
 void RenderData(InternalScopedString *buffer, const char *format,
                 const DataInfo *DI, const char *strip_path_prefix) {
-  buffer->append(kFormatData, DI->start);
+  buffer->AppendF(kFormatData, DI->start);
 }
 
 bool RenderNeedsSymbolization(const char *format) { return false; }
@@ -93,7 +93,7 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
                  uptr address, const AddressInfo *info, bool vs_style,
                  const char *strip_path_prefix) {
   CHECK(!RenderNeedsSymbolization(format));
-  buffer->append(kFormatFrame, frame_no, address);
+  buffer->AppendF(kFormatFrame, frame_no, address);
 }
 
 Symbolizer *Symbolizer::PlatformInit() {

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
index 73915715c5ba2c0..d2196ecf8f261ab 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
@@ -32,7 +32,7 @@ void ReportErrorSummary(const char *error_type, const AddressInfo &info,
                         const char *alt_tool_name) {
   if (!common_flags()->print_summary) return;
   InternalScopedString buff;
-  buff.append("%s ", error_type);
+  buff.AppendF("%s ", error_type);
   RenderFrame(&buff, "%L %F", 0, info.address, &info,
               common_flags()->symbolize_vs_style,
               common_flags()->strip_path_prefix);
@@ -148,22 +148,22 @@ static void MaybeReportNonExecRegion(uptr pc) {
 static void PrintMemoryByte(InternalScopedString *str, const char *before,
                             u8 byte) {
   SanitizerCommonDecorator d;
-  str->append("%s%s%x%x%s ", before, d.MemoryByte(), byte >> 4, byte & 15,
-              d.Default());
+  str->AppendF("%s%s%x%x%s ", before, d.MemoryByte(), byte >> 4, byte & 15,
+               d.Default());
 }
 
 static void MaybeDumpInstructionBytes(uptr pc) {
   if (!common_flags()->dump_instruction_bytes || (pc < GetPageSizeCached()))
     return;
   InternalScopedString str;
-  str.append("First 16 instruction bytes at pc: ");
+  str.AppendF("First 16 instruction bytes at pc: ");
   if (IsAccessibleMemoryRange(pc, 16)) {
     for (int i = 0; i < 16; ++i) {
       PrintMemoryByte(&str, "", ((u8 *)pc)[i]);
     }
-    str.append("\n");
+    str.AppendF("\n");
   } else {
-    str.append("unaccessible\n");
+    str.AppendF("unaccessible\n");
   }
   Report("%s", str.data());
 }

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
index 56cde2dcef1e0a9..aae3e76ea229ffc 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
@@ -231,7 +231,7 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
     CHECK(!internal_strchr(arg, '"') && "quotes in args unsupported");
     CHECK(arglen > 0 && arg[arglen - 1] != '\\' &&
           "args ending in backslash and empty args unsupported");
-    command_line.append("\"%s\" ", arg);
+    command_line.AppendF("\"%s\" ", arg);
   }
   VReport(3, "Launching symbolizer command: %s\n", command_line.data());
 

diff  --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
index 8fbeb96fcb04bf6..6acfdd437196d35 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cpp
@@ -381,16 +381,16 @@ TEST(SanitizerCommon, InternalScopedString) {
   EXPECT_EQ(0U, str.length());
   EXPECT_STREQ("", str.data());
 
-  str.append("foo");
+  str.AppendF("foo");
   EXPECT_EQ(3U, str.length());
   EXPECT_STREQ("foo", str.data());
 
   int x = 1234;
-  str.append("%d", x);
+  str.AppendF("%d", x);
   EXPECT_EQ(7U, str.length());
   EXPECT_STREQ("foo1234", str.data());
 
-  str.append("%d", x);
+  str.AppendF("%d", x);
   EXPECT_EQ(11U, str.length());
   EXPECT_STREQ("foo12341234", str.data());
 
@@ -405,7 +405,7 @@ TEST(SanitizerCommon, InternalScopedStringLarge) {
   for (int i = 0; i < 1000; ++i) {
     std::string append(i, 'a' + i % 26);
     expected += append;
-    str.append("%s", append.c_str());
+    str.AppendF("%s", append.c_str());
     EXPECT_EQ(expected, str.data());
   }
 }
@@ -416,7 +416,7 @@ TEST(SanitizerCommon, InternalScopedStringLargeFormat) {
   for (int i = 0; i < 1000; ++i) {
     std::string append(i, 'a' + i % 26);
     expected += append;
-    str.append("%s", append.c_str());
+    str.AppendF("%s", append.c_str());
     EXPECT_EQ(expected, str.data());
   }
 }

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
index 6b1ec1d04fdba90..fd9441dfcb53cbd 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
@@ -446,7 +446,7 @@ static bool InitializeMemoryProfiler() {
     ctx->memprof_fd = 2;
   } else {
     InternalScopedString filename;
-    filename.append("%s.%d", fname, (int)internal_getpid());
+    filename.AppendF("%s.%d", fname, (int)internal_getpid());
     ctx->memprof_fd = OpenFile(filename.data(), WrOnly);
     if (ctx->memprof_fd == kInvalidFd) {
       Printf("ThreadSanitizer: failed to open memory profile file '%s'\n",

diff  --git a/compiler-rt/lib/ubsan/ubsan_diag.cpp b/compiler-rt/lib/ubsan/ubsan_diag.cpp
index dd99613abbe3f17..3ab5d15b3d41398 100644
--- a/compiler-rt/lib/ubsan/ubsan_diag.cpp
+++ b/compiler-rt/lib/ubsan/ubsan_diag.cpp
@@ -134,9 +134,9 @@ Diag &Diag::operator<<(const Value &V) {
 /// Hexadecimal printing for numbers too large for Printf to handle directly.
 static void RenderHex(InternalScopedString *Buffer, UIntMax Val) {
 #if HAVE_INT128_T
-  Buffer->append("0x%08x%08x%08x%08x", (unsigned int)(Val >> 96),
-                 (unsigned int)(Val >> 64), (unsigned int)(Val >> 32),
-                 (unsigned int)(Val));
+  Buffer->AppendF("0x%08x%08x%08x%08x", (unsigned int)(Val >> 96),
+                  (unsigned int)(Val >> 64), (unsigned int)(Val >> 32),
+                  (unsigned int)(Val));
 #else
   UNREACHABLE("long long smaller than 64 bits?");
 #endif
@@ -147,7 +147,7 @@ static void RenderLocation(InternalScopedString *Buffer, Location Loc) {
   case Location::LK_Source: {
     SourceLocation SLoc = Loc.getSourceLocation();
     if (SLoc.isInvalid())
-      Buffer->append("<unknown>");
+      Buffer->AppendF("<unknown>");
     else
       RenderSourceLocation(Buffer, SLoc.getFilename(), SLoc.getLine(),
                            SLoc.getColumn(), common_flags()->symbolize_vs_style,
@@ -155,7 +155,7 @@ static void RenderLocation(InternalScopedString *Buffer, Location Loc) {
     return;
   }
   case Location::LK_Memory:
-    Buffer->append("%p", reinterpret_cast<void *>(Loc.getMemoryLocation()));
+    Buffer->AppendF("%p", reinterpret_cast<void *>(Loc.getMemoryLocation()));
     return;
   case Location::LK_Symbolized: {
     const AddressInfo &Info = Loc.getSymbolizedStack()->info;
@@ -167,11 +167,11 @@ static void RenderLocation(InternalScopedString *Buffer, Location Loc) {
       RenderModuleLocation(Buffer, Info.module, Info.module_offset,
                            Info.module_arch, common_flags()->strip_path_prefix);
     else
-      Buffer->append("%p", reinterpret_cast<void *>(Info.address));
+      Buffer->AppendF("%p", reinterpret_cast<void *>(Info.address));
     return;
   }
   case Location::LK_Null:
-    Buffer->append("<unknown>");
+    Buffer->AppendF("<unknown>");
     return;
   }
 }
@@ -180,32 +180,32 @@ static void RenderText(InternalScopedString *Buffer, const char *Message,
                        const Diag::Arg *Args) {
   for (const char *Msg = Message; *Msg; ++Msg) {
     if (*Msg != '%') {
-      Buffer->append("%c", *Msg);
+      Buffer->AppendF("%c", *Msg);
       continue;
     }
     const Diag::Arg &A = Args[*++Msg - '0'];
     switch (A.Kind) {
     case Diag::AK_String:
-      Buffer->append("%s", A.String);
+      Buffer->AppendF("%s", A.String);
       break;
     case Diag::AK_TypeName: {
       if (SANITIZER_WINDOWS)
         // The Windows implementation demangles names early.
-        Buffer->append("'%s'", A.String);
+        Buffer->AppendF("'%s'", A.String);
       else
-        Buffer->append("'%s'", Symbolizer::GetOrInit()->Demangle(A.String));
+        Buffer->AppendF("'%s'", Symbolizer::GetOrInit()->Demangle(A.String));
       break;
     }
     case Diag::AK_SInt:
       // 'long long' is guaranteed to be at least 64 bits wide.
       if (A.SInt >= INT64_MIN && A.SInt <= INT64_MAX)
-        Buffer->append("%lld", (long long)A.SInt);
+        Buffer->AppendF("%lld", (long long)A.SInt);
       else
         RenderHex(Buffer, A.SInt);
       break;
     case Diag::AK_UInt:
       if (A.UInt <= UINT64_MAX)
-        Buffer->append("%llu", (unsigned long long)A.UInt);
+        Buffer->AppendF("%llu", (unsigned long long)A.UInt);
       else
         RenderHex(Buffer, A.UInt);
       break;
@@ -223,11 +223,11 @@ static void RenderText(InternalScopedString *Buffer, const char *Message,
 #else
       snprintf(FloatBuffer, sizeof(FloatBuffer), "%Lg", (long double)A.Float);
 #endif
-      Buffer->append("%s", FloatBuffer);
+      Buffer->AppendF("%s", FloatBuffer);
       break;
     }
     case Diag::AK_Pointer:
-      Buffer->append("%p", A.Pointer);
+      Buffer->AppendF("%p", A.Pointer);
       break;
     }
   }
@@ -284,12 +284,12 @@ static void PrintMemorySnippet(const Decorator &Decor, MemoryLocation Loc,
   InternalScopedString Buffer;
   for (uptr P = Min; P != Max; ++P) {
     unsigned char C = *reinterpret_cast<const unsigned char*>(P);
-    Buffer.append("%s%02x", (P % 8 == 0) ? "  " : " ", C);
+    Buffer.AppendF("%s%02x", (P % 8 == 0) ? "  " : " ", C);
   }
-  Buffer.append("\n");
+  Buffer.AppendF("\n");
 
   // Emit highlights.
-  Buffer.append("%s", Decor.Highlight());
+  Buffer.AppendF("%s", Decor.Highlight());
   Range *InRange = upperBound(Min, Ranges, NumRanges);
   for (uptr P = Min; P != Max; ++P) {
     char Pad = ' ', Byte = ' ';
@@ -302,12 +302,12 @@ static void PrintMemorySnippet(const Decorator &Decor, MemoryLocation Loc,
     if (InRange && InRange->getStart().getMemoryLocation() <= P)
       Byte = '~';
     if (P % 8 == 0)
-      Buffer.append("%c", Pad);
-    Buffer.append("%c", Pad);
-    Buffer.append("%c", P == Loc ? '^' : Byte);
-    Buffer.append("%c", Byte);
+      Buffer.AppendF("%c", Pad);
+    Buffer.AppendF("%c", Pad);
+    Buffer.AppendF("%c", P == Loc ? '^' : Byte);
+    Buffer.AppendF("%c", Byte);
   }
-  Buffer.append("%s\n", Decor.Default());
+  Buffer.AppendF("%s\n", Decor.Default());
 
   // Go over the line again, and print names for the ranges.
   InRange = 0;
@@ -322,9 +322,9 @@ static void PrintMemorySnippet(const Decorator &Decor, MemoryLocation Loc,
 
     if (InRange && InRange->getStart().getMemoryLocation() == P) {
       while (Spaces--)
-        Buffer.append(" ");
+        Buffer.AppendF(" ");
       RenderText(&Buffer, InRange->getText(), Args);
-      Buffer.append("\n");
+      Buffer.AppendF("\n");
       // FIXME: We only support naming one range for now!
       break;
     }
@@ -358,24 +358,24 @@ Diag::~Diag() {
     Buffer.clear();
   }
 
-  Buffer.append("%s", Decor.Bold());
+  Buffer.AppendF("%s", Decor.Bold());
   RenderLocation(&Buffer, Loc);
-  Buffer.append(":");
+  Buffer.AppendF(":");
 
   switch (Level) {
   case DL_Error:
-    Buffer.append("%s runtime error: %s%s", Decor.Warning(), Decor.Default(),
-                  Decor.Bold());
+    Buffer.AppendF("%s runtime error: %s%s", Decor.Warning(), Decor.Default(),
+                   Decor.Bold());
     break;
 
   case DL_Note:
-    Buffer.append("%s note: %s", Decor.Note(), Decor.Default());
+    Buffer.AppendF("%s note: %s", Decor.Note(), Decor.Default());
     break;
   }
 
   RenderText(&Buffer, Message, Args);
 
-  Buffer.append("%s\n", Decor.Default());
+  Buffer.AppendF("%s\n", Decor.Default());
   Printf("%s", Buffer.data());
 
   if (Loc.isMemoryLocation())

diff  --git a/compiler-rt/lib/ubsan/ubsan_monitor.cpp b/compiler-rt/lib/ubsan/ubsan_monitor.cpp
index 69dd986f9bdfc52..7aa786a864e9b1e 100644
--- a/compiler-rt/lib/ubsan/ubsan_monitor.cpp
+++ b/compiler-rt/lib/ubsan/ubsan_monitor.cpp
@@ -23,7 +23,7 @@ UndefinedBehaviorReport::UndefinedBehaviorReport(const char *IssueKind,
   RegisterUndefinedBehaviorReport(this);
 
   // Make a copy of the diagnostic.
-  Buffer.append("%s", Msg.data());
+  Buffer.AppendF("%s", Msg.data());
 
   // Let the monitor know that a report is available.
   __ubsan_on_report();


        


More information about the llvm-commits mailing list