Memory leaks 为什么;字段“指出的内存潜在泄漏”;关于工厂查询表

Memory leaks 为什么;字段“指出的内存潜在泄漏”;关于工厂查询表,memory-leaks,c++17,static-analysis,Memory Leaks,C++17,Static Analysis,我试图实现一个工厂,它创建由公共基类字段继承的类型的新实例 工厂建模为工厂函数的查找表,这些函数返回唯一的\u ptr。查找表的键类型是字符串视图 在工厂函数中,我为请求的类型调用make_unique clang analyzer抱怨在返回唯一的\u ptr时可能存在内存泄漏 具有单个可用工厂条目的工厂查找表 使用FieldFactory=std::function; 静态常量std::无序映射fieldFactoryLut={ {“static text”sv,[](auto const&n

我试图实现一个工厂,它创建由公共基类字段继承的类型的新实例

工厂建模为工厂函数的查找表,这些函数返回唯一的\u ptr。查找表的键类型是字符串视图

在工厂函数中,我为请求的类型调用make_unique

clang analyzer抱怨在返回唯一的\u ptr时可能存在内存泄漏

具有单个可用工厂条目的工厂查找表

使用FieldFactory=std::function(node const&,Clf const&)>;
静态常量std::无序映射fieldFactoryLut={
{“static text”sv,[](auto const&node,auto const&parent){return std::make_unique(node,parent);}
};
用法

auto const&factoryFun=fieldFactoryLut.at(“静态文本”sv);
自动升级=factoryFun(节点,clf);
通过调用make_unique,我预计不会出现内存泄漏,但clang analyzer声称:

warning: Potential leak of memory pointed to by field '_M_head_impl' [clang-analyzer-cplusplus.NewDeleteLeaks]
[build]     {"static-text"sv, []( auto const& node, auto const& parent ) { return std::make_unique< StaticTextField >( node, parent ); }}
警告:字段“\M\u head\u impl”[clang analyzer cplusplus.NewDeleteLeaks]指向的内存可能泄漏
[build]{“static text”sv,[](auto const&node,auto const&parent){return std::make_unique(node,parent);}

有人能告诉我这里的clang是什么吗?

您使用的是哪个clang版本?我无法用版本7或版本8重新编程。你能提供一个锁销链接吗?我运行了clang 7.0.0.3附带的scan-build-7,你使用的是哪个clang版本?我无法用版本7或版本8重新编程。你能提供一个锁销链接吗?我运行了随clang 7.0.0.3提供的scan-build-7