summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2017-07-09 06:12:56 +0000
committerChandler Carruth <chandlerc@gmail.com>2017-07-09 06:12:56 +0000
commita809f28956fabc28d29103aada5f72cf847efe91 (patch)
treea484c2527a0bc4c5a619523e68fc3f7124eb0894 /llvm/unittests/ADT
parentb80b44b7b9a47058c3df08e390517617968ebc83 (diff)
downloadbcm5719-llvm-a809f28956fabc28d29103aada5f72cf847efe91.tar.gz
bcm5719-llvm-a809f28956fabc28d29103aada5f72cf847efe91.zip
[ADT] Add a default constructor and a bool conversion to function_ref.
The internal representation has a natural way to handle this and it seems nicer than having to wrap this in an optional (with its own separate flag). This also matches how std::function works. llvm-svn: 307490
Diffstat (limited to 'llvm/unittests/ADT')
-rw-r--r--llvm/unittests/ADT/FunctionRefTest.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/FunctionRefTest.cpp b/llvm/unittests/ADT/FunctionRefTest.cpp
index 075d9a070df..b7ef7d79e5f 100644
--- a/llvm/unittests/ADT/FunctionRefTest.cpp
+++ b/llvm/unittests/ADT/FunctionRefTest.cpp
@@ -14,6 +14,20 @@ using namespace llvm;
namespace {
+// Ensure that there is a default constructor and we can test for a null
+// function_ref.
+TEST(FunctionRefTest, Null) {
+ function_ref<int()> F;
+ EXPECT_FALSE(F);
+
+ auto L = [] { return 1; };
+ F = L;
+ EXPECT_TRUE(F);
+
+ F = {};
+ EXPECT_FALSE(F);
+}
+
// Ensure that copies of a function_ref copy the underlying state rather than
// causing one function_ref to chain to the next.
TEST(FunctionRefTest, Copy) {
OpenPOWER on IntegriCloud