Skip to content

False positive clang-analyzer-cplusplus.NewDelete for QWeakPointer when using -isystem flagsΒ #62985

@timxx

Description

@timxx

For the following example code, run the Clang-Tidy as clang-tidy foo.cpp -- -isystem /usr/include/qt/QtCore/ -I/usr/include/qt/ (Suppose the Qt 5 headers installed at /usr/include/qt)

#include <QWeakPointer>

void test(const QWeakPointer<QObject>& p)
{
	QWeakPointer<QObject> t;
	t = p;
}

The following warning generated

1 warning generated.
/usr/include/qt/QtCore/qsharedpointer_impl.h:159:50: warning: Use of memory after it is freed [clang-analyzer-cplusplus.NewDelete]
        inline void operator delete(void *ptr) { ::operator delete(ptr); }
                                                 ^

It's strange when using -I instead of -isystem, it won't report this problem, which is expected (Even using -header-filter=.*).

It can be reproduce on Windows platform too.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions