[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / cxx-decls.cpp
blob679150f598cfcc9c082220f520f969f43e5fea96
1 // RUN: rm -rf %t
2 // RUN: %clang_cc1 -x objective-c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Wno-deprecated-builtins -I %S/Inputs %s -verify -std=c++11
3 // RUN: %clang_cc1 -x objective-c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Wno-deprecated-builtins -I %S/Inputs %s -ast-dump -ast-dump-filter merge -std=c++11 | FileCheck %s
5 // expected-no-diagnostics
7 void use_implicit_new() { operator new[](3); }
9 @import dummy;
10 @import cxx_decls.imported;
12 void test_delete(int *p) {
13 // We can call the normal global deallocation function even though it has only
14 // ever been explicitly declared in an unimported submodule.
15 delete p;
18 void friend_1(HasFriends s) {
19 s.private_thing();
21 void test_friends(HasFriends s) {
22 friend_1(s);
23 friend_2(s);
26 static_assert(!__is_trivial(HasNontrivialDefaultConstructor), "");
27 static_assert(!__has_trivial_constructor(HasNontrivialDefaultConstructor), "");
29 void use_implicit_new_again() { operator new[](3); }
31 int importMergeUsedFlag = getMergeUsedFlag();
33 int use_name_for_linkage(NameForLinkage &nfl) {
34 return nfl.n + nfl.m;
36 int use_overrides_virtual_functions(OverridesVirtualFunctions ovf) { return 0; }
38 @import cxx_decls_merged;
40 NameForLinkage2Inner use_name_for_linkage2_inner;
41 NameForLinkage2 use_name_for_linkage2;
43 int name_for_linkage_test = use_name_for_linkage(name_for_linkage);
44 int overrides_virtual_functions_test =
45 use_overrides_virtual_functions(overrides_virtual_functions);
47 void use_extern_c_function() { ExternCFunction(); }
49 int use_namespace_alias() { return Alias::a + Alias::b; }
51 @import cxx_decls_premerged;
53 void use_extern_c_function_2() { ExternCFunction(); }
55 InhCtorB inhctorb(2);
57 // CHECK: VarDecl [[mergeUsedFlag:0x[0-9a-f]*]] {{.*}} in cxx_decls.imported used mergeUsedFlag
58 // CHECK: VarDecl {{0x[0-9a-f]*}} prev [[mergeUsedFlag]] {{.*}} in cxx_decls_merged used mergeUsedFlag