xref: /llvm-project/clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.cpp (revision cbdc7605edca26ff75a28f080089a835ed9dba92)
1 // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
2 // expected-no-diagnostics
3 
4 class Base {
5 public:
6     inline void ref();
7     inline void deref();
8 };
9 
10 class Derived : public Base {
11 public:
12   virtual ~Derived();
13 
14   void ref() const;
15   void deref() const;
16 };
17 
18 class SubDerived final : public Derived {
19 };
20 
21 class OtherObject {
22 public:
23     Derived* obj();
24 };
25 
26 class String {
27 };
28 
29 template<typename Target, typename Source>
dynamicDowncast(Source * source)30 inline Target* dynamicDowncast(Source* source)
31 {
32     return static_cast<Target*>(source);
33 }
34 
35 template<typename Target, typename Source>
checkedDowncast(Source * source)36 inline Target* checkedDowncast(Source* source)
37 {
38     return static_cast<Target*>(source);
39 }
40 
41 template<typename Target, typename Source>
uncheckedDowncast(Source * source)42 inline Target* uncheckedDowncast(Source* source)
43 {
44     return static_cast<Target*>(source);
45 }
46 
47 template<typename... Types>
48 String toString(const Types&... values);
49 
foo(OtherObject * other)50 void foo(OtherObject* other)
51 {
52     dynamicDowncast<SubDerived>(other->obj());
53     checkedDowncast<SubDerived>(other->obj());
54     uncheckedDowncast<SubDerived>(other->obj());
55     toString(other->obj());
56 }
57