nickdesaulniers updated this revision to Diff 540585. nickdesaulniers edited the summary of this revision. nickdesaulniers added a comment.
- reword description Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155342/new/ https://reviews.llvm.org/D155342 Files: clang/lib/Sema/JumpDiagnostics.cpp clang/test/Sema/asm-goto.cpp Index: clang/test/Sema/asm-goto.cpp =================================================================== --- clang/test/Sema/asm-goto.cpp +++ clang/test/Sema/asm-goto.cpp @@ -59,3 +59,13 @@ loop: return 0; } + +void test4cleanup(int*); +// No errors expected. +void test4(void) { + asm goto(""::::l0); +l0:; + int x __attribute__((cleanup(test4cleanup))); + asm goto(""::::l1); +l1:; +} Index: clang/lib/Sema/JumpDiagnostics.cpp =================================================================== --- clang/lib/Sema/JumpDiagnostics.cpp +++ clang/lib/Sema/JumpDiagnostics.cpp @@ -370,7 +370,7 @@ // have it. This makes the second scan not have to walk the AST again. LabelAndGotoScopes[S] = ParentScope; AsmJumps.push_back(GS); - for (auto *E : GS->labels()) + for (AddrLabelExpr *E : GS->labels()) AsmJumpTargets.push_back(E->getLabel()); } break; @@ -788,6 +788,17 @@ // Walk through all the jump sites, checking that they can trivially // reach this label scope. for (auto [JumpScope, JumpStmt] : JumpScopes) { + // 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 && + llvm::none_of(cast<GCCAsmStmt>(JumpStmt)->labels(), + [=](AddrLabelExpr *E) { return E->getLabel() == TL; })) + continue; + unsigned Scope = JumpScope; // Walk out the "scope chain" for this scope, looking for a scope // we've marked reachable. For well-formed code this amortizes
Index: clang/test/Sema/asm-goto.cpp =================================================================== --- clang/test/Sema/asm-goto.cpp +++ clang/test/Sema/asm-goto.cpp @@ -59,3 +59,13 @@ loop: return 0; } + +void test4cleanup(int*); +// No errors expected. +void test4(void) { + asm goto(""::::l0); +l0:; + int x __attribute__((cleanup(test4cleanup))); + asm goto(""::::l1); +l1:; +} Index: clang/lib/Sema/JumpDiagnostics.cpp =================================================================== --- clang/lib/Sema/JumpDiagnostics.cpp +++ clang/lib/Sema/JumpDiagnostics.cpp @@ -370,7 +370,7 @@ // have it. This makes the second scan not have to walk the AST again. LabelAndGotoScopes[S] = ParentScope; AsmJumps.push_back(GS); - for (auto *E : GS->labels()) + for (AddrLabelExpr *E : GS->labels()) AsmJumpTargets.push_back(E->getLabel()); } break; @@ -788,6 +788,17 @@ // Walk through all the jump sites, checking that they can trivially // reach this label scope. for (auto [JumpScope, JumpStmt] : JumpScopes) { + // 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 && + llvm::none_of(cast<GCCAsmStmt>(JumpStmt)->labels(), + [=](AddrLabelExpr *E) { return E->getLabel() == TL; })) + continue; + unsigned Scope = JumpScope; // Walk out the "scope chain" for this scope, looking for a scope // we've marked reachable. For well-formed code this amortizes
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits