blob: 0e5939ee415576e181c33de0c09e696678c54a5f [file] [log] [blame]
Stephen Hines6d186232014-11-26 17:56:19 -08001// 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]+]]
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080046// 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
Stephen Hines6d186232014-11-26 17:56:19 -080050}