55 lines · cpp
1// RUN: rm -rf %t && mkdir %t2// RUN: mkdir -p %t/ctudir3// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \4// RUN: -emit-pch -o %t/ctudir/ctu-onego-toplevel-other.cpp.ast %S/Inputs/ctu-onego-toplevel-other.cpp5// RUN: cp %S/Inputs/ctu-onego-toplevel-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt6 7// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \8// RUN: -analyzer-checker=core,debug.ExprInspection \9// RUN: -analyzer-config eagerly-assume=false \10// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \11// RUN: -analyzer-config ctu-dir=%t/ctudir \12// RUN: -analyzer-config ctu-phase1-inlining=none \13// RUN: -verify=ctu %s14 15// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \16// RUN: -analyzer-checker=core,debug.ExprInspection \17// RUN: -analyzer-config eagerly-assume=false \18// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \19// RUN: -analyzer-config ctu-dir=%t/ctudir \20// RUN: -analyzer-config ctu-phase1-inlining=none \21// RUN: -analyzer-config display-ctu-progress=true \22// RUN: -analyzer-display-progress \23// RUN: -verify=ctu %s 2>&1 | FileCheck %s24 25// CallGraph: c->b26// topological sort: c, b27// Note that `other` calls into `b` but that is not visible in the CallGraph28// because that happens in another TU.29 30// During the onego CTU analysis, we start with c() as top level function.31// Then we visit b() as non-toplevel during the processing of the FWList, thus32// that would not be visited as toplevel without special care.33 34// `c` is analyzed as toplevel and during that the other TU is loaded:35// CHECK: ANALYZE (Path, Inline_Regular): {{.*}} c(int){{.*}}CTU loaded AST file36// next, `b` is analyzed as toplevel:37// CHECK: ANALYZE (Path, Inline_Regular): {{.*}} b(int)38 39void b(int x);40void other(int y);41void c(int y) {42 other(y);43 return;44 // The below call is here to form the proper CallGraph, but will not be45 // analyzed.46 b(1);47}48 49void b(int x) {50 if (x == 0)51 (void)(1 / x);52 // ctu-warning@-1{{Division by zero}}53 // We receive the above warning only if `b` is analyzed as top-level.54}55