Using LLVM 19.1.7, I encountered a false positive bugprone-throw-keyword-missing from ITK's itkExceptionObject.h, which can be reproduced as follows:
#include <exception>
#include <memory>
class MyException : public std::exception
{
public:
MyException() = default;
private:
class NestedData;
std::shared_ptr<NestedData> m_shared_data{};
};
class Bug : public MyException
{
public:
Bug()
{
// Non-defaulted default constructor.
}
};
Output:
warning: suspicious exception object created but not thrown; did you mean 'throw shared_ptr'? [bugprone-throw-keyword-missing]
10 | std::shared_ptr<NestedData> m_shared_data{};
| ^