Clang Project

clang_source_code/test/Analysis/end-function-return-stmt.cpp
1//RUN: %clang_analyze_cc1 -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:EndFunction=true %s 2>&1 | FileCheck %s
2
3// At the end of a function, we can only obtain a ReturnStmt if the last
4// CFGElement in the CFGBlock is either a CFGStmt or a CFGAutomaticObjDtor.
5
6void noReturnStmt() {}
7
8struct S {
9  S();
10  ~S();
11};
12
13int dtorAfterReturnStmt() {
14  S s;
15  return 0;
16}
17
18S endsWithReturnStmt() {
19  return S();
20}
21
22// endsWithReturnStmt()
23// CHECK:      EndFunction
24// CHECK-NEXT: ReturnStmt: yes
25// CHECK-NEXT: CFGElement: CFGStmt
26
27// dtorAfterReturnStmt()
28// CHECK:      EndFunction
29// CHECK-NEXT: ReturnStmt: yes
30// CHECK-NEXT: CFGElement: CFGAutomaticObjDtor
31
32// noReturnStmt()
33// CHECK:      EndFunction
34// CHECK-NEXT: ReturnStmt: no
35