Mercurial > hg > CbC > CbC_llvm
comparison clang/test/Analysis/ctu-onego-existingdef.cpp @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 (2022-11-09) |
parents | |
children |
comparison
equal
deleted
inserted
replaced
232:70dce7da266c | 236:c4bab56944e8 |
---|---|
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 %s | |
6 | |
7 // RUN: rm -rf %t && mkdir %t | |
8 // RUN: mkdir -p %t/ctudir | |
9 // 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.cpp | |
11 // RUN: cp %S/Inputs/ctu-onego-existingdef-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt | |
12 | |
13 // Existing and equal function definition in both TU. `other` calls `bar` thus | |
14 // `bar` will be indirectly imported. During the import we recognize that there | |
15 // 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 directly | |
17 // inlinie that as in the case of nonctu. | |
18 // Note, we would not get a warning below, if `bar` is conservatively evaluated. | |
19 int bar() { | |
20 return 0; | |
21 } | |
22 | |
23 //Here we completely supress the CTU work list execution. We should not | |
24 //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=0 | |
34 | |
35 //Here we enable the CTU work list execution. We should not bifurcate on the | |
36 //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=1000 | |
46 //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 %s | |
56 // CHECK: CTU loaded AST file | |
57 | |
58 void other(); // Defined in the other TU. | |
59 | |
60 void 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 } |