xref: /aosp_15_r20/external/clang/test/Modules/use-after-free.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: rm -rf %t
2*67e74705SXin Li
3*67e74705SXin Li// Here, we build the module without "non-modular-include-in-framework-module".
4*67e74705SXin Li// RUN: echo '@import UseAfterFreePublic;' | \
5*67e74705SXin Li// RUN:   %clang_cc1 -fmodules -fimplicit-module-maps \
6*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -isystem %S/Inputs/UseAfterFree/ -fsyntax-only \
7*67e74705SXin Li// RUN:     -x objective-c -
8*67e74705SXin Li
9*67e74705SXin Li// RUN:   %clang_cc1 -fmodules -fimplicit-module-maps \
10*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -isystem %S/Inputs/UseAfterFree/ -fsyntax-only \
11*67e74705SXin Li// RUN:     -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module \
12*67e74705SXin Li// RUN:     -x objective-c %s -verify
13*67e74705SXin Li// expected-no-diagnostics
14*67e74705SXin Li
15*67e74705SXin Li// Here, we load the module UseAfterFreePublic, it is treated as a system module,
16*67e74705SXin Li// we ignore the inconsistency for "non-modular-include-in-framework-module".
17*67e74705SXin Li@import UseAfterFreePublic;
18*67e74705SXin Li
19*67e74705SXin Li// We start a thread to build the module for UseAfterFreePrivate.h. In the thread,
20*67e74705SXin Li// we load UseAfterFreePublic and should treat it as a system module as well.
21*67e74705SXin Li// If not, we will invalidate UseAfterFreePublic because of the inconsistency
22*67e74705SXin Li// for "non-modular-include-in-framework-module", and have a use-after-free error
23*67e74705SXin Li// of the FileEntry.
24*67e74705SXin Li#import <UseAfterFreePrivate.h>
25