[Mlir-commits] [mlir] 41135a4 - [MLIR] Make DictionaryAttr::getAs take name as && reference

Fabian Schuiki llvmlistbot at llvm.org
Wed Jun 9 01:05:17 PDT 2021


Author: Fabian Schuiki
Date: 2021-06-09T10:04:40+02:00
New Revision: 41135a4367a75cf02d9873be7bd904456ce77329

URL: https://github.com/llvm/llvm-project/commit/41135a4367a75cf02d9873be7bd904456ce77329
DIFF: https://github.com/llvm/llvm-project/commit/41135a4367a75cf02d9873be7bd904456ce77329.diff

LOG: [MLIR] Make DictionaryAttr::getAs take name as && reference

As a follow-up to the discussion in https://reviews.llvm.org/D103822,
make the templated `DictionaryAttr::getAs` take the name by `&&`
reference and properly forward the argument to the underlying `get`.

Added: 
    

Modified: 
    mlir/include/mlir/IR/BuiltinAttributes.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td
index c25c5ad0532ae..4947c26bcd654 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.td
+++ b/mlir/include/mlir/IR/BuiltinAttributes.td
@@ -346,8 +346,9 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary"> {
     /// Return the specified attribute if present and is an instance of
     /// `AttrClass`, null otherwise.
     template<typename AttrClass, typename NameClass>
-    AttrClass getAs(NameClass name) const {
-      return get(name).template dyn_cast_or_null<AttrClass>();
+    AttrClass getAs(NameClass &&name) const {
+      return get(std::forward<NameClass>(name))
+        .template dyn_cast_or_null<AttrClass>();
     }
 
   private:


        


More information about the Mlir-commits mailing list