From cd02e78cd5cdfa079f2a82f34fea25bee1ae02da Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Tue, 29 Nov 2022 04:14:55 -0800 Subject: [PATCH] [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 --- lldb/bindings/python/python-typemaps.h | 2 ++ lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h | 1 + lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h | 1 - 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lldb/bindings/python/python-typemaps.h b/lldb/bindings/python/python-typemaps.h index b45352ad6295..8a533e822988 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 + // 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 1f113167311a..c48eae457a9d 100644 --- a/lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h +++ b/lldb/source/Plugins/Instruction/RISCV/RISCVCInstructions.h @@ -12,6 +12,7 @@ #include #include +#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 0b406a1fa10e..3aca675ee637 100644 --- a/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h +++ b/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h @@ -12,7 +12,6 @@ #include #include -#include "EmulateInstructionRISCV.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/Optional.h"