From: Nicolas Vasilache Date: Sat, 14 Dec 2019 01:16:19 +0000 (-0800) Subject: Reconcile struct and class for NestedPatternMatchers - NFC X-Git-Tag: llvmorg-11-init~1466^2~73 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ef15a80d2b0647e62771b5adc6e6f639e58f8b3;p=platform%2Fupstream%2Fllvm.git Reconcile struct and class for NestedPatternMatchers - NFC This removes a warning and fixes a potential ABI issue on Windows. PiperOrigin-RevId: 285502010 --- diff --git a/mlir/include/mlir/Analysis/NestedMatcher.h b/mlir/include/mlir/Analysis/NestedMatcher.h index dd4022a..9af26e8 100644 --- a/mlir/include/mlir/Analysis/NestedMatcher.h +++ b/mlir/include/mlir/Analysis/NestedMatcher.h @@ -24,7 +24,7 @@ namespace mlir { -struct NestedPattern; +class NestedPattern; class Operation; /// An NestedPattern captures nested patterns in the IR. @@ -52,7 +52,8 @@ class Operation; /// A NestedMatch contains an Operation* and the children NestedMatch and is /// thus cheap to copy. NestedMatch is stored in a scoped bumper allocator whose /// lifetime is managed by an RAII NestedPatternContext. -struct NestedMatch { +class NestedMatch { +public: static NestedMatch build(Operation *operation, ArrayRef nestedMatches); NestedMatch(const NestedMatch &) = default; @@ -64,8 +65,8 @@ struct NestedMatch { ArrayRef getMatchedChildren() { return matchedChildren; } private: - friend struct NestedPattern; - friend struct NestedPatternContext; + friend class NestedPattern; + friend class NestedPatternContext; /// Underlying global bump allocator managed by a NestedPatternContext. static llvm::BumpPtrAllocator *&allocator(); @@ -97,7 +98,8 @@ private: /// implementation is competitive nonetheless. using FilterFunctionType = std::function; inline bool defaultFilterFunction(Operation &) { return true; } -struct NestedPattern { +class NestedPattern { +public: NestedPattern(ArrayRef nested, FilterFunctionType filter = defaultFilterFunction); NestedPattern(const NestedPattern &) = default; @@ -117,8 +119,8 @@ struct NestedPattern { unsigned getDepth() const; private: - friend struct NestedPatternContext; - friend struct NestedMatch; + friend class NestedPatternContext; + friend class NestedMatch; friend struct State; /// Underlying global bump allocator managed by a NestedPatternContext. @@ -153,7 +155,8 @@ private: /// RAII structure to transparently manage the bump allocator for /// NestedPattern and NestedMatch classes. This avoids passing a context to /// all the API functions. -struct NestedPatternContext { +class NestedPatternContext { +public: NestedPatternContext() { assert(NestedMatch::allocator() == nullptr && "Only a single NestedPatternContext is supported");