[PATCH] D121120: [clang-tidy] New check for safe usage of `std::optional` and like types.

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 5 10:30:26 PDT 2022


xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Overall this looks good to me. However, I think this might not use the full potential of the check itself. With the information that the dataflow framework have it could distinguish between **potentially** unsafe accesses and **provably** unsafe accesses depending on whether the `has_value` property is constrained to be false. From the user point of view, it would be nice to emit different warning messages for the above two cases. This can help to gradually introduce this check to a larger codebase and focus on the higher severity diagnostics first.



================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-unchecked-optional-access.rst:29
+
+Checking if a value exists, then accessing the value
+----------------------------------------------------
----------------
I wonder if it would be easier to read if we had two top level categories, one for safe and one for unsafe accesses instead of switching back and forth between examples.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121120



More information about the cfe-commits mailing list