[compiler-rt] [compiler-rt][windows] Test fixups for MSVC. (PR #109887)

Charlie Barto via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 10:07:52 PST 2025


https://github.com/barcharcraz updated https://github.com/llvm/llvm-project/pull/109887

>From 6e404e3e967ee1c896637fd8f6bc03392cb1ea3d Mon Sep 17 00:00:00 2001
From: Charlie Barto <chbarto at microsoft.com>
Date: Tue, 12 Mar 2024 10:19:51 -0700
Subject: [PATCH 01/15] Test fixups for MSVC. add XFAIL/UNSUPPORTED annotations
 for tests run wtih real MSVC macroify usages of clang-specific attributes in
 asan tests

---
 .../asan/TestCases/Windows/coverage-basic.cpp |  1 +
 .../TestCases/Windows/crash_read_write.cpp    |  5 +--
 .../test/asan/TestCases/Windows/dll_host.cpp  |  1 +
 .../Windows/dll_intercept_memcpy.cpp          |  6 ++--
 .../Windows/dll_intercept_memset.cpp          |  6 ++--
 .../asan/TestCases/Windows/dll_null_deref.cpp |  4 ++-
 ..._operator_array_new_with_dtor_left_oob.cpp |  8 ++++-
 .../Windows/dll_stack_use_after_return.cpp    |  1 +
 .../Windows/global_const_string_oob.cpp       |  2 +-
 .../TestCases/Windows/illegal_instruction.cpp |  2 ++
 .../asan/TestCases/Windows/issue64990.cpp     | 10 +++++-
 .../test/asan/TestCases/Windows/msvc/seh.cpp  | 12 +++----
 .../asan/TestCases/Windows/null_deref.cpp     | 15 ---------
 .../Windows/null_deref_multiple_dlls.cpp      |  5 +--
 .../operator_array_new_with_dtor_left_oob.cpp | 10 ++++--
 .../TestCases/Windows/sse_misalignment.cpp    |  1 +
 .../Windows/stack_use_after_return.cpp        |  2 +-
 .../asan/TestCases/Windows/unsymbolized.cpp   |  3 +-
 .../asan/TestCases/alloca_big_alignment.cpp   |  6 ++--
 .../asan/TestCases/alloca_constant_size.cpp   |  3 ++
 .../TestCases/alloca_detect_custom_size_.cpp  | 12 +++++--
 .../alloca_instruments_all_paddings.cpp       |  1 +
 .../TestCases/alloca_loop_unpoisoning.cpp     |  4 ++-
 .../TestCases/alloca_overflow_partial.cpp     |  1 +
 .../asan/TestCases/alloca_overflow_right.cpp  |  1 +
 .../asan/TestCases/alloca_safe_access.cpp     |  1 +
 .../asan/TestCases/alloca_underflow_left.cpp  |  1 +
 .../asan/TestCases/alloca_vla_interact.cpp    |  1 +
 .../asan/TestCases/contiguous_container.cpp   |  5 +--
 .../test/asan/TestCases/coverage-trace-pc.cpp |  7 ++--
 .../test/asan/TestCases/debug_locate.cpp      |  1 +
 .../test/asan/TestCases/debug_stacks.cpp      |  2 +-
 .../test/asan/TestCases/deep_tail_call.cpp    |  9 +++---
 .../asan/TestCases/default_ignorelist.cpp     |  2 +-
 .../test/asan/TestCases/default_options.cpp   |  4 ++-
 compiler-rt/test/asan/TestCases/defines.h     | 32 +++++++++++++++++++
 .../asan/TestCases/error_report_callback.cpp  |  3 +-
 compiler-rt/test/asan/TestCases/exitcode.cpp  |  2 +-
 .../test/asan/TestCases/force_inline_opt0.cpp |  9 ++++--
 .../TestCases/global-location-nodebug.cpp     |  2 +-
 .../test/asan/TestCases/global-underflow.cpp  |  1 +
 .../test/asan/TestCases/halt_on_error-1.c     |  2 +-
 .../test/asan/TestCases/heavy_uar_test.cpp    |  7 ++--
 .../test/asan/TestCases/ignorelist.cpp        |  5 ++-
 compiler-rt/test/asan/TestCases/ill.cpp       |  6 +++-
 .../asan/TestCases/initialization-bug.cpp     |  3 +-
 compiler-rt/test/asan/TestCases/inline.cpp    |  6 +++-
 .../TestCases/intercept-rethrow-exception.cpp |  3 +-
 .../TestCases/interception_failure_test.cpp   |  4 +++
 .../test/asan/TestCases/interface_test.cpp    |  4 +--
 .../invalid-pointer-pairs-compare-errors.cpp  |  2 +-
 .../invalid-pointer-pairs-subtract-errors.cpp |  2 +-
 .../asan/TestCases/invalid-pointer-pairs.cpp  |  2 +-
 .../test/asan/TestCases/large_func_test.cpp   |  7 ++--
 .../test/asan/TestCases/null_deref.cpp        |  4 ++-
 .../test/asan/TestCases/pass-struct-byval.cpp |  2 +-
 .../asan/TestCases/report_error_summary.cpp   |  2 ++
 .../test/asan/TestCases/speculative_load.cpp  |  1 +
 .../stack-buffer-overflow-with-position.cpp   |  1 +
 .../test/asan/TestCases/stack-oob-frames.cpp  |  1 +
 .../test/asan/TestCases/strcat-overlap.cpp    |  3 +-
 .../test/asan/TestCases/strcpy-overlap.cpp    |  5 +--
 .../test/asan/TestCases/strncat-overlap.cpp   |  3 +-
 .../test/asan/TestCases/strncpy-overflow.cpp  |  3 +-
 .../test/asan/TestCases/strncpy-overlap.cpp   |  3 +-
 .../test/asan/TestCases/throw_call_test.cpp   |  6 ++--
 .../test/asan/TestCases/throw_catch.cpp       |  9 +++---
 .../test/asan/TestCases/throw_invoke_test.cpp |  4 +--
 .../TestCases/use-after-scope-capture.cpp     |  3 +-
 .../TestCases/use-after-scope-dtor-order.cpp  |  3 +-
 .../TestCases/use-after-scope-inlined.cpp     |  6 +++-
 .../TestCases/use-after-scope-loop-bug.cpp    |  2 +-
 .../use-after-scope-loop-removed.cpp          |  3 +-
 .../asan/TestCases/use-after-scope-loop.cpp   |  3 +-
 .../asan/TestCases/use-after-scope-temp.cpp   |  6 ++--
 .../asan/TestCases/use-after-scope-temp2.cpp  |  7 ++--
 .../asan/TestCases/use-after-scope-types.cpp  |  3 +-
 .../asan/TestCases/vla_chrome_testcase.cpp    |  4 ++-
 .../asan/TestCases/vla_condition_overflow.cpp |  4 ++-
 .../test/asan/TestCases/vla_loop_overfow.cpp  |  1 +
 .../test/asan/TestCases/zero_page_pc.cpp      |  4 +++
 81 files changed, 246 insertions(+), 107 deletions(-)
 delete mode 100644 compiler-rt/test/asan/TestCases/Windows/null_deref.cpp
 create mode 100644 compiler-rt/test/asan/TestCases/defines.h

diff --git a/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp b/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp
index 71291e8a531583..528d60e7666bc4 100644
--- a/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp
@@ -4,6 +4,7 @@
 // RUN: %env_asan_opts=coverage=1 %run ./test.exe
 //
 // RUN: %sancov print *.sancov | FileCheck %s
+// XFAIL: MSVC
 
 #include <stdio.h>
 
diff --git a/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp b/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp
index 74200cca1521b3..2567faea9fc7a6 100644
--- a/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp
@@ -2,12 +2,13 @@
 // RUN: not %run %t       2>&1 | FileCheck %s --check-prefix=READ
 // RUN: not %run %t write 2>&1 | FileCheck %s --check-prefix=WRITE
 
+#include "../defines.h"
 #include <windows.h>
 #include <stdio.h>
 
 static volatile int sink;
-__attribute__((noinline)) void Read(int *ptr) { sink = *ptr; }
-__attribute__((noinline)) void Write(int *ptr) { *ptr = 0; }
+ATTRIBUTE_NOINLINE void Read(int *ptr) { sink = *ptr; }
+ATTRIBUTE_NOINLINE void Write(int *ptr) { *ptr = 0; }
 int main(int argc, char **argv) {
   // Writes to shadow are detected as reads from shadow gap (because of how the
   // shadow mapping works). This is kinda hard to fix. Test a random address in
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp
index 85b7967e86b510..773482783823ff 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_host.cpp
@@ -1,4 +1,5 @@
 // UNSUPPORTED: target={{.*-windows-gnu}}
+// XFAIL: msvc
 
 // This is a host program for DLL tests.
 //
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp
index 0a96752f9d0bfc..55f8a895e41cd3 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp
@@ -1,9 +1,9 @@
 // RUN: %clang_cl_asan %Od %p/dll_host.cpp %Fe%t
-// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll
+// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} %LD %Od %s %Fe%t.dll
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
 
 // Test that it works correctly even with ICF enabled.
-// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll \
+// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} %LD %Od %s %Fe%t.dll \
 // RUN:   %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections,--icf=all %} \
 // RUN:   %else %{ -link /OPT:REF /OPT:ICF %}
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
@@ -25,7 +25,7 @@ int test_function() {
   memcpy(buff2, buff1, 6);
 // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
 // CHECK: WRITE of size 6 at [[ADDR]] thread T0
-// CHECK-NEXT:  __asan_{{.*}}memcpy
+// CHECK-NEXT:  __asan_{{.*}}{{(memcpy|memmove)}}
 // CHECK-NEXT:  test_function {{.*}}dll_intercept_memcpy.cpp:[[@LINE-4]]
 // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
 // CHECK-NEXT:  test_function {{.*}}dll_intercept_memcpy.cpp
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
index 27b343f439cb55..9f57cf03929a34 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
@@ -1,9 +1,9 @@
-// RUN: %clang_cl_asan %Od %p/dll_host.cpp %Fe%t
-// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll
+// RUN: %clang_cl_asan %Od /Oy- %p/dll_host.cpp %Fe%t
+// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} /Oy- %LD %Od %s %Fe%t.dll
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
 
 // Test that it works correctly even with ICF enabled.
-// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll \
+// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} /Oy- %LD %Od %s %Fe%t.dll \
 // RUN:   %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections,--icf=all %} \
 // RUN:   %else %{ -link /OPT:REF /OPT:ICF %}
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_null_deref.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_null_deref.cpp
index b65926941cd786..d0d9a8ff0f5163 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_null_deref.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_null_deref.cpp
@@ -2,7 +2,9 @@
 // RUN: %clang_cl_asan %LD %Od %s %Fe%t.dll
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
 
-__attribute__((noinline))
+#include "../defines.h"
+
+ATTRIBUTE_NOINLINE
 static void NullDeref(int *ptr) {
   // CHECK: ERROR: AddressSanitizer: access-violation on unknown address
   // CHECK:   {{0x0*000.. .*pc 0x.*}}
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
index ca6b256654a236..df580ff10381bb 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
@@ -2,12 +2,18 @@
 // RUN: %clang_cl_asan %LD %Od %s %Fe%t.dll
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
 
+#include "../defines.h"
+
 struct C {
   int x;
   ~C() {}
 };
 
-int __attribute__((noinline, optnone)) hide(int x) { return x; }
+int ATTRIBUTE_NOINLINE
+#if __clang__ || !defined(_MSC_VER)
+__attribute__((optnone))
+#endif
+hide(int x) { return x; }
 
 extern "C" __declspec(dllexport)
 int test_function() {
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp
index be237044bb340d..1b0204ba0b0d49 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp
@@ -3,6 +3,7 @@
 // RUN: %env_asan_opts=detect_stack_use_after_return=1 not %run %t %t.dll 2>&1 | FileCheck %s
 // RUN: %clang_cl_asan %LD %Od %s %Fe%t.dll -fsanitize-address-use-after-return=always
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
+// UNSUPPORTED: MSVC
 
 #include <malloc.h>
 
diff --git a/compiler-rt/test/asan/TestCases/Windows/global_const_string_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/global_const_string_oob.cpp
index 97886097736443..9615ccfc2aa0eb 100644
--- a/compiler-rt/test/asan/TestCases/Windows/global_const_string_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/global_const_string_oob.cpp
@@ -13,7 +13,7 @@ int main(void) {
   // CHECK: AddressSanitizer: global-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
   // CHECK: READ of size 1 at [[ADDR]] thread T0
   // CHECK-NEXT:   {{#0 .* main .*global_const_string_oob.cpp:}}[[@LINE-5]]
-  // CHECK: [[ADDR]] is located 5 bytes after global variable [[STR:.*]] defined in {{'.*global_const_string_oob.cpp' .*}} of size 11
+  // CHECK: [[ADDR]] is located 5 bytes after global variable [[STR:.*]] defined in {{'.*global_const_string_oob.cpp.*}} of size 11
   // CHECK:   [[STR]] is ascii string 'foobarspam'
   return 0;
 }
diff --git a/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp b/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp
index 9b902c7536ca91..61a2b9042d611c 100644
--- a/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cl_asan %Od %s %Fe%t
 // RUN: %env_asan_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck %s
+// msvc doesn't have a __builtin_trap equivalent
+// XFAIL: MSVC
 
 // Test the error output from an illegal instruction.
 
diff --git a/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp b/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp
index b1b6e42148cb68..5f851decfea100 100644
--- a/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp
@@ -1,9 +1,13 @@
 // Repro for the issue #64990: Asan with Windows EH generates __asan_xxx runtime calls without required funclet tokens
-// RUN: %clang_cl_asan %Od %s -EHsc %Fe%t
+// RUN: %clang_cl_asan %Od %if MSVC %{ /Oi %} %s -EHsc %Fe%t
 // RUN: not %run %t 2>&1 | FileCheck %s
 
 // UNSUPPORTED: target={{.*-windows-gnu}}
 
+#if _MSC_VER && !defined(__clang__)
+#include <string.h>
+#endif
+
 char buff1[6] = "hello";
 char buff2[6] = "hello";
 
@@ -12,7 +16,11 @@ int main(int argc, char **argv) {
     throw 1;
   } catch (...) {
     // Make asan generate call to __asan_memcpy inside the EH pad.
+#if _MSC_VER && !defined(__clang__)
+    memcpy(buff1, buff2 + 3, 6);
+#else
     __builtin_memcpy(buff1, buff2 + 3, 6);
+#endif
   }
   return 0;
 }
diff --git a/compiler-rt/test/asan/TestCases/Windows/msvc/seh.cpp b/compiler-rt/test/asan/TestCases/Windows/msvc/seh.cpp
index 4cb0c55bc77302..f3c7e1a33a568f 100644
--- a/compiler-rt/test/asan/TestCases/Windows/msvc/seh.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/msvc/seh.cpp
@@ -2,15 +2,15 @@
 // different EH personality depending on the -GS setting, so test both -GS+ and
 // -GS-.
 //
-// RUN: cl -c %s -Fo%t.obj -DCOMPILE_SEH
-// RUN: %clangxx_asan -o %t.exe %s %t.obj
+// RUN: cl /EHa %MD -c %s -Fo%t.obj -DCOMPILE_SEH
+// RUN: %clangxx_asan -o %t.exe %s %t.obj -DCOMPILE_MAIN
 // RUN: %run %t.exe
 //
-// RUN: cl -GS- -c %s -Fo%t.obj -DCOMPILE_SEH
-// RUN: %clangxx_asan -o %t.exe %s %t.obj
+// RUN: cl /EHa %MD -GS- -c %s -Fo%t.obj -DCOMPILE_SEH
+// RUN: %clangxx_asan -o %t.exe %s %t.obj -DCOMPILE_MAIN
 // RUN: %run %t.exe
 //
-// RUN: %clang_cl_asan %s -DCOMPILE_SEH -Fe%t.exe
+// RUN: %clang_cl_asan /EHa %MD %s -DCOMPILE_SEH -Fe%t.exe -DCOMPILE_MAIN
 // RUN: %run %t.exe
 
 #include <windows.h>
@@ -42,7 +42,7 @@ void ThrowAndCatch() {
 }
 #endif
 
-#if defined(__clang__)
+#if defined(COMPILE_MAIN)
 int main() {
   char x[32];
   fprintf(stderr, "Before: %p poisoned: %d\n", &x,
diff --git a/compiler-rt/test/asan/TestCases/Windows/null_deref.cpp b/compiler-rt/test/asan/TestCases/Windows/null_deref.cpp
deleted file mode 100644
index 6582bac9e69e30..00000000000000
--- a/compiler-rt/test/asan/TestCases/Windows/null_deref.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
-// FIXME: merge this with the common null_deref test when we can run common
-// tests on Windows.
-
-__attribute__((noinline))
-static void NullDeref(int *ptr) {
-  // CHECK: ERROR: AddressSanitizer: access-violation on unknown address
-  // CHECK:   {{0x0*000.. .*pc 0x.*}}
-  ptr[10]++;  // BOOM
-}
-int main() {
-  NullDeref((int*)0);
-  // CHECK: {{    #1 0x.* in main.*null_deref.cpp:}}[[@LINE-1]]:3
-  // CHECK: AddressSanitizer can not provide additional info.
-}
diff --git a/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp b/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp
index ea5140a13dc883..8de681ce03e7e8 100644
--- a/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp
@@ -9,6 +9,7 @@
 // RUN: %clang_cl_asan %Od -DEXE %s %t1.lib %t2.lib %Fe%t
 // RUN: not %run %t 2>&1 | FileCheck %s
 
+#include "../defines.h"
 #include <malloc.h>
 #include <string.h>
 
@@ -27,8 +28,8 @@ extern "C" {
 __declspec(dllexport) void foo1() {}
 }
 #elif defined(DLL2)
-extern "C" {
-__attribute__((noinline)) static void NullDeref(int *ptr) {
+ATTRIBUTE_NOINLINE
+static void NullDeref(int *ptr) {
   // CHECK: ERROR: AddressSanitizer: access-violation on unknown address
   // CHECK:   {{0x0*000.. .*pc 0x.*}}
   ptr[10]++; // BOOM
diff --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
index cad28ae8ace213..6cf7d1159c27bd 100644
--- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
@@ -1,12 +1,18 @@
 // RUN: %clang_cl_asan %Od %s %Fe%t
 // RUN: not %run %t 2>&1 | FileCheck %s
 
+#include "../defines.h"
+
 struct C {
   int x;
   ~C() {}
 };
-
-int __attribute__((noinline, optnone)) hide(int x) { return x; }
+#if defined(_MSC_VER) && !defined(__clang__)
+#pragma optimize("", off)
+#else
+__attribute__((optnone))
+#endif
+int ATTRIBUTE_NOINLINE hide(int x) { return x; }
 
 int main() {
   C *buffer = new C[42];
diff --git a/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp b/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp
index 1424ee88129f6b..426e4bb363b2f7 100644
--- a/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp
@@ -3,6 +3,7 @@
 
 // FIXME: On MinGW frame #0 does not include the line number?
 // XFAIL: target={{.*-windows-gnu}}
+// XFAIL: MSVC
 
 // Test the error output from misaligned SSE2 memory access. This is a READ
 // memory access. Windows appears to always provide an address of -1 for these
diff --git a/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp b/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp
index 9385e36a37b678..d6a6b70a208ac6 100644
--- a/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp
@@ -3,7 +3,7 @@
 
 // RUN: %clang_cl_asan %Od %s %Fe%t -fsanitize-address-use-after-return=always
 // RUN: not %run %t 2>&1 | FileCheck %s
-
+// XFAIL: MSVC
 char *x;
 
 void foo() {
diff --git a/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp b/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp
index 00428b809fccd7..ba8cd16ee8ca9b 100644
--- a/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp
@@ -8,9 +8,10 @@
 // RUN: not %run %t.exe 2>&1 | FileCheck %s
 // REQUIRES: lld-available
 
+#include "../defines.h"
 #include <stdlib.h>
 #include <stdio.h>
-int __attribute__((noinline)) do_uaf(void);
+int ATTRIBUTE_NOINLINE do_uaf(void);
 int main() {
   int r = do_uaf();
   printf("r: %d\n", r);
diff --git a/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp b/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
index a451e873f2e42d..9ede7055ec50bc 100644
--- a/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
@@ -1,12 +1,14 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
+// XFAIL: MSVC
 
+#include "defines.h"
 #include <assert.h>
 #include <stdint.h>
 
-__attribute__((noinline)) void foo(int index, int len) {
-  volatile char str[len] __attribute__((aligned(128)));
+ATTRIBUTE_NOINLINE void foo(int index, int len) {
+  volatile char str[len] ATTRIBUTE_ALIGNED(128);
   assert(!(reinterpret_cast<uintptr_t>(str) & 127L));
   str[index] = '1'; // BOOM
 // CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
diff --git a/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp b/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp
index 8910ea9f8d8e23..52e17d4ad11ca1 100644
--- a/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp
@@ -7,6 +7,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#if _MSC_VER
+#include <malloc.h>
+#endif
 
 // MSVC provides _alloca instead of alloca.
 #if defined(_MSC_VER) && !defined(alloca)
diff --git a/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp b/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp
index 8b207aa07f2eb4..d6d983dccc2c27 100644
--- a/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp
@@ -2,16 +2,24 @@
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
 
+#include "defines.h"
 #include <assert.h>
 #include <stdint.h>
+#if defined(_MSC_VER) && !defined(__clang__)
+#include <malloc.h>
+#endif
 
 struct A {
   char a[3];
   int b[3];
 };
 
-__attribute__((noinline)) void foo(int index, int len) {
-  volatile struct A str[len] __attribute__((aligned(32)));
+ATTRIBUTE_NOINLINE void foo(int index, int len) {
+#if !defined(_MSC_VER) || defined(__clang__)
+  volatile struct A str[len] ATTRIBUTE_ALIGNED(32);
+#else
+  volatile struct A *str = (volatile struct A*)_alloca(len * sizeof(struct A));
+#endif
   assert(!(reinterpret_cast<uintptr_t>(str) & 31L));
   str[index].a[0] = '1'; // BOOM
 // CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
diff --git a/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp b/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
index 912c8b0abaabd0..f4e03e25dfd2a3 100644
--- a/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
@@ -2,6 +2,7 @@
 // RUN: %clangxx_asan -O3 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: %run %t 2>&1
 //
+// UNSUPPORTED: MSVC
 
 #include "sanitizer/asan_interface.h"
 #include <assert.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp b/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
index 0967b34dc7dbfe..82683934770f9a 100644
--- a/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
@@ -4,7 +4,9 @@
 // REQUIRES: stable-runtime
 
 // This testcase checks that allocas and VLAs inside loop are correctly unpoisoned.
+// UNSUPPORTED: MSVC
 
+#include "defines.h"
 #include <assert.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -21,7 +23,7 @@
 
 void *top, *bot;
 
-__attribute__((noinline)) void foo(int len) {
+ATTRIBUTE_NOINLINE void foo(int len) {
   char x;
   top = &x;
   volatile char array[len];
diff --git a/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp b/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
index 25c6d75be7a538..48d7e93111ec94 100644
--- a/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
+// UNSUPPORTED: MSVC
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp b/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
index 7ec4b86cdc715e..a46c7ee1901a70 100644
--- a/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
+// UNSUPPORTED: MSVC
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp b/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
index 98e31769812bf9..8bd941bb94674b 100644
--- a/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: %run %t 2>&1
 //
+// UNSUPPORTED: MSVC
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp b/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
index 52cd781c4bb880..d540be76c0d27b 100644
--- a/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
+// UNSUPPORTED: MSVC
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp b/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp
index 96ac4c7db291a0..30b1ec21819022 100644
--- a/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp
@@ -4,6 +4,7 @@
 // REQUIRES: stable-runtime
 
 // This testcase checks correct interaction between VLAs and allocas.
+// UNSUPPORTED: MSVC
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/contiguous_container.cpp b/compiler-rt/test/asan/TestCases/contiguous_container.cpp
index 6288e752fd4ba8..a2adb1951dde61 100644
--- a/compiler-rt/test/asan/TestCases/contiguous_container.cpp
+++ b/compiler-rt/test/asan/TestCases/contiguous_container.cpp
@@ -2,6 +2,7 @@
 //
 // Test __sanitizer_annotate_contiguous_container.
 
+#include "defines.h"
 #include <algorithm>
 #include <numeric>
 #include <vector>
@@ -247,9 +248,9 @@ void TestDoubleEndedContainer(size_t capacity, size_t off_begin,
   delete[] buffer;
 }
 
-__attribute__((noinline)) void Throw() { throw 1; }
+ATTRIBUTE_NOINLINE void Throw() { throw 1; }
 
-__attribute__((noinline)) void ThrowAndCatch() {
+ATTRIBUTE_NOINLINE void ThrowAndCatch() {
   try {
     Throw();
   } catch (...) {
diff --git a/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp b/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp
index c03a6f02f77196..906bc0c699e2ec 100644
--- a/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp
+++ b/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp
@@ -2,6 +2,8 @@
 // RUN: %clangxx_asan -O0 -DTRACE_RT %s -o %t-rt.o -c
 // RUN: %clangxx_asan -O0 -fsanitize-coverage=edge,trace-pc,indirect-calls %s -o %t %t-rt.o
 // RUN: %run %t
+// XFAIL: MSVC
+
 #ifdef TRACE_RT
 int pc_count;
 void *last_callee;
@@ -12,13 +14,14 @@ extern "C" void __sanitizer_cov_trace_pc_indir(void *callee) {
   last_callee = callee;
 }
 #else
+#include "defines.h"
 #include <stdio.h>
 #include <assert.h>
 extern int pc_count;
 extern void *last_callee;
 
-__attribute__((noinline)) void foo() { printf("foo\n"); }
-__attribute__((noinline)) void bar() { printf("bar\n"); }
+ATTRIBUTE_NOINLINE void foo() { printf("foo\n"); }
+ATTRIBUTE_NOINLINE void bar() { printf("bar\n"); }
 
 int main(int argc, char **argv) {
   void (*f)(void) = argc ? foo : bar;
diff --git a/compiler-rt/test/asan/TestCases/debug_locate.cpp b/compiler-rt/test/asan/TestCases/debug_locate.cpp
index 93d1af8b83916f..8b398915323d2f 100644
--- a/compiler-rt/test/asan/TestCases/debug_locate.cpp
+++ b/compiler-rt/test/asan/TestCases/debug_locate.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: MSVC
 // Checks the ASan memory address type debugging API, makes sure it returns
 // the correct memory type for heap, stack, global and shadow addresses and
 // that it correctly finds out which region (and name and size) the address
diff --git a/compiler-rt/test/asan/TestCases/debug_stacks.cpp b/compiler-rt/test/asan/TestCases/debug_stacks.cpp
index 67a9ac849c3aa7..391e241023462d 100644
--- a/compiler-rt/test/asan/TestCases/debug_stacks.cpp
+++ b/compiler-rt/test/asan/TestCases/debug_stacks.cpp
@@ -1,6 +1,6 @@
 // Check that the stack trace debugging API works and returns correct
 // malloc and free stacks.
-// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O0 %if MSVC %{ /wd4477 %} %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 // FIXME: Figure out why allocation/free stack traces may be too short on ARM.
 // REQUIRES: stable-runtime
diff --git a/compiler-rt/test/asan/TestCases/deep_tail_call.cpp b/compiler-rt/test/asan/TestCases/deep_tail_call.cpp
index 628ef06db14474..efe8e9ad0ba863 100644
--- a/compiler-rt/test/asan/TestCases/deep_tail_call.cpp
+++ b/compiler-rt/test/asan/TestCases/deep_tail_call.cpp
@@ -4,15 +4,16 @@
 // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 // CHECK: AddressSanitizer: global-buffer-overflow
+#include "defines.h"
 int global[10];
 // CHECK: {{#0.*call4}}
-void __attribute__((noinline)) call4(int i) { global[i+10]++; }
+void ATTRIBUTE_NOINLINE call4(int i) { global[i+10]++; }
 // CHECK: {{#1.*call3}}
-void __attribute__((noinline)) call3(int i) { call4(i); }
+void ATTRIBUTE_NOINLINE call3(int i) { call4(i); }
 // CHECK: {{#2.*call2}}
-void __attribute__((noinline)) call2(int i) { call3(i); }
+void ATTRIBUTE_NOINLINE call2(int i) { call3(i); }
 // CHECK: {{#3.*call1}}
-void __attribute__((noinline)) call1(int i) { call2(i); }
+void ATTRIBUTE_NOINLINE call1(int i) { call2(i); }
 // CHECK: {{#4.*main}}
 int main(int argc, char **argv) {
   call1(argc);
diff --git a/compiler-rt/test/asan/TestCases/default_ignorelist.cpp b/compiler-rt/test/asan/TestCases/default_ignorelist.cpp
index 8297b51e7680e9..7f8a0a0c280233 100644
--- a/compiler-rt/test/asan/TestCases/default_ignorelist.cpp
+++ b/compiler-rt/test/asan/TestCases/default_ignorelist.cpp
@@ -1,5 +1,5 @@
 // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
-// XFAIL: android
+// XFAIL: android, MSVC
 // UNSUPPORTED: ios
 //
 // Test that ASan uses the default ignorelist from resource directory.
diff --git a/compiler-rt/test/asan/TestCases/default_options.cpp b/compiler-rt/test/asan/TestCases/default_options.cpp
index 845e8a5f1793e4..3bbaba904aa72f 100644
--- a/compiler-rt/test/asan/TestCases/default_options.cpp
+++ b/compiler-rt/test/asan/TestCases/default_options.cpp
@@ -1,12 +1,14 @@
 // RUN: %clangxx_asan -O2 %s -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
 
+#include "defines.h"
+
 const char *kAsanDefaultOptions = "verbosity=1 help=1";
 // Required for dyld macOS 12.0+
 #if (__APPLE__)
 __attribute__((weak))
 #endif
-__attribute__((no_sanitize_address))
+ATTRIBUTE_NO_SANITIZE_ADDRESS
 extern "C" const char *
 __asan_default_options() {
   // CHECK: Available flags for AddressSanitizer:
diff --git a/compiler-rt/test/asan/TestCases/defines.h b/compiler-rt/test/asan/TestCases/defines.h
new file mode 100644
index 00000000000000..a3635891728b61
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/defines.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#if defined(_MSC_VER) && !defined(__clang__)
+#include <intrin.h>
+
+#define ATTRIBUTE_NOINLINE __declspec(noinline)
+#define ATTRIBUTE_ALIGNED(x) __declspec(align(x))
+#define ATTRIBUTE_NO_SANITIZE_ADDRESS __declspec(no_sanitize_address)
+#define ATTRIBUTE_USED /* FIXME: Is there a __declspec used? */
+#define ATTRIBUTE_ALWAYS_INLINE __forceinline
+#define VOLATILE volatile
+#define EXTRACT_RETURN_ADDRESS _ReturnAddress()
+#define ASM_CAUSE_SIDE_EFFECT(dest) __asm { mov eax, dest}
+#define MULTIPLE_ATTRIBUTE_DECL(a, b) __declspec(a b)
+
+#else
+
+#define ATTRIBUTE_NOINLINE __attribute__((noinline))
+#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned(x)))
+#define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
+#define ATTRIBUTE_USED __attribute__((used))
+#define ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
+#define INLINE_ASM(x) __asm__(x)
+#define VOLATILE __volatile__
+#define EXTRACT_RETURN_ADDRESS __builtin_extract_return_addr(__builtin_return_address(0))
+#define ASM_CAUSE_SIDE_EFFECT(dest) __asm__ __volatile__(""          \
+                                                         :           \
+                                                         : "r"(dest) \
+                                                         : "memory");
+#define MULTIPLE_ATTRIBUTE_DECL(a, b) __attribute__((a, b))
+
+#endif // _MSC_VER
diff --git a/compiler-rt/test/asan/TestCases/error_report_callback.cpp b/compiler-rt/test/asan/TestCases/error_report_callback.cpp
index 8c5bbe418fc521..7a326f552ec3c9 100644
--- a/compiler-rt/test/asan/TestCases/error_report_callback.cpp
+++ b/compiler-rt/test/asan/TestCases/error_report_callback.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 %s -o %t
 // RUN: not %run %t 0 2>&1 | FileCheck %s
 
+#include "defines.h"
 #include <sanitizer/asan_interface.h>
 #include <stdio.h>
 
@@ -12,7 +13,7 @@ static void ErrorReportCallbackOneToZ(const char *report) {
 int main(int argc, char **argv) {
   __asan_set_error_report_callback(ErrorReportCallbackOneToZ);
   __asan_report_error(
-      (void *)__builtin_extract_return_addr(__builtin_return_address(0)), 0, 0,
+      (void *)EXTRACT_RETURN_ADDRESS, 0, 0,
       0, true, 1);
   // CHECK: ABCDEF
   // CHECK: ERROR: AddressSanitizer
diff --git a/compiler-rt/test/asan/TestCases/exitcode.cpp b/compiler-rt/test/asan/TestCases/exitcode.cpp
index e949436e1909ce..21743bfbd7b8d7 100644
--- a/compiler-rt/test/asan/TestCases/exitcode.cpp
+++ b/compiler-rt/test/asan/TestCases/exitcode.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx_asan -g -Wno-deprecated-declarations %s -o %t
+// RUN: %clangxx_asan -g %if !MSVC %{ -Wno-deprecated-declarations %} %s -o %t
 // RUN: %env_asan_opts=exitcode=42 %run %t | FileCheck %s
 
 // Android doesn't have spawn.h or posix_spawn.
diff --git a/compiler-rt/test/asan/TestCases/force_inline_opt0.cpp b/compiler-rt/test/asan/TestCases/force_inline_opt0.cpp
index e6e5d26c7998ec..0c721bcc5c8093 100644
--- a/compiler-rt/test/asan/TestCases/force_inline_opt0.cpp
+++ b/compiler-rt/test/asan/TestCases/force_inline_opt0.cpp
@@ -1,8 +1,11 @@
 // This test checks that we are no instrumenting a memory access twice
 // (before and after inlining)
-// RUN: %clangxx_asan -O1 %s -o %t && %run %t
-// RUN: %clangxx_asan -O0 %s -o %t && %run %t
-__attribute__((always_inline))
+// RUN: %clangxx_asan -O1 %if MSVC %{ /Ob1 %} %s -o %t && %run %t
+// RUN: %clangxx_asan -O0 %if MSVC %{ /Ob1 %} %s -o %t && %run %t
+
+#include "defines.h"
+
+ATTRIBUTE_ALWAYS_INLINE
 void foo(int *x) {
   *x = 0;
 }
diff --git a/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp b/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp
index 07c8e63f439da4..ac13c496fdafca 100644
--- a/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp
+++ b/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp
@@ -11,7 +11,7 @@
 /// Solaris ld -S has different semantics, so enforce -fuse-ld= for
 /// configurations that default to GNU ld.
 // XFAIL: target={{.*solaris.*}}
-
+// XFAIL: MSVC
 // CHECK: AddressSanitizer: global-buffer-overflow
 // CLASS_STATIC-NO-G: 0x{{.*}} is located 4 bytes after global variable '{{.*}}C::array{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
 // GLOB-NO-G: 0x{{.*}} is located 4 bytes after global variable '{{.*}}global{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
diff --git a/compiler-rt/test/asan/TestCases/global-underflow.cpp b/compiler-rt/test/asan/TestCases/global-underflow.cpp
index 32b4ce82f9b04d..d0d30506be0604 100644
--- a/compiler-rt/test/asan/TestCases/global-underflow.cpp
+++ b/compiler-rt/test/asan/TestCases/global-underflow.cpp
@@ -1,3 +1,4 @@
+// XFAIL: MSVC
 // RUN: %clangxx_asan -O0 %s %p/Helpers/underflow.cpp -o %t && not %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O1 %s %p/Helpers/underflow.cpp -o %t && not %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O2 %s %p/Helpers/underflow.cpp -o %t && not %run %t 2>&1 | FileCheck %s
diff --git a/compiler-rt/test/asan/TestCases/halt_on_error-1.c b/compiler-rt/test/asan/TestCases/halt_on_error-1.c
index 63c65e58bb71b3..16f6ea105e0d47 100644
--- a/compiler-rt/test/asan/TestCases/halt_on_error-1.c
+++ b/compiler-rt/test/asan/TestCases/halt_on_error-1.c
@@ -5,7 +5,7 @@
 // RUN: env not %run %t 2>&1 | FileCheck %s
 // RUN: %env_asan_opts=halt_on_error=true not %run %t 2>&1 | FileCheck %s
 // RUN: %env_asan_opts=halt_on_error=false %run %t 2>&1 | FileCheck %s --check-prefix CHECK-RECOVER
-
+// XFAIL: MSVC
 #include <string.h>
 
 volatile int ten = 10;
diff --git a/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp b/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp
index 661867260d2603..59f39dfeae6b8b 100644
--- a/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp
+++ b/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp
@@ -15,6 +15,7 @@
 
 // UNSUPPORTED: ios
 
+#include "defines.h"
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -22,13 +23,13 @@
 #  include <windows.h>
 #endif
 
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 char *pretend_to_do_something(char *x) {
   __asm__ __volatile__("" : : "r" (x) : "memory");
   return x;
 }
 
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 char *LeakStack() {
   char x[1024];
   memset(x, 0, sizeof(x));
@@ -36,7 +37,7 @@ char *LeakStack() {
 }
 
 template<size_t kFrameSize>
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 void RecursiveFunctionWithStackFrame(int depth) {
   if (depth <= 0) return;
   char x[kFrameSize];
diff --git a/compiler-rt/test/asan/TestCases/ignorelist.cpp b/compiler-rt/test/asan/TestCases/ignorelist.cpp
index 348ea5d350bf16..75af63de46f2e5 100644
--- a/compiler-rt/test/asan/TestCases/ignorelist.cpp
+++ b/compiler-rt/test/asan/TestCases/ignorelist.cpp
@@ -15,7 +15,10 @@
 // badGlobal is accessed improperly, but we ignorelisted it. Align
 // it to make sure memory past the end of badGlobal will be in
 // the same page.
-__attribute__((aligned(16))) int badGlobal;
+
+// XFAIL: MSVC
+#include "defines.h"
+ATTRIBUTE_ALIGNED(16) int badGlobal;
 int readBadGlobal() {
   return (&badGlobal)[1];
 }
diff --git a/compiler-rt/test/asan/TestCases/ill.cpp b/compiler-rt/test/asan/TestCases/ill.cpp
index d7b5350916719a..34d6e21322ec00 100644
--- a/compiler-rt/test/asan/TestCases/ill.cpp
+++ b/compiler-rt/test/asan/TestCases/ill.cpp
@@ -2,12 +2,16 @@
 //
 // RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=0 not --crash %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0
 // RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1
-// REQUIRES: x86-target-arch
+// REQUIRES: x86-target-arch && (!MSVC || asan-32-bits)
 
 #ifdef _WIN32
 #include <windows.h>
 #endif
 
+#if _MSC_VER && !defined(__clang__)
+#define __builtin_trap() __asm ud2;
+#endif
+
 int main(int argc, char **argv) {
 #ifdef _WIN32
   // Sometimes on Windows this test generates a WER fault dialog. Suppress that.
diff --git a/compiler-rt/test/asan/TestCases/initialization-bug.cpp b/compiler-rt/test/asan/TestCases/initialization-bug.cpp
index 2775f6ce356dd4..1af6e256f0c24c 100644
--- a/compiler-rt/test/asan/TestCases/initialization-bug.cpp
+++ b/compiler-rt/test/asan/TestCases/initialization-bug.cpp
@@ -8,6 +8,7 @@
 // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=186
 // XFAIL: target={{.*windows-msvc.*}}
 
+#include "defines.h"
 #include <cstdio>
 
 // The structure of the test is:
@@ -27,7 +28,7 @@ int z = initZ();
 // result is undefined behavior, which should be caught by initialization order
 // checking.
 extern int y;
-int __attribute__((noinline)) initX() {
+int ATTRIBUTE_NOINLINE initX() {
   return y + 1;
   // CHECK: {{AddressSanitizer: initialization-order-fiasco}}
   // CHECK: {{READ of size .* at 0x.* thread T0}}
diff --git a/compiler-rt/test/asan/TestCases/inline.cpp b/compiler-rt/test/asan/TestCases/inline.cpp
index 12bd27e675844c..cd3202df58d773 100644
--- a/compiler-rt/test/asan/TestCases/inline.cpp
+++ b/compiler-rt/test/asan/TestCases/inline.cpp
@@ -2,10 +2,14 @@
 
 // Test that no_sanitize_address attribute applies even when the function would
 // be normally inlined.
+//
+// XFAIL: MSVC
+// ^ MSVC has this bug
 
+#include "defines.h"
 #include <stdlib.h>
 
-__attribute__((no_sanitize_address))
+ATTRIBUTE_NO_SANITIZE_ADDRESS
 int f(int *p) {
   return *p; // BOOOM?? Nope!
 }
diff --git a/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp b/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp
index bf51eed41fddf6..24b93c56e730c7 100644
--- a/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp
+++ b/compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp
@@ -15,6 +15,7 @@
 // https://reviews.llvm.org/D111703 made compiler incompatible with released NDK.
 // UNSUPPORTED: android && arm-target-arch
 
+#include "defines.h"
 #include <assert.h>
 #include <exception>
 #include <sanitizer/asan_interface.h>
@@ -28,7 +29,7 @@ namespace {
 // [[noreturn]] because the scenario we're emulating doesn't always throw. If it
 // were [[noreturn]], the calling code would emit a call to
 // __asan_handle_no_return.
-void __attribute__((no_sanitize("address")))
+void ATTRIBUTE_NO_SANITIZE_ADDRESS
 uninstrumented_rethrow_exception(std::exception_ptr const &exc_ptr) {
   std::rethrow_exception(exc_ptr);
 }
diff --git a/compiler-rt/test/asan/TestCases/interception_failure_test.cpp b/compiler-rt/test/asan/TestCases/interception_failure_test.cpp
index 918fa8e82bf74a..270da1e64df821 100644
--- a/compiler-rt/test/asan/TestCases/interception_failure_test.cpp
+++ b/compiler-rt/test/asan/TestCases/interception_failure_test.cpp
@@ -18,6 +18,10 @@
 // it works with the dynamic runtime.
 // XFAIL: target={{.*netbsd.*}} && !asan-dynamic-runtime
 
+#if _MSC_VER && !defined(__clang__)
+#pragma warning(disable : 4273)
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/compiler-rt/test/asan/TestCases/interface_test.cpp b/compiler-rt/test/asan/TestCases/interface_test.cpp
index 9419f07e91eae3..bc347807bcc3aa 100644
--- a/compiler-rt/test/asan/TestCases/interface_test.cpp
+++ b/compiler-rt/test/asan/TestCases/interface_test.cpp
@@ -1,8 +1,8 @@
 // Check that user may include ASan interface header.
 // RUN: %clang_asan %s -o %t && %run %t
 // RUN: %clang_asan -x c %s -o %t && %run %t
-// RUN: %clang %s -pie -o %t && %run %t
-// RUN: %clang -x c %s -pie -o %t && %run %t
+// RUN: %clang %s %pie -o %t && %run %t
+// RUN: %clang -x c %s %pie -o %t && %run %t
 #include <sanitizer/asan_interface.h>
 
 int main() {
diff --git a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp
index 7b1479e2d05bd4..bcfd999fefcfec 100644
--- a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp
+++ b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
 
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s
-
+// XFAIL: MSVC
 #include <assert.h>
 #include <stdlib.h>
 
diff --git a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp
index 535833d05c89a6..4bb389b3a94a98 100644
--- a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp
+++ b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
 
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s
-
+// XFAIL: MSVC
 #include <assert.h>
 #include <stdlib.h>
 
diff --git a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp
index accd9b7704d51b..d50877e213d6d0 100644
--- a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp
+++ b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp
@@ -4,7 +4,7 @@
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=1 not %run %t g 2>&1 | FileCheck %s -check-prefix=CMP -check-prefix=ALL-ERRORS
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=1 not %run %t s 2>&1 | FileCheck %s -check-prefix=SUB -check-prefix=ALL-ERRORS
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=1 not %run %t f 2>&1 | FileCheck %s -check-prefix=FREE -check-prefix=ALL-ERRORS
-
+// XFAIL: MSVC
 #include <assert.h>
 #include <stdlib.h>
 
diff --git a/compiler-rt/test/asan/TestCases/large_func_test.cpp b/compiler-rt/test/asan/TestCases/large_func_test.cpp
index c64fc7d3c7aa74..1c25d345cb5c41 100644
--- a/compiler-rt/test/asan/TestCases/large_func_test.cpp
+++ b/compiler-rt/test/asan/TestCases/large_func_test.cpp
@@ -7,8 +7,9 @@
 // Issue #108194: Incomplete .debug_line at -O1 and above.
 // XFAIL: target={{.*sparc.*}}
 
+#include "defines.h"
 #include <stdlib.h>
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 static void LargeFunction(int *x, int zero) {
   x[0]++;
   x[1]++;
@@ -29,7 +30,7 @@ static void LargeFunction(int *x, int zero) {
   // Darwin.
   // CHECK-Linux:  {{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-3]]
   // CHECK-SunOS:  {{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-4]]
-  // CHECK-Windows:{{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-5]]
+  // CHECK-Windows:{{#[0-1] 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-5]]
   // CHECK-FreeBSD:{{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-6]]
   // CHECK-Darwin: {{#0 0x.* in .*LargeFunction.*large_func_test.cpp}}:[[@LINE-7]]
 
@@ -48,7 +49,7 @@ static void LargeFunction(int *x, int zero) {
 int main(int argc, char **argv) {
   int *x = new int[100];
   LargeFunction(x, argc - 1);
-  // CHECK: {{    #1 0x.* in main .*large_func_test.cpp:}}[[@LINE-1]]
+  // CHECK: {{    #[1-2] 0x.* in main .*large_func_test.cpp:}}[[@LINE-1]]
   // CHECK: {{0x.* is located 12 bytes after 400-byte region}}
   // CHECK: {{allocated by thread T0 here:}}
   // CHECK-Linux:  {{    #0 0x.* in operator new}}
diff --git a/compiler-rt/test/asan/TestCases/null_deref.cpp b/compiler-rt/test/asan/TestCases/null_deref.cpp
index a8947a43780327..3ccb4753263694 100644
--- a/compiler-rt/test/asan/TestCases/null_deref.cpp
+++ b/compiler-rt/test/asan/TestCases/null_deref.cpp
@@ -3,7 +3,9 @@
 // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
 
-__attribute__((noinline))
+#include "defines.h"
+
+ATTRIBUTE_NOINLINE
 // FIXME: Static symbols don't show up in PDBs. We can remove this once we start
 // using DWARF.
 #ifndef _MSC_VER
diff --git a/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp b/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp
index ba49eccf41cab5..abfed0219095a4 100644
--- a/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp
+++ b/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp
@@ -1,6 +1,6 @@
 // RUN: %clangxx_asan -O0 %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
-
+// XFAIL: MSVC
 struct A {
   int a[8];
 };
diff --git a/compiler-rt/test/asan/TestCases/report_error_summary.cpp b/compiler-rt/test/asan/TestCases/report_error_summary.cpp
index 9e024e35bed864..e10def7218634c 100644
--- a/compiler-rt/test/asan/TestCases/report_error_summary.cpp
+++ b/compiler-rt/test/asan/TestCases/report_error_summary.cpp
@@ -2,8 +2,10 @@
 
 #include <stdio.h>
 
+#if !defined(_MSC_VER) || defined(__clang__)
 // Required for ld64 macOS 12.0+
 __attribute__((weak)) extern "C" void foo() {}
+#endif
 
 extern "C" void __sanitizer_report_error_summary(const char *summary) {
   fprintf(stderr, "test_report_error_summary\n");
diff --git a/compiler-rt/test/asan/TestCases/speculative_load.cpp b/compiler-rt/test/asan/TestCases/speculative_load.cpp
index fdf70eb39767aa..edc8d4eb14da2e 100644
--- a/compiler-rt/test/asan/TestCases/speculative_load.cpp
+++ b/compiler-rt/test/asan/TestCases/speculative_load.cpp
@@ -3,6 +3,7 @@
 // RUN: %clangxx_asan -O1 %s -o %t && %run %t 2>&1
 // RUN: %clangxx_asan -O2 %s -o %t && %run %t 2>&1
 // RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1
+// UNSUPPORTED: MSVC
 
 #include <sanitizer/asan_interface.h>
 
diff --git a/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp b/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp
index 0077663d6a1766..49c31d651709a3 100644
--- a/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp
+++ b/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp
@@ -13,6 +13,7 @@
 // RUN: not %run %t 63 2>&1 | FileCheck --check-prefix=CHECK-63 %s
 // RUN: not %run %t 73 2>&1 | FileCheck --check-prefix=CHECK-73 %s
 // RUN: not %run %t 74 2>&1 | FileCheck --check-prefix=CHECK-74 %s
+// XFAIL: MSVC
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp b/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp
index 3b5d511b26818a..e45720c4f0a34a 100644
--- a/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp
+++ b/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp
@@ -3,6 +3,7 @@
 // RUN: not %run %t 1 2>&1 | FileCheck %s --check-prefix=CHECK1
 // RUN: not %run %t 2 2>&1 | FileCheck %s --check-prefix=CHECK2
 // RUN: not %run %t 3 2>&1 | FileCheck %s --check-prefix=CHECK3
+// UNSUPPORTED: MSVC
 
 #define NOINLINE __attribute__((noinline))
 inline void break_optimization(void *arg) {
diff --git a/compiler-rt/test/asan/TestCases/strcat-overlap.cpp b/compiler-rt/test/asan/TestCases/strcat-overlap.cpp
index 76fd3e1f11d14e..af78bc44405494 100644
--- a/compiler-rt/test/asan/TestCases/strcat-overlap.cpp
+++ b/compiler-rt/test/asan/TestCases/strcat-overlap.cpp
@@ -34,11 +34,12 @@
 // UNSUPPORTED: target={{.*windows-msvc.*}}
 // UNSUPPORTED: android
 
+#include "defines.h"
 #include <string.h>
 
 
 // Don't inline function otherwise stacktrace changes.
-__attribute__((noinline)) void bad_function() {
+ATTRIBUTE_NOINLINE void bad_function() {
   char buffer[] = "hello\0XXX";
   // CHECK: strcat-param-overlap: memory ranges
   // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap
diff --git a/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp b/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp
index efd2e6b7521ef1..89ac7a39b33ca8 100644
--- a/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp
+++ b/compiler-rt/test/asan/TestCases/strcpy-overlap.cpp
@@ -26,13 +26,14 @@
 // RUN: echo "interceptor_name:strcpy" > %t.supp
 // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t
 
-// UNSUPPORTED: android
+// UNSUPPORTED: android, MSVC
 
+#include "defines.h"
 #include <string.h>
 
 
 // Don't inline function otherwise stacktrace changes.
-__attribute__((noinline)) void bad_function() {
+ATTRIBUTE_NOINLINE void bad_function() {
   char buffer[] = "hello";
   // CHECK: strcpy-param-overlap: memory ranges
   // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap
diff --git a/compiler-rt/test/asan/TestCases/strncat-overlap.cpp b/compiler-rt/test/asan/TestCases/strncat-overlap.cpp
index 3e3f7ee2723f54..e4f2fbca68abf6 100644
--- a/compiler-rt/test/asan/TestCases/strncat-overlap.cpp
+++ b/compiler-rt/test/asan/TestCases/strncat-overlap.cpp
@@ -28,11 +28,12 @@
 
 // UNSUPPORTED: android
 
+#include "defines.h"
 #include <string.h>
 
 
 // Don't inline function otherwise stacktrace changes.
-__attribute__((noinline)) void bad_function() {
+ATTRIBUTE_NOINLINE void bad_function() {
   char buffer[] = "hello\0XXX";
   // CHECK: strncat-param-overlap: memory ranges
   // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap
diff --git a/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp b/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp
index ff84052a94987a..50147d1647d998 100644
--- a/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp
+++ b/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp
@@ -6,6 +6,7 @@
 // REQUIRES: compiler-rt-optimized
 // REQUIRES: stable-runtime
 
+#include "defines.h"
 #include <string.h>
 #include <stdlib.h>
 
@@ -13,7 +14,7 @@
 // strncpy below (which otherwises writes to dead storage).  We
 // need the read to be out-of-line to prevent memory forwarding
 // from making the memory dead again.
-int sink_memory(int N, char *p) __attribute__((noinline));
+int ATTRIBUTE_NOINLINE sink_memory(int N, char *p);
 int sink_memory(int N, char *p) {
   int sum = 0;
   for (int i = 0; i < N; i++)
diff --git a/compiler-rt/test/asan/TestCases/strncpy-overlap.cpp b/compiler-rt/test/asan/TestCases/strncpy-overlap.cpp
index 860fc5d304e0e7..9334a333c052a5 100644
--- a/compiler-rt/test/asan/TestCases/strncpy-overlap.cpp
+++ b/compiler-rt/test/asan/TestCases/strncpy-overlap.cpp
@@ -28,11 +28,12 @@
 
 // UNSUPPORTED: android
 
+#include "defines.h"
 #include <string.h>
 
 
 // Don't inline function otherwise stacktrace changes.
-__attribute__((noinline)) void bad_function() {
+ATTRIBUTE_NOINLINE void bad_function() {
   char buffer[] = "hello";
   // CHECK: strncpy-param-overlap: memory ranges
   // CHECK: [{{0x.*,[ ]*0x.*}}) and [{{0x.*,[ ]*0x.*}}) overlap
diff --git a/compiler-rt/test/asan/TestCases/throw_call_test.cpp b/compiler-rt/test/asan/TestCases/throw_call_test.cpp
index 20a7c0b7660155..4481fcff6c3a30 100644
--- a/compiler-rt/test/asan/TestCases/throw_call_test.cpp
+++ b/compiler-rt/test/asan/TestCases/throw_call_test.cpp
@@ -1,7 +1,9 @@
 // RUN: %clangxx_asan %s -o %t && %run %t
 // http://code.google.com/p/address-sanitizer/issues/detail?id=147 (not fixed).
 // BROKEN: %clangxx_asan %s -o %t -static-libstdc++ && %run %t
+// UNSUPPORTED: MSVC
 
+#include "defines.h"
 #include <stdio.h>
 static volatile int zero = 0;
 inline void pretend_to_do_something(void *x) {
@@ -15,7 +17,7 @@ void ReallyThrow() {
     throw 42;
 }
 
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 void Throw() {
   int a, b, c, d, e, f, g, h;
   pretend_to_do_something(&a);
@@ -30,7 +32,7 @@ void Throw() {
   ReallyThrow();
 }
 
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 void CheckStack() {
   int ar[100];
   pretend_to_do_something(ar);
diff --git a/compiler-rt/test/asan/TestCases/throw_catch.cpp b/compiler-rt/test/asan/TestCases/throw_catch.cpp
index 2884e95f8a7e29..294fc61cfa6eb4 100644
--- a/compiler-rt/test/asan/TestCases/throw_catch.cpp
+++ b/compiler-rt/test/asan/TestCases/throw_catch.cpp
@@ -1,17 +1,18 @@
 // RUN: %clangxx_asan -fsanitize-address-use-after-return=never -O %s -o %t && %run %t
 
+#include "defines.h"
 #include <assert.h>
 #include <stdio.h>
 #include <sanitizer/asan_interface.h>
 
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 void Throw() {
   int local;
   fprintf(stderr, "Throw:  %p\n", &local);
   throw 1;
 }
 
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 void ThrowAndCatch() {
   int local;
   try {
@@ -21,7 +22,7 @@ void ThrowAndCatch() {
   }
 }
 
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 void TestThrow() {
   char x[32];
   fprintf(stderr, "Before: %p poisoned: %d\n", &x,
@@ -33,7 +34,7 @@ void TestThrow() {
   assert(!__asan_address_is_poisoned(x + 32));
 }
 
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 void TestThrowInline() {
   char x[32];
   fprintf(stderr, "Before: %p poisoned: %d\n", &x,
diff --git a/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp b/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp
index a9069e1ca8d1a5..f6da3aaa6dd6b1 100644
--- a/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp
+++ b/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp
@@ -2,7 +2,7 @@
 // RUN: %clangxx_asan %s -o %t -static-libstdc++ && %run %t
 
 // Investigate why it fails with NDK 21.
-// UNSUPPORTED: android
+// UNSUPPORTED: android, MSVC
 
 #include <stdio.h>
 static volatile int zero = 0;
@@ -34,7 +34,7 @@ void Throw() {
   ReallyThrow();
 }
 
-__attribute__((noinline))
+ATTRIBUTE_NOINLINE
 void CheckStack() {
   int ar[100];
   pretend_to_do_something(ar);
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp
index 0eca27181e54f8..110d9e52224530 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp
@@ -1,12 +1,13 @@
 // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
 
+#include "defines.h"
 #include <functional>
 
 int main() {
   std::function<int()> f;
   {
     int x = 0;
-    f = [&x]() __attribute__((noinline)) {
+    f = [&x]() ATTRIBUTE_NOINLINE {
       return x;  // BOOM
       // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
       // We cannot assert the line, after the argument promotion pass this crashes
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp
index 42f62c72397ec3..c4a188d2c86ce4 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp
@@ -1,10 +1,11 @@
 // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
 
+#include "defines.h"
 #include <stdio.h>
 
 struct IntHolder {
   explicit IntHolder(int *val = 0) : val_(val) { }
-  __attribute__((noinline)) ~IntHolder() {
+  ATTRIBUTE_NOINLINE ~IntHolder() {
     printf("Value: %d\n", *val_);  // BOOM
     // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
     // CHECK:  #0 0x{{.*}} in IntHolder::~IntHolder{{.*}}.cpp:[[@LINE-2]]
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp
index 1014ff919b9ef8..a540e233567377 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp
@@ -4,9 +4,13 @@
 //
 // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
 
+// MSVC marks this as xfail because it doesn't generate the metadata to display the "x.i" offset.
+// XFAIL: MSVC
+#include "defines.h"
+
 int *arr;
 
-__attribute__((always_inline))
+ATTRIBUTE_ALWAYS_INLINE
 void inlined(int arg) {
   int x[5];
   for (int i = 0; i < arg; i++) x[i] = i;
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp
index 286b6441a5698e..103907b6d2eeb9 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ /O1 %} %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 volatile int *p;
 
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cpp
index 8a8a7b60deb6b4..8fedceb6cf3309 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cpp
@@ -1,4 +1,5 @@
-// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ -O1 %} \
+// RUN:     %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 #include <stdlib.h>
 
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-loop.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-loop.cpp
index 3e199056930cbb..7254a785995b74 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-loop.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-loop.cpp
@@ -1,4 +1,5 @@
-// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ -O1 %} \
+// RUN:     %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 int *p[3];
 
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp
index 29680f37bfa532..ea93c5d1fcb331 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp
@@ -1,12 +1,14 @@
-// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ -O1 %} \
+// RUN:     %s -o %t && not %run %t 2>&1 | FileCheck %s
 
+#include "defines.h"
 struct IntHolder {
   int val;
 };
 
 const IntHolder *saved;
 
-__attribute__((noinline)) void save(const IntHolder &holder) {
+ATTRIBUTE_NOINLINE void save(const IntHolder &holder) {
   saved = &holder;
 }
 
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp
index b98d6f12911a78..ef4b6e5100bc98 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp
@@ -1,7 +1,10 @@
-// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ -O1 %} \
+// RUN:     %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+#include "defines.h"
 
 struct IntHolder {
-  __attribute__((noinline)) const IntHolder &Self() const {
+  ATTRIBUTE_NOINLINE const IntHolder &Self() const {
     return *this;
   }
   int val = 3;
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-types.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-types.cpp
index 5751a0a09bb4ec..3e740edfae250c 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-types.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-types.cpp
@@ -11,6 +11,7 @@
 // RUN: not %run %t 9 2>&1 | FileCheck %s
 // RUN: not %run %t 10 2>&1 | FileCheck %s
 
+#include "defines.h"
 #include <stdlib.h>
 #include <string>
 #include <vector>
@@ -32,7 +33,7 @@ template <class T, size_t N> struct Ptr<T[N]> {
   T *t;
 };
 
-template <class T> __attribute__((noinline)) void test() {
+template <class T> ATTRIBUTE_NOINLINE void test() {
   Ptr<T> ptr;
   {
     T x;
diff --git a/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp b/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
index 613d4bb2763fab..8688a374a4b4e4 100644
--- a/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
+++ b/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
@@ -1,10 +1,12 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
+// UNSUPPORTED: MSVC
 
 // This is reduced testcase based on Chromium code.
 // See http://reviews.llvm.org/D6055?vs=on&id=15616&whitespace=ignore-all#toc.
 
+#include "defines.h"
 #include <stdint.h>
 #include <assert.h>
 
@@ -13,7 +15,7 @@ int b;
 int c;
 int *p;
 
-__attribute__((noinline)) void fn3(int *first, int second) {
+ATTRIBUTE_NOINLINE void fn3(int *first, int second) {
 }
 
 int main() {
diff --git a/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp b/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp
index 00df5d2919c465..5c9bdbefacde8c 100644
--- a/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp
+++ b/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp
@@ -2,11 +2,13 @@
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
 // REQUIRES: stable-runtime
+// UNSUPPORTED: MSVC
 
+#include "defines.h"
 #include <assert.h>
 #include <stdint.h>
 
-__attribute__((noinline)) void foo(int index, int len) {
+ATTRIBUTE_NOINLINE void foo(int index, int len) {
   if (index > len) {
     char str[len];
     assert(!(reinterpret_cast<uintptr_t>(str) & 31L));
diff --git a/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp b/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp
index 370e0dc72c12f4..71e46616a4af87 100644
--- a/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp
+++ b/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp
@@ -2,6 +2,7 @@
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
 // REQUIRES: stable-runtime
+// UNSUPPORTED: MSVC
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/zero_page_pc.cpp b/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
index 9a395ecdf37c82..720a74499c37ef 100644
--- a/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
+++ b/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
@@ -1,6 +1,10 @@
 // Check that ASan correctly detects SEGV on the zero page.
 // RUN: %clangxx_asan %s -o %t && not %run %t 2>&1 | FileCheck %s
 
+#if _MSC_VER && !defined(__CLANG__)
+#define __has_feature(x) 0
+#endif
+
 #if __has_feature(ptrauth_calls)
 #  include <ptrauth.h>
 #endif

>From b7158833b0a481bbae17afe739e011aeb052d35d Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Mon, 30 Sep 2024 10:28:17 -0700
Subject: [PATCH 02/15] Add substitution for /Oy-/-fno-omit-frame-pointer

This makes the dll_intercept_memset test work with mingw
---
 .../test/asan/TestCases/Windows/dll_intercept_memset.cpp      | 4 ++--
 compiler-rt/test/asan/lit.cfg.py                              | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
index 9f57cf03929a34..661832a380ee35 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
@@ -1,9 +1,9 @@
-// RUN: %clang_cl_asan %Od /Oy- %p/dll_host.cpp %Fe%t
+// RUN: %clang_cl_asan %Od %Oy- %p/dll_host.cpp %Fe%t
 // RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} /Oy- %LD %Od %s %Fe%t.dll
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
 
 // Test that it works correctly even with ICF enabled.
-// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} /Oy- %LD %Od %s %Fe%t.dll \
+// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} %Oy- %LD %Od %s %Fe%t.dll \
 // RUN:   %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections,--icf=all %} \
 // RUN:   %else %{ -link /OPT:REF /OPT:ICF %}
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py
index dac3ef00a99af8..ba648f983b5bab 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -183,6 +183,7 @@ def build_invocation(compile_flags, with_lto=False):
         config.substitutions.append(("%MD", "-MD"))
         config.substitutions.append(("%MT", "-MT"))
         config.substitutions.append(("%Gw", "-Gw"))
+        config.substitutions.append(("%Oy-", "-Oy-"))
 
         base_lib = os.path.join(
             config.compiler_rt_libdir, "clang_rt.asan%%s%s.lib" % config.target_suffix
@@ -220,6 +221,7 @@ def build_invocation(compile_flags, with_lto=False):
         config.substitutions.append(("%MD", ""))
         config.substitutions.append(("%MT", ""))
         config.substitutions.append(("%Gw", "-fdata-sections"))
+        config.substitutions.append(("%Oy-", "-fno-omit-frame-pointer"))
 
 # FIXME: De-hardcode this path.
 asan_source_dir = os.path.join(

>From f28ea168d60d91f26290a0be1a9875848d9e9642 Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Mon, 30 Sep 2024 11:56:57 -0700
Subject: [PATCH 03/15] Use #if defined(...) instead of #if ...

---
 .../Windows/dll_operator_array_new_with_dtor_left_oob.cpp     | 2 +-
 compiler-rt/test/asan/TestCases/Windows/issue64990.cpp        | 4 ++--
 compiler-rt/test/asan/TestCases/alloca_constant_size.cpp      | 2 +-
 compiler-rt/test/asan/TestCases/ill.cpp                       | 2 +-
 compiler-rt/test/asan/TestCases/interception_failure_test.cpp | 2 +-
 compiler-rt/test/asan/TestCases/zero_page_pc.cpp              | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
index df580ff10381bb..7b4a971d897d43 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
@@ -10,7 +10,7 @@ struct C {
 };
 
 int ATTRIBUTE_NOINLINE
-#if __clang__ || !defined(_MSC_VER)
+#if defined(__clang__) || !defined(_MSC_VER)
 __attribute__((optnone))
 #endif
 hide(int x) { return x; }
diff --git a/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp b/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp
index 5f851decfea100..47f9ce184db41b 100644
--- a/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp
@@ -4,7 +4,7 @@
 
 // UNSUPPORTED: target={{.*-windows-gnu}}
 
-#if _MSC_VER && !defined(__clang__)
+#if defined(_MSC_VER) && !defined(__clang__)
 #include <string.h>
 #endif
 
@@ -16,7 +16,7 @@ int main(int argc, char **argv) {
     throw 1;
   } catch (...) {
     // Make asan generate call to __asan_memcpy inside the EH pad.
-#if _MSC_VER && !defined(__clang__)
+#if defined(_MSC_VER) && !defined(__clang__)
     memcpy(buff1, buff2 + 3, 6);
 #else
     __builtin_memcpy(buff1, buff2 + 3, 6);
diff --git a/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp b/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp
index 52e17d4ad11ca1..3e63dbe3882f7f 100644
--- a/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp
@@ -7,7 +7,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#if _MSC_VER
+#ifdef _MSC_VER
 #include <malloc.h>
 #endif
 
diff --git a/compiler-rt/test/asan/TestCases/ill.cpp b/compiler-rt/test/asan/TestCases/ill.cpp
index 34d6e21322ec00..ede8a54a259104 100644
--- a/compiler-rt/test/asan/TestCases/ill.cpp
+++ b/compiler-rt/test/asan/TestCases/ill.cpp
@@ -8,7 +8,7 @@
 #include <windows.h>
 #endif
 
-#if _MSC_VER && !defined(__clang__)
+#if defined(_MSC_VER) && !defined(__clang__)
 #define __builtin_trap() __asm ud2;
 #endif
 
diff --git a/compiler-rt/test/asan/TestCases/interception_failure_test.cpp b/compiler-rt/test/asan/TestCases/interception_failure_test.cpp
index 270da1e64df821..a55151a5218f1b 100644
--- a/compiler-rt/test/asan/TestCases/interception_failure_test.cpp
+++ b/compiler-rt/test/asan/TestCases/interception_failure_test.cpp
@@ -18,7 +18,7 @@
 // it works with the dynamic runtime.
 // XFAIL: target={{.*netbsd.*}} && !asan-dynamic-runtime
 
-#if _MSC_VER && !defined(__clang__)
+#if defined(_MSC_VER) && !defined(__clang__)
 #pragma warning(disable : 4273)
 #endif
 
diff --git a/compiler-rt/test/asan/TestCases/zero_page_pc.cpp b/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
index 720a74499c37ef..7b3fec1d9e2147 100644
--- a/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
+++ b/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
@@ -1,7 +1,7 @@
 // Check that ASan correctly detects SEGV on the zero page.
 // RUN: %clangxx_asan %s -o %t && not %run %t 2>&1 | FileCheck %s
 
-#if _MSC_VER && !defined(__CLANG__)
+#if defined(_MSC_VER) && !defined(__CLANG__)
 #define __has_feature(x) 0
 #endif
 

>From 1cca345fb2b04785ba9d4c2f9d515bfa9c8e2a0d Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Tue, 1 Oct 2024 11:05:14 -0700
Subject: [PATCH 04/15] Fix a few mangled test files

These were mangled in the process of pulling them out of the msvc fork

- null_deref_multiple_dlls.cpp -- extern "C" { got removed
- throw_invoke_test.cpp -- #include "defines.h" is needed for
  ATTRIBUTE_NOINLINE, this test is unsupported on msvc so this was not
  caught
---
 .../test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp    | 1 +
 compiler-rt/test/asan/TestCases/throw_invoke_test.cpp           | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp b/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp
index 8de681ce03e7e8..19e3beefa4e0f1 100644
--- a/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/null_deref_multiple_dlls.cpp
@@ -28,6 +28,7 @@ extern "C" {
 __declspec(dllexport) void foo1() {}
 }
 #elif defined(DLL2)
+extern "C" {
 ATTRIBUTE_NOINLINE
 static void NullDeref(int *ptr) {
   // CHECK: ERROR: AddressSanitizer: access-violation on unknown address
diff --git a/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp b/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp
index f6da3aaa6dd6b1..9f5c69c5f1a426 100644
--- a/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp
+++ b/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp
@@ -4,6 +4,8 @@
 // Investigate why it fails with NDK 21.
 // UNSUPPORTED: android, MSVC
 
+
+#include "defines.h"
 #include <stdio.h>
 static volatile int zero = 0;
 inline void pretend_to_do_something(void *x) {

>From 3b53f9a3671ba414dcfe1190970ee4878f797393 Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Tue, 1 Oct 2024 13:13:42 -0700
Subject: [PATCH 05/15] use -O1 instead of /O1 in use-after-scope-loop-bug

This is compatible with the "real" gnu toolchain
---
 compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp
index 103907b6d2eeb9..b97fe6730ddc4c 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ /O1 %} %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan %if MSVC %{ /Od %} %else %{ -O1 %} %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 volatile int *p;
 

>From 35dd4dbd5b23e6b9d73ef441ad9ae8a8a87f610a Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Tue, 1 Oct 2024 13:17:06 -0700
Subject: [PATCH 06/15] add a comment clarifying arch support in ill.cpp

With real MSVC this test only supports i386
---
 compiler-rt/test/asan/TestCases/ill.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/compiler-rt/test/asan/TestCases/ill.cpp b/compiler-rt/test/asan/TestCases/ill.cpp
index ede8a54a259104..771836e29dd362 100644
--- a/compiler-rt/test/asan/TestCases/ill.cpp
+++ b/compiler-rt/test/asan/TestCases/ill.cpp
@@ -8,6 +8,8 @@
 #include <windows.h>
 #endif
 
+// note: test is limited to i386 only ("asan-32-bits") when using "real" MSVC
+//  see the  REQUIRES: clause above
 #if defined(_MSC_VER) && !defined(__clang__)
 #define __builtin_trap() __asm ud2;
 #endif

>From a876f4a689e37d1f0276652e87873661e6b9c6de Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Tue, 1 Oct 2024 13:27:03 -0700
Subject: [PATCH 07/15] operator_array_new_with_dtor_left_oob: turn opt back on

unlike __attribute__((optnone)) MSVC's #pragma optimize("", off)
needs to be turned back on
---
 .../Windows/operator_array_new_with_dtor_left_oob.cpp         | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
index 6cf7d1159c27bd..04a4d9b87bdcac 100644
--- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
@@ -13,7 +13,9 @@ struct C {
 __attribute__((optnone))
 #endif
 int ATTRIBUTE_NOINLINE hide(int x) { return x; }
-
+#if defined(_MSC_VER) && !defined(__clang__)
+#pragma optimize("", on)
+#endif
 int main() {
   C *buffer = new C[42];
   buffer[hide(-(1 + (int)sizeof(void*) / 4))].x = 42;

>From ccc5a8f338e3143082166e49c99b7004e6ac0f60 Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Tue, 1 Oct 2024 15:26:43 -0700
Subject: [PATCH 08/15] clang-format everything

---
 .../TestCases/Windows/crash_read_write.cpp    |  2 +-
 .../Windows/dll_intercept_memcpy.cpp          | 14 +++---
 ..._operator_array_new_with_dtor_left_oob.cpp |  6 ++-
 .../asan/TestCases/Windows/issue64990.cpp     |  2 +-
 .../operator_array_new_with_dtor_left_oob.cpp |  4 +-
 .../asan/TestCases/Windows/unsymbolized.cpp   |  2 +-
 .../asan/TestCases/alloca_constant_size.cpp   |  2 +-
 .../TestCases/alloca_detect_custom_size_.cpp  |  4 +-
 .../TestCases/alloca_loop_unpoisoning.cpp     |  2 +-
 .../test/asan/TestCases/coverage-trace-pc.cpp |  6 +--
 .../test/asan/TestCases/deep_tail_call.cpp    |  2 +-
 .../test/asan/TestCases/default_options.cpp   |  3 +-
 compiler-rt/test/asan/TestCases/defines.h     | 45 +++++++++----------
 .../asan/TestCases/error_report_callback.cpp  |  4 +-
 .../test/asan/TestCases/heavy_uar_test.cpp    |  7 ++-
 compiler-rt/test/asan/TestCases/ill.cpp       |  2 +-
 .../TestCases/interception_failure_test.cpp   |  2 +-
 .../test/asan/TestCases/strncpy-overflow.cpp  |  2 +-
 .../test/asan/TestCases/throw_catch.cpp       |  2 +-
 .../test/asan/TestCases/throw_invoke_test.cpp |  1 -
 .../asan/TestCases/use-after-scope-temp.cpp   |  4 +-
 .../asan/TestCases/use-after-scope-temp2.cpp  |  4 +-
 .../asan/TestCases/vla_chrome_testcase.cpp    |  5 +--
 .../test/asan/TestCases/zero_page_pc.cpp      |  2 +-
 24 files changed, 60 insertions(+), 69 deletions(-)

diff --git a/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp b/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp
index 2567faea9fc7a6..bafc40c2c56654 100644
--- a/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/crash_read_write.cpp
@@ -3,8 +3,8 @@
 // RUN: not %run %t write 2>&1 | FileCheck %s --check-prefix=WRITE
 
 #include "../defines.h"
-#include <windows.h>
 #include <stdio.h>
+#include <windows.h>
 
 static volatile int sink;
 ATTRIBUTE_NOINLINE void Read(int *ptr) { sink = *ptr; }
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp
index 55f8a895e41cd3..4fa437960f1263 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp
@@ -23,12 +23,12 @@ int test_function() {
 // CHECK: Initial test OK
 
   memcpy(buff2, buff1, 6);
-// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 6 at [[ADDR]] thread T0
-// CHECK-NEXT:  __asan_{{.*}}{{(memcpy|memmove)}}
-// CHECK-NEXT:  test_function {{.*}}dll_intercept_memcpy.cpp:[[@LINE-4]]
-// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
-// CHECK-NEXT:  test_function {{.*}}dll_intercept_memcpy.cpp
-// CHECK: 'buff2'{{.*}} <== Memory access at offset {{.*}} overflows this variable
+  // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+  // CHECK: WRITE of size 6 at [[ADDR]] thread T0
+  // CHECK-NEXT:  __asan_{{.*}}{{(memcpy|memmove)}}
+  // CHECK-NEXT:  test_function {{.*}}dll_intercept_memcpy.cpp:[[@LINE-4]]
+  // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
+  // CHECK-NEXT:  test_function {{.*}}dll_intercept_memcpy.cpp
+  // CHECK: 'buff2'{{.*}} <== Memory access at offset {{.*}} overflows this variable
   return 0;
 }
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
index 7b4a971d897d43..1d279f279d7682 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cpp
@@ -11,9 +11,11 @@ struct C {
 
 int ATTRIBUTE_NOINLINE
 #if defined(__clang__) || !defined(_MSC_VER)
-__attribute__((optnone))
+    __attribute__((optnone))
 #endif
-hide(int x) { return x; }
+    hide(int x) {
+  return x;
+}
 
 extern "C" __declspec(dllexport)
 int test_function() {
diff --git a/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp b/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp
index 47f9ce184db41b..5222ec6e081913 100644
--- a/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/issue64990.cpp
@@ -5,7 +5,7 @@
 // UNSUPPORTED: target={{.*-windows-gnu}}
 
 #if defined(_MSC_VER) && !defined(__clang__)
-#include <string.h>
+#  include <string.h>
 #endif
 
 char buff1[6] = "hello";
diff --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
index 04a4d9b87bdcac..c66b201500e36f 100644
--- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
@@ -8,13 +8,13 @@ struct C {
   ~C() {}
 };
 #if defined(_MSC_VER) && !defined(__clang__)
-#pragma optimize("", off)
+#  pragma optimize("", off)
 #else
 __attribute__((optnone))
 #endif
 int ATTRIBUTE_NOINLINE hide(int x) { return x; }
 #if defined(_MSC_VER) && !defined(__clang__)
-#pragma optimize("", on)
+#  pragma optimize("", on)
 #endif
 int main() {
   C *buffer = new C[42];
diff --git a/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp b/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp
index ba8cd16ee8ca9b..ade5e5b914be85 100644
--- a/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp
@@ -9,8 +9,8 @@
 // REQUIRES: lld-available
 
 #include "../defines.h"
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 int ATTRIBUTE_NOINLINE do_uaf(void);
 int main() {
   int r = do_uaf();
diff --git a/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp b/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp
index 3e63dbe3882f7f..91c3ca296ac1e4 100644
--- a/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_constant_size.cpp
@@ -8,7 +8,7 @@
 #include <string.h>
 #include <stdlib.h>
 #ifdef _MSC_VER
-#include <malloc.h>
+#  include <malloc.h>
 #endif
 
 // MSVC provides _alloca instead of alloca.
diff --git a/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp b/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp
index d6d983dccc2c27..e8e73d46f8a73d 100644
--- a/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_detect_custom_size_.cpp
@@ -6,7 +6,7 @@
 #include <assert.h>
 #include <stdint.h>
 #if defined(_MSC_VER) && !defined(__clang__)
-#include <malloc.h>
+#  include <malloc.h>
 #endif
 
 struct A {
@@ -18,7 +18,7 @@ ATTRIBUTE_NOINLINE void foo(int index, int len) {
 #if !defined(_MSC_VER) || defined(__clang__)
   volatile struct A str[len] ATTRIBUTE_ALIGNED(32);
 #else
-  volatile struct A *str = (volatile struct A*)_alloca(len * sizeof(struct A));
+  volatile struct A *str = (volatile struct A *)_alloca(len * sizeof(struct A));
 #endif
   assert(!(reinterpret_cast<uintptr_t>(str) & 31L));
   str[index].a[0] = '1'; // BOOM
diff --git a/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp b/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
index 82683934770f9a..7cccca1f6a67fb 100644
--- a/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
@@ -7,10 +7,10 @@
 // UNSUPPORTED: MSVC
 
 #include "defines.h"
+#include "sanitizer/asan_interface.h"
 #include <assert.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include "sanitizer/asan_interface.h"
 
 // MSVC provides _alloca instead of alloca.
 #if defined(_MSC_VER) && !defined(alloca)
diff --git a/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp b/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp
index 906bc0c699e2ec..effcc202860301 100644
--- a/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp
+++ b/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp
@@ -14,9 +14,9 @@ extern "C" void __sanitizer_cov_trace_pc_indir(void *callee) {
   last_callee = callee;
 }
 #else
-#include "defines.h"
-#include <stdio.h>
-#include <assert.h>
+#  include "defines.h"
+#  include <assert.h>
+#  include <stdio.h>
 extern int pc_count;
 extern void *last_callee;
 
diff --git a/compiler-rt/test/asan/TestCases/deep_tail_call.cpp b/compiler-rt/test/asan/TestCases/deep_tail_call.cpp
index efe8e9ad0ba863..772fa48bab7dc3 100644
--- a/compiler-rt/test/asan/TestCases/deep_tail_call.cpp
+++ b/compiler-rt/test/asan/TestCases/deep_tail_call.cpp
@@ -7,7 +7,7 @@
 #include "defines.h"
 int global[10];
 // CHECK: {{#0.*call4}}
-void ATTRIBUTE_NOINLINE call4(int i) { global[i+10]++; }
+void ATTRIBUTE_NOINLINE call4(int i) { global[i + 10]++; }
 // CHECK: {{#1.*call3}}
 void ATTRIBUTE_NOINLINE call3(int i) { call4(i); }
 // CHECK: {{#2.*call2}}
diff --git a/compiler-rt/test/asan/TestCases/default_options.cpp b/compiler-rt/test/asan/TestCases/default_options.cpp
index 3bbaba904aa72f..33507f3c82ef11 100644
--- a/compiler-rt/test/asan/TestCases/default_options.cpp
+++ b/compiler-rt/test/asan/TestCases/default_options.cpp
@@ -8,8 +8,7 @@ const char *kAsanDefaultOptions = "verbosity=1 help=1";
 #if (__APPLE__)
 __attribute__((weak))
 #endif
-ATTRIBUTE_NO_SANITIZE_ADDRESS
-extern "C" const char *
+ATTRIBUTE_NO_SANITIZE_ADDRESS extern "C" const char *
 __asan_default_options() {
   // CHECK: Available flags for AddressSanitizer:
   return kAsanDefaultOptions;
diff --git a/compiler-rt/test/asan/TestCases/defines.h b/compiler-rt/test/asan/TestCases/defines.h
index a3635891728b61..34707f58c05a9c 100644
--- a/compiler-rt/test/asan/TestCases/defines.h
+++ b/compiler-rt/test/asan/TestCases/defines.h
@@ -1,32 +1,31 @@
 #pragma once
 
 #if defined(_MSC_VER) && !defined(__clang__)
-#include <intrin.h>
+#  include <intrin.h>
 
-#define ATTRIBUTE_NOINLINE __declspec(noinline)
-#define ATTRIBUTE_ALIGNED(x) __declspec(align(x))
-#define ATTRIBUTE_NO_SANITIZE_ADDRESS __declspec(no_sanitize_address)
-#define ATTRIBUTE_USED /* FIXME: Is there a __declspec used? */
-#define ATTRIBUTE_ALWAYS_INLINE __forceinline
-#define VOLATILE volatile
-#define EXTRACT_RETURN_ADDRESS _ReturnAddress()
-#define ASM_CAUSE_SIDE_EFFECT(dest) __asm { mov eax, dest}
-#define MULTIPLE_ATTRIBUTE_DECL(a, b) __declspec(a b)
+#  define ATTRIBUTE_NOINLINE __declspec(noinline)
+#  define ATTRIBUTE_ALIGNED(x) __declspec(align(x))
+#  define ATTRIBUTE_NO_SANITIZE_ADDRESS __declspec(no_sanitize_address)
+#  define ATTRIBUTE_USED /* FIXME: Is there a __declspec used? */
+#  define ATTRIBUTE_ALWAYS_INLINE __forceinline
+#  define VOLATILE volatile
+#  define EXTRACT_RETURN_ADDRESS _ReturnAddress()
+#  define ASM_CAUSE_SIDE_EFFECT(dest) __asm { mov eax, dest}
+#  define MULTIPLE_ATTRIBUTE_DECL(a, b) __declspec(a b)
 
 #else
 
-#define ATTRIBUTE_NOINLINE __attribute__((noinline))
-#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned(x)))
-#define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
-#define ATTRIBUTE_USED __attribute__((used))
-#define ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
-#define INLINE_ASM(x) __asm__(x)
-#define VOLATILE __volatile__
-#define EXTRACT_RETURN_ADDRESS __builtin_extract_return_addr(__builtin_return_address(0))
-#define ASM_CAUSE_SIDE_EFFECT(dest) __asm__ __volatile__(""          \
-                                                         :           \
-                                                         : "r"(dest) \
-                                                         : "memory");
-#define MULTIPLE_ATTRIBUTE_DECL(a, b) __attribute__((a, b))
+#  define ATTRIBUTE_NOINLINE __attribute__((noinline))
+#  define ATTRIBUTE_ALIGNED(x) __attribute__((aligned(x)))
+#  define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
+#  define ATTRIBUTE_USED __attribute__((used))
+#  define ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
+#  define INLINE_ASM(x) __asm__(x)
+#  define VOLATILE __volatile__
+#  define EXTRACT_RETURN_ADDRESS                                               \
+    __builtin_extract_return_addr(__builtin_return_address(0))
+#  define ASM_CAUSE_SIDE_EFFECT(dest)                                          \
+    __asm__ __volatile__("" : : "r"(dest) : "memory");
+#  define MULTIPLE_ATTRIBUTE_DECL(a, b) __attribute__((a, b))
 
 #endif // _MSC_VER
diff --git a/compiler-rt/test/asan/TestCases/error_report_callback.cpp b/compiler-rt/test/asan/TestCases/error_report_callback.cpp
index 7a326f552ec3c9..903947e729fb2f 100644
--- a/compiler-rt/test/asan/TestCases/error_report_callback.cpp
+++ b/compiler-rt/test/asan/TestCases/error_report_callback.cpp
@@ -12,9 +12,7 @@ static void ErrorReportCallbackOneToZ(const char *report) {
 
 int main(int argc, char **argv) {
   __asan_set_error_report_callback(ErrorReportCallbackOneToZ);
-  __asan_report_error(
-      (void *)EXTRACT_RETURN_ADDRESS, 0, 0,
-      0, true, 1);
+  __asan_report_error((void *)EXTRACT_RETURN_ADDRESS, 0, 0, 0, true, 1);
   // CHECK: ABCDEF
   // CHECK: ERROR: AddressSanitizer
   // CHECK: GHIJKL
diff --git a/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp b/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp
index 59f39dfeae6b8b..200d19cdbaf8a0 100644
--- a/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp
+++ b/compiler-rt/test/asan/TestCases/heavy_uar_test.cpp
@@ -17,8 +17,8 @@
 
 #include "defines.h"
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 #ifdef _WIN32
 #  include <windows.h>
 #endif
@@ -36,9 +36,8 @@ char *LeakStack() {
   return pretend_to_do_something(x);
 }
 
-template<size_t kFrameSize>
-ATTRIBUTE_NOINLINE
-void RecursiveFunctionWithStackFrame(int depth) {
+template <size_t kFrameSize>
+ATTRIBUTE_NOINLINE void RecursiveFunctionWithStackFrame(int depth) {
   if (depth <= 0) return;
   char x[kFrameSize];
   x[0] = depth;
diff --git a/compiler-rt/test/asan/TestCases/ill.cpp b/compiler-rt/test/asan/TestCases/ill.cpp
index 771836e29dd362..33ce083caf5d1c 100644
--- a/compiler-rt/test/asan/TestCases/ill.cpp
+++ b/compiler-rt/test/asan/TestCases/ill.cpp
@@ -11,7 +11,7 @@
 // note: test is limited to i386 only ("asan-32-bits") when using "real" MSVC
 //  see the  REQUIRES: clause above
 #if defined(_MSC_VER) && !defined(__clang__)
-#define __builtin_trap() __asm ud2;
+#  define __builtin_trap() __asm ud2;
 #endif
 
 int main(int argc, char **argv) {
diff --git a/compiler-rt/test/asan/TestCases/interception_failure_test.cpp b/compiler-rt/test/asan/TestCases/interception_failure_test.cpp
index a55151a5218f1b..bdaf3eb3178f2c 100644
--- a/compiler-rt/test/asan/TestCases/interception_failure_test.cpp
+++ b/compiler-rt/test/asan/TestCases/interception_failure_test.cpp
@@ -19,7 +19,7 @@
 // XFAIL: target={{.*netbsd.*}} && !asan-dynamic-runtime
 
 #if defined(_MSC_VER) && !defined(__clang__)
-#pragma warning(disable : 4273)
+#  pragma warning(disable : 4273)
 #endif
 
 #include <stdlib.h>
diff --git a/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp b/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp
index 50147d1647d998..f75f8c5eb3ff64 100644
--- a/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp
+++ b/compiler-rt/test/asan/TestCases/strncpy-overflow.cpp
@@ -7,8 +7,8 @@
 // REQUIRES: stable-runtime
 
 #include "defines.h"
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 
 // We need a way to prevent the optimize from eliminating the
 // strncpy below (which otherwises writes to dead storage).  We
diff --git a/compiler-rt/test/asan/TestCases/throw_catch.cpp b/compiler-rt/test/asan/TestCases/throw_catch.cpp
index 294fc61cfa6eb4..71e66e3fc4dd40 100644
--- a/compiler-rt/test/asan/TestCases/throw_catch.cpp
+++ b/compiler-rt/test/asan/TestCases/throw_catch.cpp
@@ -2,8 +2,8 @@
 
 #include "defines.h"
 #include <assert.h>
-#include <stdio.h>
 #include <sanitizer/asan_interface.h>
+#include <stdio.h>
 
 ATTRIBUTE_NOINLINE
 void Throw() {
diff --git a/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp b/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp
index 9f5c69c5f1a426..2faf3efe9e6ec8 100644
--- a/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp
+++ b/compiler-rt/test/asan/TestCases/throw_invoke_test.cpp
@@ -4,7 +4,6 @@
 // Investigate why it fails with NDK 21.
 // UNSUPPORTED: android, MSVC
 
-
 #include "defines.h"
 #include <stdio.h>
 static volatile int zero = 0;
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp
index ea93c5d1fcb331..ab14e14e485d9f 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp
@@ -8,9 +8,7 @@ struct IntHolder {
 
 const IntHolder *saved;
 
-ATTRIBUTE_NOINLINE void save(const IntHolder &holder) {
-  saved = &holder;
-}
+ATTRIBUTE_NOINLINE void save(const IntHolder &holder) { saved = &holder; }
 
 int main(int argc, char *argv[]) {
   save({argc});
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp
index ef4b6e5100bc98..ff65f592ee2082 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp
@@ -4,9 +4,7 @@
 #include "defines.h"
 
 struct IntHolder {
-  ATTRIBUTE_NOINLINE const IntHolder &Self() const {
-    return *this;
-  }
+  ATTRIBUTE_NOINLINE const IntHolder &Self() const { return *this; }
   int val = 3;
 };
 
diff --git a/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp b/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
index 8688a374a4b4e4..9b50a151ef34cd 100644
--- a/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
+++ b/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
@@ -7,16 +7,15 @@
 // See http://reviews.llvm.org/D6055?vs=on&id=15616&whitespace=ignore-all#toc.
 
 #include "defines.h"
-#include <stdint.h>
 #include <assert.h>
+#include <stdint.h>
 
 int a = 7;
 int b;
 int c;
 int *p;
 
-ATTRIBUTE_NOINLINE void fn3(int *first, int second) {
-}
+ATTRIBUTE_NOINLINE void fn3(int *first, int second) {}
 
 int main() {
   int d = b && c;
diff --git a/compiler-rt/test/asan/TestCases/zero_page_pc.cpp b/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
index 7b3fec1d9e2147..4242d4f1ba78c7 100644
--- a/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
+++ b/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
@@ -2,7 +2,7 @@
 // RUN: %clangxx_asan %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 #if defined(_MSC_VER) && !defined(__CLANG__)
-#define __has_feature(x) 0
+#  define __has_feature(x) 0
 #endif
 
 #if __has_feature(ptrauth_calls)

>From 094876901f47a3b1dcc5a13623c4d7fb14e757d5 Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Tue, 8 Oct 2024 13:59:52 -0700
Subject: [PATCH 09/15] fixup! Add substitution for
 /Oy-/-fno-omit-frame-pointer

---
 .../test/asan/TestCases/Windows/dll_intercept_memset.cpp        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
index 661832a380ee35..948a429e8c1a6e 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cl_asan %Od %Oy- %p/dll_host.cpp %Fe%t
-// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} /Oy- %LD %Od %s %Fe%t.dll
+// RUN: %clang_cl_asan %if !MSVC %{ -Wno-fortify-source %} %Oy- %LD %Od %s %Fe%t.dll
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
 
 // Test that it works correctly even with ICF enabled.

>From 237e66e81bf3b83b3accd6e0c1161b4a19a7b7a2 Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Tue, 8 Oct 2024 14:00:47 -0700
Subject: [PATCH 10/15] fixup! add a comment clarifying arch support in ill.cpp

---
 compiler-rt/test/asan/TestCases/ill.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/test/asan/TestCases/ill.cpp b/compiler-rt/test/asan/TestCases/ill.cpp
index 33ce083caf5d1c..da457d6737dbd9 100644
--- a/compiler-rt/test/asan/TestCases/ill.cpp
+++ b/compiler-rt/test/asan/TestCases/ill.cpp
@@ -9,7 +9,7 @@
 #endif
 
 // note: test is limited to i386 only ("asan-32-bits") when using "real" MSVC
-//  see the  REQUIRES: clause above
+//  see the requires clause above
 #if defined(_MSC_VER) && !defined(__clang__)
 #  define __builtin_trap() __asm ud2;
 #endif

>From 487adb1412849fb90a54ae7fee69ce9aa6747fbd Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Mon, 14 Oct 2024 14:49:41 -0700
Subject: [PATCH 11/15] Use an include guard instead of #pragma once

In asan/TestCases/defines.h
---
 compiler-rt/test/asan/TestCases/defines.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/test/asan/TestCases/defines.h b/compiler-rt/test/asan/TestCases/defines.h
index 34707f58c05a9c..db6e374d2a0312 100644
--- a/compiler-rt/test/asan/TestCases/defines.h
+++ b/compiler-rt/test/asan/TestCases/defines.h
@@ -1,4 +1,5 @@
-#pragma once
+#ifndef SANITIZER_TEST_DEFINES_H
+#define SANITIZER_TEST_DEFINES_H
 
 #if defined(_MSC_VER) && !defined(__clang__)
 #  include <intrin.h>
@@ -29,3 +30,5 @@
 #  define MULTIPLE_ATTRIBUTE_DECL(a, b) __attribute__((a, b))
 
 #endif // _MSC_VER
+
+#endif // SANITIZER_TEST_DEFINES

>From 6db5f641de4838a125729f0f4be5f879118ae423 Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Mon, 14 Oct 2024 14:52:06 -0700
Subject: [PATCH 12/15] Move UNSUPPORTED line to below opening comment

---
 compiler-rt/test/asan/TestCases/debug_locate.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/compiler-rt/test/asan/TestCases/debug_locate.cpp b/compiler-rt/test/asan/TestCases/debug_locate.cpp
index 8b398915323d2f..ecb0bdf22706a0 100644
--- a/compiler-rt/test/asan/TestCases/debug_locate.cpp
+++ b/compiler-rt/test/asan/TestCases/debug_locate.cpp
@@ -1,10 +1,9 @@
-// UNSUPPORTED: MSVC
 // Checks the ASan memory address type debugging API, makes sure it returns
 // the correct memory type for heap, stack, global and shadow addresses and
 // that it correctly finds out which region (and name and size) the address
 // belongs to.
 // RUN: %clangxx_asan -O0 %s -o %t && %run %t 2>&1
-
+// UNSUPPORTED: MSVC
 #include <assert.h>
 #include <sanitizer/asan_interface.h>
 #include <stdio.h>

>From 168f6fdd8af2d12d59b19ea2333725e9bc9367be Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Wed, 15 Jan 2025 08:49:44 -0800
Subject: [PATCH 13/15] MSVC -> msvc

---
 compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp      | 2 +-
 .../test/asan/TestCases/Windows/dll_stack_use_after_return.cpp  | 2 +-
 compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp | 2 +-
 compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp    | 2 +-
 .../test/asan/TestCases/Windows/stack_use_after_return.cpp      | 2 +-
 compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp        | 2 +-
 .../test/asan/TestCases/alloca_instruments_all_paddings.cpp     | 2 +-
 compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp     | 2 +-
 compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp     | 2 +-
 compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp       | 2 +-
 compiler-rt/test/asan/TestCases/alloca_safe_access.cpp          | 2 +-
 compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp       | 2 +-
 compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp         | 2 +-
 compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp           | 2 +-
 compiler-rt/test/asan/TestCases/debug_locate.cpp                | 2 +-
 compiler-rt/test/asan/TestCases/default_ignorelist.cpp          | 2 +-
 compiler-rt/test/asan/TestCases/global-location-nodebug.cpp     | 2 +-
 compiler-rt/test/asan/TestCases/global-underflow.cpp            | 2 +-
 compiler-rt/test/asan/TestCases/halt_on_error-1.c               | 2 +-
 compiler-rt/test/asan/TestCases/ignorelist.cpp                  | 2 +-
 compiler-rt/test/asan/TestCases/inline.cpp                      | 2 +-
 .../asan/TestCases/invalid-pointer-pairs-compare-errors.cpp     | 2 +-
 .../asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp    | 2 +-
 compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp       | 2 +-
 compiler-rt/test/asan/TestCases/pass-struct-byval.cpp           | 2 +-
 compiler-rt/test/asan/TestCases/speculative_load.cpp            | 2 +-
 .../test/asan/TestCases/stack-buffer-overflow-with-position.cpp | 2 +-
 compiler-rt/test/asan/TestCases/stack-oob-frames.cpp            | 2 +-
 compiler-rt/test/asan/TestCases/throw_call_test.cpp             | 2 +-
 compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp     | 2 +-
 compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp         | 2 +-
 compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp      | 2 +-
 compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp            | 2 +-
 33 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp b/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp
index 528d60e7666bc4..1b790169882606 100644
--- a/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/coverage-basic.cpp
@@ -4,7 +4,7 @@
 // RUN: %env_asan_opts=coverage=1 %run ./test.exe
 //
 // RUN: %sancov print *.sancov | FileCheck %s
-// XFAIL: MSVC
+// XFAIL: msvc
 
 #include <stdio.h>
 
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp
index 1b0204ba0b0d49..3e2a38374f920f 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp
@@ -3,7 +3,7 @@
 // RUN: %env_asan_opts=detect_stack_use_after_return=1 not %run %t %t.dll 2>&1 | FileCheck %s
 // RUN: %clang_cl_asan %LD %Od %s %Fe%t.dll -fsanitize-address-use-after-return=always
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include <malloc.h>
 
diff --git a/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp b/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp
index 61a2b9042d611c..5c71c38a5113bc 100644
--- a/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/illegal_instruction.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cl_asan %Od %s %Fe%t
 // RUN: %env_asan_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck %s
 // msvc doesn't have a __builtin_trap equivalent
-// XFAIL: MSVC
+// XFAIL: msvc
 
 // Test the error output from an illegal instruction.
 
diff --git a/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp b/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp
index 426e4bb363b2f7..ee953cd6e4bfe1 100644
--- a/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp
@@ -3,7 +3,7 @@
 
 // FIXME: On MinGW frame #0 does not include the line number?
 // XFAIL: target={{.*-windows-gnu}}
-// XFAIL: MSVC
+// XFAIL: msvc
 
 // Test the error output from misaligned SSE2 memory access. This is a READ
 // memory access. Windows appears to always provide an address of -1 for these
diff --git a/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp b/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp
index d6a6b70a208ac6..0b33ff3340cf64 100644
--- a/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cpp
@@ -3,7 +3,7 @@
 
 // RUN: %clang_cl_asan %Od %s %Fe%t -fsanitize-address-use-after-return=always
 // RUN: not %run %t 2>&1 | FileCheck %s
-// XFAIL: MSVC
+// XFAIL: msvc
 char *x;
 
 void foo() {
diff --git a/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp b/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
index 9ede7055ec50bc..5ef52e7b6e0ddf 100644
--- a/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
-// XFAIL: MSVC
+// XFAIL: msvc
 
 #include "defines.h"
 #include <assert.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp b/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
index f4e03e25dfd2a3..b959136215559b 100644
--- a/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
@@ -2,7 +2,7 @@
 // RUN: %clangxx_asan -O3 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: %run %t 2>&1
 //
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include "sanitizer/asan_interface.h"
 #include <assert.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp b/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
index 7cccca1f6a67fb..8f0e3704f95060 100644
--- a/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
@@ -4,7 +4,7 @@
 // REQUIRES: stable-runtime
 
 // This testcase checks that allocas and VLAs inside loop are correctly unpoisoned.
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include "defines.h"
 #include "sanitizer/asan_interface.h"
diff --git a/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp b/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
index 48d7e93111ec94..f3ec76147c3887 100644
--- a/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp b/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
index a46c7ee1901a70..672c9bf985112f 100644
--- a/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp b/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
index 8bd941bb94674b..19da56665b4c4c 100644
--- a/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: %run %t 2>&1
 //
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp b/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
index d540be76c0d27b..3827a2e0461036 100644
--- a/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp b/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp
index 30b1ec21819022..7e173efeeef801 100644
--- a/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp
@@ -4,7 +4,7 @@
 // REQUIRES: stable-runtime
 
 // This testcase checks correct interaction between VLAs and allocas.
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp b/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp
index effcc202860301..e55c3acce9af35 100644
--- a/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp
+++ b/compiler-rt/test/asan/TestCases/coverage-trace-pc.cpp
@@ -2,7 +2,7 @@
 // RUN: %clangxx_asan -O0 -DTRACE_RT %s -o %t-rt.o -c
 // RUN: %clangxx_asan -O0 -fsanitize-coverage=edge,trace-pc,indirect-calls %s -o %t %t-rt.o
 // RUN: %run %t
-// XFAIL: MSVC
+// XFAIL: msvc
 
 #ifdef TRACE_RT
 int pc_count;
diff --git a/compiler-rt/test/asan/TestCases/debug_locate.cpp b/compiler-rt/test/asan/TestCases/debug_locate.cpp
index ecb0bdf22706a0..2ccddd4739d4a6 100644
--- a/compiler-rt/test/asan/TestCases/debug_locate.cpp
+++ b/compiler-rt/test/asan/TestCases/debug_locate.cpp
@@ -3,7 +3,7 @@
 // that it correctly finds out which region (and name and size) the address
 // belongs to.
 // RUN: %clangxx_asan -O0 %s -o %t && %run %t 2>&1
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 #include <assert.h>
 #include <sanitizer/asan_interface.h>
 #include <stdio.h>
diff --git a/compiler-rt/test/asan/TestCases/default_ignorelist.cpp b/compiler-rt/test/asan/TestCases/default_ignorelist.cpp
index 7f8a0a0c280233..c1277394680f1e 100644
--- a/compiler-rt/test/asan/TestCases/default_ignorelist.cpp
+++ b/compiler-rt/test/asan/TestCases/default_ignorelist.cpp
@@ -1,5 +1,5 @@
 // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
-// XFAIL: android, MSVC
+// XFAIL: android, msvc
 // UNSUPPORTED: ios
 //
 // Test that ASan uses the default ignorelist from resource directory.
diff --git a/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp b/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp
index ac13c496fdafca..199816b8036abd 100644
--- a/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp
+++ b/compiler-rt/test/asan/TestCases/global-location-nodebug.cpp
@@ -11,7 +11,7 @@
 /// Solaris ld -S has different semantics, so enforce -fuse-ld= for
 /// configurations that default to GNU ld.
 // XFAIL: target={{.*solaris.*}}
-// XFAIL: MSVC
+// XFAIL: msvc
 // CHECK: AddressSanitizer: global-buffer-overflow
 // CLASS_STATIC-NO-G: 0x{{.*}} is located 4 bytes after global variable '{{.*}}C::array{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
 // GLOB-NO-G: 0x{{.*}} is located 4 bytes after global variable '{{.*}}global{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
diff --git a/compiler-rt/test/asan/TestCases/global-underflow.cpp b/compiler-rt/test/asan/TestCases/global-underflow.cpp
index d0d30506be0604..fc9b14628aece2 100644
--- a/compiler-rt/test/asan/TestCases/global-underflow.cpp
+++ b/compiler-rt/test/asan/TestCases/global-underflow.cpp
@@ -1,4 +1,4 @@
-// XFAIL: MSVC
+// XFAIL: msvc
 // RUN: %clangxx_asan -O0 %s %p/Helpers/underflow.cpp -o %t && not %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O1 %s %p/Helpers/underflow.cpp -o %t && not %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O2 %s %p/Helpers/underflow.cpp -o %t && not %run %t 2>&1 | FileCheck %s
diff --git a/compiler-rt/test/asan/TestCases/halt_on_error-1.c b/compiler-rt/test/asan/TestCases/halt_on_error-1.c
index 16f6ea105e0d47..d40a2819871339 100644
--- a/compiler-rt/test/asan/TestCases/halt_on_error-1.c
+++ b/compiler-rt/test/asan/TestCases/halt_on_error-1.c
@@ -5,7 +5,7 @@
 // RUN: env not %run %t 2>&1 | FileCheck %s
 // RUN: %env_asan_opts=halt_on_error=true not %run %t 2>&1 | FileCheck %s
 // RUN: %env_asan_opts=halt_on_error=false %run %t 2>&1 | FileCheck %s --check-prefix CHECK-RECOVER
-// XFAIL: MSVC
+// XFAIL: msvc
 #include <string.h>
 
 volatile int ten = 10;
diff --git a/compiler-rt/test/asan/TestCases/ignorelist.cpp b/compiler-rt/test/asan/TestCases/ignorelist.cpp
index 75af63de46f2e5..5fe728bfe9c210 100644
--- a/compiler-rt/test/asan/TestCases/ignorelist.cpp
+++ b/compiler-rt/test/asan/TestCases/ignorelist.cpp
@@ -16,7 +16,7 @@
 // it to make sure memory past the end of badGlobal will be in
 // the same page.
 
-// XFAIL: MSVC
+// XFAIL: msvc
 #include "defines.h"
 ATTRIBUTE_ALIGNED(16) int badGlobal;
 int readBadGlobal() {
diff --git a/compiler-rt/test/asan/TestCases/inline.cpp b/compiler-rt/test/asan/TestCases/inline.cpp
index cd3202df58d773..4bd8a08c0f9a7e 100644
--- a/compiler-rt/test/asan/TestCases/inline.cpp
+++ b/compiler-rt/test/asan/TestCases/inline.cpp
@@ -3,7 +3,7 @@
 // Test that no_sanitize_address attribute applies even when the function would
 // be normally inlined.
 //
-// XFAIL: MSVC
+// XFAIL: msvc
 // ^ MSVC has this bug
 
 #include "defines.h"
diff --git a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp
index bcfd999fefcfec..84c264b3056926 100644
--- a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp
+++ b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
 
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s
-// XFAIL: MSVC
+// XFAIL: msvc
 #include <assert.h>
 #include <stdlib.h>
 
diff --git a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp
index 4bb389b3a94a98..80742cddc0460d 100644
--- a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp
+++ b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
 
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s
-// XFAIL: MSVC
+// XFAIL: msvc
 #include <assert.h>
 #include <stdlib.h>
 
diff --git a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp
index d50877e213d6d0..061a0a7b2b8615 100644
--- a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp
+++ b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp
@@ -4,7 +4,7 @@
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=1 not %run %t g 2>&1 | FileCheck %s -check-prefix=CMP -check-prefix=ALL-ERRORS
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=1 not %run %t s 2>&1 | FileCheck %s -check-prefix=SUB -check-prefix=ALL-ERRORS
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=1 not %run %t f 2>&1 | FileCheck %s -check-prefix=FREE -check-prefix=ALL-ERRORS
-// XFAIL: MSVC
+// XFAIL: msvc
 #include <assert.h>
 #include <stdlib.h>
 
diff --git a/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp b/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp
index abfed0219095a4..69409bc6ace6b1 100644
--- a/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp
+++ b/compiler-rt/test/asan/TestCases/pass-struct-byval.cpp
@@ -1,6 +1,6 @@
 // RUN: %clangxx_asan -O0 %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
-// XFAIL: MSVC
+// XFAIL: msvc
 struct A {
   int a[8];
 };
diff --git a/compiler-rt/test/asan/TestCases/speculative_load.cpp b/compiler-rt/test/asan/TestCases/speculative_load.cpp
index edc8d4eb14da2e..b4a5c16f727abd 100644
--- a/compiler-rt/test/asan/TestCases/speculative_load.cpp
+++ b/compiler-rt/test/asan/TestCases/speculative_load.cpp
@@ -3,7 +3,7 @@
 // RUN: %clangxx_asan -O1 %s -o %t && %run %t 2>&1
 // RUN: %clangxx_asan -O2 %s -o %t && %run %t 2>&1
 // RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include <sanitizer/asan_interface.h>
 
diff --git a/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp b/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp
index 49c31d651709a3..d33c6246fd4fb4 100644
--- a/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp
+++ b/compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cpp
@@ -13,7 +13,7 @@
 // RUN: not %run %t 63 2>&1 | FileCheck --check-prefix=CHECK-63 %s
 // RUN: not %run %t 73 2>&1 | FileCheck --check-prefix=CHECK-73 %s
 // RUN: not %run %t 74 2>&1 | FileCheck --check-prefix=CHECK-74 %s
-// XFAIL: MSVC
+// XFAIL: msvc
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp b/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp
index e45720c4f0a34a..54165af65c2615 100644
--- a/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp
+++ b/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp
@@ -3,7 +3,7 @@
 // RUN: not %run %t 1 2>&1 | FileCheck %s --check-prefix=CHECK1
 // RUN: not %run %t 2 2>&1 | FileCheck %s --check-prefix=CHECK2
 // RUN: not %run %t 3 2>&1 | FileCheck %s --check-prefix=CHECK3
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #define NOINLINE __attribute__((noinline))
 inline void break_optimization(void *arg) {
diff --git a/compiler-rt/test/asan/TestCases/throw_call_test.cpp b/compiler-rt/test/asan/TestCases/throw_call_test.cpp
index 4481fcff6c3a30..2875d2dc4175b0 100644
--- a/compiler-rt/test/asan/TestCases/throw_call_test.cpp
+++ b/compiler-rt/test/asan/TestCases/throw_call_test.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan %s -o %t && %run %t
 // http://code.google.com/p/address-sanitizer/issues/detail?id=147 (not fixed).
 // BROKEN: %clangxx_asan %s -o %t -static-libstdc++ && %run %t
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include "defines.h"
 #include <stdio.h>
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp
index a540e233567377..d0154ef744241e 100644
--- a/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp
+++ b/compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp
@@ -5,7 +5,7 @@
 // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
 
 // MSVC marks this as xfail because it doesn't generate the metadata to display the "x.i" offset.
-// XFAIL: MSVC
+// XFAIL: msvc
 #include "defines.h"
 
 int *arr;
diff --git a/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp b/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
index 9b50a151ef34cd..297cddcf60c6cf 100644
--- a/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
+++ b/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 // This is reduced testcase based on Chromium code.
 // See http://reviews.llvm.org/D6055?vs=on&id=15616&whitespace=ignore-all#toc.
diff --git a/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp b/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp
index 5c9bdbefacde8c..6ce279e1bf1d57 100644
--- a/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp
+++ b/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp
@@ -2,7 +2,7 @@
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
 // REQUIRES: stable-runtime
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include "defines.h"
 #include <assert.h>
diff --git a/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp b/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp
index 71e46616a4af87..d0c1c446e8a220 100644
--- a/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp
+++ b/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp
@@ -2,7 +2,7 @@
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
 // REQUIRES: stable-runtime
-// UNSUPPORTED: MSVC
+// UNSUPPORTED: msvc
 
 #include <assert.h>
 #include <stdint.h>

>From d8f35d2d7745c96dc3451956c34eeec485c1beac Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Wed, 15 Jan 2025 10:04:28 -0800
Subject: [PATCH 14/15] say why things are unsupported on MSVC

---
 .../test/asan/TestCases/Windows/dll_stack_use_after_return.cpp  | 1 +
 .../test/asan/TestCases/alloca_instruments_all_paddings.cpp     | 2 ++
 compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp     | 2 ++
 compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp     | 1 +
 compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp       | 1 +
 compiler-rt/test/asan/TestCases/alloca_safe_access.cpp          | 1 +
 compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp       | 1 +
 compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp         | 2 ++
 compiler-rt/test/asan/TestCases/speculative_load.cpp            | 2 ++
 compiler-rt/test/asan/TestCases/stack-oob-frames.cpp            | 2 ++
 compiler-rt/test/asan/TestCases/throw_call_test.cpp             | 2 ++
 compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp         | 1 +
 compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp      | 1 +
 compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp            | 2 ++
 14 files changed, 21 insertions(+)

diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp
index 3e2a38374f920f..3a09566eb873f5 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cpp
@@ -3,6 +3,7 @@
 // RUN: %env_asan_opts=detect_stack_use_after_return=1 not %run %t %t.dll 2>&1 | FileCheck %s
 // RUN: %clang_cl_asan %LD %Od %s %Fe%t.dll -fsanitize-address-use-after-return=always
 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
+
 // UNSUPPORTED: msvc
 
 #include <malloc.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp b/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
index b959136215559b..02110de61d33dd 100644
--- a/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp
@@ -2,8 +2,10 @@
 // RUN: %clangxx_asan -O3 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: %run %t 2>&1
 //
+// MSVC does not support asan-instrament-dynamic-allocas yet
 // UNSUPPORTED: msvc
 
+
 #include "sanitizer/asan_interface.h"
 #include <assert.h>
 #include <stdint.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp b/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
index 8f0e3704f95060..7e77d963c1e65f 100644
--- a/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_loop_unpoisoning.cpp
@@ -4,6 +4,8 @@
 // REQUIRES: stable-runtime
 
 // This testcase checks that allocas and VLAs inside loop are correctly unpoisoned.
+
+// MSVC doesn't support VLAs in the first place.
 // UNSUPPORTED: msvc
 
 #include "defines.h"
diff --git a/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp b/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
index f3ec76147c3887..f06195bb7793ff 100644
--- a/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_overflow_partial.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
+// MSVC doesn't support VLAs
 // UNSUPPORTED: msvc
 
 #include <assert.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp b/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
index 672c9bf985112f..626c12488858dc 100644
--- a/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_overflow_right.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
+// MSVC doesn't support VLAs
 // UNSUPPORTED: msvc
 
 #include <assert.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp b/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
index 19da56665b4c4c..8979b6ca726eee 100644
--- a/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_safe_access.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: %run %t 2>&1
 //
+// MSVC doesn't support VLAs
 // UNSUPPORTED: msvc
 
 #include <assert.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp b/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
index 3827a2e0461036..532344319b0192 100644
--- a/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_underflow_left.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
+// MSVC doesn't support VLAs
 // UNSUPPORTED: msvc
 
 #include <assert.h>
diff --git a/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp b/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp
index 7e173efeeef801..ff784d76aaafbb 100644
--- a/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp
+++ b/compiler-rt/test/asan/TestCases/alloca_vla_interact.cpp
@@ -4,6 +4,8 @@
 // REQUIRES: stable-runtime
 
 // This testcase checks correct interaction between VLAs and allocas.
+
+// MSVC doesn't support VLA's
 // UNSUPPORTED: msvc
 
 #include <assert.h>
diff --git a/compiler-rt/test/asan/TestCases/speculative_load.cpp b/compiler-rt/test/asan/TestCases/speculative_load.cpp
index b4a5c16f727abd..27bd293d28a395 100644
--- a/compiler-rt/test/asan/TestCases/speculative_load.cpp
+++ b/compiler-rt/test/asan/TestCases/speculative_load.cpp
@@ -3,6 +3,8 @@
 // RUN: %clangxx_asan -O1 %s -o %t && %run %t 2>&1
 // RUN: %clangxx_asan -O2 %s -o %t && %run %t 2>&1
 // RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1
+
+// MSVC doesn't support GCC style inline assembly
 // UNSUPPORTED: msvc
 
 #include <sanitizer/asan_interface.h>
diff --git a/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp b/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp
index 54165af65c2615..1e077513c2168e 100644
--- a/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp
+++ b/compiler-rt/test/asan/TestCases/stack-oob-frames.cpp
@@ -3,6 +3,8 @@
 // RUN: not %run %t 1 2>&1 | FileCheck %s --check-prefix=CHECK1
 // RUN: not %run %t 2 2>&1 | FileCheck %s --check-prefix=CHECK2
 // RUN: not %run %t 3 2>&1 | FileCheck %s --check-prefix=CHECK3
+
+// MSVC doesn't support GCC style inline ASM
 // UNSUPPORTED: msvc
 
 #define NOINLINE __attribute__((noinline))
diff --git a/compiler-rt/test/asan/TestCases/throw_call_test.cpp b/compiler-rt/test/asan/TestCases/throw_call_test.cpp
index 2875d2dc4175b0..06e9422701406a 100644
--- a/compiler-rt/test/asan/TestCases/throw_call_test.cpp
+++ b/compiler-rt/test/asan/TestCases/throw_call_test.cpp
@@ -1,6 +1,8 @@
 // RUN: %clangxx_asan %s -o %t && %run %t
 // http://code.google.com/p/address-sanitizer/issues/detail?id=147 (not fixed).
 // BROKEN: %clangxx_asan %s -o %t -static-libstdc++ && %run %t
+
+// MSVC doesn't support GCC style inline ASM
 // UNSUPPORTED: msvc
 
 #include "defines.h"
diff --git a/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp b/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
index 297cddcf60c6cf..743e2ae71425b7 100644
--- a/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
+++ b/compiler-rt/test/asan/TestCases/vla_chrome_testcase.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
+// MSVC doesn't support VLAs
 // UNSUPPORTED: msvc
 
 // This is reduced testcase based on Chromium code.
diff --git a/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp b/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp
index 6ce279e1bf1d57..5269a35e9796ad 100644
--- a/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp
+++ b/compiler-rt/test/asan/TestCases/vla_condition_overflow.cpp
@@ -2,6 +2,7 @@
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
 // REQUIRES: stable-runtime
+// MSVC doesn't support VLAs
 // UNSUPPORTED: msvc
 
 #include "defines.h"
diff --git a/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp b/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp
index d0c1c446e8a220..d4cf9513d0fa67 100644
--- a/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp
+++ b/compiler-rt/test/asan/TestCases/vla_loop_overfow.cpp
@@ -2,6 +2,8 @@
 // RUN: not %run %t 2>&1 | FileCheck %s
 //
 // REQUIRES: stable-runtime
+
+// MSVC doesn't support VLAs
 // UNSUPPORTED: msvc
 
 #include <assert.h>

>From 0274a1010fba223cababa0d5d09924d6697cfabc Mon Sep 17 00:00:00 2001
From: Charlie Barto <barto.charlie at gmail.com>
Date: Wed, 15 Jan 2025 10:07:18 -0800
Subject: [PATCH 15/15] reword comment in asan/TestCases/inline.cpp

---
 compiler-rt/test/asan/TestCases/inline.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/test/asan/TestCases/inline.cpp b/compiler-rt/test/asan/TestCases/inline.cpp
index 4bd8a08c0f9a7e..42779a07ae2e64 100644
--- a/compiler-rt/test/asan/TestCases/inline.cpp
+++ b/compiler-rt/test/asan/TestCases/inline.cpp
@@ -3,8 +3,9 @@
 // Test that no_sanitize_address attribute applies even when the function would
 // be normally inlined.
 //
+// MSVC doesn't apply __declspec(no_sanitize_address) to inlined functions
+//    (i.e. it contains this bug)
 // XFAIL: msvc
-// ^ MSVC has this bug
 
 #include "defines.h"
 #include <stdlib.h>



More information about the llvm-commits mailing list