[Lldb-commits] [lldb] cd02e78 - [NFC] Make headers self-contained.

Jordan Rupprecht via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 29 04:15:02 PST 2022


Author: Jordan Rupprecht
Date: 2022-11-29T04:14:55-08:00
New Revision: cd02e78cd5cdfa079f2a82f34fea25bee1ae02da

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

LOG: [NFC] Make headers self-contained.

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

Reviewed By: labath, MaskRay

Differential Revision: https://reviews.llvm.org/D138310

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/bindings/python/python-typemaps.h b/lldb/bindings/python/python-typemaps.h
index b45352ad62952..8a533e822988e 100644
--- a/lldb/bindings/python/python-typemaps.h
+++ b/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 {

diff  --git a/lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h b/lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h
index 1f113167311ad..c48eae457a9df 100644
--- a/lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h
+++ b/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"
 

diff  --git a/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h b/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
index 0b406a1fa10ee..3aca675ee6370 100644
--- a/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
+++ b/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
@@ -12,7 +12,6 @@
 #include <cstdint>
 #include <variant>
 
-#include "EmulateInstructionRISCV.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/Optional.h"
 


        


More information about the lldb-commits mailing list