Clang Project

clang_source_code/test/Analysis/temporaries-callback-order.cpp
1// RUN: %clang_cc1 -analyze -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:Bind=true -analyzer-config debug.AnalysisOrder:RegionChanges=true %s 2>&1 | FileCheck %s
2
3struct Super {
4  virtual void m();
5};
6struct Sub : Super {
7  virtual void m() {}
8};
9
10void testTemporaries() {
11  // This triggers RegionChanges once for zero-initialization of the structure.
12  Sub().m();
13}
14
15void seeIfCheckBindWorks() {
16  // This should trigger checkBind. The rest of the code shouldn't.
17  // This also triggers checkRegionChanges after that.
18  // Note that this function is analyzed first, so the messages would be on top.
19  int x = 1;
20}
21
22// seeIfCheckBindWorks():
23// CHECK: Bind
24// CHECK-NEXT: RegionChanges
25
26// testTemporaries():
27// CHECK-NEXT: RegionChanges
28
29// Make sure there's no further output.
30// CHECK-NOT: Bind
31// CHECK-NOT: RegionChanges
32