xref: /llvm-project/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp (revision 94c0db06ab8cf0897ff32884ea6f683f5fc5a7b9)
1*94c0db06SAlexander Richardson // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --version 5
23ce0e92fSAlex Richardson // Basic C++ test for update_cc_test_checks
357c81917SNikita Popov // RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
4*94c0db06SAlexander Richardson // RUN: %clang_cc1 -triple=x86_64-apple-macho -emit-llvm -o - %s | FileCheck %s --check-prefix=MACHO
5*94c0db06SAlexander Richardson // RUN: %clang_cc1 -triple=x86_64-windows-msvc -emit-llvm -o - %s | FileCheck %s --check-prefix=MSVC
6*94c0db06SAlexander Richardson // RUN: %clang_cc1 -triple=x86_64-windows-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=MINGW
73ce0e92fSAlex Richardson 
83ce0e92fSAlex Richardson class Foo {
93ce0e92fSAlex Richardson   int x;
103ce0e92fSAlex Richardson 
113ce0e92fSAlex Richardson public:
123ce0e92fSAlex Richardson   explicit Foo(int x);
133ce0e92fSAlex Richardson   ~Foo();
143ce0e92fSAlex Richardson   inline int function_defined_inline(int arg) const {
153ce0e92fSAlex Richardson     return arg + x;
163ce0e92fSAlex Richardson   }
173ce0e92fSAlex Richardson   inline int function_defined_out_of_line(int arg) const;
183ce0e92fSAlex Richardson };
193ce0e92fSAlex Richardson 
20*94c0db06SAlexander Richardson [[clang::noinline]] static int static_noinline_fn(int arg) { return arg; }
21*94c0db06SAlexander Richardson 
223ce0e92fSAlex Richardson Foo::Foo(int x) : x(x) {}
233ce0e92fSAlex Richardson Foo::~Foo() {}
243ce0e92fSAlex Richardson int Foo::function_defined_out_of_line(int arg) const { return x - arg; }
253ce0e92fSAlex Richardson 
263ce0e92fSAlex Richardson // Call the inline methods to ensure the LLVM IR is generated:
273ce0e92fSAlex Richardson int main() {
283ce0e92fSAlex Richardson   Foo f(1);
293ce0e92fSAlex Richardson   f.function_defined_inline(2);
303ce0e92fSAlex Richardson   f.function_defined_out_of_line(3);
31*94c0db06SAlexander Richardson   return static_noinline_fn(0);
323ce0e92fSAlex Richardson }
33