[PATCH] D113148: Add new clang-tidy check for string_view(nullptr)

CJ Johnson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 4 15:15:29 PDT 2021


CJ-Johnson marked an inline comment as done.
CJ-Johnson added a comment.

Thanks for the additional info, @aaron.ballman! I had not considered the issues with duplicate warnings. I agree that it would be annoying for users. That being the case, the second option ("remove the string_view nullptr checking functionality from bugprone-string-constructor so it only lives in the new check") sounds the most appealing to me, personally.



================
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
----------------
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. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113148



More information about the cfe-commits mailing list