[PATCH] D148418: [clang-tidy] Fix typedefs handling in bugprone-dangling-handle

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 15 03:22:34 PDT 2023


carlosgalvezp accepted this revision.
carlosgalvezp added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp:55-56
 
-  operator basic_string_view() const noexcept;
+  typedef basic_string_view str_view;
+  operator str_view() const noexcept;
 
----------------
PiotrZSL wrote:
> carlosgalvezp wrote:
> > Right now the test will no longer test classes that have the conversion operator written explicitly instead of via typedef. Do you think it's worth keeping the other implementation as well, or can we safely assume that `basic_string` is always implemented like this?
> Both GCC (__sv_type) & Clang (__self_view) implement this using typedef.
> But code will work fine also without typedef.
> 
> But code will work fine also without typedef.

I guess we can't know if this will hold in the future unless we have an explicit test for it :) But I agree it's probably unlikely and if we had implemented this from scratch copying the pattern from GCC or Clang directly we would have ended up with this result.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148418



More information about the cfe-commits mailing list