aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Analysis/Checkers/WebKit/ref-countable-default-arg-nullptr.cpp
blob: a1860a5434c8643a30e5c5590d45a7549ed3aea2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// 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);
}