llvm-project/clang/test/Analysis/Checkers/WebKit/template-wrapper-call-arg.cpp
Ryosuke Niwa 50da22a9f4
[alpha.webkit.UncountedCallArgsChecker] A return value can be erroneously treated as unsafe if it's a template parameter (#157993)
When a template class takes Ref<T> as a template parameter and this
template parameter is used as the return value of a member function, the
return value can be treated as unsafe (i.e. emits a false positive). The
issue was caused by getCanonicalType sometimes converting Ref<T> to T.
Workaround this problem by avoid emitting a warning when the original,
non-canonical type is a safe pointer type.
2025-09-11 15:51:02 -07:00

22 lines
372 B
C++

// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
// expected-no-diagnostics
#include "mock-types.h"
struct Obj {
void ref() const;
void deref() const;
void someFunction();
};
template<typename T> class Wrapper {
public:
T obj();
};
static void foo(Wrapper<Ref<Obj>>&& wrapper)
{
wrapper.obj()->someFunction();
}