CJ-Johnson added inline comments.

================
Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp:84
+
+    (void)(std::string_view({nullptr})) /* a3 */;
+    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing 
basic_string_view from null is undefined; replace with the default constructor
----------------
CJ-Johnson wrote:
> aaron.ballman wrote:
> > This (and many others) also generates `-Wbraced-scalar-init`, is that 
> > intentional?
> My goal was just to be thorough in the cases tested. It's not an endorsement 
> of the source patterns. :)
As a followup to this: I've added additional test cases and a minor change to 
the AST matchers to catch another form of the `-Wbraced-scalar-init` pattern.

This: `accepts_string_view({{}});`

This pattern will select the `const CharT*` constructor overload and then 
value-initialize the argument, causing a null deref. It happens to not include 
the `nullptr` literal but it has the exact same effect as 
`accepts_string_view(nullptr);` and `accepts_string_view({nullptr});`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113148/new/

https://reviews.llvm.org/D113148

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to