File tree Expand file tree Collapse file tree 4 files changed +19
-14
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit Expand file tree Collapse file tree 4 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -462,7 +462,7 @@ bool isPtrConversion(const FunctionDecl *F) {
462462 const auto FunctionName = safeGetName (F);
463463 if (FunctionName == " getPtr" || FunctionName == " WeakPtr" ||
464464 FunctionName == " dynamicDowncast" || FunctionName == " downcast" ||
465- FunctionName == " checkedDowncast" ||
465+ FunctionName == " checkedDowncast" || FunctionName == " bit_cast " ||
466466 FunctionName == " uncheckedDowncast" || FunctionName == " bitwise_cast" ||
467467 FunctionName == " bridge_cast" || FunctionName == " bridge_id_cast" ||
468468 FunctionName == " dynamic_cf_cast" || FunctionName == " checked_cf_cast" ||
Original file line number Diff line number Diff line change @@ -173,14 +173,14 @@ namespace param_formarding_function {
173173
174174 namespace casts {
175175
176- CheckedObj* downcast (CheckedObj*) { return nullptr ; }
177-
178- template <class T >
179- T* bitwise_cast (T*) { return nullptr ; }
176+ CheckedObj* downcast (CheckedObj*);
177+ template <class T > T* bitwise_cast (T*);
178+ template <class T > T* bit_cast (T*);
180179
181180 void foo (CheckedObj* param) {
182181 consume_ref_countable_ptr (downcast (param));
183182 consume_ref_countable_ptr (bitwise_cast (param));
183+ consume_ref_countable_ptr (bit_cast (param));
184184 }
185185 }
186186}
Original file line number Diff line number Diff line change @@ -173,15 +173,15 @@ namespace param_formarding_function {
173173
174174 namespace casts {
175175
176- RefCountable* downcast (RefCountable*) { return nullptr ; }
177-
178- template <class T >
179- T* bitwise_cast (T*) { return nullptr ; }
180-
181- void foo (RefCountable* param) {
182- consume_ref_countable_ptr (downcast (param));
183- consume_ref_countable_ptr (bitwise_cast (param));
184- }
176+ RefCountable* downcast (RefCountable*);
177+ template < class T > T* bitwise_cast (T*);
178+ template <class T > T* bit_cast (T*);
179+
180+ void foo (RefCountable* param) {
181+ consume_ref_countable_ptr ( downcast ( param));
182+ consume_ref_countable_ptr (bitwise_cast (param));
183+ consume_ref_countable_ptr (bit_cast (param));
184+ }
185185 }
186186}
187187
Original file line number Diff line number Diff line change @@ -77,6 +77,9 @@ T&& forward(T& arg);
7777template <typename T>
7878T&& move( T&& t );
7979
80+ template <typename ToType, typename FromType>
81+ ToType bit_cast (FromType from);
82+
8083#define offsetof (t, d ) __builtin_offsetof(t, d)
8184
8285} // namespace std
@@ -386,6 +389,7 @@ class RefCounted {
386389 void trivial68 () { point pt = { 1.0 }; }
387390 unsigned trivial69 () { return offsetof (OtherObj, children); }
388391 DerivedNumber* trivial70 () { [[clang::suppress]] return static_cast <DerivedNumber*>(number); }
392+ unsigned trivial71 () { return std::bit_cast<unsigned >(nullptr ); }
389393
390394 static RefCounted& singleton () {
391395 static RefCounted s_RefCounted;
@@ -577,6 +581,7 @@ class UnrelatedClass {
577581 getFieldTrivial ().trivial68 (); // no-warning
578582 getFieldTrivial ().trivial69 (); // no-warning
579583 getFieldTrivial ().trivial70 (); // no-warning
584+ getFieldTrivial ().trivial71 (); // no-warning
580585
581586 RefCounted::singleton ().trivial18 (); // no-warning
582587 RefCounted::singleton ().someFunction (); // no-warning
You can’t perform that action at this time.
0 commit comments