]> granicus.if.org Git - llvm/commitdiff
[GlobalISel] Remove duplicate function using variadic templates. NFC.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Thu, 26 Jan 2017 22:07:37 +0000 (22:07 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Thu, 26 Jan 2017 22:07:37 +0000 (22:07 +0000)
I think the initial version of r293172 was trying:
  std::forward<Args...>(args)...
which doesn't compile.  This seems like the correct way:
  std::forward<Args>(args)...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293214 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/GlobalISelEmitter.cpp

index 02ef6fa47c1ee33116d970aaee9a5c5906d29bb9..a9f4d7aae23dbb9bba28558c7e21a55ce7fad5da 100644 (file)
@@ -129,7 +129,8 @@ public:
   /// Construct a new operand predicate and add it to the matcher.
   template <class Kind, class... Args>
   Kind &addPredicate(Args&&... args) {
-    Predicates.emplace_back(llvm::make_unique<Kind>(std::forward<Args...>(args)...));
+    Predicates.emplace_back(
+        llvm::make_unique<Kind>(std::forward<Args>(args)...));
     return *static_cast<Kind *>(Predicates.back().get());
   }
 
@@ -140,8 +141,8 @@ public:
   }
 
   /// Emit a C++ expression that tests whether all the predicates are met.
-  template <class Arg1>
-  void emitCxxPredicatesExpr(raw_ostream &OS, Arg1&& arg1) const {
+  template <class... Args>
+  void emitCxxPredicatesExpr(raw_ostream &OS, Args &&... args) const {
     if (Predicates.empty()) {
       OS << "true";
       return;
@@ -150,24 +151,7 @@ public:
     StringRef Separator = "";
     for (const auto &Predicate : predicates()) {
       OS << Separator << "(";
-      Predicate->emitCxxPredicateExpr(OS, std::forward<Arg1>(arg1));
-      OS << ")";
-      Separator = " && ";
-    }
-  }
-
-  template <class Arg1, class Arg2>
-  void emitCxxPredicatesExpr(raw_ostream &OS, Arg1&& arg1, Arg2&& arg2) const {
-    if (Predicates.empty()) {
-      OS << "true";
-      return;
-    }
-
-    StringRef Separator = "";
-    for (const auto &Predicate : predicates()) {
-      OS << Separator << "(";
-      Predicate->emitCxxPredicateExpr(OS, std::forward<Arg1>(arg1),
-                                      std::forward<Arg2>(arg2));
+      Predicate->emitCxxPredicateExpr(OS, std::forward<Args>(args)...);
       OS << ")";
       Separator = " && ";
     }