Make the getAnalyss<> members const. Using them does NOT modify the Pass object.

llvm-svn: 3522
This commit is contained in:
Chris Lattner 2002-08-29 20:07:59 +00:00
parent 272f3f5148
commit 30a25af88c
2 changed files with 7 additions and 7 deletions

View File

@ -126,7 +126,7 @@ protected:
/// getAnalysisUsage function.
///
template<typename AnalysisType>
AnalysisType &getAnalysis() {
AnalysisType &getAnalysis() const {
assert(Resolver && "Pass has not been inserted into a PassManager object!");
const PassInfo *PI = getClassPassInfo<AnalysisType>();
assert(PI && "getAnalysis for unregistered pass!");
@ -143,10 +143,10 @@ protected:
}
template<typename AnalysisType>
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<AnalysisType*>(Resolver->getAnalysis(PI));
}
/// getAnalysisToUpdate<AnalysisType>() - This function is used by subclasses
@ -156,11 +156,11 @@ protected:
/// provide the capability to update an analysis that exists.
///
template<typename AnalysisType>
AnalysisType *getAnalysisToUpdate() {
AnalysisType *getAnalysisToUpdate() const {
assert(Resolver && "Pass not resident in a PassManager object!");
const PassInfo *PI = getClassPassInfo<AnalysisType>();
if (PI == 0) return 0;
return (AnalysisType*)Resolver->getAnalysisToUpdate(PI);
return dynamic_cast<AnalysisType*>(Resolver->getAnalysisToUpdate(PI));
}

View File

@ -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);
}