irishrover wrote:

> > > ```c++
> > > std::string getArcana(const TemplateName &NNS) { 
> > > return std::string{""}; // no warning, explicit ctor call
> > > return std::string(""); // no warning
> > > }
> > > ```
> > 
> > 
> > It works even w/o options. Just wrap literal with `std::string(...)` or 
> > `std::string{}`. Pls, see the tests:
> > ```c++
> > std::string explicitConstructionEmpty() {
> >   return std::string("");
> > }
> > 
> > std::string explicitConstructionWithInitListEmpty() {
> >   return std::string{""};
> > }
> > ```
> 
> In tests they are marked as "todo" for now,
> 
> ```c++
> std::string explicitConstruction() {
>   // Cannot be std::string_view: returning address of local temporary object
>   // TODO: extract and return literal
>   return std::string("explicitConstruction");
> }
> 
> std::string explicitConstructionWithInitList() {
>   // Cannot be std::string_view: returning address of local temporary object
>   // TODO: extract and return literal
>   return std::string{"explicitConstruction"};
> }
> ```
> 
> When eventually have this is implemented, should become an option. Please 
> state in docs that diagnostic could be suppressed by manually constructing 
> string from literal.
> 
> Also, please state in docs what are current limitations of this check 
> (ternary op, literals inside strings) so that user don't report them as FN.

Done!

https://github.com/llvm/llvm-project/pull/172170
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to