brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 44cc561 Raw
34 lines · cpp
1//===- DiagnosedSilenceableFailure.cpp - Tri-state result -----------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file defines the DiagnosedSilenceableFailure class allowing to store10// a tri-state result (definite failure, recoverable failure, success) with an11// optional associated list of diagnostics.12//13//===----------------------------------------------------------------------===//14 15#include "mlir/Dialect/Transform/Utils/DiagnosedSilenceableFailure.h"16 17using namespace mlir;18 19LogicalResult mlir::DiagnosedSilenceableFailure::checkAndReport() {20#if LLVM_ENABLE_ABI_BREAKING_CHECKS21  assert(!reported && "attempting to report a diagnostic more than once");22  reported = true;23#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS24  if (!diagnostics.empty()) {25    for (auto &&diagnostic : diagnostics) {26      diagnostic.getLocation().getContext()->getDiagEngine().emit(27          std::move(diagnostic));28    }29    diagnostics.clear();30    result = ::mlir::failure();31  }32  return result;33}34