aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendActions.cpp
AgeCommit message (Collapse)AuthorFilesLines
4 days[Preprocessor] Do not expand macros if the input is already preprocessed ↵Juan Manuel Martinez Caamaño1-1/+1
(#137665) Preprocessing the preprocessor output again interacts poorly with some flag combinations when we perform a separate preprocessing stage. In our case, `-no-integrated-cpp -dD` triggered this issue; but I guess that other flags could also trigger problems (`-save-temps` instead of `-no-integrated-cpp`). Full context (which is quite weird I'll admit): * To cache OpenCL kernel compilation results, we use the `-no-integrated-cpp` for the driver to generate a separate preprocessing command (`clang -E`) before the rest of the compilation. * Some OpenCL C language features are implemented as macro definitions (in `opencl-c-base.h`). The semantic analysis queries the preprocessor to check if these are defined or not, for example, when we checks if a builtin is available when using `-fdeclare-opencl-builtins`. * To preserve these `#define` directives, on the preprocessor's output, we use `-dD`. However, other `#define` directives are also maintained besides OpenCL ones; which triggers the issue shown in this PR. A better fix for our particular case could have been to move the language features implemented as macros into some sort of a flag to be used together with `-fdeclare-opencl-builtins`. But I also thought that not preprocessing preprocessor outputs seemed like something desirable. I hope to work on this on a follow up.
2025-07-15[clang][modules] Serialize `CodeGenOptions` (#146422)Jan Svoboda1-8/+9
Some `LangOptions` duplicate their `CodeGenOptions` counterparts. My understanding is that this was done solely because some infrastructure (like preprocessor initialization, serialization, module compatibility checks, etc.) were only possible/convenient for `LangOptions`. This PR implements the missing support for `CodeGenOptions`, which makes it possible to remove some duplicate `LangOptions` fields and simplify the logic. Motivated by https://github.com/llvm/llvm-project/pull/146342.
2025-07-07[clang] Refactor `LangOptions` to specify compatibility as X macro arg (#146766)Jan Svoboda1-6/+10
This removes the `{BENIGN,COMPATIBLE}{,_ENUM,_VALUE}_LANGOPT` X macros controlling `LangOptions`. These are permutations of the base `LANGOPT`, `ENUM_LANGOPT` and `VALUE_LANGOPT` X macros that also carry the information of their effect on AST (and therefore module compatibility). Their functionality is now implemented by passing `Benign`, `Compatible` or `NotCompatible` argument to the base X macros and using C++17 `if constexpr` in the clients to achieve the same codegen. This PR solves this FIXME: ``` // FIXME: Clients should be able to more easily select whether they want // different levels of compatibility versus how to handle different kinds // of option. ``` The base X macros are preserved, since they are used in `LangOptions.h` to generate different kinds of field and function declarations for flags, values and enums, which can't be achieved with `if constexpr`. The new syntax also forces developers to think about compatibility when adding new language option, hopefully reducing the number of new options that are affecting by default even though they are benign or compatible. Note that the `BENIGN_` macros used to forward to their `COMPATIBLE_` counterparts. I don't think this ever kicked in, since there are no clients of the `.def` file that define `COMPATIBLE_` without also defining `BENIGN_`. However, this might be something downstream forks need to take care of by doing `if constexpr (CK::Compatibility == CK::Benign || CK::Compatibility == CK::Compatible)` in place of `#define COMPATIBLE_`.
2025-05-31[Frontend] Remove unused includes (NFC) (#142256)Kazu Hirata1-1/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-05-22Reapply "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Jan Svoboda1-8/+8
(#139584)" This reverts commit e2a885537f11f8d9ced1c80c2c90069ab5adeb1d. Build failures were fixed right away and reverting the original commit without the fixes breaks the build again.
2025-05-22Revert "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Kazu Hirata1-8/+8
(#139584)" This reverts commit 9e306ad4600c4d3392c194a8be88919ee758425c. Multiple builtbot failures have been reported: https://github.com/llvm/llvm-project/pull/139584
2025-05-22[clang] Remove intrusive reference count from `DiagnosticOptions` (#139584)Jan Svoboda1-8/+8
The `DiagnosticOptions` class is currently intrusively reference-counted, which makes reasoning about its lifetime very difficult in some cases. For example, `CompilerInvocation` owns the `DiagnosticOptions` instance (wrapped in `llvm::IntrusiveRefCntPtr`) and only exposes an accessor returning `DiagnosticOptions &`. One would think this gives `CompilerInvocation` exclusive ownership of the object, but that's not the case: ```c++ void shareOwnership(CompilerInvocation &CI) { llvm::IntrusiveRefCntPtr<DiagnosticOptions> CoOwner = &CI.getDiagnosticOptions(); // ... } ``` This is a perfectly valid pattern that is being actually used in the codebase. I would like to ensure the ownership of `DiagnosticOptions` by `CompilerInvocation` is guaranteed to be exclusive. This can be leveraged for a copy-on-write optimization later on. This PR changes usages of `DiagnosticOptions` across `clang`, `clang-tools-extra` and `lldb` to not be intrusively reference-counted.
2025-05-09[clang][modules] Allow not forcing validation of user headers (#139091)Jan Svoboda1-1/+1
Force-validation of user headers was implemented in acb803e8 to deal with files changing during build. The dependency scanner guarantees an immutable file system during single build session, so the validation is unnecessary. (We don't hit the disk too often due to the caching VFS, but even avoiding going to the cache and deserializing the input files makes sense.)
2025-04-29[clang][modules] Validate input file format for ↵Naveen Seth Hanig1-0/+14
GenerateModuleInterfaceAction (#132692) (#137711) Fixes #132692. `clang -cc1` crashes when generating a module interface with `emit-module-interface` or `emit-reduced-module-interface` using an input file which is already a precompiled module (`.pcm`) file. This commit adds validation for the input file format and Clang will now emit an error message instead of crashing.
2025-04-17Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵yronglin1-2/+2
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-2/+2
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-2/+2
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>
2025-04-08 [clang][DependencyScanning] Track dependencies from prebuilt modules to ↵Cyndy Ishida1-3/+4
determine IsInStableDir (#132237) When a module is being scanned, it can depend on modules that have already been built from a pch dependency. When this happens, the pcm files are reused for the module dependencies. When this is the case, check if input files recorded from the PCMs come from the provided stable directories transitively since the scanner will not have access to the full set of file dependencies from prebuilt modules.
2025-03-21[clang] Make `HeaderSearchOptions` references const (#130825)Jan Svoboda1-1/+2
This PR makes the `HeaderSearchOptions` object referenced by `HeaderSearch` constant. Depends on #130823.
2025-03-10Revert "[clang] Implement instantiation context note for checking template ↵Nikita Popov1-16/+8
parameters (#126088)" This reverts commit a24523ac8dc07f3478311a5969184b922b520395. This is causing significant compile-time regressions for C++ code, see: https://github.com/llvm/llvm-project/pull/126088#issuecomment-2704874202
2025-03-06[clang] Implement instantiation context note for checking template ↵Matheus Izvekov1-8/+16
parameters (#126088) Instead of manually adding a note pointing to the relevant template parameter to every relevant error, which is very easy to miss, this patch adds a new instantiation context note, so that this can work using RAII magic. This fixes a bunch of places where these notes were missing, and is more future-proof. Some diagnostics are reworked to make better use of this note: - Errors about missing template arguments now refer to the parameter which is missing an argument. - Template Template parameter mismatches now refer to template parameters as parameters instead of arguments. It's likely this will add the note to some diagnostics where the parameter is not super relevant, but this can be reworked with time and the decrease in maintenance burden makes up for it. This bypasses the templight dumper for the new context entry, as the tests are very hard to update. This depends on #125453, which is needed to avoid losing the context note for errors occuring during template argument deduction.
2025-01-23Reland: [clang] unified CWG2398 and P0522 changes; finishes implementation ↵Matheus Izvekov1-0/+2
of P3310 (#124137) This patch relands the following PRs: * #111711 * #107350 * #111457 All of these patches were reverted due to an issue reported in https://github.com/llvm/llvm-project/pull/111711#issuecomment-2406491485, due to interdependencies. --- [clang] Finish implementation of P0522 This finishes the clang implementation of P0522, getting rid of the fallback to the old, pre-P0522 rules. Before this patch, when partial ordering template template parameters, we would perform, in order: * If the old rules would match, we would accept it. Otherwise, don't generate diagnostics yet. * If the new rules would match, just accept it. Otherwise, don't generate any diagnostics yet again. * Apply the old rules again, this time with diagnostics. This situation was far from ideal, as we would sometimes: * Accept some things we shouldn't. * Reject some things we shouldn't. * Only diagnose rejection in terms of the old rules. With this patch, we apply the P0522 rules throughout. This needed to extend template argument deduction in order to accept the historial rule for TTP matching pack parameter to non-pack arguments. This change also makes us accept some combinations of historical and P0522 allowances we wouldn't before. It also fixes a bunch of bugs that were documented in the test suite, which I am not sure there are issues already created for them. This causes a lot of changes to the way these failures are diagnosed, with related test suite churn. The problem here is that the old rules were very simple and non-recursive, making it easy to provide customized diagnostics, and to keep them consistent with each other. The new rules are a lot more complex and rely on template argument deduction, substitutions, and they are recursive. The approach taken here is to mostly rely on existing diagnostics, and create a new instantiation context that keeps track of this context. So for example when a substitution failure occurs, we use the error produced there unmodified, and just attach notes to it explaining that it occurred in the context of partial ordering this template argument against that template parameter. This diverges from the old diagnostics, which would lead with an error pointing to the template argument, explain the problem in subsequent notes, and produce a final note pointing to the parameter. --- [clang] CWG2398: improve overload resolution backwards compat With this change, we discriminate if the primary template and which partial specializations would have participated in overload resolution prior to P0522 changes. We collect those in an initial set. If this set is not empty, or the primary template would have matched, we proceed with this set as the candidates for overload resolution. Otherwise, we build a new overload set with everything else, and proceed as usual. --- [clang] Implement TTP 'reversed' pack matching for deduced function template calls. Clang previously missed implementing P0522 pack matching for deduced function template calls.
2025-01-03[clang] Allow generating module interfaces with parsing errors (#121485)Alejandro Álvarez Ayllón1-2/+4
Fixes a regression introduced in commit da00c60dae0040185dc45039c4397f6e746548e9 This functionality was originally added in commit 5834996fefc937d6211dc8c8a5b200068753391a Co-authored-by: Tomasz Kaminski <tomasz.kaminski@sonarsource.com>
2024-10-28Remove support for RenderScript (#112916)Aaron Ballman1-1/+0
See https://discourse.llvm.org/t/rfc-deprecate-and-eventually-remove-renderscript-support/81284 for the RFC
2024-10-11Revert "Reland: [clang] Finish implementation of P0522 (#111711)"Mikhail Goncharov1-2/+0
See discussion in https://github.com/llvm/llvm-project/pull/111711 This reverts commit 6213aa5e58a7d32bdc82dd40322fb1bab83c4783.
2024-10-10Reland: [clang] Finish implementation of P0522 (#111711)Matheus Izvekov1-0/+2
This finishes the clang implementation of P0522, getting rid of the fallback to the old, pre-P0522 rules. Before this patch, when partial ordering template template parameters, we would perform, in order: * If the old rules would match, we would accept it. Otherwise, don't generate diagnostics yet. * If the new rules would match, just accept it. Otherwise, don't generate any diagnostics yet again. * Apply the old rules again, this time with diagnostics. This situation was far from ideal, as we would sometimes: * Accept some things we shouldn't. * Reject some things we shouldn't. * Only diagnose rejection in terms of the old rules. With this patch, we apply the P0522 rules throughout. This needed to extend template argument deduction in order to accept the historial rule for TTP matching pack parameter to non-pack arguments. This change also makes us accept some combinations of historical and P0522 allowances we wouldn't before. It also fixes a bunch of bugs that were documented in the test suite, which I am not sure there are issues already created for them. This causes a lot of changes to the way these failures are diagnosed, with related test suite churn. The problem here is that the old rules were very simple and non-recursive, making it easy to provide customized diagnostics, and to keep them consistent with each other. The new rules are a lot more complex and rely on template argument deduction, substitutions, and they are recursive. The approach taken here is to mostly rely on existing diagnostics, and create a new instantiation context that keeps track of this context. So for example when a substitution failure occurs, we use the error produced there unmodified, and just attach notes to it explaining that it occurred in the context of partial ordering this template argument against that template parameter. This diverges from the old diagnostics, which would lead with an error pointing to the template argument, explain the problem in subsequent notes, and produce a final note pointing to the parameter.
2024-10-09Revert "[clang] Finish implementation of P0522 (#96023)"Hans Wennborg1-2/+0
This caused Clang to reject valid code, see discussion on the PR https://github.com/llvm/llvm-project/pull/96023#issuecomment-2393228464 and https://github.com/llvm/llvm-project/issues/111363 This reverts commit 6afe56732a172d3f2cbd0330b1fcb34bbfd002a9 and follow-up commit 9abb97f9663a27fe5b8e346ed557b3435aa9ec2f.
2024-10-01[clang] Finish implementation of P0522 (#96023)Matheus Izvekov1-0/+2
This finishes the clang implementation of P0522, getting rid of the fallback to the old, pre-P0522 rules. Before this patch, when partial ordering template template parameters, we would perform, in order: * If the old rules would match, we would accept it. Otherwise, don't generate diagnostics yet. * If the new rules would match, just accept it. Otherwise, don't generate any diagnostics yet again. * Apply the old rules again, this time with diagnostics. This situation was far from ideal, as we would sometimes: * Accept some things we shouldn't. * Reject some things we shouldn't. * Only diagnose rejection in terms of the old rules. With this patch, we apply the P0522 rules throughout. This needed to extend template argument deduction in order to accept the historial rule for TTP matching pack parameter to non-pack arguments. This change also makes us accept some combinations of historical and P0522 allowances we wouldn't before. It also fixes a bunch of bugs that were documented in the test suite, which I am not sure there are issues already created for them. This causes a lot of changes to the way these failures are diagnosed, with related test suite churn. The problem here is that the old rules were very simple and non-recursive, making it easy to provide customized diagnostics, and to keep them consistent with each other. The new rules are a lot more complex and rely on template argument deduction, substitutions, and they are recursive. The approach taken here is to mostly rely on existing diagnostics, and create a new instantiation context that keeps track of things. So for example when a substitution failure occurs, we use the error produced there unmodified, and just attach notes to it explaining that it occurred in the context of partial ordering this template argument against that template parameter. This diverges from the old diagnostics, which would lead with an error pointing to the template argument, explain the problem in subsequent notes, and produce a final note pointing to the parameter.
2024-09-06[NFC] Add explicit #include llvm-config.h where its macros are used, clang ↵Daniil Fukalov1-0/+1
part. (#107301) (this is clang related part) Without these explicit includes, removing other headers, who implicitly include llvm-config.h, may have non-trivial side effects. For example, `clagd` may report even `llvm-config.h` as "no used" in case it defines a macro, that is explicitly used with #ifdef. It is actually amplified with different build configs which use different set of macros.
2024-09-03Revert "[C++20] [Modules] Embed all source files for C++20 Modules (#102444)"Chuanqi Xu1-12/+3
This reverts commit 2eeeff842f993a694159183a2834b4d305549cad. See the post commit discussion in https://github.com/llvm/llvm-project/commit/2eeeff842f993a694159183a2834b4d305549cad
2024-08-29[C++20] [Modules] Embed all source files for C++20 Modules (#102444)Chuanqi Xu1-3/+12
Close https://github.com/llvm/llvm-project/issues/72383 The implementation rationale is, I don't want to pass `-fmodules-embed-all-files` all the time since we can't test it in lit tests (we're using `clang_cc1`). So I tried to set it in FrontendActions for modules.
2024-08-08[re-format][Modules] Follow-up formatting to "Mention which AST file's ↵Volodymyr Sapsai1-5/+8
options differ from the current TU options." (#102484) Fix formatting for fdf8e3e31103bc81917cdb27150877f524bb2669.
2024-08-08[Modules][Diagnostic] Mention which AST file's options differ from the ↵Volodymyr Sapsai1-3/+5
current TU options. (#101413) Claiming a mismatch is always in a precompiled header is wrong and misleading as a mismatch can happen in any provided AST file. Emitting a path for a file with a problem allows to disambiguate between multiple input files. Use generic term "AST file" because we don't always know a kind of the provided file (for example, see `ASTReader::readASTFileControlBlock`). rdar://65005546
2024-07-11[Clang] Don't crash if input file is not a module. (#98439)Dmitriy Chestnykh1-2/+9
Currently clang crashes with `-module-file-info` and input file which is not a module Emit error instead of segfaulting. Fix #98365
2024-06-05Revert "Pass LangOpts from CompilerInstance to DependencyScanningWorker ↵Nishith Kumar M Shah1-2/+2
(#93753)" (#94488) This reverts commit 9862080b1cbf685c0d462b29596e3f7206d24aa2.
2024-06-03Pass LangOpts from CompilerInstance to DependencyScanningWorker (#93753)Nishith Kumar M Shah1-2/+2
This commit fixes https://github.com/llvm/llvm-project/issues/88896 by passing LangOpts from the CompilerInstance to DependencyScanningWorker so that the original LangOpts are preserved/respected. This makes for more accurate parsing/lexing when certain language versions or features specific to versions are to be used.
2024-06-03[NFC] [C++20] [Modules] [Reduced BMI] Reorder Emitting reduced BMI and ↵Chuanqi Xu1-3/+4
normal BMI for named modules When we generate the reduced BMI on the fly, the order of the emitting phase is different within `-emit-obj` and `-emit-module-interface`. Although this is meant to be fine, we observed it in https://github.com/llvm/llvm-project/issues/93859 (that the different phase order may cause problems). Also it turns out to be a different fundamental reason to the orders. But it might be fine to make the order of emitting reducing BMI at first to avoid such confusions in the future.
2024-04-30[NFC] [C++20] [Modules] Use new class CXX20ModulesGenerator to genera… ↵Chuanqi Xu1-7/+4
(#90570) …te module file for C++20 modules instead of PCHGenerator Previously we're re-using PCHGenerator to generate the module file for C++20 modules. But this is slighty more or less odd. This patch tries to use a new class 'CXX20ModulesGenerator' to generate the module file for C++20 modules.
2024-04-30[C++20] [Modules] Don't skip pragma diagnostic mappingsChuanqi Xu1-1/+0
Close https://github.com/llvm/llvm-project/issues/75057 Previously, I thought the diagnostic mappings is not meaningful with modules incorrectly. And this problem get revealed by another change recently. So this patch tried to rever the previous "optimization" partially.
2024-04-30Revert "[C++20] [Modules] Don't skip pragma diagnostic mappings"Chuanqi Xu1-4/+8
and "[NFC] [C++20] [Modules] Use new class CXX20ModulesGenerator to generate module file for C++20 modules instead of PCHGenerator" This reverts commit fb21343473e33e9a886b42d2fe95d1cec1cd0030. and commit 18268ac0f48d93c2bcddb69732761971669c09ab. It looks like there are some problems about linking the compiler
2024-04-30[NFC] [C++20] [Modules] Use new class CXX20ModulesGenerator to generate ↵Chuanqi Xu1-8/+4
module file for C++20 modules instead of PCHGenerator Previously we're re-using PCHGenerator to generate the module file for C++20 modules. But this is slighty more or less odd. This patch tries to use a new class 'CXX20ModulesGenerator' to generate the module file for C++20 modules.
2024-04-15[C++20] [Modules] Introduce -fexperimental-modules-reduced-bmi (#85050)Chuanqi Xu1-0/+7
This is the driver part of https://github.com/llvm/llvm-project/pull/75894. This patch introduces '-fexperimental-modules-reduced-bmi' to enable generating the reduced BMI. This patch did: - When `-fexperimental-modules-reduced-bmi` is specified but `--precompile` is not specified for a module unit, we'll skip the precompile phase to avoid unnecessary two-phase compilation phases. Then if `-c` is specified, we will generate the reduced BMI in CodeGenAction as a by-product. - When `-fexperimental-modules-reduced-bmi` is specified and `--precompile` is specified, we will generate the reduced BMI in GenerateModuleInterfaceAction as a by-product. - When `-fexperimental-modules-reduced-bmi` is specified for a non-module unit. We don't do anything nor try to give a warn. This is more user friendly so that the end users can try to test and experiment with the feature without asking help from the build systems. The core design idea is that users should be able to enable this easily with the existing cmake mechanisms. The future plan for the flag is: - Add this to clang19 and make it opt-in for 1~2 releases. It depends on the testing feedback to decide how long we like to make it opt-in. - Then we can announce the existing BMI generating may be deprecated and suggesting people (end users or build systems) to enable this for 1~2 releases. - Finally we will enable this by default. When that time comes, the term `BMI` will refer to the reduced BMI today and the existing BMI will only be meaningful to build systems which loves to support two phase compilations. I'll send release notes and document in seperate commits after this get landed.
2024-04-09Revert "[clang] Move state out of `PreprocessorOptions` (1/n) (#86358)"Jan Svoboda1-6/+1
This reverts commit 407a2f23 which stopped propagating the callback to module compiles, effectively disabling dependency directive scanning for all modular dependencies. Also added a regression test.
2024-04-09[Sema][NFC] Cleanups after 843cc474f (#87996)Younan Zhang1-1/+1
I forgot to tidy up these lines that should've been done in the previous commit, specifically: 1. Merge two `CodeSynthesisContext`s into one in `CheckTemplateIdType`. 2. Remove some gratuitous `Sema::` specifiers. 3. Rename the parameter `Template` to `Entity` to avoid confusion.
2024-04-05[Clang][Sema] Fix the lambda call expression inside of a type alias ↵Younan Zhang1-0/+2
declaration (#82310) This patch attempts to fix the lambda call expression inside of a type alias declaration from two aspects: 1. Defer the lambda call expression building until after we have sufficient template arguments. This avoids the overeager (and often wrong) semantic checking before the type alias instantiation. 2. Properly obtain template arguments involving a template type alias for constraint checking. It is unfortunate that a `TypeAliasTemplateDecl` (or a `TypeAliasDecl`) is never a `DeclContext`, nor does it have an associated specialization Decl from which we could collect these template arguments. Thus, I added a new CodeSynthesisContext to record template arguments for alias declarations. Fixes https://github.com/llvm/llvm-project/issues/70601 Fixes https://github.com/llvm/llvm-project/issues/76674 Fixes https://github.com/llvm/llvm-project/issues/79555 Fixes https://github.com/llvm/llvm-project/issues/81145 Fixes https://github.com/llvm/llvm-project/issues/82104 Note that this doesn't involve the fix for https://github.com/llvm/llvm-project/issues/28461. That seems different, and I'd like to leave it as a follow-up.
2024-03-29[clang] Move state out of `PreprocessorOptions` (1/n) (#86358)Jan Svoboda1-1/+6
An instance of `PreprocessorOptions` is part of `CompilerInvocation` which is supposed to be a value type. The `DependencyDirectivesForFile` member is problematic, since it holds an owning reference of the scanning VFS. This makes it not a true value type, and it can keep potentially large chunk of memory (the local cache in the scanning VFS) alive for longer than clients might expect. Let's move it into the `Preprocessor` instead.
2024-03-21[CIR][Basic][NFC] Add the CIR language to the Language enumNathan Lanza1-0/+1
Add the CIR language to the Language enum and the standard usages of it. commit-id:fd12b2c2 Reviewers: bcardosolopes, AaronBallman, erichkeane Reviewed By: AaronBallman, bcardosolopes Pull Request: https://github.com/llvm/llvm-project/pull/86072
2024-03-13[NFC] [C++20] [Modules] Refactor ReducedBMIGeneratorChuanqi Xu1-5/+3
Changes: - Don't lookup the emitting module from HeaderSearch. We will use the module from the ASTContext directly. - Remove some useless arguments. Let's addback in the future if required.
2024-03-08[clang] Remove std::move in GenerateModuleAction::CreateMultiplexConsumer (NFC)Jie Fu1-1/+1
llvm-project/clang/lib/Frontend/FrontendActions.cpp:213:10: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move] 213 | return std::move(Consumers); | ^ /Users/jiefu/llvm-project/clang/lib/Frontend/FrontendActions.cpp:213:10: note: remove std::move call here 213 | return std::move(Consumers); | ^~~~~~~~~~ ~ 1 error generated.
2024-03-08[C++20] [Modules] Introduce reduced BMI (#75894)Chuanqi Xu1-6/+31
Close https://github.com/llvm/llvm-project/issues/71034 See https://discourse.llvm.org/t/rfc-c-20-modules-introduce-thin-bmi-and-decls-hash/74755 This patch introduces reduced BMI, which doesn't contain the definitions of functions and variables if its definitions won't contribute to the ABI. Testing is a big part of the patch. We want to make sure the reduced BMI contains the same behavior with the existing and relatively stable fatBMI. This is pretty helpful for further reduction. The user interfaces part it left to following patches to ease the reviewing.
2024-01-31[clang] Use StringRef::starts_with (NFC)Kazu Hirata1-2/+1
2023-12-07[C++20] [Modules] Skip Writing diagnostic options, header search paths and ↵Chuanqi Xu1-0/+10
pragma diagnostic mappings It simply wastes of space and time to write diagnostic options, header search paths and pragma diagnostic mappings for C++20 Named modules. This patch tries to avoid the unnecessary writings.
2023-11-02[clang][deps] Skip slow `UNHASHED_CONTROL_BLOCK` records (#69975)Jan Svoboda1-0/+15
Deserialization of the `DIAGNOSTIC_OPTIONS` and `HEADER_SEARCH_PATHS` records is slow and done for every transitively loaded PCM. Deserialization of these records cannot be skipped, because the words are VBR6-encoded and we don't store the length of the entire record. We could either turn them into binary blobs that can be skipped during deserialization, or skip writing them altogether. This patch takes the latter approach, since these records are not necessary in scanning PCMs. The scanner doesn't make any guarantees about the accuracy of diagnostics, and we always have the same header search paths due to strict context hashing. The commit that makes the `DIAGNOSTIC_OPTIONS` record skippable was originally implemented by @benlangmuir in a downstream repo.
2023-08-17[clang][modules] Avoid storing command-line macro definitions into ↵Jan Svoboda1-3/+5
implicitly built PCM files With implicit modules, it's impossible to load a PCM file that was built using different command-line macro definitions. This is guaranteed by the fact that they contribute to the context hash. This means that we don't need to store those macros into PCM files for validation purposes. This patch avoids serializing them in those circumstances, since there's no other use for command-line macro definitions (besides "-module-file-info"). For a typical Apple project, this speeds up the dependency scan by 5.6% and shrinks the cache with scanning PCMs by 26%. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D158136
2023-06-29[Clang] Implements CTAD for aggregates P1816R0 and P2082R1Yuanfang Chen1-0/+2
Differential Revision: https://reviews.llvm.org/D139837