Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / model-file.cpp
blob3a8322075bbb27494c6c5a0db42833e68582664b
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config faux-bodies=true,model-path=%S/Inputs/Models -analyzer-output=plist-multi-file -verify %s -o %t
2 // RUN: %normalize_plist <%t | diff -ub %S/Inputs/expected-plists/model-file.cpp.plist -
4 typedef int* intptr;
6 // This function is modeled and the p pointer is dereferenced in the model
7 // function and there is no function definition available. The modeled
8 // function can use any types that are available in the original translation
9 // unit, for example intptr in this case.
10 void modeledFunction(intptr p);
12 // This function is modeled and returns true if the parameter is not zero
13 // and there is no function definition available.
14 bool notzero(int i);
16 // This functions is not modeled and there is no function definition.
17 // available
18 bool notzero_notmodeled(int i);
20 int main() {
21 // There is a nullpointer dereference inside this function.
22 modeledFunction(0);
24 int p = 0;
25 if (notzero(p)) {
26 // It is known that p != 0 because of the information provided by the
27 // model of the notzero function.
28 int j = 5 / p;
31 if (notzero_notmodeled(p)) {
32 // There is no information about the value of p, because
33 // notzero_notmodeled is not modeled and the function definition
34 // is not available.
35 int j = 5 / p; // expected-warning {{Division by zero}}
38 return 0;