- const PassInfo *PI = getClassPassInfo<AnalysisType>();
- if (PI == 0) return 0;
- return dynamic_cast<AnalysisType*>
- (Resolver->getAnalysisIfAvailable(PI, true));
+ const void *PI = &AnalysisType::ID;
+
+ Pass *ResultPass = Resolver->getAnalysisIfAvailable(PI, true);
+ if (ResultPass == 0) return 0;
+
+ // Because the AnalysisType may not be a subclass of pass (for
+ // AnalysisGroups), we use getAdjustedAnalysisPointer here to potentially
+ // adjust the return pointer (because the class may multiply inherit, once
+ // from pass, once from AnalysisType).
+ return (AnalysisType*)ResultPass->getAdjustedAnalysisPointer(PI);