Clang Project

clang_source_code/test/Analysis/cxxnewexpr-callback-inline.cpp
1// RUN: %clang_analyze_cc1 -analyzer-checker=debug.AnalysisOrder -analyzer-config c++-allocator-inlining=true,debug.AnalysisOrder:PreStmtCXXNewExpr=true,debug.AnalysisOrder:PostStmtCXXNewExpr=true,debug.AnalysisOrder:PreCall=true,debug.AnalysisOrder:PostCall=true,debug.AnalysisOrder:NewAllocator=true %s 2>&1 | FileCheck %s
2
3#include "Inputs/system-header-simulator-cxx.h"
4
5namespace std {
6  void *malloc(size_t);
7}
8
9void *operator new(size_t size) { return std::malloc(size); }
10
11struct S {
12  S() {}
13};
14
15void foo();
16
17void test() {
18  S *s = new S();
19  foo();
20}
21
22// CHECK:      PreCall (operator new)
23// CHECK-NEXT: PreCall (std::malloc)
24// CHECK-NEXT: PostCall (std::malloc)
25// CHECK-NEXT: PostCall (operator new)
26// CHECK-NEXT: NewAllocator
27// CHECK-NEXT: PreCall (S::S)
28// CHECK-NEXT: PostCall (S::S)
29// CHECK-NEXT: PreStmt<CXXNewExpr>
30// CHECK-NEXT: PostStmt<CXXNewExpr>
31// CHECK-NEXT: PreCall (foo)
32// CHECK-NEXT: PostCall (foo)
33