// 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
// RUN: FileCheck --input-file=%t %s
typedef int* intptr;
// This function is modeled and the p pointer is dereferenced in the model
// function and there is no function definition available. The modeled
// function can use any types that are available in the original translation
// unit, for example intptr in this case.
void modeledFunction(intptr p);
// This function is modeled and returns true if the parameter is not zero
// and there is no function definition available.
bool notzero(int i);
// This functions is not modeled and there is no function definition.
// available
bool notzero_notmodeled(int i);
int main() {
// There is a nullpointer dereference inside this function.
modeledFunction(0);
int p = 0;
if (notzero(p)) {
// It is known that p != 0 because of the information provided by the
// model of the notzero function.
int j = 5 / p;
}
if (notzero_notmodeled(p)) {
// There is no information about the value of p, because
// notzero_notmodeled is not modeled and the function definition
// is not available.
int j = 5 / p; // expected-warning {{Division by zero}}
}
return 0;
}
// CHECK: diagnostics
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: path
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: kindcontrol
// CHECK-NEXT: edges
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: start
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line22
// CHECK-NEXT: col3
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line22
// CHECK-NEXT: col17
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: end
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line24
// CHECK-NEXT: col3
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line24
// CHECK-NEXT: col5
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: kindevent
// CHECK-NEXT: location
// CHECK-NEXT:
// CHECK-NEXT: line24
// CHECK-NEXT: col3
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT: ranges
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line24
// CHECK-NEXT: col3
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line24
// CHECK-NEXT: col7
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: depth0
// CHECK-NEXT: extended_message
// CHECK-NEXT: 'p' initialized to 0
// CHECK-NEXT: message
// CHECK-NEXT: 'p' initialized to 0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: kindcontrol
// CHECK-NEXT: edges
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: start
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line24
// CHECK-NEXT: col3
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line24
// CHECK-NEXT: col5
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: end
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line25
// CHECK-NEXT: col3
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line25
// CHECK-NEXT: col4
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: kindcontrol
// CHECK-NEXT: edges
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: start
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line25
// CHECK-NEXT: col3
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line25
// CHECK-NEXT: col4
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: end
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col3
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col4
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: kindcontrol
// CHECK-NEXT: edges
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: start
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col3
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col4
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: end
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col7
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col24
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: kindevent
// CHECK-NEXT: location
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col7
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT: ranges
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col7
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col27
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: depth0
// CHECK-NEXT: extended_message
// CHECK-NEXT: Assuming the condition is true
// CHECK-NEXT: message
// CHECK-NEXT: Assuming the condition is true
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: kindcontrol
// CHECK-NEXT: edges
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: start
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col7
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line31
// CHECK-NEXT: col24
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: end
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line35
// CHECK-NEXT: col15
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line35
// CHECK-NEXT: col15
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: kindevent
// CHECK-NEXT: location
// CHECK-NEXT:
// CHECK-NEXT: line35
// CHECK-NEXT: col15
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT: ranges
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line35
// CHECK-NEXT: col13
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: line35
// CHECK-NEXT: col17
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: depth0
// CHECK-NEXT: extended_message
// CHECK-NEXT: Division by zero
// CHECK-NEXT: message
// CHECK-NEXT: Division by zero
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: descriptionDivision by zero
// CHECK-NEXT: categoryLogic error
// CHECK-NEXT: typeDivision by zero
// CHECK-NEXT: check_namecore.DivideZero
// CHECK-NEXT:
// CHECK-NEXT: issue_hash_content_of_line_in_context86cb845e4f1e6abde1c5b319d5b08eca
// CHECK-NEXT: issue_context_kindfunction
// CHECK-NEXT: issue_contextmain
// CHECK-NEXT: issue_hash_function_offset15
// CHECK-NEXT: location
// CHECK-NEXT:
// CHECK-NEXT: line35
// CHECK-NEXT: col15
// CHECK-NEXT: file0
// CHECK-NEXT:
// CHECK-NEXT:
// CHECK-NEXT: