[llvm] 5897175 - [ORC] Add ConnectionSpec::str() to reconstruct original spec (#224215)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 03:56:43 PDT 2026


Author: Lang Hames
Date: 2026-09-17T20:56:37+10:00
New Revision: 589717519502a8a52478e34fa6f3fa4483ed2dfd

URL: https://github.com/llvm/llvm-project/commit/589717519502a8a52478e34fa6f3fa4483ed2dfd
DIFF: https://github.com/llvm/llvm-project/commit/589717519502a8a52478e34fa6f3fa4483ed2dfd.diff

LOG: [ORC] Add ConnectionSpec::str() to reconstruct original spec (#224215)

Rebuilds the original connection string from the parsed transport,
action, and descriptor fields.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/Orc/Shared/ConnectionSpec.h
    llvm/unittests/ExecutionEngine/Orc/ConnectionSpecTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/ConnectionSpec.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/ConnectionSpec.h
index 8cdeececef5c5..9c5243c2b4ebf 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/ConnectionSpec.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/ConnectionSpec.h
@@ -58,6 +58,18 @@ class ConnectionSpec {
   /// The transport-specific address. May be empty (e.g. "fd=").
   StringRef getDescriptor() const { return Descriptor; }
 
+  /// Rebuilds the original connection string, e.g. "tcp:connect=host:port".
+  std::string str() const {
+    std::string S = Transport;
+    if (!Action.empty()) {
+      S += ':';
+      S += Action;
+    }
+    S += '=';
+    S += Descriptor;
+    return S;
+  }
+
 private:
   ConnectionSpec(std::string Transport, std::string Action,
                  std::string Descriptor)

diff  --git a/llvm/unittests/ExecutionEngine/Orc/ConnectionSpecTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ConnectionSpecTest.cpp
index adb460b221e9c..ce2f5b1bbd6bd 100644
--- a/llvm/unittests/ExecutionEngine/Orc/ConnectionSpecTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/ConnectionSpecTest.cpp
@@ -21,6 +21,7 @@ TEST(ConnectionSpecTest, TransportAndDescriptorOnly) {
   EXPECT_EQ(Spec->getTransport(), "fd");
   EXPECT_EQ(Spec->getAction(), "");
   EXPECT_EQ(Spec->getDescriptor(), "3");
+  EXPECT_EQ(Spec->str(), "fd=3");
 }
 
 TEST(ConnectionSpecTest, TransportActionAndDescriptor) {
@@ -29,6 +30,7 @@ TEST(ConnectionSpecTest, TransportActionAndDescriptor) {
   EXPECT_EQ(Spec->getTransport(), "tcp");
   EXPECT_EQ(Spec->getAction(), "connect");
   EXPECT_EQ(Spec->getDescriptor(), "localhost:20000");
+  EXPECT_EQ(Spec->str(), "tcp:connect=localhost:20000");
 }
 
 TEST(ConnectionSpecTest, EmptyDescriptorIsLegal) {
@@ -37,6 +39,7 @@ TEST(ConnectionSpecTest, EmptyDescriptorIsLegal) {
   EXPECT_EQ(Spec->getTransport(), "fd");
   EXPECT_EQ(Spec->getAction(), "");
   EXPECT_EQ(Spec->getDescriptor(), "");
+  EXPECT_EQ(Spec->str(), "fd=");
 }
 
 TEST(ConnectionSpecTest, ColonInDescriptorAfterAction) {
@@ -47,6 +50,7 @@ TEST(ConnectionSpecTest, ColonInDescriptorAfterAction) {
   EXPECT_EQ(Spec->getTransport(), "tcp");
   EXPECT_EQ(Spec->getAction(), "listen");
   EXPECT_EQ(Spec->getDescriptor(), "[::1]:0");
+  EXPECT_EQ(Spec->str(), "tcp:listen=[::1]:0");
 }
 
 TEST(ConnectionSpecTest, EqualsInDescriptor) {
@@ -57,6 +61,7 @@ TEST(ConnectionSpecTest, EqualsInDescriptor) {
   EXPECT_EQ(Spec->getTransport(), "unix");
   EXPECT_EQ(Spec->getAction(), "listen");
   EXPECT_EQ(Spec->getDescriptor(), "/tmp/a=b.sock");
+  EXPECT_EQ(Spec->str(), "unix:listen=/tmp/a=b.sock");
 }
 
 TEST(ConnectionSpecTest, ColonInActionIsLegal) {
@@ -69,6 +74,7 @@ TEST(ConnectionSpecTest, ColonInActionIsLegal) {
   EXPECT_EQ(Spec->getTransport(), "tcp");
   EXPECT_EQ(Spec->getAction(), ":listen");
   EXPECT_EQ(Spec->getDescriptor(), "[::1]:0");
+  EXPECT_EQ(Spec->str(), "tcp::listen=[::1]:0");
 }
 
 TEST(ConnectionSpecTest, NamesArePreservedVerbatim) {


        


More information about the llvm-commits mailing list