2 // RUN: %clangxx_asan -O0 -g %s -o %t.executable
3 // RUN: %env_asan_opts="symbolize=0" not %run %t.executable > %t_no_module_map.log 2>&1
4 // RUN: %asan_symbolize --force-system-symbolizer < %t_no_module_map.log 2>&1 | FileCheck %s
10 // This test is deliberately convoluted so that there is a function call
11 // in the stack trace that contains nested parentheses.
13 template <class CallBackTy
>
16 std::function
<CallBackTy
> callback_
;
19 IntWrapper(int value
, std::function
<CallBackTy
> callback
) : value_(value
), callback_(callback
) {}
20 int &operator=(const int &new_value
) {
26 using IntW
= IntWrapper
<void(int)>;
30 void writeToA(T new_value
) {
31 // CHECK: heap-use-after-free
32 // NOTE: atos seems to emit the `void` return type here for some reason.
33 // CHECK: #{{[0-9]+}} 0x{{.+}} in {{(void +)?}}writeToA<IntWrapper<void{{ *}}(int)>{{ *}}>(IntWrapper<void{{ *}}(int)>) asan-symbolize-templated-cxx.cpp:[[@LINE+1]]
37 extern "C" void callback(int new_value
) {
38 printf("new value is %d\n", new_value
);
41 template <class T
, class V
>
43 std::function
<T
> call
;
44 Foo(std::function
<T
> c
) : call(c
) {}
45 void doCall(V new_value
) {
46 // CHECK: #{{[0-9]+}} 0x{{.+}} in Foo<void (IntWrapper<void{{ *}}(int)>),{{ *}}IntWrapper<void{{ *}}(int)>{{ *}}>::doCall(IntWrapper<void{{ *}}(int)>) asan-symbolize-templated-cxx.cpp:[[@LINE+1]]
52 a
= new IntW(0, callback
);
54 // Foo<void(IntWrapper<void(int)>)>
55 // This type is deliberately convoluted so that the demangled type contains nested parentheses.
56 // In particular trying to match parentheses using a least-greedy regex approach will fail.
57 Foo
<void(IntW
), IntW
> foo(writeToA
<IntW
>);
59 // CHECK: #{{[0-9]+}} 0x{{.+}} in main asan-symbolize-templated-cxx.cpp:[[@LINE+1]]
60 foo
.doCall(IntW(5, callback
)); // BOOM