1*6186971aSVedant Kumar // REQUIRES: shell 2*6186971aSVedant Kumar 3*6186971aSVedant Kumar // Check that all of the hashes in this file are unique (i.e, that none of the 4*6186971aSVedant Kumar // profiles for these functions are mutually interchangeable). 5*6186971aSVedant Kumar // 6*6186971aSVedant Kumar // RUN: llvm-profdata show -all-functions %S/Inputs/cxx-hash-v2.profdata.v5 | grep "Hash: 0x" | sort > %t.hashes 7*6186971aSVedant Kumar // RUN: uniq %t.hashes > %t.hashes.unique 8*6186971aSVedant Kumar // RUN: diff %t.hashes %t.hashes.unique 9*6186971aSVedant Kumar 10*6186971aSVedant Kumar // RUN: llvm-profdata merge %S/Inputs/cxx-hash-v2.proftext -o %t.profdata 11*6186971aSVedant Kumar // RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-apple-macosx10.9 -main-file-name cxx-hash-v2.mm %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -allow-empty 12*6186971aSVedant Kumar // RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-apple-macosx10.9 -main-file-name cxx-hash-v2.mm %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%S/Inputs/cxx-hash-v2.profdata.v5 2>&1 | FileCheck %s -allow-empty 13*6186971aSVedant Kumar 14*6186971aSVedant Kumar // CHECK-NOT: warning: profile data may be out of date 15*6186971aSVedant Kumar 16*6186971aSVedant Kumar int x; 17*6186971aSVedant Kumar int arr[1] = {0}; 18*6186971aSVedant Kumar loop_after_if_else()19*6186971aSVedant Kumarvoid loop_after_if_else() { 20*6186971aSVedant Kumar if (1) 21*6186971aSVedant Kumar x = 1; 22*6186971aSVedant Kumar else 23*6186971aSVedant Kumar x = 2; 24*6186971aSVedant Kumar while (0) 25*6186971aSVedant Kumar ++x; 26*6186971aSVedant Kumar } 27*6186971aSVedant Kumar loop_in_then_block()28*6186971aSVedant Kumarvoid loop_in_then_block() { 29*6186971aSVedant Kumar if (1) { 30*6186971aSVedant Kumar while (0) 31*6186971aSVedant Kumar ++x; 32*6186971aSVedant Kumar } else { 33*6186971aSVedant Kumar x = 2; 34*6186971aSVedant Kumar } 35*6186971aSVedant Kumar } 36*6186971aSVedant Kumar loop_in_else_block()37*6186971aSVedant Kumarvoid loop_in_else_block() { 38*6186971aSVedant Kumar if (1) { 39*6186971aSVedant Kumar x = 1; 40*6186971aSVedant Kumar } else { 41*6186971aSVedant Kumar while (0) 42*6186971aSVedant Kumar ++x; 43*6186971aSVedant Kumar } 44*6186971aSVedant Kumar } 45*6186971aSVedant Kumar if_inside_of_for()46*6186971aSVedant Kumarvoid if_inside_of_for() { 47*6186971aSVedant Kumar for (x = 0; x < 0; ++x) { 48*6186971aSVedant Kumar x = 1; 49*6186971aSVedant Kumar if (1) 50*6186971aSVedant Kumar x = 2; 51*6186971aSVedant Kumar } 52*6186971aSVedant Kumar } 53*6186971aSVedant Kumar if_outside_of_for()54*6186971aSVedant Kumarvoid if_outside_of_for() { 55*6186971aSVedant Kumar for (x = 0; x < 0; ++x) 56*6186971aSVedant Kumar x = 1; 57*6186971aSVedant Kumar if (1) 58*6186971aSVedant Kumar x = 2; 59*6186971aSVedant Kumar } 60*6186971aSVedant Kumar if_inside_of_while()61*6186971aSVedant Kumarvoid if_inside_of_while() { 62*6186971aSVedant Kumar while (0) { 63*6186971aSVedant Kumar x = 1; 64*6186971aSVedant Kumar if (1) 65*6186971aSVedant Kumar x = 2; 66*6186971aSVedant Kumar } 67*6186971aSVedant Kumar } 68*6186971aSVedant Kumar if_outside_of_while()69*6186971aSVedant Kumarvoid if_outside_of_while() { 70*6186971aSVedant Kumar while (0) 71*6186971aSVedant Kumar x = 1; 72*6186971aSVedant Kumar if (1) 73*6186971aSVedant Kumar x = 2; 74*6186971aSVedant Kumar } 75*6186971aSVedant Kumar nested_dos()76*6186971aSVedant Kumarvoid nested_dos() { 77*6186971aSVedant Kumar do { 78*6186971aSVedant Kumar do { 79*6186971aSVedant Kumar ++x; 80*6186971aSVedant Kumar } while (0); 81*6186971aSVedant Kumar } while (0); 82*6186971aSVedant Kumar } 83*6186971aSVedant Kumar consecutive_dos()84*6186971aSVedant Kumarvoid consecutive_dos() { 85*6186971aSVedant Kumar do { 86*6186971aSVedant Kumar } while (0); 87*6186971aSVedant Kumar do { 88*6186971aSVedant Kumar ++x; 89*6186971aSVedant Kumar } while (0); 90*6186971aSVedant Kumar } 91*6186971aSVedant Kumar loop_empty()92*6186971aSVedant Kumarvoid loop_empty() { 93*6186971aSVedant Kumar for (x = 0; x < 5; ++x) {} 94*6186971aSVedant Kumar } 95*6186971aSVedant Kumar loop_return()96*6186971aSVedant Kumarvoid loop_return() { 97*6186971aSVedant Kumar for (x = 0; x < 5; ++x) 98*6186971aSVedant Kumar return; 99*6186971aSVedant Kumar } 100*6186971aSVedant Kumar loop_continue()101*6186971aSVedant Kumarvoid loop_continue() { 102*6186971aSVedant Kumar for (x = 0; x < 5; ++x) 103*6186971aSVedant Kumar continue; 104*6186971aSVedant Kumar } 105*6186971aSVedant Kumar loop_break()106*6186971aSVedant Kumarvoid loop_break() { 107*6186971aSVedant Kumar for (x = 0; x < 5; ++x) 108*6186971aSVedant Kumar break; 109*6186971aSVedant Kumar } 110*6186971aSVedant Kumar no_gotos()111*6186971aSVedant Kumarvoid no_gotos() { 112*6186971aSVedant Kumar static void *dispatch[] = {&&done}; 113*6186971aSVedant Kumar x = 0; 114*6186971aSVedant Kumar done: 115*6186971aSVedant Kumar ++x; 116*6186971aSVedant Kumar } 117*6186971aSVedant Kumar direct_goto()118*6186971aSVedant Kumarvoid direct_goto() { 119*6186971aSVedant Kumar static void *dispatch[] = {&&done}; 120*6186971aSVedant Kumar x = 0; 121*6186971aSVedant Kumar goto done; 122*6186971aSVedant Kumar done: 123*6186971aSVedant Kumar ++x; 124*6186971aSVedant Kumar } 125*6186971aSVedant Kumar indirect_goto()126*6186971aSVedant Kumarvoid indirect_goto() { 127*6186971aSVedant Kumar static void *dispatch[] = {&&done}; 128*6186971aSVedant Kumar x = 0; 129*6186971aSVedant Kumar goto *dispatch[x]; 130*6186971aSVedant Kumar done: 131*6186971aSVedant Kumar ++x; 132*6186971aSVedant Kumar } 133*6186971aSVedant Kumar nested_for_ranges()134*6186971aSVedant Kumarvoid nested_for_ranges() { 135*6186971aSVedant Kumar for (int a : arr) 136*6186971aSVedant Kumar for (int b : arr) 137*6186971aSVedant Kumar ++x; 138*6186971aSVedant Kumar } 139*6186971aSVedant Kumar consecutive_for_ranges()140*6186971aSVedant Kumarvoid consecutive_for_ranges() { 141*6186971aSVedant Kumar for (int a : arr) {} 142*6186971aSVedant Kumar for (int b : arr) 143*6186971aSVedant Kumar ++x; 144*6186971aSVedant Kumar } 145*6186971aSVedant Kumar nested_try_catch()146*6186971aSVedant Kumarvoid nested_try_catch() { 147*6186971aSVedant Kumar try { 148*6186971aSVedant Kumar try { 149*6186971aSVedant Kumar ++x; 150*6186971aSVedant Kumar } catch (...) {} 151*6186971aSVedant Kumar } catch (...) {} 152*6186971aSVedant Kumar } 153*6186971aSVedant Kumar consecutive_try_catch()154*6186971aSVedant Kumarvoid consecutive_try_catch() { 155*6186971aSVedant Kumar try {} catch (...) {} 156*6186971aSVedant Kumar try { 157*6186971aSVedant Kumar ++x; 158*6186971aSVedant Kumar } catch (...) {} 159*6186971aSVedant Kumar } 160*6186971aSVedant Kumar no_throw()161*6186971aSVedant Kumarvoid no_throw() {} 162*6186971aSVedant Kumar has_throw()163*6186971aSVedant Kumarvoid has_throw() { 164*6186971aSVedant Kumar throw 0; 165*6186971aSVedant Kumar } 166*6186971aSVedant Kumar single_lnot()167*6186971aSVedant Kumarvoid single_lnot() { 168*6186971aSVedant Kumar if (!x) {} 169*6186971aSVedant Kumar } 170*6186971aSVedant Kumar double_lnot()171*6186971aSVedant Kumarvoid double_lnot() { 172*6186971aSVedant Kumar if (!!x) {} 173*6186971aSVedant Kumar } 174*6186971aSVedant Kumar main()175*6186971aSVedant Kumarint main() { 176*6186971aSVedant Kumar return 0; 177*6186971aSVedant Kumar } 178