-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[analyzer] WebKit checkers: recognize dynamicDowncast as a safe funct…
…ion. It can take raw pointers without triggering a warning. Also retire the support for makeRef and makeWeakPtr as they have been removed from WebKit.
- Loading branch information
Showing
4 changed files
with
37 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
clang/test/Analysis/Checkers/WebKit/call-args-dynamic-downcast.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s | ||
// expected-no-diagnostics | ||
|
||
class Base { | ||
public: | ||
inline void ref(); | ||
inline void deref(); | ||
}; | ||
|
||
class Derived : public Base { | ||
public: | ||
virtual ~Derived(); | ||
|
||
void ref() const; | ||
void deref() const; | ||
}; | ||
|
||
class SubDerived final : public Derived { | ||
}; | ||
|
||
class OtherObject { | ||
public: | ||
Derived* obj(); | ||
}; | ||
|
||
template<typename Target, typename Source> | ||
inline Target* dynamicDowncast(Source* source) | ||
{ | ||
return static_cast<Target*>(source); | ||
} | ||
|
||
void foo(OtherObject* other) | ||
{ | ||
dynamicDowncast<SubDerived>(other->obj()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters