[clang] 24f36a2 - [Modules] Move modulemaps to header search directories. NFC intended.

Volodymyr Sapsai via cfe-commits cfe-commits at lists.llvm.org
Wed May 3 13:08:04 PDT 2023


Author: Volodymyr Sapsai
Date: 2023-05-03T13:07:47-07:00
New Revision: 24f36a215b4eabd1d0e4abcce0c9277085d88a96

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

LOG: [Modules] Move modulemaps to header search directories. NFC intended.

In code we use `#include "llvm/Lib/Header.h"` which is located in
"llvm/include/llvm/Lib/Header.h", so we use "llvm/include/" as a header
search path. We should put modulemaps in the same directory and
shouldn't rely on clang to search in immediate subdirectories.

rdar://106677321

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

Added: 
    clang/include/module.modulemap
    lldb/include/module.modulemap
    llvm/include/CMakeLists.txt
    llvm/include/module.extern.modulemap
    llvm/include/module.install.modulemap
    llvm/include/module.modulemap
    llvm/include/module.modulemap.build

Modified: 
    llvm/CMakeLists.txt
    llvm/include/llvm/CMakeLists.txt

Removed: 
    clang/include/clang-c/module.modulemap
    clang/include/clang/module.modulemap
    lldb/include/lldb/module.modulemap
    llvm/include/llvm-c/module.modulemap
    llvm/include/llvm/module.extern.modulemap
    llvm/include/llvm/module.install.modulemap
    llvm/include/llvm/module.modulemap
    llvm/include/llvm/module.modulemap.build


################################################################################
diff  --git a/clang/include/clang-c/module.modulemap b/clang/include/clang-c/module.modulemap
deleted file mode 100644
index 95a59d62344cc..0000000000000
--- a/clang/include/clang-c/module.modulemap
+++ /dev/null
@@ -1,4 +0,0 @@
-module Clang_C {
-  umbrella "."
-  module * { export * }
-}

diff  --git a/clang/include/clang/module.modulemap b/clang/include/clang/module.modulemap
deleted file mode 100644
index 624045dc4c57b..0000000000000
--- a/clang/include/clang/module.modulemap
+++ /dev/null
@@ -1,199 +0,0 @@
-module Clang_Analysis {
-  requires cplusplus
-  umbrella "Analysis"
-
-  textual header "Analysis/Analyses/ThreadSafetyOps.def"
-
-  module * { export * }
-
-  // FIXME: Exclude these headers to avoid pulling all of the AST matchers
-  // library into clang. Due to inline key functions in the headers,
-  // importing the AST matchers library gives a link dependency on the AST
-  // matchers (and thus the AST), which clang-format should not have.
-  exclude header "Analysis/Analyses/ExprMutationAnalyzer.h"
-}
-
-module Clang_AST {
-  requires cplusplus
-  umbrella "AST"
-
-  textual header "AST/BuiltinTypes.def"
-  textual header "AST/CXXRecordDeclDefinitionBits.def"
-  textual header "AST/OperationKinds.def"
-  textual header "AST/TypeLocNodes.def"
-
-  module * { export * }
-}
-
-module Clang_ASTMatchers { requires cplusplus umbrella "ASTMatchers" module * { export * } }
-
-module Clang_Basic {
-  requires cplusplus
-  umbrella "Basic"
-
-  textual header "Basic/AArch64SVEACLETypes.def"
-  textual header "Basic/BuiltinsAArch64.def"
-  textual header "Basic/BuiltinsAMDGPU.def"
-  textual header "Basic/BuiltinsAArch64NeonSVEBridge.def"
-  textual header "Basic/BuiltinsAArch64NeonSVEBridge_cg.def"
-  textual header "Basic/BuiltinsARM.def"
-  textual header "Basic/BuiltinsBPF.def"
-  textual header "Basic/Builtins.def"
-  textual header "Basic/BuiltinHeaders.def"
-  textual header "Basic/BuiltinsHexagon.def"
-  textual header "Basic/BuiltinsHexagonDep.def"
-  textual header "Basic/BuiltinsHexagonMapCustomDep.def"
-  textual header "Basic/BuiltinsLoongArch.def"
-  textual header "Basic/BuiltinsMips.def"
-  textual header "Basic/BuiltinsNEON.def"
-  textual header "Basic/BuiltinsNVPTX.def"
-  textual header "Basic/BuiltinsPPC.def"
-  textual header "Basic/BuiltinsRISCV.def"
-  textual header "Basic/BuiltinsRISCVVector.def"
-  textual header "Basic/BuiltinsSVE.def"
-  textual header "Basic/BuiltinsSystemZ.def"
-  textual header "Basic/BuiltinsVE.def"
-  textual header "Basic/BuiltinsVEVL.gen.def"
-  textual header "Basic/BuiltinsWebAssembly.def"
-  textual header "Basic/BuiltinsX86.def"
-  textual header "Basic/BuiltinsX86_64.def"
-  textual header "Basic/BuiltinsXCore.def"
-  textual header "Basic/CodeGenOptions.def"
-  textual header "Basic/DiagnosticOptions.def"
-  textual header "Basic/Features.def"
-  textual header "Basic/FPOptions.def"
-  textual header "Basic/MSP430Target.def"
-  textual header "Basic/LangOptions.def"
-  textual header "Basic/OpenCLExtensions.def"
-  textual header "Basic/OpenCLImageTypes.def"
-  textual header "Basic/OpenCLExtensionTypes.def"
-  textual header "Basic/OpenMPKinds.def"
-  textual header "Basic/OperatorKinds.def"
-  textual header "Basic/PPCTypes.def"
-  textual header "Basic/RISCVVTypes.def"
-  textual header "Basic/Sanitizers.def"
-  textual header "Basic/TargetCXXABI.def"
-  textual header "Basic/TransformTypeTraits.def"
-  textual header "Basic/TokenKinds.def"
-  textual header "Basic/WebAssemblyReferenceTypes.def"
-
-  module * { export * }
-}
-module Clang_Basic_TokenKinds {
-  requires cplusplus
-
-  header "Basic/TokenKinds.h"
-  textual header "Basic/TokenKinds.def"
-
-  export *
-}
-
-module Clang_CodeGen { requires cplusplus umbrella "CodeGen" module * { export * } }
-module Clang_Config { requires cplusplus umbrella "Config" module * { export * } }
-
-// Files for diagnostic groups are spread all over the include/clang/ tree, but
-// logically form a single module.
-module Clang_Diagnostics {
-  requires cplusplus
-
-  module All { header "Basic/AllDiagnostics.h" export * }
-  module Analysis { textual header "Analysis/Analyses/UnsafeBufferUsageGadgets.def" }
-  module AST { header "AST/ASTDiagnostic.h" export * }
-  module Comment { header "AST/CommentDiagnostic.h" export * }
-  module Driver { header "Driver/DriverDiagnostic.h" export * }
-  module Frontend { header "Frontend/FrontendDiagnostic.h" export * }
-  module Lex { header "Lex/LexDiagnostic.h" export * }
-  module Parse { header "Parse/ParseDiagnostic.h" export * }
-  module Sema { header "Sema/SemaDiagnostic.h" export * }
-  module Serialization { header "Serialization/SerializationDiagnostic.h" export * }
-  module Refactoring { header "Tooling/Refactoring/RefactoringDiagnostic.h" export * }
-}
-
-module Clang_Driver {
-  requires cplusplus
-  umbrella "Driver"
-
-  textual header "Driver/Types.def"
-
-  module * { export * }
-}
-
-module Clang_Edit { requires cplusplus umbrella "Edit" module * { export * } }
-module Clang_Format { requires cplusplus umbrella "Format" module * { export * } }
-
-module Clang_Frontend {
-  requires cplusplus
-  umbrella "Frontend"
-
-  textual header "Basic/LangStandards.def"
-
-  module * { export * }
-}
-
-module Clang_FrontendTool { requires cplusplus umbrella "FrontendTool" module * { export * } }
-module Clang_Index { requires cplusplus umbrella "Index" module * { export * } }
-module Clang_Lex { requires cplusplus umbrella "Lex" module * { export * } }
-module Clang_Parse { requires cplusplus umbrella "Parse" module * { export * } }
-module Clang_Rewrite { requires cplusplus umbrella "Rewrite/Core" module * { export * } }
-module Clang_RewriteFrontend { requires cplusplus umbrella "Rewrite/Frontend" module * { export * } }
-module Clang_Sema { requires cplusplus umbrella "Sema" module * { export * } }
-
-module Clang_Serialization {
-  requires cplusplus
-  umbrella "Serialization"
-
-  textual header "Serialization/TypeBitCodes.def"
-
-  module * { export * }
-}
-
-module Clang_StaticAnalyzer_Core {
-  requires cplusplus
-  umbrella "StaticAnalyzer/Core"
-
-  textual header "StaticAnalyzer/Core/Analyses.def"
-  textual header "StaticAnalyzer/Core/AnalyzerOptions.def"
-  textual header "StaticAnalyzer/Core/PathSensitive/SVals.def"
-  textual header "StaticAnalyzer/Core/PathSensitive/Symbols.def"
-  textual header "StaticAnalyzer/Core/PathSensitive/Regions.def"
-
-  module * { export * }
-}
-
-module Clang_StaticAnalyzer_Checkers {
-  requires cplusplus
-  umbrella "StaticAnalyzer/Checkers"
-  module * { export * }
-}
-
-module Clang_StaticAnalyzer_Frontend {
-  requires cplusplus
-  umbrella "StaticAnalyzer/Frontend"
-  module * { export * }
-}
-
-module Clang_Testing {
-  requires cplusplus
-  umbrella "Testing"
-  module * { export * }
-}
-
-module Clang_Tooling {
-  requires cplusplus umbrella "Tooling" module * { export * }
-  // FIXME: Exclude these headers to avoid pulling all of the AST matchers
-  // library into clang-format. Due to inline key functions in the headers,
-  // importing the AST matchers library gives a link dependency on the AST
-  // matchers (and thus the AST), which clang-format should not have.
-  exclude header "Tooling/RefactoringCallbacks.h"
-}
-
-module Clang_ToolingCore {
-  requires cplusplus
-  umbrella "Tooling/Core" module * { export * }
-}
-
-module Clang_ToolingInclusions {
-  requires cplusplus
-  umbrella "Tooling/Inclusions"
-  module * { export * }
-}

diff  --git a/clang/include/module.modulemap b/clang/include/module.modulemap
new file mode 100644
index 0000000000000..9fea3620100f4
--- /dev/null
+++ b/clang/include/module.modulemap
@@ -0,0 +1,204 @@
+module Clang_C {
+  umbrella "clang-c"
+  module * { export * }
+}
+
+module Clang_Analysis {
+  requires cplusplus
+  umbrella "clang/Analysis"
+
+  textual header "clang/Analysis/Analyses/ThreadSafetyOps.def"
+
+  module * { export * }
+
+  // FIXME: Exclude these headers to avoid pulling all of the AST matchers
+  // library into clang. Due to inline key functions in the headers,
+  // importing the AST matchers library gives a link dependency on the AST
+  // matchers (and thus the AST), which clang-format should not have.
+  exclude header "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
+}
+
+module Clang_AST {
+  requires cplusplus
+  umbrella "clang/AST"
+
+  textual header "clang/AST/BuiltinTypes.def"
+  textual header "clang/AST/CXXRecordDeclDefinitionBits.def"
+  textual header "clang/AST/OperationKinds.def"
+  textual header "clang/AST/TypeLocNodes.def"
+
+  module * { export * }
+}
+
+module Clang_ASTMatchers { requires cplusplus umbrella "clang/ASTMatchers" module * { export * } }
+
+module Clang_Basic {
+  requires cplusplus
+  umbrella "clang/Basic"
+
+  textual header "clang/Basic/AArch64SVEACLETypes.def"
+  textual header "clang/Basic/BuiltinsAArch64.def"
+  textual header "clang/Basic/BuiltinsAMDGPU.def"
+  textual header "clang/Basic/BuiltinsAArch64NeonSVEBridge.def"
+  textual header "clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def"
+  textual header "clang/Basic/BuiltinsARM.def"
+  textual header "clang/Basic/BuiltinsBPF.def"
+  textual header "clang/Basic/Builtins.def"
+  textual header "clang/Basic/BuiltinHeaders.def"
+  textual header "clang/Basic/BuiltinsHexagon.def"
+  textual header "clang/Basic/BuiltinsHexagonDep.def"
+  textual header "clang/Basic/BuiltinsHexagonMapCustomDep.def"
+  textual header "clang/Basic/BuiltinsLoongArch.def"
+  textual header "clang/Basic/BuiltinsMips.def"
+  textual header "clang/Basic/BuiltinsNEON.def"
+  textual header "clang/Basic/BuiltinsNVPTX.def"
+  textual header "clang/Basic/BuiltinsPPC.def"
+  textual header "clang/Basic/BuiltinsRISCV.def"
+  textual header "clang/Basic/BuiltinsRISCVVector.def"
+  textual header "clang/Basic/BuiltinsSVE.def"
+  textual header "clang/Basic/BuiltinsSystemZ.def"
+  textual header "clang/Basic/BuiltinsVE.def"
+  textual header "clang/Basic/BuiltinsVEVL.gen.def"
+  textual header "clang/Basic/BuiltinsWebAssembly.def"
+  textual header "clang/Basic/BuiltinsX86.def"
+  textual header "clang/Basic/BuiltinsX86_64.def"
+  textual header "clang/Basic/BuiltinsXCore.def"
+  textual header "clang/Basic/CodeGenOptions.def"
+  textual header "clang/Basic/DiagnosticOptions.def"
+  textual header "clang/Basic/Features.def"
+  textual header "clang/Basic/FPOptions.def"
+  textual header "clang/Basic/MSP430Target.def"
+  textual header "clang/Basic/LangOptions.def"
+  textual header "clang/Basic/OpenCLExtensions.def"
+  textual header "clang/Basic/OpenCLImageTypes.def"
+  textual header "clang/Basic/OpenCLExtensionTypes.def"
+  textual header "clang/Basic/OpenMPKinds.def"
+  textual header "clang/Basic/OperatorKinds.def"
+  textual header "clang/Basic/PPCTypes.def"
+  textual header "clang/Basic/RISCVVTypes.def"
+  textual header "clang/Basic/Sanitizers.def"
+  textual header "clang/Basic/TargetCXXABI.def"
+  textual header "clang/Basic/TransformTypeTraits.def"
+  textual header "clang/Basic/TokenKinds.def"
+  textual header "clang/Basic/WebAssemblyReferenceTypes.def"
+
+  module * { export * }
+}
+module Clang_Basic_TokenKinds {
+  requires cplusplus
+
+  header "clang/Basic/TokenKinds.h"
+  textual header "clang/Basic/TokenKinds.def"
+
+  export *
+}
+
+module Clang_CodeGen { requires cplusplus umbrella "clang/CodeGen" module * { export * } }
+module Clang_Config { requires cplusplus umbrella "clang/Config" module * { export * } }
+
+// Files for diagnostic groups are spread all over the include/clang/ tree, but
+// logically form a single module.
+module Clang_Diagnostics {
+  requires cplusplus
+
+  module All { header "clang/Basic/AllDiagnostics.h" export * }
+  module Analysis { textual header "clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def" }
+  module AST { header "clang/AST/ASTDiagnostic.h" export * }
+  module Comment { header "clang/AST/CommentDiagnostic.h" export * }
+  module Driver { header "clang/Driver/DriverDiagnostic.h" export * }
+  module Frontend { header "clang/Frontend/FrontendDiagnostic.h" export * }
+  module Lex { header "clang/Lex/LexDiagnostic.h" export * }
+  module Parse { header "clang/Parse/ParseDiagnostic.h" export * }
+  module Sema { header "clang/Sema/SemaDiagnostic.h" export * }
+  module Serialization { header "clang/Serialization/SerializationDiagnostic.h" export * }
+  module Refactoring { header "clang/Tooling/Refactoring/RefactoringDiagnostic.h" export * }
+}
+
+module Clang_Driver {
+  requires cplusplus
+  umbrella "clang/Driver"
+
+  textual header "clang/Driver/Types.def"
+
+  module * { export * }
+}
+
+module Clang_Edit { requires cplusplus umbrella "clang/Edit" module * { export * } }
+module Clang_Format { requires cplusplus umbrella "clang/Format" module * { export * } }
+
+module Clang_Frontend {
+  requires cplusplus
+  umbrella "clang/Frontend"
+
+  textual header "clang/Basic/LangStandards.def"
+
+  module * { export * }
+}
+
+module Clang_FrontendTool { requires cplusplus umbrella "clang/FrontendTool" module * { export * } }
+module Clang_Index { requires cplusplus umbrella "clang/Index" module * { export * } }
+module Clang_Lex { requires cplusplus umbrella "clang/Lex" module * { export * } }
+module Clang_Parse { requires cplusplus umbrella "clang/Parse" module * { export * } }
+module Clang_Rewrite { requires cplusplus umbrella "clang/Rewrite/Core" module * { export * } }
+module Clang_RewriteFrontend { requires cplusplus umbrella "clang/Rewrite/Frontend" module * { export * } }
+module Clang_Sema { requires cplusplus umbrella "clang/Sema" module * { export * } }
+
+module Clang_Serialization {
+  requires cplusplus
+  umbrella "clang/Serialization"
+
+  textual header "clang/Serialization/TypeBitCodes.def"
+
+  module * { export * }
+}
+
+module Clang_StaticAnalyzer_Core {
+  requires cplusplus
+  umbrella "clang/StaticAnalyzer/Core"
+
+  textual header "clang/StaticAnalyzer/Core/Analyses.def"
+  textual header "clang/StaticAnalyzer/Core/AnalyzerOptions.def"
+  textual header "clang/StaticAnalyzer/Core/PathSensitive/SVals.def"
+  textual header "clang/StaticAnalyzer/Core/PathSensitive/Symbols.def"
+  textual header "clang/StaticAnalyzer/Core/PathSensitive/Regions.def"
+
+  module * { export * }
+}
+
+module Clang_StaticAnalyzer_Checkers {
+  requires cplusplus
+  umbrella "clang/StaticAnalyzer/Checkers"
+  module * { export * }
+}
+
+module Clang_StaticAnalyzer_Frontend {
+  requires cplusplus
+  umbrella "clang/StaticAnalyzer/Frontend"
+  module * { export * }
+}
+
+module Clang_Testing {
+  requires cplusplus
+  umbrella "clang/Testing"
+  module * { export * }
+}
+
+module Clang_Tooling {
+  requires cplusplus umbrella "clang/Tooling" module * { export * }
+  // FIXME: Exclude these headers to avoid pulling all of the AST matchers
+  // library into clang-format. Due to inline key functions in the headers,
+  // importing the AST matchers library gives a link dependency on the AST
+  // matchers (and thus the AST), which clang-format should not have.
+  exclude header "clang/Tooling/RefactoringCallbacks.h"
+}
+
+module Clang_ToolingCore {
+  requires cplusplus
+  umbrella "clang/Tooling/Core" module * { export * }
+}
+
+module Clang_ToolingInclusions {
+  requires cplusplus
+  umbrella "clang/Tooling/Inclusions"
+  module * { export * }
+}

diff  --git a/lldb/include/lldb/module.modulemap b/lldb/include/lldb/module.modulemap
deleted file mode 100644
index 3e5a903dc1c6c..0000000000000
--- a/lldb/include/lldb/module.modulemap
+++ /dev/null
@@ -1,142 +0,0 @@
-
-module lldb_API {
-  requires cplusplus
-
-  textual header "Utility/Instrumentation.h"
-
-  umbrella "API"
-  module * { export * }
-}
-
-module lldb_Host {
-  requires cplusplus
-
-  // Because we have OS-specific headers in Host, we just list
-  // all OS-independent headers here that will include the correct
-  // OS-specific header for us.
-  module ConnectionFileDescriptor { header "Host/ConnectionFileDescriptor.h" export * }
-  module Debug { header "Host/Debug.h" export * }
-  module Editline { header "Host/Editline.h" export * }
-  module FileCache { header "Host/FileCache.h" export * }
-  module File { header "Host/File.h" export * }
-  module FileAction { header "Host/FileAction.h" export * }
-  module FileSystem { header "Host/FileSystem.h" export * }
-  module HostGetOpt { header "Host/HostGetOpt.h" export * }
-  module Host { header "Host/Host.h" export * }
-  module HostInfoBase { header "Host/HostInfoBase.h" export * }
-  module HostInfo { header "Host/HostInfo.h" export * }
-  module HostNativeProcessBase { header "Host/HostNativeProcessBase.h" export * }
-  module HostNativeProcess { header "Host/HostNativeProcess.h" export * }
-  module HostNativeThreadBase { header "Host/HostNativeThreadBase.h" export * }
-  module HostNativeThreadForward { header "Host/HostNativeThreadForward.h" export * }
-  module HostNativeThread { header "Host/HostNativeThread.h" export * }
-  module HostProcess { header "Host/HostProcess.h" export * }
-  module HostThread { header "Host/HostThread.h" export * }
-  module LockFileBase { header "Host/LockFileBase.h" export * }
-  module LockFile { header "Host/LockFile.h" export * }
-  module MainLoopBase { header "Host/MainLoopBase.h" export * }
-  module MainLoop { header "Host/MainLoop.h" export * }
-  module MonitoringProcessLauncher { header "Host/MonitoringProcessLauncher.h" export * }
-  module OptionParser { header "Host/OptionParser.h" export * }
-  module PipeBase { header "Host/PipeBase.h" export * }
-  module Pipe { header "Host/Pipe.h" export * }
-  module PosixApi { header "Host/PosixApi.h" export * }
-  module ProcessLauncher { header "Host/ProcessLauncher.h" export * }
-  module ProcessLaunchInfo { header "Host/ProcessLaunchInfo.h" export * }
-  module ProcessRunLock { header "Host/ProcessRunLock.h" export * }
-  module PseudoTerminal { header "Host/PseudoTerminal.h" export * }
-  module SafeMachO { header "Host/SafeMachO.h" export * }
-  module SocketAddress { header "Host/SocketAddress.h" export * }
-  module Socket { header "Host/Socket.h" export * }
-  module Terminal { header "Host/Terminal.h" export * }
-  module ThreadLauncher { header "Host/ThreadLauncher.h" export * }
-  module Time { header "Host/Time.h" export * }
-  module XML { header "Host/XML.h" export * }
-
-  module common {
-    umbrella "Host/common"
-    module * { export * }
-  }
-
-  export *
-}
-
-module lldb_Initialization {
-  requires cplusplus
-
-  umbrella "Initialization"
-  module * { export * }
-}
-
-
-module lldb_Wrapper {
-
-  module lldb_Breakpoint {
-    requires cplusplus
-
-    umbrella "Breakpoint"
-    module * { export * }
-  }
-
-  module lldb_Core {
-    requires cplusplus
-
-    umbrella "Core"
-    module * { export * }
-  }
-
-  module lldb_DataFormatters {
-    requires cplusplus
-
-    umbrella "DataFormatters"
-    module * { export * }
-  }
-
-  module lldb_Expression {
-    requires cplusplus
-
-    umbrella "Expression"
-    module * { export * }
-  }
-
-  module lldb_Interpreter {
-    requires cplusplus
-
-    umbrella "Interpreter"
-    module * { export * }
-  }
-
-  module lldb_Symbol {
-    requires cplusplus
-
-    umbrella "Symbol"
-    module * { export * }
-  }
-  module lldb_Target {
-    requires cplusplus
-
-    umbrella "Target"
-    textual header "Target/AppleArm64ExceptionClass.def"
-    module * { export * }
-  }
-}
-
-
-module lldb_Utility {
-  requires cplusplus
-
-  umbrella "Utility"
-  module * { export * }
-
-  module lldb_defines { header "lldb-defines.h" export * }
-  module lldb_enumerations { header "lldb-enumerations.h" export * }
-  module lldb_forward { header "lldb-forward.h" export * }
-  module lldb_private_enumerations { header "lldb-private-enumerations.h" export * }
-  module lldb_private_forward { header "lldb-private-forward.h" export * }
-  module lldb_private { header "lldb-private.h" export * }
-  module lldb_private_interfaces { header "lldb-private-interfaces.h" export * }
-  module lldb_private_types { header "lldb-private-types.h" export * }
-  module lldb_public { header "lldb-public.h" export * }
-  module lldb_types { header "lldb-types.h" export * }
-  module lldb_versioning { header "lldb-versioning.h" export * }
-}

diff  --git a/lldb/include/module.modulemap b/lldb/include/module.modulemap
new file mode 100644
index 0000000000000..9500427eed581
--- /dev/null
+++ b/lldb/include/module.modulemap
@@ -0,0 +1,142 @@
+
+module lldb_API {
+  requires cplusplus
+
+  textual header "lldb/Utility/Instrumentation.h"
+
+  umbrella "lldb/API"
+  module * { export * }
+}
+
+module lldb_Host {
+  requires cplusplus
+
+  // Because we have OS-specific headers in Host, we just list
+  // all OS-independent headers here that will include the correct
+  // OS-specific header for us.
+  module ConnectionFileDescriptor { header "lldb/Host/ConnectionFileDescriptor.h" export * }
+  module Debug { header "lldb/Host/Debug.h" export * }
+  module Editline { header "lldb/Host/Editline.h" export * }
+  module FileCache { header "lldb/Host/FileCache.h" export * }
+  module File { header "lldb/Host/File.h" export * }
+  module FileAction { header "lldb/Host/FileAction.h" export * }
+  module FileSystem { header "lldb/Host/FileSystem.h" export * }
+  module HostGetOpt { header "lldb/Host/HostGetOpt.h" export * }
+  module Host { header "lldb/Host/Host.h" export * }
+  module HostInfoBase { header "lldb/Host/HostInfoBase.h" export * }
+  module HostInfo { header "lldb/Host/HostInfo.h" export * }
+  module HostNativeProcessBase { header "lldb/Host/HostNativeProcessBase.h" export * }
+  module HostNativeProcess { header "lldb/Host/HostNativeProcess.h" export * }
+  module HostNativeThreadBase { header "lldb/Host/HostNativeThreadBase.h" export * }
+  module HostNativeThreadForward { header "lldb/Host/HostNativeThreadForward.h" export * }
+  module HostNativeThread { header "lldb/Host/HostNativeThread.h" export * }
+  module HostProcess { header "lldb/Host/HostProcess.h" export * }
+  module HostThread { header "lldb/Host/HostThread.h" export * }
+  module LockFileBase { header "lldb/Host/LockFileBase.h" export * }
+  module LockFile { header "lldb/Host/LockFile.h" export * }
+  module MainLoopBase { header "lldb/Host/MainLoopBase.h" export * }
+  module MainLoop { header "lldb/Host/MainLoop.h" export * }
+  module MonitoringProcessLauncher { header "lldb/Host/MonitoringProcessLauncher.h" export * }
+  module OptionParser { header "lldb/Host/OptionParser.h" export * }
+  module PipeBase { header "lldb/Host/PipeBase.h" export * }
+  module Pipe { header "lldb/Host/Pipe.h" export * }
+  module PosixApi { header "lldb/Host/PosixApi.h" export * }
+  module ProcessLauncher { header "lldb/Host/ProcessLauncher.h" export * }
+  module ProcessLaunchInfo { header "lldb/Host/ProcessLaunchInfo.h" export * }
+  module ProcessRunLock { header "lldb/Host/ProcessRunLock.h" export * }
+  module PseudoTerminal { header "lldb/Host/PseudoTerminal.h" export * }
+  module SafeMachO { header "lldb/Host/SafeMachO.h" export * }
+  module SocketAddress { header "lldb/Host/SocketAddress.h" export * }
+  module Socket { header "lldb/Host/Socket.h" export * }
+  module Terminal { header "lldb/Host/Terminal.h" export * }
+  module ThreadLauncher { header "lldb/Host/ThreadLauncher.h" export * }
+  module Time { header "lldb/Host/Time.h" export * }
+  module XML { header "lldb/Host/XML.h" export * }
+
+  module common {
+    umbrella "lldb/Host/common"
+    module * { export * }
+  }
+
+  export *
+}
+
+module lldb_Initialization {
+  requires cplusplus
+
+  umbrella "lldb/Initialization"
+  module * { export * }
+}
+
+
+module lldb_Wrapper {
+
+  module lldb_Breakpoint {
+    requires cplusplus
+
+    umbrella "lldb/Breakpoint"
+    module * { export * }
+  }
+
+  module lldb_Core {
+    requires cplusplus
+
+    umbrella "lldb/Core"
+    module * { export * }
+  }
+
+  module lldb_DataFormatters {
+    requires cplusplus
+
+    umbrella "lldb/DataFormatters"
+    module * { export * }
+  }
+
+  module lldb_Expression {
+    requires cplusplus
+
+    umbrella "lldb/Expression"
+    module * { export * }
+  }
+
+  module lldb_Interpreter {
+    requires cplusplus
+
+    umbrella "lldb/Interpreter"
+    module * { export * }
+  }
+
+  module lldb_Symbol {
+    requires cplusplus
+
+    umbrella "lldb/Symbol"
+    module * { export * }
+  }
+  module lldb_Target {
+    requires cplusplus
+
+    umbrella "lldb/Target"
+    textual header "lldb/Target/AppleArm64ExceptionClass.def"
+    module * { export * }
+  }
+}
+
+
+module lldb_Utility {
+  requires cplusplus
+
+  umbrella "lldb/Utility"
+  module * { export * }
+
+  module lldb_defines { header "lldb/lldb-defines.h" export * }
+  module lldb_enumerations { header "lldb/lldb-enumerations.h" export * }
+  module lldb_forward { header "lldb/lldb-forward.h" export * }
+  module lldb_private_enumerations { header "lldb/lldb-private-enumerations.h" export * }
+  module lldb_private_forward { header "lldb/lldb-private-forward.h" export * }
+  module lldb_private { header "lldb/lldb-private.h" export * }
+  module lldb_private_interfaces { header "lldb/lldb-private-interfaces.h" export * }
+  module lldb_private_types { header "lldb/lldb-private-types.h" export * }
+  module lldb_public { header "lldb/lldb-public.h" export * }
+  module lldb_types { header "lldb/lldb-types.h" export * }
+  module lldb_versioning { header "lldb/lldb-versioning.h" export * }
+}

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index bd23d6657829a..ce6cd1a52d3a1 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1163,7 +1163,7 @@ add_subdirectory(lib/TableGen)
 
 add_subdirectory(utils/TableGen)
 
-add_subdirectory(include/llvm)
+add_subdirectory(include)
 
 add_subdirectory(lib)
 
@@ -1275,14 +1275,14 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
     )
 
   if (LLVM_INSTALL_MODULEMAPS)
-    install(DIRECTORY include/llvm include/llvm-c
+    install(DIRECTORY include
             DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
             COMPONENT llvm-headers
             FILES_MATCHING
             PATTERN "module.modulemap"
             )
-    install(FILES include/llvm/module.install.modulemap
-            DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm"
+    install(FILES include/module.install.modulemap
+            DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
             COMPONENT llvm-headers
             RENAME "module.extern.modulemap"
             )

diff  --git a/llvm/include/CMakeLists.txt b/llvm/include/CMakeLists.txt
new file mode 100644
index 0000000000000..06da8dcc26097
--- /dev/null
+++ b/llvm/include/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_subdirectory(llvm)
+
+# If we're doing an out-of-tree build, copy a module map for generated
+# header files into the build area.
+if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
+  configure_file(module.modulemap.build module.modulemap COPYONLY)
+endif (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")

diff  --git a/llvm/include/llvm-c/module.modulemap b/llvm/include/llvm-c/module.modulemap
deleted file mode 100644
index a456119595c95..0000000000000
--- a/llvm/include/llvm-c/module.modulemap
+++ /dev/null
@@ -1,4 +0,0 @@
-module LLVM_C {
-  umbrella "."
-  module * { export * }
-}

diff  --git a/llvm/include/llvm/CMakeLists.txt b/llvm/include/llvm/CMakeLists.txt
index 58b71e8b220f5..ac6b96a68ab92 100644
--- a/llvm/include/llvm/CMakeLists.txt
+++ b/llvm/include/llvm/CMakeLists.txt
@@ -7,9 +7,3 @@ add_subdirectory(IR)
 add_subdirectory(Support)
 add_subdirectory(Frontend)
 add_subdirectory(TargetParser)
-
-# If we're doing an out-of-tree build, copy a module map for generated
-# header files into the build area.
-if (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
-  configure_file(module.modulemap.build module.modulemap COPYONLY)
-endif (NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")

diff  --git a/llvm/include/llvm/module.install.modulemap b/llvm/include/llvm/module.install.modulemap
deleted file mode 100644
index e12656f554efb..0000000000000
--- a/llvm/include/llvm/module.install.modulemap
+++ /dev/null
@@ -1,35 +0,0 @@
-
-module LLVM_Extern_CodeGenTypes_Gen {
-  textual header "CodeGen/GenVT.inc"
-}
-
-module LLVM_Extern_Config_Def {
- textual header "Config/AsmParsers.def"
- textual header "Config/AsmPrinters.def"
- textual header "Config/Disassemblers.def"
- textual header "Config/Targets.def"
- export *
-}
-
-module LLVM_Extern_IR_Attributes_Gen {
-  textual header "IR/Attributes.gen"
-  textual header "IR/Attributes.inc"
-}
-
-module LLVM_Extern_IR_Intrinsics_Gen {
-  textual header "IR/Intrinsics.gen"
-  textual header "IR/Intrinsics.inc"
-}
-
-module LLVM_Extern_IR_Intrinsics_Enum {
-  textual header "IR/IntrinsicEnums.inc"
-}
-
-module LLVM_Extern_Utils_DataTypes {
-  header "Support/DataTypes.h"
-  export *
-}
-
-module LLVM_Extern_TargetParser_Gen {
-  textual header "TargetParser/RISCVTargetParserDef.inc"
-}

diff  --git a/llvm/include/llvm/module.modulemap b/llvm/include/llvm/module.modulemap
deleted file mode 100644
index f3da1437d867c..0000000000000
--- a/llvm/include/llvm/module.modulemap
+++ /dev/null
@@ -1,423 +0,0 @@
-module LLVM_Analysis {
-  requires cplusplus
-  umbrella "Analysis"
-  module * { export * }
-
-  // This is intended for (repeated) textual inclusion.
-  textual header "Analysis/ScalarFuncs.def"
-  textual header "Analysis/TargetLibraryInfo.def"
-  textual header "Analysis/VecFuncs.def"
-}
-
-module LLVM_AsmParser {
-  requires cplusplus
-  umbrella "AsmParser"
-  module * { export * }
-}
-
-module LLVM_CodeGenTypes {
-  requires cplusplus
-
-  module LLT {
-    header "CodeGen/LowLevelType.h" export *
-  }
-  module MVT {
-    header "CodeGen/MachineValueType.h" export *
-    extern module LLVM_Extern_CodeGenTypes_Gen "module.extern.modulemap"
-  }
-}
-
-// A module covering CodeGen/ and Target/. These are intertwined
-// and codependent, and thus notionally form a single module.
-module LLVM_Backend {
-  requires cplusplus
-
-  module CodeGen {
-    umbrella "CodeGen"
-    module * { export * }
-
-    // Exclude these; they're intended to be included into only a single
-    // translation unit (or none) and aren't part of this module.
-    exclude header "CodeGen/LinkAllAsmWriterComponents.h"
-    exclude header "CodeGen/LinkAllCodegenComponents.h"
-
-    exclude header "CodeGen/CodeGenPassBuilder.h"
-
-    // These are intended for (repeated) textual inclusion.
-    textual header "CodeGen/DIEValue.def"
-    textual header "CodeGen/MachinePassRegistry.def"
-  }
-}
-
-// FIXME: Make this as a submodule of LLVM_Backend again.
-//        Doing so causes a linker error in clang-format.
-module LLVM_Backend_Target {
-  umbrella "Target"
-  module * { export * }
-}
-
-module LLVM_Bitcode {
- requires cplusplus
- umbrella "Bitcode"
- module * { export * }
-}
-
-module LLVM_Bitstream {
- requires cplusplus
- umbrella "Bitstream"
- module * { export * }
-}
-
-module LLVM_BinaryFormat {
-    requires cplusplus
-    umbrella "BinaryFormat" module * { export * }
-    textual header "BinaryFormat/Dwarf.def"
-    textual header "BinaryFormat/DXContainerConstants.def"
-    textual header "BinaryFormat/DynamicTags.def"
-    textual header "BinaryFormat/MachO.def"
-    textual header "BinaryFormat/MinidumpConstants.def"
-    textual header "BinaryFormat/Swift.def"
-    textual header "BinaryFormat/ELFRelocs/AArch64.def"
-    textual header "BinaryFormat/ELFRelocs/AMDGPU.def"
-    textual header "BinaryFormat/ELFRelocs/ARM.def"
-    textual header "BinaryFormat/ELFRelocs/ARC.def"
-    textual header "BinaryFormat/ELFRelocs/AVR.def"
-    textual header "BinaryFormat/ELFRelocs/BPF.def"
-    textual header "BinaryFormat/ELFRelocs/CSKY.def"
-    textual header "BinaryFormat/ELFRelocs/Hexagon.def"
-    textual header "BinaryFormat/ELFRelocs/i386.def"
-    textual header "BinaryFormat/ELFRelocs/Lanai.def"
-    textual header "BinaryFormat/ELFRelocs/LoongArch.def"
-    textual header "BinaryFormat/ELFRelocs/M68k.def"
-    textual header "BinaryFormat/ELFRelocs/Mips.def"
-    textual header "BinaryFormat/ELFRelocs/MSP430.def"
-    textual header "BinaryFormat/ELFRelocs/PowerPC64.def"
-    textual header "BinaryFormat/ELFRelocs/PowerPC.def"
-    textual header "BinaryFormat/ELFRelocs/RISCV.def"
-    textual header "BinaryFormat/ELFRelocs/Sparc.def"
-    textual header "BinaryFormat/ELFRelocs/SystemZ.def"
-    textual header "BinaryFormat/ELFRelocs/VE.def"
-    textual header "BinaryFormat/ELFRelocs/x86_64.def"
-    textual header "BinaryFormat/ELFRelocs/Xtensa.def"
-    textual header "BinaryFormat/WasmRelocs.def"
-    textual header "BinaryFormat/MsgPack.def"
-}
-
-module LLVM_Config {
-  requires cplusplus
-  umbrella "Config"
-  extern module LLVM_Extern_Config_Def "module.extern.modulemap"
-  module * { export * }
-}
-
-module LLVM_DebugInfo {
-  requires cplusplus
-  module DIContext { header "DebugInfo/DIContext.h" export * }
-}
-
-module LLVM_DebugInfo_DWARF {
-  requires cplusplus
-
-  umbrella "DebugInfo/DWARF"
-  module * { export * }
-}
-
-module LLVM_DebugInfo_PDB {
-  requires cplusplus
-
-  umbrella "DebugInfo/PDB"
-  module * { export * }
-
-  // Separate out this subdirectory; it's an optional component that depends on
-  // a separate library which might not be available.
-  //
-  // FIXME: There should be a better way to specify this.
-  exclude header "DebugInfo/PDB/DIA/DIADataStream.h"
-  exclude header "DebugInfo/PDB/DIA/DIAEnumDebugStreams.h"
-  exclude header "DebugInfo/PDB/DIA/DIAEnumFrameData.h"
-  exclude header "DebugInfo/PDB/DIA/DIAEnumInjectedSources.h"
-  exclude header "DebugInfo/PDB/DIA/DIAEnumLineNumbers.h"
-  exclude header "DebugInfo/PDB/DIA/DIAEnumSectionContribs.h"
-  exclude header "DebugInfo/PDB/DIA/DIAEnumSourceFiles.h"
-  exclude header "DebugInfo/PDB/DIA/DIAEnumSymbols.h"
-  exclude header "DebugInfo/PDB/DIA/DIAEnumTables.h"
-  exclude header "DebugInfo/PDB/DIA/DIAError.h"
-  exclude header "DebugInfo/PDB/DIA/DIAFrameData.h"
-  exclude header "DebugInfo/PDB/DIA/DIAInjectedSource.h"
-  exclude header "DebugInfo/PDB/DIA/DIALineNumber.h"
-  exclude header "DebugInfo/PDB/DIA/DIARawSymbol.h"
-  exclude header "DebugInfo/PDB/DIA/DIASectionContrib.h"
-  exclude header "DebugInfo/PDB/DIA/DIASession.h"
-  exclude header "DebugInfo/PDB/DIA/DIASourceFile.h"
-  exclude header "DebugInfo/PDB/DIA/DIASupport.h"
-  exclude header "DebugInfo/PDB/DIA/DIATable.h"
-  exclude header "DebugInfo/PDB/DIA/DIAUtils.h"
-}
-
-module LLVM_DebugInfo_PDB_DIA {
-  requires cplusplus
-
-  umbrella "DebugInfo/PDB/DIA"
-  module * { export * }
-}
-
-module LLVM_DebugInfo_MSF {
-  requires cplusplus
-
-  umbrella "DebugInfo/MSF"
-  module * { export * }
-}
-
-module LLVM_DebugInfo_CodeView {
-  requires cplusplus
-
-  umbrella "DebugInfo/CodeView"
-  module * { export * }
-
-  // These are intended for (repeated) textual inclusion.
-  textual header "DebugInfo/CodeView/CodeViewRegisters.def"
-  textual header "DebugInfo/CodeView/CodeViewTypes.def"
-  textual header "DebugInfo/CodeView/CodeViewSymbols.def"
-}
-
-module LLVM_DWARFLinker {
-  requires cplusplus
-
-  umbrella "DWARFLinker"
-  module * { export * }
-}
-
-module LLVM_ExecutionEngine {
-  requires cplusplus
-
-  umbrella "ExecutionEngine"
-  module * { export * }
-
-  // Exclude this; it's an optional component of the ExecutionEngine.
-  exclude header "ExecutionEngine/OProfileWrapper.h"
-
-  // Exclude these; they're intended to be included into only a single
-  // translation unit (or none) and aren't part of this module.
-  exclude header "ExecutionEngine/MCJIT.h"
-  exclude header "ExecutionEngine/Interpreter.h"
-
-  // Exclude headers from LLVM_OrcSupport.
-  exclude header "ExecutionEngine/Orc/Shared/OrcError.h"
-}
-
-module LLVM_FileCheck {
-  requires cplusplus
-
-  umbrella "FileCheck"
-  module * { export * }
-}
-
-module LLVM_Frontend_OpenMP {
-  requires cplusplus
-
-  umbrella "Frontend/OpenMP"
-  module * { export * }
-
-  exclude header "Frontend/OpenMP/OMPKinds.def"
-}
-
-// Orc utilities that don't depend only on Support (not ExecutionEngine or
-// IR). This is a workaround for ExecutionEngine's broken layering, and will
-// be removed in the future.
-module LLVM_OrcSupport {
-  requires cplusplus
-
-  header "ExecutionEngine/Orc/Shared/OrcError.h"
-
-  export *
-}
-
-module LLVM_Pass {
-  module Pass {
-    // PassSupport.h and PassAnalysisSupport.h are made available only through
-    // Pass.h.
-    header "Pass.h"
-    textual header "PassSupport.h"
-    textual header "PassAnalysisSupport.h"
-    export *
-  }
-
-  module PassRegistry { header "PassRegistry.h" export * }
-  module InitializePasses { header "InitializePasses.h" export * }
-}
-
-module LLVM_IR {
-  requires cplusplus
-
-  umbrella "IR"
-  module * { export * }
-
-  extern module LLVM_Extern_IR_Attributes_Gen "module.extern.modulemap"
-  extern module LLVM_Extern_IR_Intricsics_Gen "module.extern.modulemap"
-  extern module LLVM_Extern_IR_Intrinsics_Enum "module.extern.modulemap"
-
-  // These are intended for (repeated) textual inclusion.
-  textual header "IR/ConstrainedOps.def"
-  textual header "IR/DebugInfoFlags.def"
-  textual header "IR/Instruction.def"
-  textual header "IR/Metadata.def"
-  textual header "IR/FixedMetadataKinds.def"
-  textual header "IR/Value.def"
-  textual header "IR/VPIntrinsics.def"
-  textual header "IR/RuntimeLibcalls.def"
-}
-
-module LLVM_IRReader {
-  requires cplusplus
-  umbrella "IRReader"
-  module * { export * }
-}
-
-module LLVM_LineEditor {
-  requires cplusplus
-  umbrella "LineEditor"
-  module * { export * }
-}
-
-module LLVM_LTO {
-  requires cplusplus
-  umbrella "LTO"
-  module * { export * }
-}
-
-module LLVM_MC {
-  requires cplusplus
-
-  umbrella "MC"
-  module * { export * }
-}
-
-module LLVM_Object {
-  requires cplusplus
-  umbrella "Object"
-  module * { export * }
-}
-
-module LLVM_Option {
-  requires cplusplus
-  umbrella "Option"
-  module * { export * }
-}
-
-module LLVM_ProfileData {
-  requires cplusplus
-
-  umbrella "ProfileData"
-  module * { export * }
-
-  textual header "ProfileData/InstrProfData.inc"
-  textual header "ProfileData/MemProfData.inc"
-  textual header "ProfileData/MIBEntryDef.inc"
-}
-
-// FIXME: Mislayered?
-module LLVM_Support_TargetRegistry {
-  requires cplusplus
-  header "Support/TargetRegistry.h"
-  export *
-}
-
-module LLVM_TableGen {
-  requires cplusplus
-  umbrella "TableGen"
-  module * { export * }
-}
-
-module LLVM_Transforms {
-  requires cplusplus
-  umbrella "Transforms"
-
-  module * { export * }
-
-  // Requires DEBUG_TYPE to be defined by including file.
-  exclude header "Transforms/Utils/InstructionWorklist.h"
-}
-
-extern module LLVM_Extern_Utils_DataTypes "module.extern.modulemap"
-
-// Build the module with the tablegen-generated files needed by the
-// TargetParser module before building the TargetParser module itself.
-module TargetParserGen {
-  module RISCVTargetParserDef {
-    header "TargetParser/RISCVTargetParser.h"
-    extern module LLVM_Extern_TargetParser_Gen "module.extern.modulemap"
-    export *
-  }
-}
-
-// A module covering ADT/ and Support/. These are intertwined and
-// codependent, and notionally form a single module.
-module LLVM_Utils {
-  module ADT {
-    requires cplusplus
-
-    umbrella "ADT"
-    module * { export * }
-  }
-
-  module Demangle {
-    requires cplusplus
-
-    umbrella "Demangle"
-    module * { export * }
-
-    textual header "Demangle/ItaniumNodes.def"
-  }
-
-  module Support {
-    requires cplusplus
-
-    umbrella "Support"
-    module * { export * }
-
-    // Exclude this; deprecated.
-    exclude header "Support/Host.h"
-
-    // Exclude this; it should only be used on Windows.
-    exclude header "Support/Windows/WindowsSupport.h"
-
-    // Exclude these; they are fundamentally non-modular.
-    exclude header "Support/PluginLoader.h"
-    exclude header "Support/Solaris/sys/regset.h"
-    textual header "Support/TargetOpcodes.def"
-
-  }
-
-  module TargetParser {
-    requires cplusplus
-
-    umbrella "TargetParser"
-    module * { export * }
-
-    // These are intended for textual inclusion.
-    textual header "TargetParser/ARMTargetParser.def"
-    textual header "TargetParser/CSKYTargetParser.def"
-    textual header "TargetParser/X86TargetParser.def"
-    textual header "TargetParser/LoongArchTargetParser.def"
-  }
-
-  // This part of the module is usable from both C and C++ code.
-  module ConvertUTF {
-    header "Support/ConvertUTF.h"
-    export *
-  }
-}
-
-// This is used for a $src == $build compilation. Otherwise we use
-// LLVM_Support_DataTypes_Build, defined in a module map that is
-// copied into the build area.
-module LLVM_Support_DataTypes_Src {
-  header "llvm/Support/DataTypes.h"
-  export *
-}
-
-module LLVM_WindowsManifest {
-  requires cplusplus
-  umbrella "WindowsManifest"
-  module * { export * }
-}

diff  --git a/llvm/include/llvm/module.extern.modulemap b/llvm/include/module.extern.modulemap
similarity index 100%
rename from llvm/include/llvm/module.extern.modulemap
rename to llvm/include/module.extern.modulemap

diff  --git a/llvm/include/module.install.modulemap b/llvm/include/module.install.modulemap
new file mode 100644
index 0000000000000..f7302830f561d
--- /dev/null
+++ b/llvm/include/module.install.modulemap
@@ -0,0 +1,35 @@
+
+module LLVM_Extern_CodeGenTypes_Gen {
+  textual header "llvm/CodeGen/GenVT.inc"
+}
+
+module LLVM_Extern_Config_Def {
+  textual header "llvm/Config/AsmParsers.def"
+  textual header "llvm/Config/AsmPrinters.def"
+  textual header "llvm/Config/Disassemblers.def"
+  textual header "llvm/Config/Targets.def"
+  export *
+}
+
+module LLVM_Extern_IR_Attributes_Gen {
+  textual header "llvm/IR/Attributes.gen"
+  textual header "llvm/IR/Attributes.inc"
+}
+
+module LLVM_Extern_IR_Intrinsics_Gen {
+  textual header "llvm/IR/Intrinsics.gen"
+  textual header "llvm/IR/Intrinsics.inc"
+}
+
+module LLVM_Extern_IR_Intrinsics_Enum {
+  textual header "llvm/IR/IntrinsicEnums.inc"
+}
+
+module LLVM_Extern_Utils_DataTypes {
+  header "llvm/Support/DataTypes.h"
+  export *
+}
+
+module LLVM_Extern_TargetParser_Gen {
+  textual header "llvm/TargetParser/RISCVTargetParserDef.inc"
+}

diff  --git a/llvm/include/module.modulemap b/llvm/include/module.modulemap
new file mode 100644
index 0000000000000..4c2ba437edb9f
--- /dev/null
+++ b/llvm/include/module.modulemap
@@ -0,0 +1,428 @@
+module LLVM_C {
+  umbrella "llvm-c"
+  module * { export * }
+}
+
+module LLVM_Analysis {
+  requires cplusplus
+  umbrella "llvm/Analysis"
+  module * { export * }
+
+  // This is intended for (repeated) textual inclusion.
+  textual header "llvm/Analysis/ScalarFuncs.def"
+  textual header "llvm/Analysis/TargetLibraryInfo.def"
+  textual header "llvm/Analysis/VecFuncs.def"
+}
+
+module LLVM_AsmParser {
+  requires cplusplus
+  umbrella "llvm/AsmParser"
+  module * { export * }
+}
+
+module LLVM_CodeGenTypes {
+  requires cplusplus
+
+  module LLT {
+    header "llvm/CodeGen/LowLevelType.h" export *
+  }
+  module MVT {
+    header "llvm/CodeGen/MachineValueType.h" export *
+    extern module LLVM_Extern_CodeGenTypes_Gen "module.extern.modulemap"
+  }
+}
+
+// A module covering CodeGen/ and Target/. These are intertwined
+// and codependent, and thus notionally form a single module.
+module LLVM_Backend {
+  requires cplusplus
+
+  module CodeGen {
+    umbrella "llvm/CodeGen"
+    module * { export * }
+
+    // Exclude these; they're intended to be included into only a single
+    // translation unit (or none) and aren't part of this module.
+    exclude header "llvm/CodeGen/LinkAllAsmWriterComponents.h"
+    exclude header "llvm/CodeGen/LinkAllCodegenComponents.h"
+
+    exclude header "llvm/CodeGen/CodeGenPassBuilder.h"
+
+    // These are intended for (repeated) textual inclusion.
+    textual header "llvm/CodeGen/DIEValue.def"
+    textual header "llvm/CodeGen/MachinePassRegistry.def"
+  }
+}
+
+// FIXME: Make this as a submodule of LLVM_Backend again.
+//        Doing so causes a linker error in clang-format.
+module LLVM_Backend_Target {
+  umbrella "llvm/Target"
+  module * { export * }
+}
+
+module LLVM_Bitcode {
+ requires cplusplus
+ umbrella "llvm/Bitcode"
+ module * { export * }
+}
+
+module LLVM_Bitstream {
+ requires cplusplus
+ umbrella "llvm/Bitstream"
+ module * { export * }
+}
+
+module LLVM_BinaryFormat {
+    requires cplusplus
+    umbrella "llvm/BinaryFormat" module * { export * }
+    textual header "llvm/BinaryFormat/Dwarf.def"
+    textual header "llvm/BinaryFormat/DXContainerConstants.def"
+    textual header "llvm/BinaryFormat/DynamicTags.def"
+    textual header "llvm/BinaryFormat/MachO.def"
+    textual header "llvm/BinaryFormat/MinidumpConstants.def"
+    textual header "llvm/BinaryFormat/Swift.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/AArch64.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/ARM.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/ARC.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/AVR.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/BPF.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/CSKY.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/Hexagon.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/i386.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/Lanai.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/LoongArch.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/M68k.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/Mips.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/MSP430.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/PowerPC64.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/PowerPC.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/RISCV.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/Sparc.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/SystemZ.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/VE.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/x86_64.def"
+    textual header "llvm/BinaryFormat/ELFRelocs/Xtensa.def"
+    textual header "llvm/BinaryFormat/WasmRelocs.def"
+    textual header "llvm/BinaryFormat/MsgPack.def"
+}
+
+module LLVM_Config {
+  requires cplusplus
+  umbrella "llvm/Config"
+  extern module LLVM_Extern_Config_Def "module.extern.modulemap"
+  module * { export * }
+}
+
+module LLVM_DebugInfo {
+  requires cplusplus
+  module DIContext { header "llvm/DebugInfo/DIContext.h" export * }
+}
+
+module LLVM_DebugInfo_DWARF {
+  requires cplusplus
+
+  umbrella "llvm/DebugInfo/DWARF"
+  module * { export * }
+}
+
+module LLVM_DebugInfo_PDB {
+  requires cplusplus
+
+  umbrella "llvm/DebugInfo/PDB"
+  module * { export * }
+
+  // Separate out this subdirectory; it's an optional component that depends on
+  // a separate library which might not be available.
+  //
+  // FIXME: There should be a better way to specify this.
+  exclude header "llvm/DebugInfo/PDB/DIA/DIADataStream.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAEnumFrameData.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAEnumInjectedSources.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAEnumLineNumbers.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAEnumSectionContribs.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAEnumSourceFiles.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAEnumTables.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAError.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAFrameData.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIALineNumber.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIASectionContrib.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIASession.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIASourceFile.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIASupport.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIATable.h"
+  exclude header "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
+}
+
+module LLVM_DebugInfo_PDB_DIA {
+  requires cplusplus
+
+  umbrella "llvm/DebugInfo/PDB/DIA"
+  module * { export * }
+}
+
+module LLVM_DebugInfo_MSF {
+  requires cplusplus
+
+  umbrella "llvm/DebugInfo/MSF"
+  module * { export * }
+}
+
+module LLVM_DebugInfo_CodeView {
+  requires cplusplus
+
+  umbrella "llvm/DebugInfo/CodeView"
+  module * { export * }
+
+  // These are intended for (repeated) textual inclusion.
+  textual header "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
+  textual header "llvm/DebugInfo/CodeView/CodeViewTypes.def"
+  textual header "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
+}
+
+module LLVM_DWARFLinker {
+  requires cplusplus
+
+  umbrella "llvm/DWARFLinker"
+  module * { export * }
+}
+
+module LLVM_ExecutionEngine {
+  requires cplusplus
+
+  umbrella "llvm/ExecutionEngine"
+  module * { export * }
+
+  // Exclude this; it's an optional component of the ExecutionEngine.
+  exclude header "llvm/ExecutionEngine/OProfileWrapper.h"
+
+  // Exclude these; they're intended to be included into only a single
+  // translation unit (or none) and aren't part of this module.
+  exclude header "llvm/ExecutionEngine/MCJIT.h"
+  exclude header "llvm/ExecutionEngine/Interpreter.h"
+
+  // Exclude headers from LLVM_OrcSupport.
+  exclude header "llvm/ExecutionEngine/Orc/Shared/OrcError.h"
+}
+
+module LLVM_FileCheck {
+  requires cplusplus
+
+  umbrella "llvm/FileCheck"
+  module * { export * }
+}
+
+module LLVM_Frontend_OpenMP {
+  requires cplusplus
+
+  umbrella "llvm/Frontend/OpenMP"
+  module * { export * }
+
+  exclude header "llvm/Frontend/OpenMP/OMPKinds.def"
+}
+
+// Orc utilities that don't depend only on Support (not ExecutionEngine or
+// IR). This is a workaround for ExecutionEngine's broken layering, and will
+// be removed in the future.
+module LLVM_OrcSupport {
+  requires cplusplus
+
+  header "llvm/ExecutionEngine/Orc/Shared/OrcError.h"
+
+  export *
+}
+
+module LLVM_Pass {
+  module Pass {
+    // PassSupport.h and PassAnalysisSupport.h are made available only through
+    // Pass.h.
+    header "llvm/Pass.h"
+    textual header "llvm/PassSupport.h"
+    textual header "llvm/PassAnalysisSupport.h"
+    export *
+  }
+
+  module PassRegistry { header "llvm/PassRegistry.h" export * }
+  module InitializePasses { header "llvm/InitializePasses.h" export * }
+}
+
+module LLVM_IR {
+  requires cplusplus
+
+  umbrella "llvm/IR"
+  module * { export * }
+
+  extern module LLVM_Extern_IR_Attributes_Gen "module.extern.modulemap"
+  extern module LLVM_Extern_IR_Intrinsics_Gen "module.extern.modulemap"
+  extern module LLVM_Extern_IR_Intrinsics_Enum "module.extern.modulemap"
+
+  // These are intended for (repeated) textual inclusion.
+  textual header "llvm/IR/ConstrainedOps.def"
+  textual header "llvm/IR/DebugInfoFlags.def"
+  textual header "llvm/IR/Instruction.def"
+  textual header "llvm/IR/Metadata.def"
+  textual header "llvm/IR/FixedMetadataKinds.def"
+  textual header "llvm/IR/Value.def"
+  textual header "llvm/IR/VPIntrinsics.def"
+  textual header "llvm/IR/RuntimeLibcalls.def"
+}
+
+module LLVM_IRReader {
+  requires cplusplus
+  umbrella "llvm/IRReader"
+  module * { export * }
+}
+
+module LLVM_LineEditor {
+  requires cplusplus
+  umbrella "llvm/LineEditor"
+  module * { export * }
+}
+
+module LLVM_LTO {
+  requires cplusplus
+  umbrella "llvm/LTO"
+  module * { export * }
+}
+
+module LLVM_MC {
+  requires cplusplus
+
+  umbrella "llvm/MC"
+  module * { export * }
+}
+
+module LLVM_Object {
+  requires cplusplus
+  umbrella "llvm/Object"
+  module * { export * }
+}
+
+module LLVM_Option {
+  requires cplusplus
+  umbrella "llvm/Option"
+  module * { export * }
+}
+
+module LLVM_ProfileData {
+  requires cplusplus
+
+  umbrella "llvm/ProfileData"
+  module * { export * }
+
+  textual header "llvm/ProfileData/InstrProfData.inc"
+  textual header "llvm/ProfileData/MemProfData.inc"
+  textual header "llvm/ProfileData/MIBEntryDef.inc"
+}
+
+// FIXME: Mislayered?
+module LLVM_Support_TargetRegistry {
+  requires cplusplus
+  header "llvm/Support/TargetRegistry.h"
+  export *
+}
+
+module LLVM_TableGen {
+  requires cplusplus
+  umbrella "llvm/TableGen"
+  module * { export * }
+}
+
+module LLVM_Transforms {
+  requires cplusplus
+  umbrella "llvm/Transforms"
+
+  module * { export * }
+
+  // Requires DEBUG_TYPE to be defined by including file.
+  exclude header "llvm/Transforms/Utils/InstructionWorklist.h"
+}
+
+extern module LLVM_Extern_Utils_DataTypes "module.extern.modulemap"
+
+// Build the module with the tablegen-generated files needed by the
+// TargetParser module before building the TargetParser module itself.
+module TargetParserGen {
+  module RISCVTargetParserDef {
+    header "llvm/TargetParser/RISCVTargetParser.h"
+    extern module LLVM_Extern_TargetParser_Gen "module.extern.modulemap"
+    export *
+  }
+}
+
+// A module covering ADT/ and Support/. These are intertwined and
+// codependent, and notionally form a single module.
+module LLVM_Utils {
+  module ADT {
+    requires cplusplus
+
+    umbrella "llvm/ADT"
+    module * { export * }
+  }
+
+  module Demangle {
+    requires cplusplus
+
+    umbrella "llvm/Demangle"
+    module * { export * }
+
+    textual header "llvm/Demangle/ItaniumNodes.def"
+  }
+
+  module Support {
+    requires cplusplus
+
+    umbrella "llvm/Support"
+    module * { export * }
+
+    // Exclude this; deprecated.
+    exclude header "llvm/Support/Host.h"
+
+    // Exclude this; it should only be used on Windows.
+    exclude header "llvm/Support/Windows/WindowsSupport.h"
+
+    // Exclude these; they are fundamentally non-modular.
+    exclude header "llvm/Support/PluginLoader.h"
+    exclude header "llvm/Support/Solaris/sys/regset.h"
+    textual header "llvm/Support/TargetOpcodes.def"
+
+  }
+
+  module TargetParser {
+    requires cplusplus
+
+    umbrella "llvm/TargetParser"
+    module * { export * }
+
+    // These are intended for textual inclusion.
+    textual header "llvm/TargetParser/ARMTargetParser.def"
+    textual header "llvm/TargetParser/CSKYTargetParser.def"
+    textual header "llvm/TargetParser/X86TargetParser.def"
+    textual header "llvm/TargetParser/LoongArchTargetParser.def"
+  }
+
+  // This part of the module is usable from both C and C++ code.
+  module ConvertUTF {
+    header "llvm/Support/ConvertUTF.h"
+    export *
+  }
+}
+
+// This is used for a $src == $build compilation. Otherwise we use
+// LLVM_Support_DataTypes_Build, defined in a module map that is
+// copied into the build area.
+module LLVM_Support_DataTypes_Src {
+  header "llvm/Support/DataTypes.h"
+  export *
+}
+
+module LLVM_WindowsManifest {
+  requires cplusplus
+  umbrella "llvm/WindowsManifest"
+  module * { export * }
+}

diff  --git a/llvm/include/llvm/module.modulemap.build b/llvm/include/module.modulemap.build
similarity index 64%
rename from llvm/include/llvm/module.modulemap.build
rename to llvm/include/module.modulemap.build
index 162a262a00a78..2a5b23f2a4128 100644
--- a/llvm/include/llvm/module.modulemap.build
+++ b/llvm/include/module.modulemap.build
@@ -1,13 +1,13 @@
 // This is copied into the build area for a $src != $build compilation.
 module LLVM_Support_DataTypes {
-  header "Support/DataTypes.h"
+  header "llvm/Support/DataTypes.h"
   export *
 }
 module LLVM_Config_ABI_Breaking {
-  header "Config/abi-breaking.h"
+  header "llvm/Config/abi-breaking.h"
   export *
 }
 module LLVM_Config_Config {
-  header "Config/llvm-config.h"
+  header "llvm/Config/llvm-config.h"
   export *
 }


        


More information about the cfe-commits mailing list