
Main reason for this change is that these checkers were implemented in the same class but had different dependency ordering. (NonNullParamChecker should run before StdCLibraryFunctionArgs to get more special warning about null arguments, but the apiModeling.StdCLibraryFunctions was a modeling checker that should run before other non-modeling checkers. The modeling checker changes state in a way that makes it impossible to detect a null argument by NonNullParamChecker.) To make it more simple, the modeling part is removed as separate checker and can be only used if checker StdCLibraryFunctions is turned on, that produces the warnings too. Modeling the functions without bug detection (for invalid argument) is not possible. The modeling of standard functions does not happen by default from this change on. Reviewed By: Szelethus Differential Revision: https://reviews.llvm.org/D151225
38 lines
2.3 KiB
C++
38 lines
2.3 KiB
C++
// RUN: %clang_analyze_cc1 %s \
|
|
// RUN: -analyzer-checker=core \
|
|
// RUN: -analyzer-checker=alpha.unix.StdCLibraryFunctions \
|
|
// RUN: -analyzer-config alpha.unix.StdCLibraryFunctions:ModelPOSIX=true \
|
|
// RUN: -analyzer-config alpha.unix.StdCLibraryFunctions:DisplayLoadedSummaries=true \
|
|
// RUN: -analyzer-checker=debug.ExprInspection \
|
|
// RUN: -analyzer-config eagerly-assume=false \
|
|
// RUN: -triple i686-unknown-linux 2>&1 | FileCheck %s
|
|
|
|
// We test here that functions from socket.h are added when sockaddr is not a
|
|
// transparent union of other sockaddr_ pointers. This is the case in C++.
|
|
|
|
// CHECK: Loaded summary for: int accept(int socket, struct sockaddr *address, socklen_t *address_len)
|
|
// CHECK: Loaded summary for: int bind(int socket, const struct sockaddr *address, socklen_t address_len)
|
|
// CHECK: Loaded summary for: int getpeername(int socket, struct sockaddr *address, socklen_t *address_len)
|
|
// CHECK: Loaded summary for: int getsockname(int socket, struct sockaddr *address, socklen_t *address_len)
|
|
// CHECK: Loaded summary for: int connect(int socket, const struct sockaddr *address, socklen_t address_len)
|
|
// CHECK: Loaded summary for: ssize_t recvfrom(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len)
|
|
// CHECK: Loaded summary for: ssize_t sendto(int socket, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len)
|
|
|
|
struct sockaddr;
|
|
using socklen_t = unsigned;
|
|
int accept(int socket, struct sockaddr *address, socklen_t *address_len);
|
|
int bind(int socket, const struct sockaddr *address, socklen_t address_len);
|
|
int getpeername(int socket, struct sockaddr *address, socklen_t *address_len);
|
|
int getsockname(int socket, struct sockaddr *address, socklen_t *address_len);
|
|
int connect(int socket, const struct sockaddr *address, socklen_t address_len);
|
|
typedef decltype(sizeof(int)) size_t;
|
|
typedef size_t ssize_t;
|
|
ssize_t recvfrom(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len);
|
|
ssize_t sendto(int socket, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len);
|
|
|
|
// Must have at least one call expression to initialize the summary map.
|
|
int bar(void);
|
|
void foo() {
|
|
bar();
|
|
}
|