[MLIR] Make DictionaryAttr::getAs take name as && reference
authorFabian Schuiki <fabian@schuiki.ch>
Wed, 9 Jun 2021 08:03:18 +0000 (10:03 +0200)
committerFabian Schuiki <fabian@schuiki.ch>
Wed, 9 Jun 2021 08:04:40 +0000 (10:04 +0200)
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`.

mlir/include/mlir/IR/BuiltinAttributes.td

index c25c5ad..4947c26 100644 (file)
@@ -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: