/home/arjun/llvm-project/mlir/include/mlir/IR/Diagnostics.h
| Line | Count | Source (jump to first uncovered line) | 
| 1 |  | //===- Diagnostics.h - MLIR Diagnostics -------------------------*- C++ -*-===// | 
| 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-exception | 
| 6 |  | // | 
| 7 |  | //===----------------------------------------------------------------------===// | 
| 8 |  | // | 
| 9 |  | // This file defines utilities for emitting diagnostics. | 
| 10 |  | // | 
| 11 |  | //===----------------------------------------------------------------------===// | 
| 12 |  |  | 
| 13 |  | #ifndef MLIR_IR_DIAGNOSTICS_H | 
| 14 |  | #define MLIR_IR_DIAGNOSTICS_H | 
| 15 |  |  | 
| 16 |  | #include "mlir/IR/Location.h" | 
| 17 |  | #include <functional> | 
| 18 |  |  | 
| 19 |  | namespace llvm { | 
| 20 |  | class MemoryBuffer; | 
| 21 |  | class SMLoc; | 
| 22 |  | class SourceMgr; | 
| 23 |  | } // end namespace llvm | 
| 24 |  |  | 
| 25 |  | namespace mlir { | 
| 26 |  | class DiagnosticEngine; | 
| 27 |  | class Identifier; | 
| 28 |  | struct LogicalResult; | 
| 29 |  | class MLIRContext; | 
| 30 |  | class Operation; | 
| 31 |  | class OperationName; | 
| 32 |  | class Type; | 
| 33 |  |  | 
| 34 |  | namespace detail { | 
| 35 |  | struct DiagnosticEngineImpl; | 
| 36 |  | } // end namespace detail | 
| 37 |  |  | 
| 38 |  | /// Defines the different supported severity of a diagnostic. | 
| 39 |  | enum class DiagnosticSeverity { | 
| 40 |  |   Note, | 
| 41 |  |   Warning, | 
| 42 |  |   Error, | 
| 43 |  |   Remark, | 
| 44 |  | }; | 
| 45 |  |  | 
| 46 |  | //===----------------------------------------------------------------------===// | 
| 47 |  | // DiagnosticArgument | 
| 48 |  | //===----------------------------------------------------------------------===// | 
| 49 |  |  | 
| 50 |  | /// A variant type that holds a single argument for a diagnostic. | 
| 51 |  | class DiagnosticArgument { | 
| 52 |  | public: | 
| 53 |  |   /// Enum that represents the different kinds of diagnostic arguments | 
| 54 |  |   /// supported. | 
| 55 |  |   enum class DiagnosticArgumentKind { | 
| 56 |  |     Attribute, | 
| 57 |  |     Double, | 
| 58 |  |     Integer, | 
| 59 |  |     String, | 
| 60 |  |     Type, | 
| 61 |  |     Unsigned, | 
| 62 |  |   }; | 
| 63 |  |  | 
| 64 |  |   /// Outputs this argument to a stream. | 
| 65 |  |   void print(raw_ostream &os) const; | 
| 66 |  |  | 
| 67 |  |   /// Returns the kind of this argument. | 
| 68 | 0 |   DiagnosticArgumentKind getKind() const { return kind; } | 
| 69 |  |  | 
| 70 |  |   /// Returns this argument as an Attribute. | 
| 71 |  |   Attribute getAsAttribute() const; | 
| 72 |  |  | 
| 73 |  |   /// Returns this argument as a double. | 
| 74 | 0 |   double getAsDouble() const { | 
| 75 | 0 |     assert(getKind() == DiagnosticArgumentKind::Double); | 
| 76 | 0 |     return doubleVal; | 
| 77 | 0 |   } | 
| 78 |  |  | 
| 79 |  |   /// Returns this argument as a signed integer. | 
| 80 | 0 |   int64_t getAsInteger() const { | 
| 81 | 0 |     assert(getKind() == DiagnosticArgumentKind::Integer); | 
| 82 | 0 |     return static_cast<int64_t>(opaqueVal); | 
| 83 | 0 |   } | 
| 84 |  |  | 
| 85 |  |   /// Returns this argument as a string. | 
| 86 | 0 |   StringRef getAsString() const { | 
| 87 | 0 |     assert(getKind() == DiagnosticArgumentKind::String); | 
| 88 | 0 |     return stringVal; | 
| 89 | 0 |   } | 
| 90 |  |  | 
| 91 |  |   /// Returns this argument as a Type. | 
| 92 |  |   Type getAsType() const; | 
| 93 |  |  | 
| 94 |  |   /// Returns this argument as an unsigned integer. | 
| 95 | 0 |   uint64_t getAsUnsigned() const { | 
| 96 | 0 |     assert(getKind() == DiagnosticArgumentKind::Unsigned); | 
| 97 | 0 |     return static_cast<uint64_t>(opaqueVal); | 
| 98 | 0 |   } | 
| 99 |  |  | 
| 100 |  | private: | 
| 101 |  |   friend class Diagnostic; | 
| 102 |  |  | 
| 103 |  |   // Construct from an Attribute. | 
| 104 |  |   explicit DiagnosticArgument(Attribute attr); | 
| 105 |  |  | 
| 106 |  |   // Construct from a floating point number. | 
| 107 |  |   explicit DiagnosticArgument(double val) | 
| 108 | 0 |       : kind(DiagnosticArgumentKind::Double), doubleVal(val) {} | 
| 109 | 0 |   explicit DiagnosticArgument(float val) : DiagnosticArgument(double(val)) {} | 
| 110 |  |  | 
| 111 |  |   // Construct from a signed integer. | 
| 112 |  |   template <typename T> | 
| 113 |  |   explicit DiagnosticArgument( | 
| 114 |  |       T val, typename std::enable_if<std::is_signed<T>::value && | 
| 115 |  |                                      std::numeric_limits<T>::is_integer && | 
| 116 |  |                                      sizeof(T) <= sizeof(int64_t)>::type * = 0) | 
| 117 | 0 |       : kind(DiagnosticArgumentKind::Integer), opaqueVal(int64_t(val)) {} | 
| 118 |  |  | 
| 119 |  |   // Construct from an unsigned integer. | 
| 120 |  |   template <typename T> | 
| 121 |  |   explicit DiagnosticArgument( | 
| 122 |  |       T val, typename std::enable_if<std::is_unsigned<T>::value && | 
| 123 |  |                                      std::numeric_limits<T>::is_integer && | 
| 124 |  |                                      sizeof(T) <= sizeof(uint64_t)>::type * = 0) | 
| 125 | 0 |       : kind(DiagnosticArgumentKind::Unsigned), opaqueVal(uint64_t(val)) {}Unexecuted instantiation: _ZN4mlir18DiagnosticArgumentC2IjEET_PNSt9enable_ifIXaaaasr3std11is_unsignedIS2_EE5valuesr3std14numeric_limitsIS2_EE10is_integerlestS2_Lm8EEvE4typeEUnexecuted instantiation: _ZN4mlir18DiagnosticArgumentC2ImEET_PNSt9enable_ifIXaaaasr3std11is_unsignedIS2_EE5valuesr3std14numeric_limitsIS2_EE10is_integerlestS2_Lm8EEvE4typeE | 
| 126 |  |  | 
| 127 |  |   // Construct from a string reference. | 
| 128 |  |   explicit DiagnosticArgument(StringRef val) | 
| 129 | 0 |       : kind(DiagnosticArgumentKind::String), stringVal(val) {} | 
| 130 |  |  | 
| 131 |  |   // Construct from a Type. | 
| 132 |  |   explicit DiagnosticArgument(Type val); | 
| 133 |  |  | 
| 134 |  |   /// The kind of this argument. | 
| 135 |  |   DiagnosticArgumentKind kind; | 
| 136 |  |  | 
| 137 |  |   /// The value of this argument. | 
| 138 |  |   union { | 
| 139 |  |     double doubleVal; | 
| 140 |  |     intptr_t opaqueVal; | 
| 141 |  |     StringRef stringVal; | 
| 142 |  |   }; | 
| 143 |  | }; | 
| 144 |  |  | 
| 145 | 0 | inline raw_ostream &operator<<(raw_ostream &os, const DiagnosticArgument &arg) { | 
| 146 | 0 |   arg.print(os); | 
| 147 | 0 |   return os; | 
| 148 | 0 | } | 
| 149 |  |  | 
| 150 |  | //===----------------------------------------------------------------------===// | 
| 151 |  | // Diagnostic | 
| 152 |  | //===----------------------------------------------------------------------===// | 
| 153 |  |  | 
| 154 |  | /// This class contains all of the information necessary to report a diagnostic | 
| 155 |  | /// to the DiagnosticEngine. It should generally not be constructed directly, | 
| 156 |  | /// and instead used transitively via InFlightDiagnostic. | 
| 157 |  | class Diagnostic { | 
| 158 |  |   using NoteVector = std::vector<std::unique_ptr<Diagnostic>>; | 
| 159 |  |  | 
| 160 |  |   /// This class implements a wrapper iterator around NoteVector::iterator to | 
| 161 |  |   /// implicitly dereference the unique_ptr. | 
| 162 |  |   template <typename IteratorTy, typename NotePtrTy = decltype(*IteratorTy()), | 
| 163 |  |             typename ResultTy = decltype(**IteratorTy())> | 
| 164 |  |   class NoteIteratorImpl | 
| 165 |  |       : public llvm::mapped_iterator<IteratorTy, ResultTy (*)(NotePtrTy)> { | 
| 166 | 0 |     static ResultTy &unwrap(NotePtrTy note) { return *note; }Unexecuted instantiation: _ZN4mlir10Diagnostic16NoteIteratorImplIN9__gnu_cxx17__normal_iteratorIPSt10unique_ptrIS0_St14default_deleteIS0_EESt6vectorIS7_SaIS7_EEEERS7_RS0_E6unwrapESD_Unexecuted instantiation: _ZN4mlir10Diagnostic16NoteIteratorImplIN9__gnu_cxx17__normal_iteratorIPKSt10unique_ptrIS0_St14default_deleteIS0_EESt6vectorIS7_SaIS7_EEEERS8_RS0_E6unwrapESE_ | 
| 167 |  |  | 
| 168 |  |   public: | 
| 169 |  |     NoteIteratorImpl(IteratorTy it) | 
| 170 |  |         : llvm::mapped_iterator<IteratorTy, ResultTy (*)(NotePtrTy)>(it, | 
| 171 | 0 |                                                                      &unwrap) {} | 
| 172 |  |   }; | 
| 173 |  |  | 
| 174 |  | public: | 
| 175 |  |   Diagnostic(Location loc, DiagnosticSeverity severity) | 
| 176 | 0 |       : loc(loc), severity(severity) {} | 
| 177 | 0 |   Diagnostic(Diagnostic &&) = default; | 
| 178 | 0 |   Diagnostic &operator=(Diagnostic &&) = default; | 
| 179 |  |  | 
| 180 |  |   /// Returns the severity of this diagnostic. | 
| 181 | 0 |   DiagnosticSeverity getSeverity() const { return severity; } | 
| 182 |  |  | 
| 183 |  |   /// Returns the source location for this diagnostic. | 
| 184 | 0 |   Location getLocation() const { return loc; } | 
| 185 |  |  | 
| 186 |  |   /// Returns the current list of diagnostic arguments. | 
| 187 | 0 |   MutableArrayRef<DiagnosticArgument> getArguments() { return arguments; } | 
| 188 | 0 |   ArrayRef<DiagnosticArgument> getArguments() const { return arguments; } | 
| 189 |  |  | 
| 190 |  |   /// Stream operator for inserting new diagnostic arguments. | 
| 191 |  |   template <typename Arg> | 
| 192 |  |   typename std::enable_if<!std::is_convertible<Arg, StringRef>::value, | 
| 193 |  |                           Diagnostic &>::type | 
| 194 | 0 |   operator<<(Arg &&val) { | 
| 195 | 0 |     arguments.push_back(DiagnosticArgument(std::forward<Arg>(val))); | 
| 196 | 0 |     return *this; | 
| 197 | 0 |   } Unexecuted instantiation: _ZN4mlir10DiagnosticlsImEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS3_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIRjEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS4_Unexecuted instantiation: _ZN4mlir10DiagnosticlsINS_4TypeEEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS4_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIRNS_9AttributeEEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS5_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIRKNS_4TypeEEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS6_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIRNS_10MemRefTypeEEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS5_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIRlEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS4_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIRNS_4TypeEEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS5_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIjEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS3_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIRNS_10StringAttrEEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS5_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIRmEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS4_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIRNS_10TensorTypeEEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS5_Unexecuted instantiation: _ZN4mlir10DiagnosticlsIRKjEENSt9enable_ifIXntsr3std14is_convertibleIT_N4llvm9StringRefEEE5valueERS0_E4typeEOS5_ | 
| 198 |  |  | 
| 199 |  |   /// Stream in a string literal. | 
| 200 | 0 |   Diagnostic &operator<<(const char *val) { | 
| 201 | 0 |     arguments.push_back(DiagnosticArgument(val)); | 
| 202 | 0 |     return *this; | 
| 203 | 0 |   } | 
| 204 |  |  | 
| 205 |  |   /// Stream in a Twine argument. | 
| 206 |  |   Diagnostic &operator<<(char val); | 
| 207 |  |   Diagnostic &operator<<(const Twine &val); | 
| 208 |  |   Diagnostic &operator<<(Twine &&val); | 
| 209 |  |  | 
| 210 |  |   /// Stream in an Identifier. | 
| 211 |  |   Diagnostic &operator<<(Identifier val); | 
| 212 |  |  | 
| 213 |  |   /// Stream in an OperationName. | 
| 214 |  |   Diagnostic &operator<<(OperationName val); | 
| 215 |  |  | 
| 216 |  |   /// Stream in an Operation. | 
| 217 |  |   Diagnostic &operator<<(Operation &val); | 
| 218 | 0 |   Diagnostic &operator<<(Operation *val) { | 
| 219 | 0 |     return *this << *val; | 
| 220 | 0 |   } | 
| 221 |  |  | 
| 222 |  |   /// Stream in a range. | 
| 223 |  |   template <typename T> Diagnostic &operator<<(iterator_range<T> range) { | 
| 224 |  |     return appendRange(range); | 
| 225 |  |   } | 
| 226 |  |   template <typename T> Diagnostic &operator<<(ArrayRef<T> range) { | 
| 227 |  |     return appendRange(range); | 
| 228 |  |   } | 
| 229 |  |  | 
| 230 |  |   /// Append a range to the diagnostic. The default delimiter between elements | 
| 231 |  |   /// is ','. | 
| 232 |  |   template <typename T, template <typename> class Container> | 
| 233 |  |   Diagnostic &appendRange(const Container<T> &c, const char *delim = ", ") { | 
| 234 |  |     llvm::interleave( | 
| 235 |  |         c, [this](const auto &a) { *this << a; }, [&]() { *this << delim; }); | 
| 236 |  |     return *this; | 
| 237 |  |   } | 
| 238 |  |  | 
| 239 |  |   /// Append arguments to the diagnostic. | 
| 240 |  |   template <typename Arg1, typename Arg2, typename... Args> | 
| 241 | 0 |   Diagnostic &append(Arg1 &&arg1, Arg2 &&arg2, Args &&... args) { | 
| 242 | 0 |     append(std::forward<Arg1>(arg1)); | 
| 243 | 0 |     return append(std::forward<Arg2>(arg2), std::forward<Args>(args)...); | 
| 244 | 0 |   } Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA31_KcN4llvm9StringRefEJRA2_S2_EEERS0_OT_OT0_DpOT1_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIN4llvm9StringRefERA2_KcJEEERS0_OT_OT0_DpOT1_ | 
| 245 |  |   /// Append one argument to the diagnostic. | 
| 246 | 0 |   template <typename Arg> Diagnostic &append(Arg &&arg) { | 
| 247 | 0 |     *this << std::forward<Arg>(arg); | 
| 248 | 0 |     return *this; | 
| 249 | 0 |   } Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRN4llvm9StringRefEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA2_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRKN4llvm5TwineEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA46_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendImEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA33_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA23_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA26_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRjEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA25_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendINS_4TypeEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA62_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA66_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA45_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA28_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA56_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA12_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIN4llvm9StringRefEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA32_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA18_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA38_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA30_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRNS_9AttributeEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA43_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA24_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA3_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRKNS_4TypeEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA49_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA77_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA11_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRNS_10MemRefTypeEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA16_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA8_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRlEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIPKcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA20_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA70_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA34_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRNS_4TypeEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA19_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIjEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA10_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA29_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA41_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA52_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA39_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA61_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA54_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA71_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA31_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRNS_10StringAttrEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRmEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA36_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA44_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA42_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA74_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA85_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA53_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA83_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA92_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA103_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRNS_10TensorTypeEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA50_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRNS_10IdentifierEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA37_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA27_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendINS_13OperationNameEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA6_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA22_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA9_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA17_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRKjEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIN4llvm5TwineEEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA5_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA60_KcEERS0_OT_Unexecuted instantiation: _ZN4mlir10Diagnostic6appendIRA75_KcEERS0_OT_ | 
| 250 |  |  | 
| 251 |  |   /// Outputs this diagnostic to a stream. | 
| 252 |  |   void print(raw_ostream &os) const; | 
| 253 |  |  | 
| 254 |  |   /// Converts the diagnostic to a string. | 
| 255 |  |   std::string str() const; | 
| 256 |  |  | 
| 257 |  |   /// Attaches a note to this diagnostic. A new location may be optionally | 
| 258 |  |   /// provided, if not, then the location defaults to the one specified for this | 
| 259 |  |   /// diagnostic. Notes may not be attached to other notes. | 
| 260 |  |   Diagnostic &attachNote(Optional<Location> noteLoc = llvm::None); | 
| 261 |  |  | 
| 262 |  |   using note_iterator = NoteIteratorImpl<NoteVector::iterator>; | 
| 263 |  |   using const_note_iterator = NoteIteratorImpl<NoteVector::const_iterator>; | 
| 264 |  |  | 
| 265 |  |   /// Returns the notes held by this diagnostic. | 
| 266 | 0 |   iterator_range<note_iterator> getNotes() { | 
| 267 | 0 |     return {notes.begin(), notes.end()}; | 
| 268 | 0 |   } | 
| 269 | 0 |   iterator_range<const_note_iterator> getNotes() const { | 
| 270 | 0 |     return {notes.begin(), notes.end()}; | 
| 271 | 0 |   } | 
| 272 |  |  | 
| 273 |  |   /// Allow a diagnostic to be converted to 'failure'. | 
| 274 |  |   operator LogicalResult() const; | 
| 275 |  |  | 
| 276 |  | private: | 
| 277 |  |   Diagnostic(const Diagnostic &rhs) = delete; | 
| 278 |  |   Diagnostic &operator=(const Diagnostic &rhs) = delete; | 
| 279 |  |  | 
| 280 |  |   /// The source location. | 
| 281 |  |   Location loc; | 
| 282 |  |  | 
| 283 |  |   /// The severity of this diagnostic. | 
| 284 |  |   DiagnosticSeverity severity; | 
| 285 |  |  | 
| 286 |  |   /// The current list of arguments. | 
| 287 |  |   SmallVector<DiagnosticArgument, 4> arguments; | 
| 288 |  |  | 
| 289 |  |   /// A list of string values used as arguments. This is used to guarantee the | 
| 290 |  |   /// liveness of non-constant strings used in diagnostics. | 
| 291 |  |   std::vector<std::unique_ptr<char[]>> strings; | 
| 292 |  |  | 
| 293 |  |   /// A list of attached notes. | 
| 294 |  |   NoteVector notes; | 
| 295 |  | }; | 
| 296 |  |  | 
| 297 | 0 | inline raw_ostream &operator<<(raw_ostream &os, const Diagnostic &diag) { | 
| 298 | 0 |   diag.print(os); | 
| 299 | 0 |   return os; | 
| 300 | 0 | } | 
| 301 |  |  | 
| 302 |  | //===----------------------------------------------------------------------===// | 
| 303 |  | // InFlightDiagnostic | 
| 304 |  | //===----------------------------------------------------------------------===// | 
| 305 |  |  | 
| 306 |  | /// This class represents a diagnostic that is inflight and set to be reported. | 
| 307 |  | /// This allows for last minute modifications of the diagnostic before it is | 
| 308 |  | /// emitted by a DiagnosticEngine. | 
| 309 |  | class InFlightDiagnostic { | 
| 310 |  | public: | 
| 311 |  |   InFlightDiagnostic() = default; | 
| 312 |  |   InFlightDiagnostic(InFlightDiagnostic &&rhs) | 
| 313 | 0 |       : owner(rhs.owner), impl(std::move(rhs.impl)) { | 
| 314 | 0 |     // Reset the rhs diagnostic. | 
| 315 | 0 |     rhs.impl.reset(); | 
| 316 | 0 |     rhs.abandon(); | 
| 317 | 0 |   } | 
| 318 | 0 |   ~InFlightDiagnostic() { | 
| 319 | 0 |     if (isInFlight()) | 
| 320 | 0 |       report(); | 
| 321 | 0 |   } | 
| 322 |  |  | 
| 323 |  |   /// Stream operator for new diagnostic arguments. | 
| 324 | 0 |   template <typename Arg> InFlightDiagnostic &operator<<(Arg &&arg) & { | 
| 325 | 0 |     return append(std::forward<Arg>(arg)); | 
| 326 | 0 |   } | 
| 327 | 0 |   template <typename Arg> InFlightDiagnostic &&operator<<(Arg &&arg) && { | 
| 328 | 0 |     return std::move(append(std::forward<Arg>(arg))); | 
| 329 | 0 |   } Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRN4llvm9StringRefEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA2_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRKN4llvm5TwineEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA46_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsImEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA33_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA23_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA26_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRjEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA25_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsINS_4TypeEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA62_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA66_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA45_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA28_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA56_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA12_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIN4llvm9StringRefEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA32_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA18_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA38_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA30_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRNS_9AttributeEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA43_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA24_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA3_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRKNS_4TypeEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA49_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA77_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA11_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRNS_10MemRefTypeEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA16_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA8_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRlEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIPKcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA20_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA70_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA34_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRNS_4TypeEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA19_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIjEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA10_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA29_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA41_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA52_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA39_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA61_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA54_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA71_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA31_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRNS_10StringAttrEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRmEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA36_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA44_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA42_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA74_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA85_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA53_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA83_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA92_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA103_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRNS_10TensorTypeEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA50_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRNS_10IdentifierEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA37_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA27_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsINS_13OperationNameEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA6_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA22_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA9_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA17_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRKjEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIN4llvm5TwineEEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA5_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA60_KcEEOS0_OT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnosticlsIRA75_KcEEOS0_OT_ | 
| 330 |  |  | 
| 331 |  |   /// Append arguments to the diagnostic. | 
| 332 | 0 |   template <typename... Args> InFlightDiagnostic &append(Args &&... args) & { | 
| 333 | 0 |     assert(isActive() && "diagnostic not active"); | 
| 334 | 0 |     if (isInFlight()) | 
| 335 | 0 |       impl->append(std::forward<Args>(args)...); | 
| 336 | 0 |     return *this; | 
| 337 | 0 |   } Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRN4llvm9StringRefEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA2_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRKN4llvm5TwineEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA46_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJmEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA33_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA23_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA26_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRjEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA25_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJNS_4TypeEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA62_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA66_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA45_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA28_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA56_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA12_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJN4llvm9StringRefEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA32_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA18_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA38_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA30_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRNS_9AttributeEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA43_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA24_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA3_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRKNS_4TypeEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA49_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA77_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA11_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRNS_10MemRefTypeEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA16_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA8_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRlEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJPKcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA20_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA70_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA34_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRNS_4TypeEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA19_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJjEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA10_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA29_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA41_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA52_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA39_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA61_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA54_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA71_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA31_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRNS_10StringAttrEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRmEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA36_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA44_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA42_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA74_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA85_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA53_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA83_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA92_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA103_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRNS_10TensorTypeEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA50_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRNS_10IdentifierEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA37_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA27_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJNS_13OperationNameEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA6_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA22_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA9_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA17_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRKjEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJN4llvm5TwineEEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA5_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA60_KcEEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA31_KcN4llvm9StringRefERA2_S2_EEERS0_DpOT_Unexecuted instantiation: _ZNR4mlir18InFlightDiagnostic6appendIJRA75_KcEEERS0_DpOT_ | 
| 338 | 0 |   template <typename... Args> InFlightDiagnostic &&append(Args &&... args) && { | 
| 339 | 0 |     return std::move(append(std::forward<Args>(args)...)); | 
| 340 | 0 |   } Unexecuted instantiation: _ZNO4mlir18InFlightDiagnostic6appendIJRA28_KcEEEOS0_DpOT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnostic6appendIJRA20_KcEEEOS0_DpOT_Unexecuted instantiation: _ZNO4mlir18InFlightDiagnostic6appendIJRA31_KcN4llvm9StringRefERA2_S2_EEEOS0_DpOT_ | 
| 341 |  |  | 
| 342 |  |   /// Attaches a note to this diagnostic. | 
| 343 | 0 |   Diagnostic &attachNote(Optional<Location> noteLoc = llvm::None) { | 
| 344 | 0 |     assert(isActive() && "diagnostic not active"); | 
| 345 | 0 |     return impl->attachNote(noteLoc); | 
| 346 | 0 |   } | 
| 347 |  |  | 
| 348 |  |   /// Reports the diagnostic to the engine. | 
| 349 |  |   void report(); | 
| 350 |  |  | 
| 351 |  |   /// Abandons this diagnostic so that it will no longer be reported. | 
| 352 |  |   void abandon(); | 
| 353 |  |  | 
| 354 |  |   /// Allow an inflight diagnostic to be converted to 'failure', otherwise | 
| 355 |  |   /// 'success' if this is an empty diagnostic. | 
| 356 |  |   operator LogicalResult() const; | 
| 357 |  |  | 
| 358 |  | private: | 
| 359 |  |   InFlightDiagnostic &operator=(const InFlightDiagnostic &) = delete; | 
| 360 |  |   InFlightDiagnostic &operator=(InFlightDiagnostic &&) = delete; | 
| 361 |  |   InFlightDiagnostic(DiagnosticEngine *owner, Diagnostic &&rhs) | 
| 362 | 0 |       : owner(owner), impl(std::move(rhs)) {} | 
| 363 |  |  | 
| 364 |  |   /// Returns if the diagnostic is still active, i.e. it has a live diagnostic. | 
| 365 | 0 |   bool isActive() const { return impl.hasValue(); } | 
| 366 |  |  | 
| 367 |  |   /// Returns if the diagnostic is still in flight to be reported. | 
| 368 | 0 |   bool isInFlight() const { return owner; } | 
| 369 |  |  | 
| 370 |  |   // Allow access to the constructor. | 
| 371 |  |   friend DiagnosticEngine; | 
| 372 |  |  | 
| 373 |  |   /// The engine that this diagnostic is to report to. | 
| 374 |  |   DiagnosticEngine *owner = nullptr; | 
| 375 |  |  | 
| 376 |  |   /// The raw diagnostic that is inflight to be reported. | 
| 377 |  |   Optional<Diagnostic> impl; | 
| 378 |  | }; | 
| 379 |  |  | 
| 380 |  | //===----------------------------------------------------------------------===// | 
| 381 |  | // DiagnosticEngine | 
| 382 |  | //===----------------------------------------------------------------------===// | 
| 383 |  |  | 
| 384 |  | /// This class is the main interface for diagnostics. The DiagnosticEngine | 
| 385 |  | /// manages the registration of diagnostic handlers as well as the core API for | 
| 386 |  | /// diagnostic emission. This class should not be constructed directly, but | 
| 387 |  | /// instead interfaced with via an MLIRContext instance. | 
| 388 |  | class DiagnosticEngine { | 
| 389 |  | public: | 
| 390 |  |   ~DiagnosticEngine(); | 
| 391 |  |  | 
| 392 |  |   // Diagnostic handler registration and use. MLIR supports the ability for the | 
| 393 |  |   // IR to carry arbitrary metadata about operation location information. If a | 
| 394 |  |   // problem is detected by the compiler, it can invoke the emitError / | 
| 395 |  |   // emitWarning / emitRemark method on an Operation and have it get reported | 
| 396 |  |   // through this interface. | 
| 397 |  |   // | 
| 398 |  |   // Tools using MLIR are encouraged to register error handlers and define a | 
| 399 |  |   // schema for their location information.  If they don't, then warnings and | 
| 400 |  |   // notes will be dropped and errors will be emitted to errs. | 
| 401 |  |  | 
| 402 |  |   /// The handler type for MLIR diagnostics. This function takes a diagnostic as | 
| 403 |  |   /// input, and returns success if the handler has fully processed this | 
| 404 |  |   /// diagnostic. Returns failure otherwise. | 
| 405 |  |   using HandlerTy = std::function<LogicalResult(Diagnostic &)>; | 
| 406 |  |  | 
| 407 |  |   /// A handle to a specific registered handler object. | 
| 408 |  |   using HandlerID = uint64_t; | 
| 409 |  |  | 
| 410 |  |   /// Register a new handler for diagnostics to the engine. Diagnostics are | 
| 411 |  |   /// process by handlers in stack-like order, meaning that the last added | 
| 412 |  |   /// handlers will process diagnostics first. This function returns a unique | 
| 413 |  |   /// identifier for the registered handler, which can be used to unregister | 
| 414 |  |   /// this handler at a later time. | 
| 415 |  |   HandlerID registerHandler(const HandlerTy &handler); | 
| 416 |  |  | 
| 417 |  |   /// Set the diagnostic handler with a function that returns void. This is a | 
| 418 |  |   /// convenient wrapper for handlers that always completely process the given | 
| 419 |  |   /// diagnostic. | 
| 420 |  |   template <typename FuncTy, typename RetT = decltype(std::declval<FuncTy>()( | 
| 421 |  |                                  std::declval<Diagnostic &>()))> | 
| 422 |  |   std::enable_if_t<std::is_same<RetT, void>::value, HandlerID> | 
| 423 | 0 |   registerHandler(FuncTy &&handler) { | 
| 424 | 0 |     return registerHandler([=](Diagnostic &diag) { | 
| 425 | 0 |       handler(diag); | 
| 426 | 0 |       return success(); | 
| 427 | 0 |     }); Unexecuted instantiation: Diagnostics.cpp:_ZZN4mlir16DiagnosticEngine15registerHandlerIZNS_26SourceMgrDiagnosticHandlerC1ERN4llvm9SourceMgrEPNS_11MLIRContextERNS3_11raw_ostreamEE3$_0vEENSt9enable_ifIXsr3std7is_sameIT0_vEE5valueEmE4typeEOT_ENKUlRNS_10DiagnosticEE_clESI_Unexecuted instantiation: Diagnostics.cpp:_ZZN4mlir16DiagnosticEngine15registerHandlerIZNS_34SourceMgrDiagnosticVerifierHandlerC1ERN4llvm9SourceMgrEPNS_11MLIRContextERNS3_11raw_ostreamEE3$_1vEENSt9enable_ifIXsr3std7is_sameIT0_vEE5valueEmE4typeEOT_ENKUlRNS_10DiagnosticEE_clESI_ | 
| 428 | 0 |   } Unexecuted instantiation: Diagnostics.cpp:_ZN4mlir16DiagnosticEngine15registerHandlerIZNS_26SourceMgrDiagnosticHandlerC1ERN4llvm9SourceMgrEPNS_11MLIRContextERNS3_11raw_ostreamEE3$_0vEENSt9enable_ifIXsr3std7is_sameIT0_vEE5valueEmE4typeEOT_Unexecuted instantiation: Diagnostics.cpp:_ZN4mlir16DiagnosticEngine15registerHandlerIZNS_34SourceMgrDiagnosticVerifierHandlerC1ERN4llvm9SourceMgrEPNS_11MLIRContextERNS3_11raw_ostreamEE3$_1vEENSt9enable_ifIXsr3std7is_sameIT0_vEE5valueEmE4typeEOT_ | 
| 429 |  |  | 
| 430 |  |   /// Erase the registered diagnostic handler with the given identifier. | 
| 431 |  |   void eraseHandler(HandlerID id); | 
| 432 |  |  | 
| 433 |  |   /// Create a new inflight diagnostic with the given location and severity. | 
| 434 | 0 |   InFlightDiagnostic emit(Location loc, DiagnosticSeverity severity) { | 
| 435 | 0 |     assert(severity != DiagnosticSeverity::Note && | 
| 436 | 0 |            "notes should not be emitted directly"); | 
| 437 | 0 |     return InFlightDiagnostic(this, Diagnostic(loc, severity)); | 
| 438 | 0 |   } | 
| 439 |  |  | 
| 440 |  |   /// Emit a diagnostic using the registered issue handler if present, or with | 
| 441 |  |   /// the default behavior if not. | 
| 442 |  |   void emit(Diagnostic diag); | 
| 443 |  |  | 
| 444 |  | private: | 
| 445 |  |   friend class MLIRContextImpl; | 
| 446 |  |   DiagnosticEngine(); | 
| 447 |  |  | 
| 448 |  |   /// The internal implementation of the DiagnosticEngine. | 
| 449 |  |   std::unique_ptr<detail::DiagnosticEngineImpl> impl; | 
| 450 |  | }; | 
| 451 |  |  | 
| 452 |  | /// Utility method to emit an error message using this location. | 
| 453 |  | InFlightDiagnostic emitError(Location loc); | 
| 454 |  | InFlightDiagnostic emitError(Location loc, const Twine &message); | 
| 455 |  |  | 
| 456 |  | /// Utility method to emit a warning message using this location. | 
| 457 |  | InFlightDiagnostic emitWarning(Location loc); | 
| 458 |  | InFlightDiagnostic emitWarning(Location loc, const Twine &message); | 
| 459 |  |  | 
| 460 |  | /// Utility method to emit a remark message using this location. | 
| 461 |  | InFlightDiagnostic emitRemark(Location loc); | 
| 462 |  | InFlightDiagnostic emitRemark(Location loc, const Twine &message); | 
| 463 |  |  | 
| 464 |  | /// Overloads of the above emission functions that take an optionally null | 
| 465 |  | /// location. If the location is null, no diagnostic is emitted and a failure is | 
| 466 |  | /// returned. Given that the provided location may be null, these methods take | 
| 467 |  | /// the diagnostic arguments directly instead of relying on the returned | 
| 468 |  | /// InFlightDiagnostic. | 
| 469 |  | template <typename... Args> | 
| 470 | 0 | LogicalResult emitOptionalError(Optional<Location> loc, Args &&... args) { | 
| 471 | 0 |   if (loc) | 
| 472 | 0 |     return emitError(*loc).append(std::forward<Args>(args)...); | 
| 473 | 0 |   return failure(); | 
| 474 | 0 | } Unexecuted instantiation: _ZN4mlir17emitOptionalErrorIJRA28_KcEEENS_13LogicalResultEN4llvm8OptionalINS_8LocationEEEDpOT_Unexecuted instantiation: _ZN4mlir17emitOptionalErrorIJRA20_KcEEENS_13LogicalResultEN4llvm8OptionalINS_8LocationEEEDpOT_ | 
| 475 |  | template <typename... Args> | 
| 476 |  | LogicalResult emitOptionalWarning(Optional<Location> loc, Args &&... args) { | 
| 477 |  |   if (loc) | 
| 478 |  |     return emitWarning(*loc).append(std::forward<Args>(args)...); | 
| 479 |  |   return failure(); | 
| 480 |  | } | 
| 481 |  | template <typename... Args> | 
| 482 |  | LogicalResult emitOptionalRemark(Optional<Location> loc, Args &&... args) { | 
| 483 |  |   if (loc) | 
| 484 |  |     return emitRemark(*loc).append(std::forward<Args>(args)...); | 
| 485 |  |   return failure(); | 
| 486 |  | } | 
| 487 |  |  | 
| 488 |  | //===----------------------------------------------------------------------===// | 
| 489 |  | // ScopedDiagnosticHandler | 
| 490 |  | //===----------------------------------------------------------------------===// | 
| 491 |  |  | 
| 492 |  | /// This diagnostic handler is a simple RAII class that registers and erases a | 
| 493 |  | /// diagnostic handler on a given context. This class can be either be used | 
| 494 |  | /// directly, or in conjunction with a derived diagnostic handler. | 
| 495 |  | class ScopedDiagnosticHandler { | 
| 496 |  | public: | 
| 497 | 0 |   explicit ScopedDiagnosticHandler(MLIRContext *ctx) : handlerID(0), ctx(ctx) {} | 
| 498 |  |   template <typename FuncTy> | 
| 499 |  |   ScopedDiagnosticHandler(MLIRContext *ctx, FuncTy &&handler) | 
| 500 |  |       : handlerID(0), ctx(ctx) { | 
| 501 |  |     setHandler(std::forward<FuncTy>(handler)); | 
| 502 |  |   } | 
| 503 |  |   ~ScopedDiagnosticHandler(); | 
| 504 |  |  | 
| 505 |  | protected: | 
| 506 |  |   /// Set the handler to manage via RAII. | 
| 507 | 0 |   template <typename FuncTy> void setHandler(FuncTy &&handler) { | 
| 508 | 0 |     auto &diagEngine = ctx->getDiagEngine(); | 
| 509 | 0 |     if (handlerID) | 
| 510 | 0 |       diagEngine.eraseHandler(handlerID); | 
| 511 | 0 |     handlerID = diagEngine.registerHandler(std::forward<FuncTy>(handler)); | 
| 512 | 0 |   } Unexecuted instantiation: Diagnostics.cpp:_ZN4mlir23ScopedDiagnosticHandler10setHandlerIZNS_26SourceMgrDiagnosticHandlerC1ERN4llvm9SourceMgrEPNS_11MLIRContextERNS3_11raw_ostreamEE3$_0EEvOT_Unexecuted instantiation: Diagnostics.cpp:_ZN4mlir23ScopedDiagnosticHandler10setHandlerIZNS_34SourceMgrDiagnosticVerifierHandlerC1ERN4llvm9SourceMgrEPNS_11MLIRContextERNS3_11raw_ostreamEE3$_1EEvOT_ | 
| 513 |  |  | 
| 514 |  | private: | 
| 515 |  |   /// The unique id for the scoped handler. | 
| 516 |  |   DiagnosticEngine::HandlerID handlerID; | 
| 517 |  |  | 
| 518 |  |   /// The context to erase the handler from. | 
| 519 |  |   MLIRContext *ctx; | 
| 520 |  | }; | 
| 521 |  |  | 
| 522 |  | //===----------------------------------------------------------------------===// | 
| 523 |  | // SourceMgrDiagnosticHandler | 
| 524 |  | //===----------------------------------------------------------------------===// | 
| 525 |  |  | 
| 526 |  | namespace detail { | 
| 527 |  | struct SourceMgrDiagnosticHandlerImpl; | 
| 528 |  | } // end namespace detail | 
| 529 |  |  | 
| 530 |  | /// This class is a utility diagnostic handler for use with llvm::SourceMgr. | 
| 531 |  | class SourceMgrDiagnosticHandler : public ScopedDiagnosticHandler { | 
| 532 |  | public: | 
| 533 |  |   SourceMgrDiagnosticHandler(llvm::SourceMgr &mgr, MLIRContext *ctx, | 
| 534 |  |                              raw_ostream &os); | 
| 535 |  |   SourceMgrDiagnosticHandler(llvm::SourceMgr &mgr, MLIRContext *ctx); | 
| 536 |  |   ~SourceMgrDiagnosticHandler(); | 
| 537 |  |  | 
| 538 |  |   /// Emit the given diagnostic information with the held source manager. | 
| 539 |  |   void emitDiagnostic(Location loc, Twine message, DiagnosticSeverity kind, | 
| 540 |  |                       bool displaySourceLine = true); | 
| 541 |  |  | 
| 542 |  | protected: | 
| 543 |  |   /// Emit the given diagnostic with the held source manager. | 
| 544 |  |   void emitDiagnostic(Diagnostic &diag); | 
| 545 |  |  | 
| 546 |  |   /// Get a memory buffer for the given file, or nullptr if no file is | 
| 547 |  |   /// available. | 
| 548 |  |   const llvm::MemoryBuffer *getBufferForFile(StringRef filename); | 
| 549 |  |  | 
| 550 |  |   /// The source manager that we are wrapping. | 
| 551 |  |   llvm::SourceMgr &mgr; | 
| 552 |  |  | 
| 553 |  |   /// The output stream to use when printing diagnostics. | 
| 554 |  |   raw_ostream &os; | 
| 555 |  |  | 
| 556 |  | private: | 
| 557 |  |   /// Convert a location into the given memory buffer into an SMLoc. | 
| 558 |  |   llvm::SMLoc convertLocToSMLoc(FileLineColLoc loc); | 
| 559 |  |  | 
| 560 |  |   /// The maximum depth that a call stack will be printed. | 
| 561 |  |   /// TODO(riverriddle) This should be a tunable flag. | 
| 562 |  |   unsigned callStackLimit = 10; | 
| 563 |  |  | 
| 564 |  |   std::unique_ptr<detail::SourceMgrDiagnosticHandlerImpl> impl; | 
| 565 |  | }; | 
| 566 |  |  | 
| 567 |  | //===----------------------------------------------------------------------===// | 
| 568 |  | // SourceMgrDiagnosticVerifierHandler | 
| 569 |  | //===----------------------------------------------------------------------===// | 
| 570 |  |  | 
| 571 |  | namespace detail { | 
| 572 |  | struct SourceMgrDiagnosticVerifierHandlerImpl; | 
| 573 |  | } // end namespace detail | 
| 574 |  |  | 
| 575 |  | /// This class is a utility diagnostic handler for use with llvm::SourceMgr that | 
| 576 |  | /// verifies that emitted diagnostics match 'expected-*' lines on the | 
| 577 |  | /// corresponding line of the source file. | 
| 578 |  | class SourceMgrDiagnosticVerifierHandler : public SourceMgrDiagnosticHandler { | 
| 579 |  | public: | 
| 580 |  |   SourceMgrDiagnosticVerifierHandler(llvm::SourceMgr &srcMgr, MLIRContext *ctx, | 
| 581 |  |                                      raw_ostream &out); | 
| 582 |  |   SourceMgrDiagnosticVerifierHandler(llvm::SourceMgr &srcMgr, MLIRContext *ctx); | 
| 583 |  |   ~SourceMgrDiagnosticVerifierHandler(); | 
| 584 |  |  | 
| 585 |  |   /// Returns the status of the handler and verifies that all expected | 
| 586 |  |   /// diagnostics were emitted. This return success if all diagnostics were | 
| 587 |  |   /// verified correctly, failure otherwise. | 
| 588 |  |   LogicalResult verify(); | 
| 589 |  |  | 
| 590 |  | private: | 
| 591 |  |   /// Process a single diagnostic. | 
| 592 |  |   void process(Diagnostic &diag); | 
| 593 |  |  | 
| 594 |  |   /// Process a FileLineColLoc diagnostic. | 
| 595 |  |   void process(FileLineColLoc loc, StringRef msg, DiagnosticSeverity kind); | 
| 596 |  |  | 
| 597 |  |   std::unique_ptr<detail::SourceMgrDiagnosticVerifierHandlerImpl> impl; | 
| 598 |  | }; | 
| 599 |  |  | 
| 600 |  | //===----------------------------------------------------------------------===// | 
| 601 |  | // ParallelDiagnosticHandler | 
| 602 |  | //===----------------------------------------------------------------------===// | 
| 603 |  |  | 
| 604 |  | namespace detail { | 
| 605 |  | struct ParallelDiagnosticHandlerImpl; | 
| 606 |  | } // end namespace detail | 
| 607 |  |  | 
| 608 |  | /// This class is a utility diagnostic handler for use when multi-threading some | 
| 609 |  | /// part of the compiler where diagnostics may be emitted. This handler ensures | 
| 610 |  | /// a deterministic ordering to the emitted diagnostics that mirrors that of a | 
| 611 |  | /// single-threaded compilation. | 
| 612 |  | class ParallelDiagnosticHandler { | 
| 613 |  | public: | 
| 614 |  |   ParallelDiagnosticHandler(MLIRContext *ctx); | 
| 615 |  |   ~ParallelDiagnosticHandler(); | 
| 616 |  |  | 
| 617 |  |   /// Set the order id for the current thread. This is required to be set by | 
| 618 |  |   /// each thread that will be emitting diagnostics to this handler. The orderID | 
| 619 |  |   /// corresponds to the order in which diagnostics would be emitted when | 
| 620 |  |   /// executing synchronously. For example, if we were processing a list | 
| 621 |  |   /// of operations [a, b, c] on a single-thread. Diagnostics emitted while | 
| 622 |  |   /// processing operation 'a' would be emitted before those for 'b' or 'c'. | 
| 623 |  |   /// This corresponds 1-1 with the 'orderID'. The thread that is processing 'a' | 
| 624 |  |   /// should set the orderID to '0'; the thread processing 'b' should set it to | 
| 625 |  |   /// '1'; and so on and so forth. This provides a way for the handler to | 
| 626 |  |   /// deterministically order the diagnostics that it receives given the thread | 
| 627 |  |   /// that it is receiving on. | 
| 628 |  |   void setOrderIDForThread(size_t orderID); | 
| 629 |  |  | 
| 630 |  |   /// Remove the order id for the current thread. This removes the thread from | 
| 631 |  |   /// diagnostics tracking. | 
| 632 |  |   void eraseOrderIDForThread(); | 
| 633 |  |  | 
| 634 |  | private: | 
| 635 |  |   std::unique_ptr<detail::ParallelDiagnosticHandlerImpl> impl; | 
| 636 |  | }; | 
| 637 |  | } // namespace mlir | 
| 638 |  |  | 
| 639 |  | #endif |