StringRef LoopFixer::checkDeferralsAndRejections(ASTContext *Context, const Expr *ContainerExpr, Confidence ConfidenceLevel, const ForStmt *TheLoop) { // If we already modified the range of this for loop, don't do any further // updates on this iteration. // FIXME: Once Replacements can detect conflicting edits, replace this // implementation and rely on conflicting edit detection instead. if (ReplacedVarRanges->count(TheLoop)) { ++*DeferredChanges; return ""; } ParentFinder->gatherAncestors(Context->getTranslationUnitDecl()); // Ensure that we do not try to move an expression dependent on a local // variable declared inside the loop outside of it! DependencyFinderASTVisitor DependencyFinder(&ParentFinder->getStmtToParentStmtMap(), &ParentFinder->getDeclToParentStmtMap(), ReplacedVarRanges, TheLoop); // Not all of these are actually deferred changes. // FIXME: Determine when the external dependency isn't an expression converted // by another loop. if (DependencyFinder.dependsOnInsideVariable(ContainerExpr)) { ++*DeferredChanges; return ""; } if (ConfidenceLevel.get() < RequiredConfidenceLevel) { ++*RejectedChanges; return ""; } StringRef ContainerString = getStringFromRange(Context->getSourceManager(), Context->getLangOpts(), ContainerExpr->getSourceRange()); // In case someone is using an evil macro, reject this change. if (ContainerString.empty()) ++*RejectedChanges; return ContainerString; }