[clang] [clang][modules] Separate parsing of modulemaps (PR #119740)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 12:13:39 PST 2025
================
@@ -0,0 +1,164 @@
+//===- ModuleMapFile.h - Parsing and representation -------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LEX_MODULEMAPFILE_H
+#define LLVM_CLANG_LEX_MODULEMAPFILE_H
+
+#include "clang/Basic/LLVM.h"
+// TODO: Consider moving ModuleId to another header, parsing a modulemap file is
+// intended to not depend on anything about the clang::Module class.
+#include "clang/Basic/Module.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/StringRef.h"
+
+#include <optional>
+#include <variant>
+
+namespace clang {
+
+class DiagnosticsEngine;
+class SourceManager;
+
+namespace modulemap {
+
+struct ExportDecl;
+
+/// All declarations that can appear in a `module` declaration.
+using Decl =
+ std::variant<struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl,
+ struct ModuleDecl, struct ExcludeDecl, struct ExportDecl,
+ struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl,
+ struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl>;
----------------
jansvoboda11 wrote:
Sizes of these types have large variance (`UmbrellaDirDecl` is 24B, `ModuleDecl` is 128B). I think it would make sense to either work on shrinking these or store them out-of-line.
https://github.com/llvm/llvm-project/pull/119740
More information about the cfe-commits
mailing list