brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 743c5ad Raw
51 lines · cpp
1// RUN: %clang_analyze_cc1 %s \2// RUN:  -analyzer-checker=debug.AnalysisOrder \3// RUN:  -analyzer-config debug.AnalysisOrder:EvalCall=true \4// RUN:  -analyzer-config debug.AnalysisOrder:PreCall=true \5// RUN:  -analyzer-config debug.AnalysisOrder:PostCall=true \6// RUN:  2>&1 | FileCheck %s7 8// This test ensures that eval::Call event will be triggered for constructors.9 10class C {11public:12  C(){};13  C(int x){};14  C(int x, int y){};15};16 17void foo() {18  C C0;19  C C1(42);20  C *C2 = new C{2, 3};21  delete C2;22}23 24// CHECK:  PreCall (C::C) [CXXConstructorCall]25// CHECK-NEXT:  EvalCall (C::C) {argno: 0} [CXXConstructorCall]26// CHECK-NEXT:  PostCall (C::C) [CXXConstructorCall]27 28// CHECK-NEXT:  PreCall (C::C) [CXXConstructorCall]29// CHECK-NEXT:  EvalCall (C::C) {argno: 1} [CXXConstructorCall]30// CHECK-NEXT:  PostCall (C::C) [CXXConstructorCall]31 32// CHECK-NEXT:  PreCall (operator new) [CXXAllocatorCall]33//    COMMENT: Operator new calls (CXXNewExpr) are intentionally not eval-called,34//    COMMENT: because it does not make sense to eval call user-provided functions.35//    COMMENT: 1) If the new operator can be inlined, then don't prevent it from36//    COMMENT:    inlining by having an eval-call of that operator.37//    COMMENT: 2) If it can't be inlined, then the default conservative modeling38//    COMMENT:    is what we anyways want anyway.39//    COMMENT: So the EvalCall event will not be triggered for operator new calls.40// CHECK-NOT:   EvalCall41// CHECK-NEXT:  PostCall (operator new) [CXXAllocatorCall]42 43// CHECK-NEXT:  PreCall (C::C) [CXXConstructorCall]44// CHECK-NEXT:  EvalCall (C::C) {argno: 2} [CXXConstructorCall]45// CHECK-NEXT:  PostCall (C::C) [CXXConstructorCall]46 47// CHECK-NEXT: PreCall (operator delete) [CXXDeallocatorCall]48//    COMMENT: Same reasoning as for CXXNewExprs above.49// CHECK-NOT:  EvalCall50// CHECK-NEXT: PostCall (operator delete) [CXXDeallocatorCall]51