- Cleaned up the interface to AnalysisUsage to take analysis class names
authorChris Lattner <sabre@nondot.org>
Thu, 8 Aug 2002 19:01:11 +0000 (19:01 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 8 Aug 2002 19:01:11 +0000 (19:01 +0000)
   instead of ::ID's.
 - Pass::getAnalysis<> now no longer takes an optional argument

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

include/llvm/Pass.h
include/llvm/PassAnalysisSupport.h

index 0ff286a50d2b0609d91f1df58302f8405c2da84d..edd7e738c8d657a5d29824f81b44bfe1856766b5 100644 (file)
@@ -114,9 +114,15 @@ protected:
   // getAnalysisUsage function.
   //
   template<typename AnalysisType>
-  AnalysisType &getAnalysis(AnalysisID AID = AnalysisType::ID) {
+  AnalysisType &getAnalysis() {
     assert(Resolver && "Pass not resident in a PassManager object!");
-    return *(AnalysisType*)Resolver->getAnalysis(AID);
+    return *(AnalysisType*)Resolver->getAnalysis(AnalysisType::ID);
+  }
+
+  template<typename AnalysisType>
+  AnalysisType &getAnalysisID(const PassInfo *PI) {
+    assert(Resolver && "Pass not resident in a PassManager object!");
+    return *(AnalysisType*)Resolver->getAnalysis(PI);
   }
 
   // getAnalysisToUpdate<AnalysisType>() - This function is used by subclasses
@@ -126,9 +132,9 @@ protected:
   // provide the capability to update an analysis that exists.
   //
   template<typename AnalysisType>
-  AnalysisType *getAnalysisToUpdate(AnalysisID AID = AnalysisType::ID) {
+  AnalysisType *getAnalysisToUpdate() {
     assert(Resolver && "Pass not resident in a PassManager object!");
-    return (AnalysisType*)Resolver->getAnalysisToUpdate(AID);
+    return (AnalysisType*)Resolver->getAnalysisToUpdate(AnalysisType::ID);
   }
 
 
index c08b883024237c52e8bacc7b87d031da8411afd4..f04b4a6b468ce8e0fb0d562185ad36168cae376e 100644 (file)
@@ -30,28 +30,38 @@ class AnalysisUsage {
 public:
   AnalysisUsage() : PreservesAll(false) {}
   
-  // addRequires - Add the specified ID to the required set of the usage info
+  // addRequired - Add the specified ID to the required set of the usage info
   // for a pass.
   //
-  AnalysisUsage &addRequired(AnalysisID ID) {
+  AnalysisUsage &addRequiredID(AnalysisID ID) {
     Required.push_back(ID);
     return *this;
   }
+  template<class PassClass>
+  AnalysisUsage &addRequired() {
+    Required.push_back(PassClass::ID);
+    return *this;
+  }
 
-  // addPreserves - Add the specified ID to the set of analyses preserved by
+  // addPreserved - Add the specified ID to the set of analyses preserved by
   // this pass
   //
-  AnalysisUsage &addPreserved(AnalysisID ID) {
+  AnalysisUsage &addPreservedID(AnalysisID ID) {
     Preserved.push_back(ID);
     return *this;
   }
 
-  // PreservesAll - Set by analyses that do not transform their input at all
+  template<class PassClass>
+  AnalysisUsage &addPreserved() {
+    Preserved.push_back(PassClass::ID);
+    return *this;
+  }
+
+  // setPreservesAll - Set by analyses that do not transform their input at all
   void setPreservesAll() { PreservesAll = true; }
   bool preservesAll() const { return PreservesAll; }
 
-  // preservesCFG - This function should be called to by the pass, iff they do
-  // not:
+  // preservesCFG - This function should be called by the pass, iff they do not:
   //
   //  1. Add or remove basic blocks from the function
   //  2. Modify terminator instructions in any way.