brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · e60c9b3 Raw
68 lines · cpp
1// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \2// RUN:   -analyzer-checker=core,debug.ExprInspection \3// RUN:   -analyzer-config eagerly-assume=false \4// RUN:   -analyze-function='baruser(int)' -x c++ \5// RUN:   -verify=nonctu %s6 7// RUN: rm -rf %t && mkdir %t8// RUN: mkdir -p %t/ctudir9// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \10// RUN:   -emit-pch -o %t/ctudir/ctu-onego-existingdef-other.cpp.ast %S/Inputs/ctu-onego-existingdef-other.cpp11// RUN: cp %S/Inputs/ctu-onego-existingdef-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt12 13// Existing and equal function definition in both TU. `other` calls `bar` thus14// `bar` will be indirectly imported. During the import we recognize that there15// is an existing definition in the main TU, so we don't create a new Decl.16// Thus, ctu should not bifurcate on the call of `bar` it should directly17// inlinie that as in the case of nonctu.18// Note, we would not get a warning below, if `bar` is conservatively evaluated.19int bar() {20  return 0;21}22 23//Here we completely supress the CTU work list execution. We should not24//bifurcate on the call of `bar`. (We do not load the foreign AST at all.)25// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \26// RUN:   -analyzer-checker=core,debug.ExprInspection \27// RUN:   -analyzer-config eagerly-assume=false \28// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \29// RUN:   -analyzer-config ctu-dir=%t/ctudir \30// RUN:   -verify=stu %s \31// RUN:   -analyze-function='baruser(int)' -x c++ \32// RUN:   -analyzer-config ctu-max-nodes-pct=0 \33// RUN:   -analyzer-config ctu-max-nodes-min=034 35//Here we enable the CTU work list execution. We should not bifurcate on the36//call of `bar`.37// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \38// RUN:   -analyzer-checker=core,debug.ExprInspection \39// RUN:   -analyzer-config eagerly-assume=false \40// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \41// RUN:   -analyzer-config ctu-dir=%t/ctudir \42// RUN:   -verify=ctu %s \43// RUN:   -analyze-function='baruser(int)' -x c++ \44// RUN:   -analyzer-config ctu-max-nodes-pct=100 \45// RUN:   -analyzer-config ctu-max-nodes-min=100046//Check that the AST file is loaded.47// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \48// RUN:   -analyzer-checker=core,debug.ExprInspection \49// RUN:   -analyzer-config eagerly-assume=false \50// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \51// RUN:   -analyzer-config ctu-dir=%t/ctudir \52// RUN:   -analyze-function='baruser(int)' -x c++ \53// RUN:   -analyzer-config ctu-max-nodes-pct=100 \54// RUN:   -analyzer-config display-ctu-progress=true \55// RUN:   -analyzer-config ctu-max-nodes-min=1000 2>&1 %s | FileCheck %s56// CHECK: CTU loaded AST file57 58void other(); // Defined in the other TU.59 60void baruser(int) {61  other();62  int x = bar();63  (void)(1 / x);64  // ctu-warning@-1{{Division by zero}}65  // stu-warning@-2{{Division by zero}}66  // nonctu-warning@-3{{Division by zero}}67}68