Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <windows.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <windows.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <windows.h>
Expand Down
4 changes: 1 addition & 3 deletions compiler-rt/test/asan/TestCases/Windows/operator_new_uaf.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <windows.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <windows.h>
Expand Down
4 changes: 1 addition & 3 deletions compiler-rt/test/asan/TestCases/Windows/realloc_left_oob.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <malloc.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <malloc.h>
Expand Down
4 changes: 1 addition & 3 deletions compiler-rt/test/asan/TestCases/Windows/realloc_uaf.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <malloc.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s
// REQUIRES: asan-32-bits

Expand Down
9 changes: 5 additions & 4 deletions compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: %env_asan_opts=handle_sigfpe=1 not %run %t 2>&1 | FileCheck %s

// FIXME: On MinGW frame #0 does not include the line number?
// XFAIL: target={{.*-windows-gnu}}

// 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
// types of faults, and there doesn't seem to be a way to distinguish them from
Expand All @@ -27,4 +28,4 @@ int main() {
// CHECK: before alignment fault
// CHECK: ERROR: AddressSanitizer: access-violation on unknown address {{0x[fF]*}}
// CHECK-NEXT: The signal is caused by a READ memory access.
// CHECK-NEXT: #0 {{.*}} in test(void) {{.*}}misalignment.cpp:{{.*}}
// CHECK-NEXT: #0 {{.*}} in test({{(void)?}}) {{.*}}misalignment.cpp:{{.*}}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: %run %t | FileCheck %s

#include <stdio.h>
Expand Down
4 changes: 1 addition & 3 deletions compiler-rt/test/asan/TestCases/Windows/thread_simple.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: %run %t

#include <windows.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <windows.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <windows.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: %run %t

#include <windows.h>
Expand Down
4 changes: 1 addition & 3 deletions compiler-rt/test/asan/TestCases/Windows/thread_stress.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: %run %t

#include <windows.h>
Expand Down
4 changes: 1 addition & 3 deletions compiler-rt/test/asan/TestCases/Windows/thread_suspended.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: %run %t

#include <windows.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <malloc.h>
Expand Down
4 changes: 1 addition & 3 deletions compiler-rt/test/asan/TestCases/Windows/windows_h.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: %run %t

// Just make sure we can parse <windows.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

class Parent {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// UNSUPPORTED: target={{.*-windows-gnu}}

// RUN: %clang_cl_asan -Od %s -Fe%t
// RUN: %clang_cl_asan %Od %s %Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s

class Parent {
Expand Down
54 changes: 32 additions & 22 deletions compiler-rt/test/asan/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,28 +146,38 @@ def build_invocation(compile_flags):
config.substitutions.append( ("%clang_asan_static ", build_invocation(clang_asan_static_cflags)) )
config.substitutions.append( ("%clangxx_asan_static ", build_invocation(clang_asan_static_cxxflags)) )

# MSVC-specific tests might also use the clang-cl.exe driver.
if platform.system() == 'Windows' and target_is_msvc:
clang_cl_cxxflags = ["-Wno-deprecated-declarations",
"-WX",
"-D_HAS_EXCEPTIONS=0",
"-Zi"] + target_cflags
clang_cl_asan_cxxflags = ["-fsanitize=address"] + clang_cl_cxxflags
if config.asan_dynamic:
clang_cl_asan_cxxflags.append("-MD")

clang_cl_invocation = build_invocation(clang_cl_cxxflags)
clang_cl_invocation = clang_cl_invocation.replace("clang.exe","clang-cl.exe")
config.substitutions.append( ("%clang_cl ", clang_cl_invocation) )

clang_cl_asan_invocation = build_invocation(clang_cl_asan_cxxflags)
clang_cl_asan_invocation = clang_cl_asan_invocation.replace("clang.exe","clang-cl.exe")
config.substitutions.append( ("%clang_cl_asan ", clang_cl_asan_invocation) )

base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.asan%%s%s.lib" % config.target_suffix)
config.substitutions.append( ("%asan_lib", base_lib % "") )
config.substitutions.append( ("%asan_cxx_lib", base_lib % "_cxx") )
config.substitutions.append( ("%asan_dll_thunk", base_lib % "_dll_thunk") )
if platform.system() == 'Windows':
# MSVC-specific tests might also use the clang-cl.exe driver.
if target_is_msvc:
clang_cl_cxxflags = ["-Wno-deprecated-declarations",
"-WX",
"-D_HAS_EXCEPTIONS=0",
"-Zi"] + target_cflags
clang_cl_asan_cxxflags = ["-fsanitize=address"] + clang_cl_cxxflags
if config.asan_dynamic:
clang_cl_asan_cxxflags.append("-MD")

clang_cl_invocation = build_invocation(clang_cl_cxxflags)
clang_cl_invocation = clang_cl_invocation.replace("clang.exe","clang-cl.exe")
config.substitutions.append( ("%clang_cl ", clang_cl_invocation) )

clang_cl_asan_invocation = build_invocation(clang_cl_asan_cxxflags)
clang_cl_asan_invocation = clang_cl_asan_invocation.replace("clang.exe","clang-cl.exe")
config.substitutions.append( ("%clang_cl_asan ", clang_cl_asan_invocation) )
config.substitutions.append( ("%Od", "-Od") )
config.substitutions.append( ("%Fe", "-Fe") )

base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.asan%%s%s.lib" % config.target_suffix)
config.substitutions.append( ("%asan_lib", base_lib % "") )
config.substitutions.append( ("%asan_cxx_lib", base_lib % "_cxx") )
config.substitutions.append( ("%asan_dll_thunk", base_lib % "_dll_thunk") )
else:
# To make some of these tests work on MinGW target without changing their
# behaviour for MSVC target, substitute clang-cl flags with gcc-like ones.
config.substitutions.append( ("%clang_cl ", build_invocation(target_cxxflags)) )
config.substitutions.append( ("%clang_cl_asan ", build_invocation(clang_asan_cxxflags)) )
config.substitutions.append( ("%Od", "-O0") )
config.substitutions.append( ("%Fe", "-o") )

# FIXME: De-hardcode this path.
asan_source_dir = os.path.join(
Expand Down