aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/StringRefTest.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-12-13 17:03:49 +0000
committerZachary Turner <zturner@google.com>2016-12-13 17:03:49 +0000
commitbc48d20ef77713852f4f0543956c116e8098e44d (patch)
tree05f2af03c95ba8b0ef3fe8c14a48aeed424e89fc /llvm/unittests/ADT/StringRefTest.cpp
parent09d5daab49a016b6eb6271e9f4b144774b59540e (diff)
downloadllvm-bc48d20ef77713852f4f0543956c116e8098e44d.zip
llvm-bc48d20ef77713852f4f0543956c116e8098e44d.tar.gz
llvm-bc48d20ef77713852f4f0543956c116e8098e44d.tar.bz2
[ADT] Add llvm::StringLiteral.
StringLiteral is a wrapper around a string literal useful for replacing global tables of char arrays with global tables of StringRefs that can initialized in a constexpr context, avoiding the invocation of a global constructor. Differential Revision: https://reviews.llvm.org/D27686 llvm-svn: 289551
Diffstat (limited to 'llvm/unittests/ADT/StringRefTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index c1cc558..5b6822e 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -1002,4 +1002,10 @@ TEST(StringRefTest, DropWhileUntil) {
EXPECT_EQ("", Taken);
}
+TEST(StringRefTest, StringLiteral) {
+ constexpr StringLiteral Strings[] = {"Foo", "Bar"};
+ EXPECT_EQ(StringRef("Foo"), Strings[0]);
+ EXPECT_EQ(StringRef("Bar"), Strings[1]);
+}
+
} // end anonymous namespace