From 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 19 Jan 2019 10:04:05 +0000 Subject: Vendor import of clang trunk r351319 (just before the release_80 branch point): https://llvm.org/svn/llvm-project/cfe/trunk@351319 --- test/Analysis/end-function-return-stmt.cpp | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/Analysis/end-function-return-stmt.cpp (limited to 'test/Analysis/end-function-return-stmt.cpp') diff --git a/test/Analysis/end-function-return-stmt.cpp b/test/Analysis/end-function-return-stmt.cpp new file mode 100644 index 000000000000..036ccba3aa93 --- /dev/null +++ b/test/Analysis/end-function-return-stmt.cpp @@ -0,0 +1,34 @@ +//RUN: %clang_analyze_cc1 -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:EndFunction=true %s 2>&1 | FileCheck %s + +// At the end of a function, we can only obtain a ReturnStmt if the last +// CFGElement in the CFGBlock is either a CFGStmt or a CFGAutomaticObjDtor. + +void noReturnStmt() {} + +struct S { + S(); + ~S(); +}; + +int dtorAfterReturnStmt() { + S s; + return 0; +} + +S endsWithReturnStmt() { + return S(); +} + +// endsWithReturnStmt() +// CHECK: EndFunction +// CHECK-NEXT: ReturnStmt: yes +// CHECK-NEXT: CFGElement: CFGStmt + +// dtorAfterReturnStmt() +// CHECK: EndFunction +// CHECK-NEXT: ReturnStmt: yes +// CHECK-NEXT: CFGElement: CFGAutomaticObjDtor + +// noReturnStmt() +// CHECK: EndFunction +// CHECK-NEXT: ReturnStmt: no -- cgit v1.3