CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
137 lines
6.3 KiB
C++
137 lines
6.3 KiB
C++
// RUN: %clang_analyze_cc1 -std=c++20 -fblocks -verify %s \
|
|
// RUN: -analyzer-checker=core \
|
|
// RUN: -analyzer-checker=debug.AnalysisOrder \
|
|
// RUN: -analyzer-config debug.AnalysisOrder:PreStmtCXXNewExpr=true \
|
|
// RUN: -analyzer-config debug.AnalysisOrder:PostStmtCXXNewExpr=true \
|
|
// RUN: -analyzer-config debug.AnalysisOrder:PreStmtCXXDeleteExpr=true \
|
|
// RUN: -analyzer-config debug.AnalysisOrder:PostStmtCXXDeleteExpr=true \
|
|
// RUN: -analyzer-config debug.AnalysisOrder:PreCall=true \
|
|
// RUN: -analyzer-config debug.AnalysisOrder:PostCall=true \
|
|
// RUN: 2>&1 | FileCheck %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
#include "Inputs/system-header-simulator-cxx.h"
|
|
|
|
void f() {
|
|
// C++20 standard draft 17.6.1.15:
|
|
// Required behavior: A call to an operator delete with a size parameter may
|
|
// be changed to a call to the corresponding operator delete without a size
|
|
// parameter, without affecting memory allocation. [ Note: A conforming
|
|
// implementation is for operator delete(void* ptr, size_t size) to simply
|
|
// call operator delete(ptr). — end note ]
|
|
//
|
|
// C++20 standard draft 17.6.1.24, about nothrow operator delete:
|
|
// void operator delete(void* ptr, const std::nothrow_t&) noexcept;
|
|
// void operator delete(void* ptr, std::align_val_t alignment,
|
|
// const std::nothrow_t&) noexcept;
|
|
// Default behavior: Calls operator delete(ptr), or operator delete(ptr,
|
|
// alignment), respectively.
|
|
|
|
// FIXME: All calls to operator new should be CXXAllocatorCall, and calls to
|
|
// operator delete should be CXXDeallocatorCall.
|
|
{
|
|
int *p = new int;
|
|
delete p;
|
|
// CHECK: PreCall (operator new) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PostCall (operator new) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PreStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PostStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PreStmt<CXXDeleteExpr>
|
|
// CHECK-NEXT: PostStmt<CXXDeleteExpr>
|
|
// CHECK-NEXT: PreCall (operator delete) [CXXDeallocatorCall]
|
|
// CHECK-NEXT: PostCall (operator delete) [CXXDeallocatorCall]
|
|
|
|
p = new int;
|
|
operator delete(p, 23542368);
|
|
// CHECK-NEXT: PreCall (operator new) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PostCall (operator new) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PreStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PostStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PreCall (operator delete) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator delete) [SimpleFunctionCall]
|
|
|
|
void *v = operator new(sizeof(int[2]), std::align_val_t(2));
|
|
operator delete(v, std::align_val_t(2));
|
|
// CHECK-NEXT: PreCall (operator new) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator new) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PreCall (operator delete) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator delete) [SimpleFunctionCall]
|
|
|
|
v = operator new(sizeof(int[2]), std::align_val_t(2));
|
|
operator delete(v, 345345, std::align_val_t(2));
|
|
// CHECK-NEXT: PreCall (operator new) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator new) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PreCall (operator delete) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator delete) [SimpleFunctionCall]
|
|
|
|
p = new (std::nothrow) int;
|
|
operator delete(p, std::nothrow);
|
|
// CHECK-NEXT: PreCall (operator new) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PostCall (operator new) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PreStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PostStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PreCall (operator delete) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator delete) [SimpleFunctionCall]
|
|
|
|
v = operator new(sizeof(int[2]), std::align_val_t(2), std::nothrow);
|
|
operator delete(v, std::align_val_t(2), std::nothrow);
|
|
// CHECK-NEXT: PreCall (operator new) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator new) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PreCall (operator delete) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator delete) [SimpleFunctionCall]
|
|
}
|
|
|
|
{
|
|
int *p = new int[2];
|
|
delete[] p;
|
|
// CHECK-NEXT: PreCall (operator new[]) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PostCall (operator new[]) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PreStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PostStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PreStmt<CXXDeleteExpr>
|
|
// CHECK-NEXT: PostStmt<CXXDeleteExpr>
|
|
// CHECK-NEXT: PreCall (operator delete[]) [CXXDeallocatorCall]
|
|
// CHECK-NEXT: PostCall (operator delete[]) [CXXDeallocatorCall]
|
|
|
|
p = new int[2];
|
|
operator delete[](p, 23542368);
|
|
// CHECK-NEXT: PreCall (operator new[]) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PostCall (operator new[]) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PreStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PostStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PreCall (operator delete[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator delete[]) [SimpleFunctionCall]
|
|
|
|
void *v = operator new[](sizeof(int[2]), std::align_val_t(2));
|
|
operator delete[](v, std::align_val_t(2));
|
|
// CHECK-NEXT: PreCall (operator new[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator new[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PreCall (operator delete[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator delete[]) [SimpleFunctionCall]
|
|
|
|
v = operator new[](sizeof(int[2]), std::align_val_t(2));
|
|
operator delete[](v, 345345, std::align_val_t(2));
|
|
// CHECK-NEXT: PreCall (operator new[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator new[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PreCall (operator delete[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator delete[]) [SimpleFunctionCall]
|
|
|
|
p = new (std::nothrow) int[2];
|
|
operator delete[](p, std::nothrow);
|
|
// CHECK-NEXT: PreCall (operator new[]) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PostCall (operator new[]) [CXXAllocatorCall]
|
|
// CHECK-NEXT: PreStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PostStmt<CXXNewExpr>
|
|
// CHECK-NEXT: PreCall (operator delete[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator delete[]) [SimpleFunctionCall]
|
|
|
|
v = operator new[](sizeof(int[2]), std::align_val_t(2), std::nothrow);
|
|
operator delete[](v, std::align_val_t(2), std::nothrow);
|
|
// CHECK-NEXT: PreCall (operator new[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator new[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PreCall (operator delete[]) [SimpleFunctionCall]
|
|
// CHECK-NEXT: PostCall (operator delete[]) [SimpleFunctionCall]
|
|
}
|
|
}
|