Minor code cleanups
[oota-llvm.git] / include / llvm / PassAnalysisSupport.h
index 0b318fc8fb0752ef401b5f5e177e4c2a5539d5e6..f6265b62cbf5735e7b1e02fb17b2871750277e07 100644 (file)
@@ -40,7 +40,7 @@ public:
 
 private:
   /// Sets of analyses required and preserved by a pass
-  VectorType Required, RequiredTransitive, Preserved;
+  VectorType Required, RequiredTransitive, Preserved, Used;
   bool PreservesAll;
 
 public:
@@ -72,14 +72,32 @@ public:
     Preserved.push_back(&ID);
     return *this;
   }
-  ///@}
-
   /// Add the specified Pass class to the set of analyses preserved by this pass.
   template<class PassClass>
   AnalysisUsage &addPreserved() {
     Preserved.push_back(&PassClass::ID);
     return *this;
   }
+  ///@}
+
+  ///@{
+  /// Add the specified ID to the set of analyses used by this pass if they are
+  /// available..
+  AnalysisUsage &addUsedIfAvailableID(const void *ID) {
+    Used.push_back(ID);
+    return *this;
+  }
+  AnalysisUsage &addUsedIfAvailableID(char &ID) {
+    Used.push_back(&ID);
+    return *this;
+  }
+  /// Add the specified Pass class to the set of analyses used by this pass.
+  template<class PassClass>
+  AnalysisUsage &addUsedIfAvailable() {
+    Used.push_back(&PassClass::ID);
+    return *this;
+  }
+  ///@}
 
   /// Add the Pass with the specified argument string to the set of analyses
   /// preserved by this pass. If no such Pass exists, do nothing. This can be
@@ -108,6 +126,7 @@ public:
     return RequiredTransitive;
   }
   const VectorType &getPreservedSet() const { return Preserved; }
+  const VectorType &getUsedSet() const { return Used; }
 };
 
 //===----------------------------------------------------------------------===//