Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ bool isPtrConversion(const FunctionDecl *F) {
const auto FunctionName = safeGetName(F);
if (FunctionName == "getPtr" || FunctionName == "WeakPtr" ||
FunctionName == "dynamicDowncast" || FunctionName == "downcast" ||
FunctionName == "checkedDowncast" ||
FunctionName == "checkedDowncast" || FunctionName == "bit_cast" ||
FunctionName == "uncheckedDowncast" || FunctionName == "bitwise_cast" ||
FunctionName == "bridge_cast" || FunctionName == "bridge_id_cast" ||
FunctionName == "dynamic_cf_cast" || FunctionName == "checked_cf_cast" ||
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Analysis/Checkers/WebKit/call-args-checked-ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ namespace param_formarding_function {

namespace casts {

CheckedObj* downcast(CheckedObj*) { return nullptr; }

template<class T>
T* bitwise_cast(T*) { return nullptr; }
CheckedObj* downcast(CheckedObj*);
template<class T> T* bitwise_cast(T*);
template<class T> T* bit_cast(T*);

void foo(CheckedObj* param) {
consume_ref_countable_ptr(downcast(param));
consume_ref_countable_ptr(bitwise_cast(param));
consume_ref_countable_ptr(bit_cast(param));
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions clang/test/Analysis/Checkers/WebKit/call-args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ namespace param_formarding_function {

namespace casts {

RefCountable* downcast(RefCountable*) { return nullptr; }

template<class T>
T* bitwise_cast(T*) { return nullptr; }

void foo(RefCountable* param) {
consume_ref_countable_ptr(downcast(param));
consume_ref_countable_ptr(bitwise_cast(param));
}
RefCountable* downcast(RefCountable*);
template<class T> T* bitwise_cast(T*);
template<class T> T* bit_cast(T*);

void foo(RefCountable* param) {
consume_ref_countable_ptr(downcast(param));
consume_ref_countable_ptr(bitwise_cast(param));
consume_ref_countable_ptr(bit_cast(param));
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ T&& forward(T& arg);
template<typename T>
T&& move( T&& t );

template<typename ToType, typename FromType>
ToType bit_cast(FromType from);

#define offsetof(t, d) __builtin_offsetof(t, d)

} // namespace std
Expand Down Expand Up @@ -386,6 +389,7 @@ class RefCounted {
void trivial68() { point pt = { 1.0 }; }
unsigned trivial69() { return offsetof(OtherObj, children); }
DerivedNumber* trivial70() { [[clang::suppress]] return static_cast<DerivedNumber*>(number); }
unsigned trivial71() { return std::bit_cast<unsigned>(nullptr); }

static RefCounted& singleton() {
static RefCounted s_RefCounted;
Expand Down Expand Up @@ -577,6 +581,7 @@ class UnrelatedClass {
getFieldTrivial().trivial68(); // no-warning
getFieldTrivial().trivial69(); // no-warning
getFieldTrivial().trivial70(); // no-warning
getFieldTrivial().trivial71(); // no-warning

RefCounted::singleton().trivial18(); // no-warning
RefCounted::singleton().someFunction(); // no-warning
Expand Down
Loading