[Lldb-commits] [PATCH] D138310: [NFC] Make headers self-contained.

Jordan Rupprecht via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 18 08:59:37 PST 2022


rupprecht created this revision.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, arichardson.
Herald added a project: All.
rupprecht requested review of this revision.
Herald added subscribers: lldb-commits, pcwang-thead.
Herald added a project: LLDB.

Some headers in LLDB work only when considered as textual inclusion, but not if one attempts to use them on their own or with a different context.

- python-typemaps.h: uses Python definitions without using "Python.h".
- RISCVCInstructions.h uses RISC-V register enums without including the enums header.
- RISCVInstructions.h includes EmulateInstructionRISCV.h, but is unnecessary since we forward-declare EmulateInstructionRISCV anyway. Including the header is problematic because EmulateInstructionRISCV.h uses DecodeResult which isn't defined until later in RISCVInstructions.h.

This makes LLDB build cleanly with the "parse_headers" feature [1]. I'm not sure what the analagous CMake option is.

[1] I didn't find public documentation but @MaskRay wrote this up: https://maskray.me/blog/2022-09-25-layering-check-with-clang#parse_headers


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138310

Files:
  lldb/bindings/python/python-typemaps.h
  lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h
  lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h


Index: lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
===================================================================
--- lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
+++ lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
@@ -12,7 +12,6 @@
 #include <cstdint>
 #include <variant>
 
-#include "EmulateInstructionRISCV.h"
 #include "llvm/ADT/Optional.h"
 
 namespace lldb_private {
Index: lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h
===================================================================
--- lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h
+++ lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h
@@ -12,6 +12,7 @@
 #include <cstdint>
 #include <variant>
 
+#include "Plugins/Process/Utility/lldb-riscv-register-enums.h"
 #include "RISCVInstructions.h"
 #include "llvm/ADT/Optional.h"
 
Index: lldb/bindings/python/python-typemaps.h
===================================================================
--- lldb/bindings/python/python-typemaps.h
+++ lldb/bindings/python/python-typemaps.h
@@ -1,6 +1,8 @@
 #ifndef LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H
 #define LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H
 
+#include <Python.h>
+
 // Defined here instead of a .swig file because SWIG 2 doesn't support
 // explicit deleted functions.
 struct Py_buffer_RAII {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138310.476502.patch
Type: text/x-patch
Size: 1331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221118/983dcec4/attachment.bin>


More information about the lldb-commits mailing list