From: Chris Lattner Date: Thu, 29 Aug 2002 20:07:59 +0000 (+0000) Subject: Make the getAnalyss<> members const. Using them does NOT modify the Pass object. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=3f917b6f99d1835f8bd9be6f7c74876dacf486c8;p=oota-llvm.git Make the getAnalyss<> members const. Using them does NOT modify the Pass object. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3522 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index e717b1971ca..0f4b56fdbcc 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -126,7 +126,7 @@ protected: /// getAnalysisUsage function. /// template - AnalysisType &getAnalysis() { + AnalysisType &getAnalysis() const { assert(Resolver && "Pass has not been inserted into a PassManager object!"); const PassInfo *PI = getClassPassInfo(); assert(PI && "getAnalysis for unregistered pass!"); @@ -143,10 +143,10 @@ protected: } template - AnalysisType &getAnalysisID(const PassInfo *PI) { + AnalysisType &getAnalysisID(const PassInfo *PI) const { assert(Resolver && "Pass has not been inserted into a PassManager object!"); assert(PI && "getAnalysis for unregistered pass!"); - return *(AnalysisType*)Resolver->getAnalysis(PI); + return *dynamic_cast(Resolver->getAnalysis(PI)); } /// getAnalysisToUpdate() - This function is used by subclasses @@ -156,11 +156,11 @@ protected: /// provide the capability to update an analysis that exists. /// template - AnalysisType *getAnalysisToUpdate() { + AnalysisType *getAnalysisToUpdate() const { assert(Resolver && "Pass not resident in a PassManager object!"); const PassInfo *PI = getClassPassInfo(); if (PI == 0) return 0; - return (AnalysisType*)Resolver->getAnalysisToUpdate(PI); + return dynamic_cast(Resolver->getAnalysisToUpdate(PI)); } diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h index fac8cea545f..490c5bf12c6 100644 --- a/include/llvm/PassAnalysisSupport.h +++ b/include/llvm/PassAnalysisSupport.h @@ -86,14 +86,14 @@ public: struct AnalysisResolver { virtual Pass *getAnalysisOrNullUp(AnalysisID ID) const = 0; virtual Pass *getAnalysisOrNullDown(AnalysisID ID) const = 0; - Pass *getAnalysis(AnalysisID ID) { + Pass *getAnalysis(AnalysisID ID) const { Pass *Result = getAnalysisOrNullUp(ID); assert(Result && "Pass has an incorrect analysis uses set!"); return Result; } // getAnalysisToUpdate - Return an analysis result or null if it doesn't exist - Pass *getAnalysisToUpdate(AnalysisID ID) { + Pass *getAnalysisToUpdate(AnalysisID ID) const { return getAnalysisOrNullUp(ID); }