[Lldb-commits] [lldb] [lldb] Fix a circular include dependency (PR #188931)

Sergei Barannikov via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 27 02:17:35 PDT 2026


https://github.com/s-barannikov updated https://github.com/llvm/llvm-project/pull/188931

>From 9eda4be357ded103d4f2979639878a5c13c9f8f8 Mon Sep 17 00:00:00 2001
From: Sergei Barannikov <barannikov88 at gmail.com>
Date: Fri, 27 Mar 2026 12:06:25 +0300
Subject: [PATCH] [lldb] Fix a circular include dependency

`lldb-private-types.h` includes `lldb-private.h`, which in turn includes
`lldb-private-types.h`. Because of that, `lldb-public.h` included by
`lldb-private.h` after `lldb-private-types.h` is not actually included.

The practical consequence of this is that types defined in
`lldb-public-types.h` (for example, `addr_t` needed downstream) are not
available in `lldb-private-types.h`.

Fix this by "including what you use", which is `lldb-types.h`.
---
 lldb/include/lldb/Interpreter/OptionArgParser.h               | 2 +-
 lldb/include/lldb/lldb-private-types.h                        | 4 +---
 .../Plugins/Process/Utility/RegisterContextWindows_i386.cpp   | 1 +
 .../Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp | 1 +
 lldb/unittests/Utility/ArchSpecTest.cpp                       | 1 +
 5 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/OptionArgParser.h b/lldb/include/lldb/Interpreter/OptionArgParser.h
index 76a48fca69208..3376f1a3e6012 100644
--- a/lldb/include/lldb/Interpreter/OptionArgParser.h
+++ b/lldb/include/lldb/Interpreter/OptionArgParser.h
@@ -10,7 +10,7 @@
 #define LLDB_INTERPRETER_OPTIONARGPARSER_H
 
 #include "lldb/lldb-private-types.h"
-
+#include "llvm/Support/Error.h"
 #include <optional>
 
 namespace lldb_private {
diff --git a/lldb/include/lldb/lldb-private-types.h b/lldb/include/lldb/lldb-private-types.h
index 185467e91bf62..a60034314b77e 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -9,11 +9,9 @@
 #ifndef LLDB_LLDB_PRIVATE_TYPES_H
 #define LLDB_LLDB_PRIVATE_TYPES_H
 
-#include "lldb/lldb-private.h"
-
+#include "lldb/lldb-types.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
-
 #include <type_traits>
 
 namespace llvm {
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.cpp
index faf4021aa4993..093a43a828cdc 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.cpp
@@ -9,6 +9,7 @@
 #include "RegisterContextWindows_i386.h"
 #include "RegisterContext_x86.h"
 #include "lldb-x86-register-enums.h"
+#include "lldb/lldb-defines.h"
 
 using namespace lldb_private;
 using namespace lldb;
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp
index c3fc2e0026bc8..bd483707ef88f 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp
@@ -9,6 +9,7 @@
 #include "RegisterContextWindows_x86_64.h"
 #include "RegisterContext_x86.h"
 #include "lldb-x86-register-enums.h"
+#include "lldb/lldb-defines.h"
 
 #include <vector>
 
diff --git a/lldb/unittests/Utility/ArchSpecTest.cpp b/lldb/unittests/Utility/ArchSpecTest.cpp
index 3bf1c3f81876f..2f6cc01a315e8 100644
--- a/lldb/unittests/Utility/ArchSpecTest.cpp
+++ b/lldb/unittests/Utility/ArchSpecTest.cpp
@@ -9,6 +9,7 @@
 #include "gtest/gtest.h"
 
 #include "lldb/Utility/ArchSpec.h"
+#include "lldb/lldb-defines.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/BinaryFormat/MachO.h"
 



More information about the lldb-commits mailing list