最近看别人的程序时,发现居然有
LoopInfo &LI = getAnalysis<LoopInfo>(*F);
这样的代码,百思不得其解,不知道getAnalysis是函数还是类中的方法?
得到相关代码如下:
00167 /// getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to
00168 /// get analysis information that might be around, for example to update it.
00174 ///
00175 template<typename AnalysisType>
00176 AnalysisType *Pass::getAnalysisIfAvailable() const {
00177 assert(Resolver && "ass not resident in a PassManager object!");
00178
00179 const void *PI = &AnalysisType::ID;
00180
00181 Pass *ResultPass = Resolver->getAnalysisIfAvailable(PI, true);
00182 if (ResultPass == 0) return 0;
00183
00188 return (AnalysisType*)ResultPass->getAdjustedAnalysisPointer(PI);
00189 }
00191 /// getAnalysis<AnalysisType>() - This function is used by subclasses to get
00192 /// to the analysis information that they claim to use by overriding the
00193 /// getAnalysisUsage function.
00194 ///
00195 template<typename AnalysisType>
00196 AnalysisType &ass::getAnalysis() const {
00197 assert(Resolver && "ass has not been inserted into a PassManager object!");
00198 return getAnalysisID<AnalysisType>(&AnalysisType::ID);
00199 }
00201 template<typename AnalysisType>
00202 AnalysisType &ass::getAnalysisID(AnalysisID PI) const {
00203 assert(PI && "getAnalysis for unregistered pass!");
00204 assert(Resolver&&"ass has not been inserted into a PassManager object!");
00208 Pass *ResultPass = Resolver->findImplPass(PI);
00209 assert (ResultPass &&
00210 "getAnalysis*() called on an analysis that was not "
00211 "'required' by pass!");
00217 return *(AnalysisType*)ResultPass->getAdjustedAnalysisPointer(PI);
00218 }
00220 /// getAnalysis<AnalysisType>() - This function is used by subclasses to get
00221 /// to the analysis information that they claim to use by overriding the
00222 /// getAnalysisUsage function.
00223 ///
00224 template<typename AnalysisType>
00225 AnalysisType &ass::getAnalysis(Function &F) {
00226 assert(Resolver &&"ass has not been inserted into a PassManager object!");
00227
00228 return getAnalysisID<AnalysisType>(&AnalysisType::ID, F);
00229 }