Updates the check and tests to not diagnose the null case for string_view (but retains it for string). This prevents the check from giving duplicate warnings that are caught by bugprone-stringview-nullptr (D113148).
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
CJ -- please mention "bugprone-stringview-nullptr" explicitly and explain that it will cover those features, etc. so that the description will be clear on its own. Thanks!
clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp | ||
---|---|---|
181–182 | Slightly prefer an early return here: return; |
I'm in 2 minds about this. This diagnostic is a good fit for this warning and shouldn't be removed. Likewise duplicate diagnostics from different checks is annoying. Maybe a better path forward would be to suppress the diagnostic if the bugprone-stringview-nullptr check is enabled. These kinds of intercheck dependencies are found in modernize-prefer-member-init check IIRC. You can just copy the impl from there.
Slightly prefer an early return here:
Filter out basic_string_view to avoid conflicts with
bugprone-stringview-nullptr
if (Result.Nodes.getNodeAs<CXXRecordDecl>("basic_string_view_decl") != nullptr)