aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaModule.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-26[clang][Preprocessor] Handle the first pp-token in EnterMainSourceFile (#145244)yronglin1-5/+3
Depends on [[clang][Preprocessor] Add peekNextPPToken, makes look ahead next token without side-effects](https://github.com/llvm/llvm-project/pull/143898). This PR fix the performance regression that introduced in https://github.com/llvm/llvm-project/pull/144233. The original PR(https://github.com/llvm/llvm-project/pull/144233) handle the first pp-token in the main source file in the macro definition/expansion and `Lexer::Lex`, but the lexer is almost always on the hot path, we may hit a performance regression. In this PR, we handle the first pp-token in `Preprocessor::EnterMainSourceFile`. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-21[C++][Modules] A module directive may only appear as the first preprocessing ↵yronglin1-9/+6
tokens in a file (#144233) This PR is 2nd part of [P1857R3](https://github.com/llvm/llvm-project/pull/107168) implementation, and mainly implement the restriction `A module directive may only appear as the first preprocessing tokens in a file (excluding the global module fragment.)`: [cpp.pre](https://eel.is/c++draft/cpp.pre): ``` module-file: pp-global-module-fragment[opt] pp-module group[opt] pp-private-module-fragment[opt] ``` We also refine tests use `split-file` instead of conditional macro. Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-20[C++20] [Modules] Add exported modules as transitive imported modulesChuanqi Xu1-4/+9
Close https://github.com/llvm/llvm-project/issues/144230 The root cause of the problem is, when we decide the transitive imports, we didn't deal with exported imports.
2025-06-12[C++20] [Modules] Treat directly imported internal partition unit as reachableChuanqi Xu1-6/+7
Close https://github.com/llvm/llvm-project/issues/143788 See the discussion for details.
2025-05-13[NFC] Use more isa and isa_and_nonnull instead dyn_cast for predicates (#137393)Max Graey1-1/+1
Also fix some typos in comments --------- Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
2025-05-06[clang][modules] Lazily load by name lookups in module maps (#132853)Michael Spencer1-1/+1
Instead of eagerly populating the `clang::ModuleMap` when looking up a module by name, this patch changes `HeaderSearch` to only load the modules that are actually used. This introduces `ModuleMap::findOrLoadModule` which will load modules from parsed but not loaded module maps. This cannot be used anywhere that the module loading code calls into as it can create infinite recursion. This currently just reparses module maps when looking up a module by header. This is fine as redeclarations are allowed from the same file, but future patches will also make looking up a module by header lazy. This patch changes the shadow.m test to use explicitly built modules and `#import`. This test and the shadow feature are very brittle and do not work in general. The test relied on pcm files being left behind by prior failing clang invocations that were then reused by the last invocation. If you clean the cache then the last invocation will always fail. This is because the input module map and the `-fmodule-map-file=` module map are parsed in the same module scope, and `-fmodule-map-file=` is forwarded to implicit module builds. That means you are guaranteed to hit a module redeclaration error if the TU actually imports the module it is trying to shadow. This patch changes when we load A2's module map to after the `A` module has been loaded, which sets the `IsFromModuleFile` bit on `A`. This means that A2's `A` is skipped entirely instead of creating a shadow module, and we get textual inclusion. It is possible to construct a case where this would happen before this patch too. An upcoming patch in this series will rework shadowing to work in the general case, but that's only possible once header -> module lookup is lazy too.
2025-04-17Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵yronglin1-19/+23
structures to `IdentifierLoc` (#136077) This PR reland https://github.com/llvm/llvm-project/pull/135808, fixed some missed changes in LLDB. I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - std::pair<IdentifierInfo *, SourceLocation>. - Element type of ModuleIdPath. - IdentifierLocPair. - IdentifierLoc. This PR unify these data structures to IdentifierLoc, moved IdentifierLoc definition to SourceLocation.h, and deleted other similer data structures. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2025-04-16Revert "[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵Michael Buch1-23/+19
structures to `IdentifierLoc`" (#135974) Reverts llvm/llvm-project#135808 Example from the LLDB macOS CI: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/24084/execution/node/54/log/?consoleFull ``` /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp:360:49: error: no viable conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'clang::ModuleIdPath' (aka 'ArrayRef<IdentifierLoc>') clang::Module *top_level_module = DoGetModule(clang_path.front(), false); ^~~~~~~~~~~~~~~~~~ /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'const llvm::ArrayRef<clang::IdentifierLoc> &' for 1st argument class LLVM_GSL_POINTER [[nodiscard]] ArrayRef { ^ /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'llvm::ArrayRef<clang::IdentifierLoc> &&' for 1st argument /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:70:18: note: candidate constructor not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'std::nullopt_t' for 1st argument /*implicit*/ ArrayRef(std::nullopt_t) {} ```
2025-04-16[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵yronglin1-19/+23
structures to `IdentifierLoc` (#135808) I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - `std::pair<IdentifierInfo *, SourceLocation>`. - Element type of `ModuleIdPath`. - `IdentifierLocPair`. - `IdentifierLoc`. This PR unify these data structures to `IdentifierLoc`, moved `IdentifierLoc` definition to SourceLocation.h, and deleted other similer data structures. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2024-11-16[Sema] Remove unused includes (NFC) (#116461)Kazu Hirata1-1/+0
Identified with misc-include-cleaner.
2024-09-14[C++20] [Modules] Warn for importing implementation partition unit in ↵Chuanqi Xu1-0/+8
interface units (#108493) Recently, there are multiple false positive issue reports about the reachability of implementation partition units: - https://github.com/llvm/llvm-project/issues/105882 - https://github.com/llvm/llvm-project/issues/101348 - https://lists.isocpp.org/core/2024/08/16232.php And according to our use experience for modules, we find it is a pretty good practice to not import implementation partition units in the interface units. It can help developers to have a pretty good mental model for when to use an implementation partition unit: that any unit in the module but not in the module interfaces can be in the implementation partition unit. So I think it is good to add the diagnostics.
2024-07-01[HLSL] Implement `export` keyword (#96823)Helena Kotas1-19/+33
Implements `export` keyword in HLSL. There are two ways the `export` keyword can be used: 1. On individual function declarations ``` export void f() {} ``` 2. On a group of function declaration: ``` export { void f1(); void f2() {} } ``` Functions declared with the `export` keyword have external linkage. The implementation does not include validation of when a function can or cannot be exported, such as when it has resource argument or semantic annotations. That will be covered by llvm/llvm-project#93330. Currently all function declarations in global or named namespaces have external linkage by default so there are no specific code changes required right now to make sure exported function have external linkage as well. That will change as part of llvm/llvm-project#92071. Any additional changes to make sure exported functions still have external linkage will be done as part of this work item. Fixes #92812
2024-07-01[clang][NFC] Move documentation of `Sema` functions into `Sema.h`Vlad Serebrennikov1-3/+0
This patch moves documentation of `Sema` functions from `.cpp` files to `Sema.h` when there was no documentation in the latter, or it can be trivially subsumed. More complicated cases when there's less trivial divergence between documentation attached to declaration and the one attached to implementation are left for a later PR that would require review. It appears that doxygen can find the documentation for a function defined out-of-line even if it's attached to an implementation, and not declaration. But other tools, e.g. clangd, are not as powerful. So this patch significantly improves autocompletion experience for (at least) clangd-based IDEs.
2024-06-24[NFC] [Modules] Extract the logic to decide whether the module units belongs ↵Chuanqi Xu1-9/+11
to the same module This patch extracts the logci to decide how we decide the module units belongs to the same module into a member function of ASTContext. This is helpful to refactor the implementation in the future.
2024-04-19[C++20] [Modules] Mark exported all declarations as usedChuanqi Xu1-0/+4
Close https://github.com/llvm/llvm-project/issues/85122 As the title suggested, it looks pretty sensible.
2024-04-18[C++20] [Modules] Avoid writing untouched DeclUpdates from GMF inChuanqi Xu1-0/+4
Reduced BMI Mitigate https://github.com/llvm/llvm-project/issues/61447 The root cause of the above problem is that when we write a declaration, we need to lookup all the redeclarations in the imported modules. Then it will be pretty slow if there are too many redeclarations in different modules. This patch doesn't solve the porblem. What the patchs mitigated is, when we writing a named module, we shouldn't write the declarations from GMF if it is unreferenced **in current module unit**. The difference here is that, if the declaration is used in the imported modules, we used to emit it as an update. But we definitely want to avoid that after this patch. For that reproducer in https://github.com/llvm/llvm-project/issues/61447, it used to take 2.5s to compile and now it only takes 0.49s to compile, which is a big win.
2024-03-13[C++20] [Modules] Disambuguous Clang module and C++20 Named module furtherChuanqi Xu1-5/+5
This patch tries to make the boundary of clang module and C++20 named module more clear. The changes included: - Rename `TranslationUnitKind::TU_Module` to `TranslationUnitKind::TU_ClangModule`. - Rename `Sema::ActOnModuleInclude` to `Sema::ActOnAnnotModuleInclude`. - Rename `ActOnModuleBegin` to `Sema::ActOnAnnotModuleBegin`. - Rename `Sema::ActOnModuleEnd` to `Sema::ActOnAnnotModuleEnd`. - Removes a warning if we're trying to compile a non-module unit as C++20 module unit. This is not actually useful and makes (the future) implementation unnecessarily complex. This patch meant to be a NFC fix. But it shows that it fixed a bug suprisingly that previously we would surppress the unused-value warning in named modules. Because it shares the same logic with clang modules, which has headers semantics. This shows the change is meaningful.
2024-03-06[C++20] [Modules] Handle transitive import in the module properlyChuanqi Xu1-3/+91
Close https://github.com/llvm/llvm-project/issues/84002 Per [module.import]p7: > Additionally, when a module-import-declaration in a module unit of > some module M imports another module unit U of M, it also imports all > translation units imported by non-exported module-import-declarations > in the module unit purview of U. However, we only tried to implement it during the implicit import of primary module interface for module implementation unit. Also we didn't implement the last sentence from [module.import]p7 completely: > These rules can in turn lead to the importation of yet more > translation units. This patch tries to care the both issues.
2023-12-28[Modules] Don't prevent @import from ObjectiveCChuanqi Xu1-1/+2
Previously we forbiden the users to import named modules from clang header modules. However, due to an oversight, the @import form of Objective C got involved. This is not want and we fix that in this patch.
2023-12-13[clang] Use StringRef::{starts,ends}_with (NFC) (#75149)Kazu Hirata1-1/+1
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-11-09[C++20] [Modules] Allow export from language linkageChuanqi Xu1-11/+28
Close https://github.com/llvm/llvm-project/issues/71347 Previously I misread the concept of module purview. I thought if a declaration attached to a unnamed module, it can't be part of the module purview. But after the issue report, I recognized that module purview is more of a concept about locations instead of semantics. Concretely, the things in the language linkage after module declarations can be exported. This patch refactors `Module::isModulePurview()` and introduces some possible code cleanups.
2023-11-09[NFC] [C++20] [Modules] Remove 'ModuleInterface' bit in Sema::ModuleScopeChuanqi Xu1-11/+3
The 'ModuleInterface' in Sema::ModuleScope is confusing. It actually means 'not implementation'. This patch removes that bit and extract the information from the recorded clang::Module.
2023-11-02[clang][NFC] Refactor `clang::Linkage` (#71049)Vlad Serebrennikov1-3/+3
This patch introduces a new enumerator `Invalid = 0`, shifting other enumerators by +1. Contrary to how it might sound, this actually affirms status quo of how this enum is stored in `clang::Decl`: ``` /// If 0, we have not computed the linkage of this declaration. /// Otherwise, it is the linkage + 1. mutable unsigned CacheValidAndLinkage : 3; ``` This patch makes debuggers to not be mistaken about enumerator stored in this bit-field. It also converts `clang::Linkage` to a scoped enum.
2023-11-01[clang][NFC] Refactor `LinkageSpecDecl::LanguageIDs`Vlad Serebrennikov1-2/+2
This patch converts `LinkageSpecDecl::LanguageIDs` into scoped enum, and moves it to namespace scope, so that it can be forward-declared where required.
2023-09-08Reapply "[clang] NFCI: Adopt `SourceManager::getFileEntryRefForID()`"Jan Svoboda1-1/+2
This reapplies ddbcc10b9e26b18f6a70e23d0611b9da75ffa52f, except for a tiny part that was reverted separately: 65331da0032ab4253a4bc0ddcb2da67664bd86a9. That will be reapplied later on, since it turned out to be more involved. This commit is enabled by 5523fefb01c282c4cbcaf6314a9aaf658c6c145f and f0f548a65a215c450d956dbcedb03656449705b9, specifically the part that makes 'clang-tidy/checkers/misc/header-include-cycle.cpp' separator agnostic.
2023-09-06Revert "[clang] NFCI: Adopt `SourceManager::getFileEntryRefForID()`"Jan Svoboda1-2/+1
This reverts commit ddbcc10b9e26b18f6a70e23d0611b9da75ffa52f. The 'clang-tidy/checkers/misc/header-include-cycle.cpp' test started failing on Windows: https://lab.llvm.org/buildbot/#/builders/216/builds/26855.
2023-09-06[clang] NFCI: Adopt `SourceManager::getFileEntryRefForID()`Jan Svoboda1-1/+2
This commit replaces some calls to the deprecated `FileEntry::getName()` with `FileEntryRef::getName()` by swapping current usages of `SourceManager::getFileEntryForID()` with `SourceManager::getFileEntryRefForID()`. This lowers the number of usages of the deprecated `FileEntry::getName()` from 95 to 50.
2023-08-17[C++20] [Modules] Prevent to accept clang modulesChuanqi Xu1-0/+6
Close https://github.com/llvm/llvm-project/issues/64755 This wouldn't affect the form @import as the test shows. The two affected test case `diag-flags.cpp` and `diag-pragma.cpp` are old test cases in 2017 and 2018, when we're not so clear about the direction of modules. And the things that these 2 tests tested can be covered by clang modules naturally. So I change the them into clang modules to not block this patch.
2023-06-25[llvm] Add missing StringExtras.h includesElliot Goodrich1-0/+1
In preparation for removing the `#include "llvm/ADT/StringExtras.h"` from the header to source file of `llvm/Support/Error.h`, first add in all the missing includes that were previously included transitively through this header.
2023-06-25[C++20][Modules] Complete implementation of module.import p7.Iain Sandoe1-0/+1
The following test fails to compile TU b.cpp because we are not making the transitively imported modules visible (per [module.import]/p7) ``` a.cppm: export module a; export int foo() { return 42; } b.cppm: export module b; import a; export int bar(); b.cpp: module b; int bar() { return foo(); } clang++ -c -std=c++2b -fmodule-output a.cppm clang++ -c -std=c++2b -fmodule-output -fprebuilt-module-path=. b.cppm clang++ -c -std=c++2b -fprebuilt-module-path=. b.cpp b.cpp:4:12: error: declaration of 'foo' must be imported from module 'a' before it is required return foo(); ``` This is fixed by the following patch (which also addresses a FIXME in basic.def.odr/p6.cppm). Differential Revision: https://reviews.llvm.org/D152746
2023-06-24[C++20][Modules] Implement P2615R1 revised export diagnostics.Iain Sandoe1-89/+29
It has been reported to that the current clang errors for, specifically, static_assert in export contexts are a serious blocker to adoption of modules in some cases. There is also implementation divergence with GCC and MSVC allowing the constructs mentioned below where clang currently rejects them with an error. The category of errors [for declarations in an exported context] is: (unnamed, static_assert, empty and asm decls). These are now permitted after P2615R1 which was approved by WG21 as a DR (and thus should be applied to C++20 as well). This patch removes these diagnostics and amends the testsuite accordingly. Differential Revision: https://reviews.llvm.org/D152946
2023-06-16[clang] Don't create import decls without -fmodulesKadir Cetinkaya1-5/+3
When modules are disabled, there's no loaded module for these import decls to point at. This results in crashes when there are modulemap files but no -fmodules flag (this configuration is used for layering check violations). This patch makes sure import declarations are introduced only when modules are enabled, which makes this case similar to textual headers (no import decls are created for #include of textual headers from a modulemap). Differential Revision: https://reviews.llvm.org/D152274
2023-05-23[NFC] [C++20] [Modules] Refactor Sema::isModuleUnitOfCurrentTU intoChuanqi Xu1-13/+0
Decl::isInAnotherModuleUnit Refactor `Sema::isModuleUnitOfCurrentTU` to `Decl::isInAnotherModuleUnit` to make code simpler a little bit. Note that although this patch introduces a FIXME, this is an existing issue and this patch just tries to describe it explicitly.
2023-05-18[C++20] [Modules] Emit an warning for experimental header unitsChuanqi Xu1-0/+3
Currently, the header units are rarely used and it is not well tested. To avoid further misunderstandings, let's mark it as experimental and emit a warning when users wants to import it. This is discussed in modules developers meeting.
2023-05-16[NFC] [C++20] [Modules] Rename ASTContext::getNamedModuleForCodeGen to ↵Chuanqi Xu1-1/+1
ASTContext::getCurrentNamedModule The original name "ASTContext::getNamedModuleForCodeGen" is not properly reflecting the usage of the interface. This interface can be used to judge the current module unit in both sema analysis and code generation. So the original name was not so correct.
2023-05-16Revert "[NFC] [C++20] [Modules] Refactor Sema::isModuleUnitOfCurrentTU into"Chuanqi Xu1-1/+14
This reverts commit f109b1016801e2b0dbee278f3c517057c0b1d441 as required in https://github.com/llvm/llvm-project/commit/f109b1016801e2b0dbee278f3c517057c0b1d441#commitcomment-113477829.
2023-05-10[NFC] [C++20] [Modules] Refactor Sema::isModuleUnitOfCurrentTU intoChuanqi Xu1-14/+1
Decl::isInCurrentModuleUnit Refactor `Sema::isModuleUnitOfCurrentTU` to `Decl::isInCurrentModuleUnit` to make code simpler a little bit. Note that although this patch introduces a FIXME, this is an existing issue and this patch just tries to describe it explicitly.
2023-05-04[clang] Use -std=c++23 instead of -std=c++2bMark de Wever1-1/+1
During the ISO C++ Committee meeting plenary session the C++23 Standard has been voted as technical complete. This updates the reference to c++2b to c++23 and updates the __cplusplus macro. Drive-by fixes c++1z -> c++17 and c++2a -> c++20 when seen. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D149553
2023-04-13[C++20] [Modules] Continue parsing after we found reserved module namesChuanqi Xu1-4/+3
Close https://github.com/llvm/llvm-project/issues/62112 In the previous change, we'll stop parsing directly after we found reserved module names. But this may be too aggressive. This patch changes this. Note that the parsing will still be stopped if the module name is `module` or `import`.
2023-03-29re-land [C++20][Modules] Introduce an implementation module.Iain Sandoe1-24/+35
We need to be able to distinguish individual TUs from the same module in cases where TU-local entities either need to be hidden (or, for some cases of ADL in template instantiation, need to be detected as exposures). This creates a module type for the implementation which implicitly imports its primary module interface per C++20: [module.unit/8] 'A module-declaration that contains neither an export-keyword nor a module-partition implicitly imports the primary module interface unit of the module as if by a module-import-declaration. Implementation modules are never serialized (-emit-module-interface for an implementation unit is diagnosed and rejected). Differential Revision: https://reviews.llvm.org/D126959
2023-03-28Downgrade reserved module identifier error into a warningAaron Ballman1-6/+9
Any project that wants to import std; potentially needs to be able to build a module that does export std;. We silenced the error diagnostic if the module identified itself as a system header, but this isn't quite good enough, what we really need is a way to identify a system module. It would be nice for that feature to be shared among the major implementations, so this downgrades the diagnostic from an error to a warning temporarily to give implementers time to determine what that mechanism will look like. We may convert this warning back into an error in a future release of Clang, but it's not guaranteed we will do so. Fixes https://github.com/llvm/llvm-project/issues/61446 Differential Revision: https://reviews.llvm.org/D146986
2023-03-27Revert "[C++20][Modules] Introduce an implementation module."Mitch Phillips1-35/+24
This reverts commit c6e9823724ef6bdfee262289ee34d162db436af0. Reason: Broke the ASan buildbots, see https://reviews.llvm.org/D126959 (the original phabricator review) for more info.
2023-03-23[C++20][Modules] Introduce an implementation module.Iain Sandoe1-24/+35
We need to be able to distinguish individual TUs from the same module in cases where TU-local entities either need to be hidden (or, for some cases of ADL in template instantiation, need to be detected as exposures). This creates a module type for the implementation which implicitly imports its primary module interface per C++20: [module.unit/8] 'A module-declaration that contains neither an export-keyword nor a module-partition implicitly imports the primary module interface unit of the module as if by a module-import-declaration. Implementation modules are never serialized (-emit-module-interface for an implementation unit is diagnosed and rejected). Differential Revision: https://reviews.llvm.org/D126959
2023-03-03[C++20] [Modules] Support to export declarations in language linkageChuanqi Xu1-11/+39
Close https://github.com/llvm/llvm-project/issues/60405 See the discussion in the above link for the background. What the patch does: - Rename `Module::ModuleKind::GlobalModuleFragment` to `Module::ModuleKind::ExplicitGlobalModuleFragment`. - Add another module kind `ImplicitGlobalModuleFragment` to `ModuleKind`. - Create an implicit global module fragment for the language linkage declarations inside a module purview. - If the language linkage lives inside the scope of an export decl, the created modules is marked as exported to outer modules. - In fact, Sema will only create at most 2 implicit global module fragments to avoid creating a lot of unnecessary modules in the edging case. Reviewed By: iains Differential Revision: https://reviews.llvm.org/D144367
2023-02-20[NFC] Remove the unused parameter in Sema::PushGlobalModuleFragmentChuanqi Xu1-5/+3
The `IsImplicit` parameter should be removed since it is not used now.
2023-02-20[NFC] Remove unused Sema::DirectModuleImportsChuanqi Xu1-5/+0
Sema::DirectModuleImports is not used now. Remove it for clearness.
2023-02-16[Modules] Code cleanup after removing ModulesTSChuanqi Xu1-7/+1
Some codes become unused after we remove ModulesTS.
2023-02-16[Modules] Remove -fmodules-tsChuanqi Xu1-19/+7
As the diagnostic message shows, we should remove -fmodules-ts flag in clang/llvm17. Since clang/llvm16 is already branched. We can remove the depreacared flag now.
2023-02-13[NFC] Set C++20 Named Modules for CodeGen in ASTContext in the early placeChuanqi Xu1-0/+2
Previously we'll set the named modules for ASTContext in ParseAST. But this is not intuitive and we need comments to tell the intuition. This patch moves the code the right the place, where the corrresponding module is first created/loaded. Now it is more intuitive and we can use the value in the earlier places.
2023-02-08[C++20] [Modules] Allow -fmodule-file=<module-name>=<BMI-Path> for ↵Chuanqi Xu1-2/+11
implementation unit and document the behavior Close https://github.com/llvm/llvm-project/issues/57293. Previsouly we can't use `-fmodule-file=<module-name>=<BMI-Path>` for implementation units, it is a bug. Also the behavior of the above option is not tested nor documented for C++20 Modules. This patch addresses the 2 problems.