[llvm] r321836 - [ORC] Add dereference operator to SymbolStringPtr.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 16:04:13 PST 2018


Author: lhames
Date: Thu Jan  4 16:04:13 2018
New Revision: 321836

URL: http://llvm.org/viewvc/llvm-project?rev=321836&view=rev
Log:
[ORC] Add dereference operator to SymbolStringPtr.

Dereference yields a StringRef.

Modified:
    llvm/trunk/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
    llvm/trunk/unittests/ExecutionEngine/Orc/SymbolStringPoolTest.cpp

Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h?rev=321836&r1=321835&r2=321836&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h Thu Jan  4 16:04:13 2018
@@ -92,6 +92,8 @@ public:
     return S->getValue() < Other.S->getValue();
   }
 
+  StringRef operator*() const { return S->first(); }
+
 private:
 
   SymbolStringPtr(SymbolStringPool::PoolMapEntry *S)

Modified: llvm/trunk/unittests/ExecutionEngine/Orc/SymbolStringPoolTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Orc/SymbolStringPoolTest.cpp?rev=321836&r1=321835&r2=321836&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/Orc/SymbolStringPoolTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/Orc/SymbolStringPoolTest.cpp Thu Jan  4 16:04:13 2018
@@ -34,6 +34,12 @@ TEST(SymbolStringPool, UniquingAndCompar
   (void)(P1 < P3);
 }
 
+TEST(SymbolStringPool, Dereference) {
+  SymbolStringPool SP;
+  auto Foo = SP.intern("foo");
+  EXPECT_EQ(*Foo, "foo") << "Equality on dereferenced string failed";
+}
+
 TEST(SymbolStringPool, ClearDeadEntries) {
   SymbolStringPool SP;
   {




More information about the llvm-commits mailing list