File tree Expand file tree Collapse file tree 4 files changed +37
-19
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit Expand file tree Collapse file tree 4 files changed +37
-19
lines changed Original file line number Diff line number Diff line change @@ -186,8 +186,7 @@ bool isPtrConversion(const FunctionDecl *F) {
186186 // FIXME: check # of params == 1
187187 const auto FunctionName = safeGetName (F);
188188 if (FunctionName == " getPtr" || FunctionName == " WeakPtr" ||
189- FunctionName == " makeWeakPtr"
190-
189+ FunctionName == " dynamicDowncast"
191190 || FunctionName == " downcast" || FunctionName == " bitwise_cast" )
192191 return true ;
193192
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ class UncountedCallArgsChecker
149149
150150 auto name = safeGetName (Callee);
151151 if (name == " adoptRef" || name == " getPtr" || name == " WeakPtr" ||
152- name == " makeWeakPtr " || name == " downcast" || name == " bitwise_cast" ||
152+ name == " dynamicDowncast " || name == " downcast" || name == " bitwise_cast" ||
153153 name == " is" || name == " equal" || name == " hash" ||
154154 name == " isType"
155155 // FIXME: Most/all of these should be implemented via attributes.
Original file line number Diff line number Diff line change 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+ template <typename Target, typename Source>
27+ inline Target* dynamicDowncast (Source* source)
28+ {
29+ return static_cast <Target*>(source);
30+ }
31+
32+ void foo (OtherObject* other)
33+ {
34+ dynamicDowncast<SubDerived>(other->obj ());
35+ }
Original file line number Diff line number Diff line change @@ -262,22 +262,6 @@ namespace param_forwarding_method {
262262 }
263263}
264264
265- namespace make_ref {
266- void makeRef (RefCountable*) {}
267- void makeRefPtr (RefCountable*) {}
268- void makeWeakPtr (RefCountable*) {}
269- void makeWeakPtr (RefCountable&) {}
270-
271- void foo () {
272- makeRef (provide ());
273- makeRefPtr (provide ());
274- RefPtr<RefCountable> a (provide ());
275- Ref<RefCountable> b (provide ());
276- makeWeakPtr (provide ());
277- makeWeakPtr (*provide ());
278- }
279- }
280-
281265namespace downcast {
282266 void consume_ref_countable (RefCountable*) {}
283267 RefCountable* downcast (RefCountable*) { return nullptr ; }
You can’t perform that action at this time.
0 commit comments