[clang] [CIR] Upstream GotoOp (PR #153701)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 14 17:26:11 PDT 2025
================
@@ -1649,7 +1649,27 @@ void cir::FuncOp::print(OpAsmPrinter &p) {
// TODO(CIR): The properties of functions that require verification haven't
// been implemented yet.
-mlir::LogicalResult cir::FuncOp::verify() { return success(); }
+mlir::LogicalResult cir::FuncOp::verify() {
+
+ std::set<llvm::StringRef> labels;
+ std::set<llvm::StringRef> gotos;
+
+ getOperation()->walk([&](mlir::Operation *op) {
+ if (auto lab = dyn_cast<cir::LabelOp>(op)) {
+ labels.emplace(lab.getLabel());
+ } else if (auto goTo = dyn_cast<cir::GotoOp>(op)) {
+ gotos.emplace(goTo.getLabel());
+ }
+ });
+
+ std::vector<llvm::StringRef> mismatched;
+ std::set_difference(gotos.begin(), gotos.end(), labels.begin(), labels.end(),
----------------
andykaylor wrote:
If you use SmallSet this becomes
```suggestion
SmallSet<llvm::StringRef, 16> mismatched = llvm::set_difference(gotos, labels));
```
https://github.com/llvm/llvm-project/pull/153701
More information about the cfe-commits
mailing list