[clang] 857bf5d - [FIX] Do not copy an llvm::function_ref if it has to be reused

Johannes Doerfert via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 15 22:55:07 PST 2020


Author: Johannes Doerfert
Date: 2020-02-16T00:51:11-06:00
New Revision: 857bf5da35af8e1f9425e1865dab5f5fce5e38f2

URL: https://github.com/llvm/llvm-project/commit/857bf5da35af8e1f9425e1865dab5f5fce5e38f2
DIFF: https://github.com/llvm/llvm-project/commit/857bf5da35af8e1f9425e1865dab5f5fce5e38f2.diff

LOG: [FIX] Do not copy an llvm::function_ref if it has to be reused

Some buildbots signaled a problem in this method when the
llvm::function_ref was copied and reused after 1228d42ddab8. To
eliminate the problem we avoid copying the llvm::function_ref and
instead we pass it as a const reference.

Added: 
    

Modified: 
    clang/include/clang/AST/OpenMPClause.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h
index a3831fd5950f..453c068bbeb0 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6682,10 +6682,10 @@ struct OMPTraitInfo {
   llvm::SmallVector<OMPTraitSet, 4> Sets;
 
   bool anyScoreOrCondition(
-      llvm::function_ref<bool(Expr *&, bool /* IsScore */)> Cond) {
-    return llvm::any_of(Sets, [Cond](OMPTraitInfo::OMPTraitSet &Set) {
+      const llvm::function_ref<bool(Expr *&, bool /* IsScore */)> &Cond) {
+    return llvm::any_of(Sets, [&Cond](OMPTraitInfo::OMPTraitSet &Set) {
       return llvm::any_of(
-          Set.Selectors, [Cond](OMPTraitInfo::OMPTraitSelector &Selector) {
+          Set.Selectors, [&Cond](OMPTraitInfo::OMPTraitSelector &Selector) {
             return Cond(Selector.ScoreOrCondition,
                         /* IsScore */ Selector.Kind !=
                             llvm::omp::TraitSelector::user_condition);


        


More information about the cfe-commits mailing list