Files
clang-p2996/clang/test/Analysis/Checkers/WebKit/ref-countable-default-arg-nullptr.cpp
Ryosuke Niwa 2dbfa8407e [analyzer] Allow default arguments to be evaluated like other arguments. (#80956)
This PR aligns the evaluation of default arguments with other kinds of
arguments by extracting the expressions within them as argument values
to be evaluated.
2024-02-12 15:01:40 -08:00

26 lines
760 B
C++

// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
#include "mock-types.h"
class Obj {
public:
static Obj* get();
static RefPtr<Obj> create();
void ref() const;
void deref() const;
};
void someFunction(Obj*, Obj* = nullptr);
void otherFunction(Obj*, Obj* = Obj::get());
// expected-warning@-1{{Call argument is uncounted and unsafe [alpha.webkit.UncountedCallArgsChecker]}}
void anotherFunction(Obj*, Obj* = Obj::create().get());
void otherFunction() {
someFunction(nullptr);
someFunction(Obj::get());
// expected-warning@-1{{Call argument is uncounted and unsafe [alpha.webkit.UncountedCallArgsChecker]}}
someFunction(Obj::create().get());
otherFunction(nullptr);
anotherFunction(nullptr);
}