[PATCH] D155342: [clang][JumpDiagnostics] ignore non-asm goto target scopes

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 15 05:23:55 PDT 2023


cor3ntin added a comment.

Thanks a lot for working on this.
This probably needs a release note entry



================
Comment at: clang/lib/Sema/JumpDiagnostics.cpp:790
     // reach this label scope.
     for (auto [JumpScope, JumpStmt] : JumpScopes) {
+      // This unnecessary copy is because:
----------------
We don't need to make 3 copies!


================
Comment at: clang/lib/Sema/JumpDiagnostics.cpp:791-800
+      // This unnecessary copy is because:
+      // warning: captured structured bindings are a C++20 extension
+      // [-Wc++20-extensions]
+      LabelDecl *TL = TargetLabel;
+      // Is TargetLabel one of the targets of the JumpStmt? If not, then skip
+      // it.
+      if (IsAsmGoto &&
----------------
I don't think the pointer adds that much, you can init capture by copy which simplifies a bit 


================
Comment at: clang/test/Sema/asm-goto.cpp:71
+l1:;
+}
----------------
can you add more tests? Maybe something like that

```cpp
void f() {
  try{
    __label__ label;
    asm goto("" : : : : label);
    label:;
  }
  catch(...){
    __label__ label;
    asm goto("" : : : : label);
    label:;
  };
  if constexpr(false) {
    __label__ label;
    asm goto("" : : : : label);
    label:;
  }
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155342



More information about the cfe-commits mailing list