diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2020-09-20 09:29:14 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2022-03-25 09:17:14 +0000 |
commit | 6c0e60e884a20016ccc0d7c7e6f06df089a0de86 (patch) | |
tree | 9e39107ec89a3a8d97bb0b3583c7000725ec8c24 /clang/lib/Lex/ModuleMap.cpp | |
parent | c48b4641c7baf9f7280d352c13299b3aa0203179 (diff) | |
download | llvm-6c0e60e884a20016ccc0d7c7e6f06df089a0de86.zip llvm-6c0e60e884a20016ccc0d7c7e6f06df089a0de86.tar.gz llvm-6c0e60e884a20016ccc0d7c7e6f06df089a0de86.tar.bz2 |
[C++20][Modules][HU 1/5] Introduce header units as a module type.
This is the first in a series of patches that introduce C++20 importable
header units.
These differ from clang header modules in that:
(a) they are identifiable by an internal name
(b) they represent the top level source for a single header - although
that might include or import other headers.
We name importable header units with the path by which they are specified
(although that need not be the absolute path for the file).
So "foo/bar.h" would have a name "foo/bar.h". Header units are made a
separate module type so that we can deal with diagnosing places where they
are permitted but a named module is not.
Differential Revision: https://reviews.llvm.org/D121095
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index a5eca40..75a0e6b 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -905,6 +905,19 @@ Module *ModuleMap::createHeaderModule(StringRef Name, return Result; } +Module *ModuleMap::createHeaderUnit(SourceLocation Loc, StringRef Name, + Module::Header H) { + assert(LangOpts.CurrentModule == Name && "module name mismatch"); + assert(!Modules[Name] && "redefining existing module"); + + auto *Result = new Module(Name, Loc, nullptr, /*IsFramework*/ false, + /*IsExplicit*/ false, NumCreatedModules++); + Result->Kind = Module::ModuleHeaderUnit; + Modules[Name] = SourceModule = Result; + addHeader(Result, H, NormalHeader); + return Result; +} + /// For a framework module, infer the framework against which we /// should link. static void inferFrameworkLink(Module *Mod, const DirectoryEntry *FrameworkDir, |