[PATCH] D127643: [Static Analyzer] Structured bindings to data members

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 1 03:37:24 PDT 2022


Szelethus added a comment.

I read https://en.cppreference.com/w/cpp/language/structured_binding carefully, and there are a number of interesting rules that might deserve their own test case, even if this isn't the patch where you solve that issue, or believe that the solution handles it without the need for special case handling.

Just to name a few, you seem to not have test cases for when the bindings are cv-qualified. If you declare structured bindings like this:

  struct s {
    int a;
    int b;
  };
  
  void a(void) {
    s tst;
  
    auto [i, j](tst); // Syntax (3) according to cppreference
  
    int x = i; // expected-warning{{Assigned value is garbage or undefined}}
  }

then the bindings are direct initialized, not copy initialized.

I'm not sure that the actual standard <https://eel.is/c++draft/dcl.struct.bind#:structured_binding_declaration> has anything that cppreference doesn't, but maybe we could give it a glance.



================
Comment at: clang/test/Analysis/uninit-structured-binding-struct.cpp:10
+
+void a(void) {
+  s tst;
----------------
In the long run, it might make your own life easier to create more talkative test function names, like `testPODDecomp` or smt like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127643



More information about the cfe-commits mailing list