demangled_names.cc revision 6d1862363c88c183b0ed7740fca876342cf0474b
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 8namespace foo { 9// A template function in a namespace. 10template<int x> 11void bar(char *p) { 12 *p = x; 13} 14 15// A regular function in a namespace. 16void spam(char *p) { 17 bar<42>(p); 18} 19} 20 21// A multi-argument template with a bool template parameter. 22template<typename T, bool U> 23void baz(T t) { 24 if (U) 25 foo::spam(t); 26} 27 28template<typename T> 29struct A { 30 A(T v) { v_ = v; } 31 ~A(); 32 char *v_; 33}; 34 35// A destructor of a template class. 36template<> 37A<char*>::~A() { 38 baz<char*, true>(v_); 39} 40 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