[llvm] 324f5a1 - Make llvm::function_ref's operator bool explicit
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 26 20:14:31 PDT 2020
Author: David Blaikie
Date: 2020-03-26T20:09:57-07:00
New Revision: 324f5a14d7cfb4922a0345d67b20b8cb5953ee82
URL: https://github.com/llvm/llvm-project/commit/324f5a14d7cfb4922a0345d67b20b8cb5953ee82
DIFF: https://github.com/llvm/llvm-project/commit/324f5a14d7cfb4922a0345d67b20b8cb5953ee82.diff
LOG: Make llvm::function_ref's operator bool explicit
This can avoid all sorts of mistakes with implicit conversion
(indirectly) to int, etc. I'm quite surprise there aren't any things to
fixup with this - but I guess most uses of function_ref aren't
optional/nullable.
Added:
Modified:
llvm/include/llvm/ADT/STLExtras.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 638895ee4dc6..ad1150b6251b 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -124,7 +124,7 @@ class function_ref<Ret(Params...)> {
return callback(callable, std::forward<Params>(params)...);
}
- operator bool() const { return callback; }
+ explicit operator bool() const { return callback; }
};
// deleter - Very very very simple method that is used to invoke operator
More information about the llvm-commits
mailing list