18 lines · cpp
1// RUN: %check_clang_tidy %s cppcoreguidelines-no-malloc %t \2// RUN: -config='{CheckOptions: \3// RUN: {cppcoreguidelines-no-malloc.Allocations: "::malloc",\4// RUN: cppcoreguidelines-no-malloc.Reallocations: "",\5// RUN: cppcoreguidelines-no-malloc.Deallocations: ""}}' \6// RUN: --7 8// Just ensure, the check will not crash, when no functions shall be checked.9 10using size_t = __SIZE_TYPE__;11 12void *malloc(size_t size);13 14void malloced_array() {15 int *array0 = (int *)malloc(sizeof(int) * 20);16 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not manage memory manually; consider a container or a smart pointer [cppcoreguidelines-no-malloc]17}18