1 // RUN: %clang_cl_asan -O0 %s -Fe%t 2 // RUN: not %run %t 2>&1 | FileCheck %s 3 // 4 // This test makes sure ASan symbolizes stack traces the way they are typically 5 // symbolized on Windows. 6 #include <malloc.h> 7 8 namespace foo { 9 // A template function in a namespace. 10 template<int x> bar(char * p)11void bar(char *p) { 12 *p = x; 13 } 14 15 // A regular function in a namespace. spam(char * p)16void spam(char *p) { 17 bar<42>(p); 18 } 19 } 20 21 // A multi-argument template with a bool template parameter. 22 template<typename T, bool U> baz(T t)23void baz(T t) { 24 if (U) 25 foo::spam(t); 26 } 27 28 template<typename T> 29 struct A { AA30 A(T v) { v_ = v; } 31 ~A(); 32 char *v_; 33 }; 34 35 // A destructor of a template class. 36 template<> ~A()37A<char*>::~A() { 38 baz<char*, true>(v_); 39 } 40 main()41int main() { 42 char *buffer = (char*)malloc(42); 43 free(buffer); 44 A<char*> a(buffer); 45 // CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]] 46 // CHECK: foo::bar<42>{{.*}}demangled_names.cc 47 // CHECK: foo::spam{{.*}}demangled_names.cc 48 // CHECK: baz<char *,1>{{.*}}demangled_names.cc 49 // CHECK: A<char *>::~A<char *>{{.*}}demangled_names.cc 50 } 51