[llvm] 918e343 - [SanitizerCoverage] Use llvm::all_of (NFC)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 19:03:52 PST 2020


On Sun, Nov 15, 2020 at 7:01 PM Kazu Hirata via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
>
> Author: Kazu Hirata
> Date: 2020-11-15T19:01:20-08:00
> New Revision: 918e3439e20d068b3336febf084d7e11baa48311
>
> URL: https://github.com/llvm/llvm-project/commit/918e3439e20d068b3336febf084d7e11baa48311
> DIFF: https://github.com/llvm/llvm-project/commit/918e3439e20d068b3336febf084d7e11baa48311.diff
>
> LOG: [SanitizerCoverage] Use llvm::all_of (NFC)
>
> Added:
>
>
> Modified:
>     llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
>
> Removed:
>
>
>
> ################################################################################
> diff  --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
> index 7e2d5260fb6c..f4f94edd3ce2 100644
> --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
> +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
> @@ -519,29 +519,23 @@ bool ModuleSanitizerCoverage::instrumentModule(
>
>  // True if block has successors and it dominates all of them.
>  static bool isFullDominator(const BasicBlock *BB, const DominatorTree *DT) {
> -  if (succ_begin(BB) == succ_end(BB))
> +  if (succ_empty(BB))
>      return false;
>
> -  for (const BasicBlock *SUCC : make_range(succ_begin(BB), succ_end(BB))) {
> -    if (!DT->dominates(BB, SUCC))
> -      return false;
> -  }
> -
> -  return true;
> +  return llvm::all_of(successors(BB), [BB, DT](const BasicBlock *SUCC) {
> +    return DT->dominates(BB, SUCC);
> +  });
>  }
>
>  // True if block has predecessors and it postdominates all of them.
>  static bool isFullPostDominator(const BasicBlock *BB,
>                                  const PostDominatorTree *PDT) {
> -  if (pred_begin(BB) == pred_end(BB))
> +  if (pred_empty(BB))
>      return false;
>
> -  for (const BasicBlock *PRED : make_range(pred_begin(BB), pred_end(BB))) {
> -    if (!PDT->dominates(BB, PRED))
> -      return false;
> -  }
> -
> -  return true;
> +  return llvm::all_of(predecessors(BB), [BB, PDT](const BasicBlock *PRED) {

Generally for locally scoped lambdas (ones that aren't captured/escape
their scope) I'd suggest using "[&]" for captures as it makes changes
to the code simpler - there's no need to think about which variables
are or are not captured.

> +    return PDT->dominates(BB, PRED);
> +  });
>  }
>
>  static bool shouldInstrumentBlock(const Function &F, const BasicBlock *BB,
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list