summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2019-08-26 20:47:56 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2019-08-26 20:47:56 +0000
commit57effbdadc0b382db4ef86addcfd03a64c9eda0a (patch)
tree146f2b3a5ba8b98e50b61fcfb7d96de5595034ee /llvm/unittests
parent3c5bd65154acbe052c9be1a22bc9457fdc2836f6 (diff)
downloadbcm5719-llvm-57effbdadc0b382db4ef86addcfd03a64c9eda0a.tar.gz
bcm5719-llvm-57effbdadc0b382db4ef86addcfd03a64c9eda0a.zip
[ADT] Make StringRef(const char*) constexpr
This should let us get rid of StringLiteral in the long term and avoid chasing accidental StringRef globals once and for all. This requires C++14, I godbolted it on every compiler I know we support so I hope there won't be much fallout. llvm-svn: 369961
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp4
-rw-r--r--llvm/unittests/ProfileData/SampleProfTest.cpp1
2 files changed, 4 insertions, 1 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index f341cf402a0..c37ecf36b63 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -1050,6 +1050,10 @@ TEST(StringRefTest, DropWhileUntil) {
}
TEST(StringRefTest, StringLiteral) {
+ constexpr StringRef StringRefs[] = {"Foo", "Bar"};
+ EXPECT_EQ(StringRef("Foo"), StringRefs[0]);
+ EXPECT_EQ(StringRef("Bar"), StringRefs[1]);
+
constexpr StringLiteral Strings[] = {"Foo", "Bar"};
EXPECT_EQ(StringRef("Foo"), Strings[0]);
EXPECT_EQ(StringRef("Bar"), Strings[1]);
diff --git a/llvm/unittests/ProfileData/SampleProfTest.cpp b/llvm/unittests/ProfileData/SampleProfTest.cpp
index a28a1d8a1aa..ebf66b22c5b 100644
--- a/llvm/unittests/ProfileData/SampleProfTest.cpp
+++ b/llvm/unittests/ProfileData/SampleProfTest.cpp
@@ -305,7 +305,6 @@ TEST_F(SampleProfTest, sample_overflow_saturation) {
const uint64_t Max = std::numeric_limits<uint64_t>::max();
sampleprof_error Result;
- StringRef FooName("_Z3fooi");
FunctionSamples FooSamples;
Result = FooSamples.addTotalSamples(1);
ASSERT_EQ(Result, sampleprof_error::success);
OpenPOWER on IntegriCloud