Files
clang-p2996/clang/test/Analysis/Checkers/WebKit/uncounted-obj-const-v-muable.cpp
Ryosuke Niwa 91ec9cb960 [alpha.webkit.UncountedCallArgsChecker] Use canonical type (#109393)
This PR fixes a bug in UncountedCallArgsChecker that calling a function
with a member variable which is Ref/RefPtr is erroneously treated as
safe by canoniclizing the type before checking whether it's ref counted
or not.
2024-09-26 22:18:07 -07:00

28 lines
607 B
C++

// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
#include "mock-types.h"
class Object {
public:
void ref() const;
void deref() const;
bool constFunc() const;
void mutableFunc();
};
class Caller {
void someFunction();
void otherFunction();
private:
RefPtr<Object> m_obj;
};
void Caller::someFunction()
{
m_obj->constFunc();
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
m_obj->mutableFunc();
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
}