[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / captured-stmt.cpp
blob6f5ca3836e05191b764660ca117850ecaab248e3
1 // RUN: %clang_cc1 -x c++-header -emit-pch %s -o %t
2 // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
4 // expected-no-diagnostics
6 #ifndef HEADER_INCLUDED
7 #define HEADER_INCLUDED
9 static inline void foo(int &x, int y) {
10 // Capturing x and y
11 #pragma clang __debug captured
13 x += y;
17 struct C {
18 int val;
20 explicit C(int v) : val(v) { }
22 void bar(int &x) {
23 // Capturing x and this
24 #pragma clang __debug captured
26 x += val;
31 #else
33 void test_foo(int &x) {
34 foo(x, 10);
37 void test_bar(int &x) {
38 C Obj(10);
39 Obj.bar(x);
42 #endif