xref: /aosp_15_r20/external/clang/test/Profile/c-outdated-data.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Test that outdated data is ignored.
2*67e74705SXin Li 
3*67e74705SXin Li // FIXME: It would be nice to use -verify here instead of FileCheck, but -verify
4*67e74705SXin Li // doesn't play well with warnings that have no line number.
5*67e74705SXin Li 
6*67e74705SXin Li // RUN: llvm-profdata merge %S/Inputs/c-outdated-data.proftext -o %t.profdata
7*67e74705SXin Li // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata -Wprofile-instr-dropped 2>&1 | FileCheck %s
8*67e74705SXin Li // CHECK: warning: profile data may be out of date: of 3 functions, 1 has no data and 1 has mismatched data that will be ignored
9*67e74705SXin Li 
no_usable_data()10*67e74705SXin Li void no_usable_data() {
11*67e74705SXin Li   int i = 0;
12*67e74705SXin Li 
13*67e74705SXin Li   if (i) {}
14*67e74705SXin Li 
15*67e74705SXin Li #ifdef GENERATE_OUTDATED_DATA
16*67e74705SXin Li   if (i) {}
17*67e74705SXin Li #endif
18*67e74705SXin Li }
19*67e74705SXin Li 
20*67e74705SXin Li #ifndef GENERATE_OUTDATED_DATA
no_data()21*67e74705SXin Li void no_data() {
22*67e74705SXin Li }
23*67e74705SXin Li #endif
24*67e74705SXin Li 
main(int argc,const char * argv[])25*67e74705SXin Li int main(int argc, const char *argv[]) {
26*67e74705SXin Li   no_usable_data();
27*67e74705SXin Li   return 0;
28*67e74705SXin Li }
29