xref: /aosp_15_r20/external/clang/test/Profile/c-unprofiled.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Test that unprofiled files are recognized. Here, we have two functions in the
2*67e74705SXin Li // profile, main() and function_in_header, but we use the profile on a file that
3*67e74705SXin Li // has the profile-less some_unprofiled_function so that the only profiled code
4*67e74705SXin Li // in #included in a header.
5*67e74705SXin Li 
6*67e74705SXin Li // FIXME: It would be nice to use -verify here instead of FileCheck, but -verify
7*67e74705SXin Li // doesn't play well with warnings that have no line number.
8*67e74705SXin Li 
9*67e74705SXin Li // RUN: llvm-profdata merge %S/Inputs/c-unprofiled.proftext -o %t.profdata
10*67e74705SXin Li // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-unprofiled.c -I %S/Inputs/ %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata -Wprofile-instr-unprofiled 2>&1 | FileCheck %s
11*67e74705SXin Li 
12*67e74705SXin Li // CHECK: warning: no profile data available for file "c-unprofiled.c"
13*67e74705SXin Li 
14*67e74705SXin Li #include "profiled_header.h"
15*67e74705SXin Li 
16*67e74705SXin Li #ifdef GENERATE_OUTDATED_DATA
main(int argc,const char * argv[])17*67e74705SXin Li int main(int argc, const char *argv[]) {
18*67e74705SXin Li   function_in_header(0);
19*67e74705SXin Li   return 0;
20*67e74705SXin Li }
21*67e74705SXin Li #else
some_unprofiled_function(int i)22*67e74705SXin Li void some_unprofiled_function(int i) {
23*67e74705SXin Li   if (i)
24*67e74705SXin Li     function_in_header(i);
25*67e74705SXin Li }
26*67e74705SXin Li #endif
27