[llvm] [orc-rt] Add new ControllerAccess logging category. (PR #209380)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 22:50:08 PDT 2026


https://github.com/lhames created https://github.com/llvm/llvm-project/pull/209380

The orc_rt_log_Category_ControllerAccess category should be used to log messages from ControllerAccess implementations. E.g.

  ORC_RT_LOG(Error, ControllerAccess, "connect() failed with <error>");

>From 8718341205633e05c9c809fa7ac02fb536480113 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Tue, 14 Jul 2026 15:38:13 +1000
Subject: [PATCH] [orc-rt] Add new ControllerAccess logging category.

The orc_rt_log_Category_ControllerAccess category should be used to log
messages from ControllerAccess implementations. E.g.

  ORC_RT_LOG(Error, ControllerAccess, "connect() failed with <error>");
---
 orc-rt/include/orc-rt-c/Logging.h |  1 +
 orc-rt/lib/executor/Logging.cpp   |  2 +-
 orc-rt/test/unit/LoggingTest.cpp  | 19 ++++++++++++++++---
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/orc-rt/include/orc-rt-c/Logging.h b/orc-rt/include/orc-rt-c/Logging.h
index 8c3830580c95d..60618d2f90a55 100644
--- a/orc-rt/include/orc-rt-c/Logging.h
+++ b/orc-rt/include/orc-rt-c/Logging.h
@@ -60,6 +60,7 @@ ORC_RT_C_EXTERN_C_BEGIN
  */
 typedef enum {
   orc_rt_log_Category_General,
+  orc_rt_log_Category_ControllerAccess,
 
   /*
    * Count is the number of defined categories; it is not itself a valid
diff --git a/orc-rt/lib/executor/Logging.cpp b/orc-rt/lib/executor/Logging.cpp
index b95ef3b0bc5c0..6aaf443a1e492 100644
--- a/orc-rt/lib/executor/Logging.cpp
+++ b/orc-rt/lib/executor/Logging.cpp
@@ -17,7 +17,7 @@
 #include <cctype>
 #include <cstring>
 
-static const char *CategoryNames[] = {"General"};
+static const char *CategoryNames[] = {"General", "ControllerAccess"};
 static_assert(std::size(CategoryNames) == orc_rt_log_Category_Count,
               "CategoryNames array is the wrong size");
 
diff --git a/orc-rt/test/unit/LoggingTest.cpp b/orc-rt/test/unit/LoggingTest.cpp
index 8d1bc637763c6..186f5982bee00 100644
--- a/orc-rt/test/unit/LoggingTest.cpp
+++ b/orc-rt/test/unit/LoggingTest.cpp
@@ -14,6 +14,9 @@
 
 #include "gtest/gtest.h"
 
+#include <string>
+#include <unordered_set>
+
 namespace {
 
 // Every level and category must compile and be usable as a plain statement,
@@ -68,10 +71,20 @@ TEST(LoggingTest, LevelParseGetNameRoundTrip) {
   }
 }
 
-TEST(LoggingTest, CategoryGetName) {
-  EXPECT_STREQ("General",
-               orc_rt_log_Category_getName(orc_rt_log_Category_General));
+TEST(LoggingTest, CategoryNamesAreUniqueAndNonNull) {
+  // Check that every category has a unique, non-null name.
+  std::unordered_set<std::string> Seen;
+  for (int C = orc_rt_log_Category_General; C != orc_rt_log_Category_Count;
+       ++C) {
+    const char *Name =
+        orc_rt_log_Category_getName(static_cast<orc_rt_log_Category>(C));
+    ASSERT_NE(Name, nullptr) << "category " << C << " has no name";
+    EXPECT_TRUE(Seen.insert(Name).second)
+        << "category " << C << " has a duplicate name: " << Name;
+  }
+}
 
+TEST(LoggingTest, OutOfRangeCategoryNamesAreNull) {
   // The Count sentinel is not a real category, and out-of-range values have no
   // name.
   EXPECT_EQ(nullptr, orc_rt_log_Category_getName(orc_rt_log_Category_Count));



More information about the llvm-commits mailing list