aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/Preprocessor.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-08-18[clang] Allow trivial pp-directives before C++ module directive (#153641)yronglin1-3/+37
Consider the following code: ```cpp # 1 __FILE__ 1 3 export module a; ``` According to the wording in [P1857R3](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1857r3.html): ``` A module directive may only appear as the first preprocessing tokens in a file (excluding the global module fragment.) ``` and the wording in [[cpp.pre]](https://eel.is/c++draft/cpp.pre#nt:module-file) ``` module-file: pp-global-module-fragment[opt] pp-module group[opt] pp-private-module-fragment[opt] ``` `#` is the first pp-token in the translation unit, and it was rejected by clang, but they really should be exempted from this rule. The goal is to not allow any preprocessor conditionals or most state changes, but these don't fit that. State change would mean most semantically observable preprocessor state, particularly anything that is order dependent. Global flags like being a system header/module shouldn't matter. We should exempt a brunch of directives, even though it violates the current standard wording. In this patch, we introduce a `TrivialDirectiveTracer` to trace the **State change** that described above and propose to exempt the following kind of directive: `#line`, GNU line marker, `#ident`, `#pragma comment`, `#pragma mark`, `#pragma detect_mismatch`, `#pragma clang __debug`, `#pragma message`, `#pragma GCC warning`, `#pragma GCC error`, `#pragma gcc diagnostic`, `#pragma OPENCL EXTENSION`, `#pragma warning`, `#pragma execution_character_set`, `#pragma clang assume_nonnull` and builtin macro expansion. Fixes https://github.com/llvm/llvm-project/issues/145274 --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2025-07-19 [clang][deps] Properly capture the global module and '\n' for all module ↵Naveen Seth Hanig1-0/+2
directives (#148685) Previously, the newline after a module directive was not properly captured and printed by `clang::printDependencyDirectivesAsSource`. According to P1857R3, each directive must, after skipping horizontal whitespace, appear at the start of a logical line. Because the newline after module directives was missing, this invalidated the following line. This fixes tests that were previously in violation of P1857R3, including for Objective-C directives, which should also comply with P1857R3. This also ensures that the global module fragment `module;` is captured by the dependency directives scanner.
2025-06-26[clang] NFC: Add alias for std::pair<FileID, unsigned> used in ↵Haojian Wu1-1/+1
SourceLocation (#145711) Introduce a type alias for the commonly used `std::pair<FileID, unsigned>` to improve code readability, and make it easier for future updates (64-bit source locations).
2025-06-26[clang][Preprocessor] Handle the first pp-token in EnterMainSourceFile (#145244)yronglin1-0/+15
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-26[NFC][Clang][Preprocessor] Refine the implementation of isNextPPTokenOneOf ↵yronglin1-2/+2
(#145546) This PR follow the suggestion(https://github.com/llvm/llvm-project/pull/143898#discussion_r2164253141) to refine the implementation of `Preprocessor::isNextPPToken`, also use C++ fold expression to refine `Token::isOneOf`. We don't need `bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const` anymore. In order to reduce the impact, specificed `TokenKind` is still passed to `Token::isOneOf` and `Preprocessor::isNextPPTokenOneOf` as function parameters. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-24[clang][Preprocessor] Add peekNextPPToken, makes look ahead next token ↵yronglin1-2/+2
without side-effects (#143898) This PR introduce a new function `peekNextPPToken`. It's an extension of `isNextPPTokenLParen` and can makes look ahead one token in preprocessor without side-effects. It's also the 1st part of https://github.com/llvm/llvm-project/pull/107168 and it was used to look ahead next token then determine whether current lexing pp directive is one of pp-import or pp-module directive. At the start of phase 4 an import or module token is treated as starting a directive and are converted to their respective keywords iff: - After skipping horizontal whitespace are - at the start of a logical line, or - preceded by an export at the start of the logical line. - Are followed by an identifier pp token (before macro expansion), or - <, ", or : (but not ::) pp tokens for import, or - ; for module Otherwise the token is treated as an identifier. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-21[C++][Modules] A module directive may only appear as the first preprocessing ↵yronglin1-0/+2
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-05-19[clang] Use *Map::try_emplace (NFC) (#140477)Kazu Hirata1-1/+1
We can simplify the code with *Map::try_emplace where we need default-constructed values while avoding calling constructors when keys are already present.
2025-05-16[Clang][Lex][NFC] Assert getExternalSource() in updateOutOfDateIdentifier ↵Shafik Yaghmour1-0/+2
(#140137) Static analysis flagged the unconditional access of getExternalSource(). We don't initialize ExternalSource during construction but via setExternalSource(). If this is not set it will violate the invariant covered by the assert.
2025-05-02[C] Diagnose use of C++ keywords in C (#137234)Aaron Ballman1-0/+5
This adds a new diagnostic group, -Wc++-keyword, which is off by default and grouped under -Wc++-compat. The diagnostic catches use of C++ keywords in C code. This change additionally fixes an issue with -Wreserved-identifier not diagnosing use of reserved identifiers in function parameter lists in a function declaration which is not a definition. Fixes https://github.com/llvm/llvm-project/issues/21898
2025-04-17Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵yronglin1-8/+8
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-8/+8
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-8/+8
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-04[clang] Do not share ownership of `PreprocessorOptions` (#133467)Jan Svoboda1-14/+14
This PR makes it so that `CompilerInvocation` is the sole owner of the `PreprocessorOptions` instance.
2025-03-28[clang] Make `PreprocessorOptions` reference constJan Svoboda1-1/+1
2025-02-21[clang][modules] Fix local submodule visibility of macros from transitive ↵Ben Langmuir1-2/+3
import (#122955) When we mark a module visible, we normally mark all of its non-explicit submodules and other exports as visible. However, when we first enter a submodule we should not make them visible to the submodule itself until they are actually imported. Marking exports visible before import would cause bizarre behaviour with local submodule visibility, because it happened before we discovered the submodule's transitive imports and could fail to make them visible in the parent module depending on whether the submodules involved were explicitly defined (module X) or implicitly defined from an umbrella (module *). rdar://136524433
2024-11-16[Lex] Remove unused includes (NFC) (#116460)Kazu Hirata1-3/+0
Identified with misc-include-cleaner.
2024-10-11[C++20][Modules] Allow import for a header unit after #pragma (#111662)Dmitry Polukhin1-0/+4
Summary: `#pragma` and headers that finish with them shouldn't prevent `import "header_unit.h"` syntax. Test Plan: check-clang
2024-07-29[Clang][Parse] Fix ambiguity with nested-name-specifiers that may ↵Krystian Stasiowski1-1/+1
declarative (#96364) Consider the following: ``` template<typename T> struct A { }; template<typename T> int A<T>::B::* f(); // error: no member named 'B' in 'A<T>' ``` Although this is clearly valid, clang rejects it because the _nested-name-specifier_ `A<T>::` is parsed as-if it was declarative, meaning, we parse it as-if it was the _nested-name-specifier_ in a redeclaration/specialization. However, we don't (and can't) know whether the _nested-name-specifier_ is declarative until we see the '`*`' token, but at that point we have already complained that `A` has no member named `B`! This patch addresses this bug by adding support for _fully_ unannotated _and_ unbounded tentative parsing, which allows for us to parse past tokens without having to cache them until we reach a point where we can guarantee to be past the construct we are disambiguating. I don't know where the approach taken here is ideal -- alternatives are welcome. However, the performance impact (as measured by llvm-compile-time-tracker (https://llvm-compile-time-tracker.com/?config=Overview&stat=instructions%3Au&remote=sdkrystian) is quite minimal (0.09%, which I plan to further improve).
2024-07-22Revert "[Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros" ↵yronglin1-310/+134
(#99838) Reverts llvm/llvm-project#90574
2024-07-20[Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (#90574)yronglin1-134/+310
This PR implement [P3034R1 Module Declarations Shouldn’t be Macros](https://wg21.link/P3034R1), and refactor the convoluted state machines in module name lexical analysis. --------- Signed-off-by: yronglin <yronglin777@gmail.com> Co-authored-by: Aaron Ballman <aaron@aaronballman.com> Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2024-07-18[clang] Fix typo in commentsCyndy Ishida1-1/+1
2024-06-13[Safe Buffers] Serialize unsafe_buffer_usage pragmas (#92031)Ziqing Luo1-19/+91
The commit adds serialization and de-serialization implementations for the stored regions. Basically, the serialized representation of the regions of a PP is a (ordered) sequence of source location encodings. For de-serialization, regions from loaded files are stored by their ASTs. When later one queries if a loaded location L is in an opt-out region, PP looks up the regions of the loaded AST where L is at. (Background if helps: a pair of `#pragma clang unsafe_buffer_usage begin/end` pragmas marks a warning-opt-out region. The begin and end locations (opt-out regions) are stored in preprocessor instances (PP) and will be queried by the `-Wunsafe-buffer-usage` analyzer.) The reported issue at upstream: https://github.com/llvm/llvm-project/issues/90501 rdar://124035402
2024-04-11[NFC][Clang] Improve const correctness for IdentifierInfo (#79365)Bill Wendling1-1/+1
The IdentifierInfo isn't typically modified. Use 'const' wherever possible.
2024-01-27[clang][Diagnostics] Highlight code snippets (#66514)Timm Baeder1-0/+24
Add some primitive syntax highlighting to our code snippet output. This adds "checkpoints" to the Preprocessor, which we can use to start lexing from. When printing a code snippet, we lex from the nearest checkpoint and highlight the tokens based on their token type.
2024-01-22[CLANG] Add warning when INF or NAN are used in a binary operation or as ↵Zahira Ammarguellat1-0/+5
function argument in fast math mode. (#76873) Check for operations using INF or NaN when in ffast-math mode and generate a warning.
2023-11-06[clang] Change representation of CurLexerKind (#70381)serge-sans-paille1-49/+14
Previous representation used an enumeration combined to a switch to dispatch to the appropriate lexer. Use function pointer so that the dispatching is just an indirect call, which is actually better because lexing is a costly task compared to a function call. This also makes the code slightly cleaner, speedup on compile time tracker are consistent and range form -0.05% to -0.20% for NewPM-O0-g, see https://llvm-compile-time-tracker.com/compare.php?from=f9906508bc4f05d3950e2219b4c56f6c078a61ef&to=608c85ec1283638db949d73e062bcc3355001ce4&stat=instructions:u Considering just the preprocessing task, preprocessing the sqlite amalgametion takes -0.6% instructions (according to valgrind --tool=callgrind) --------- Co-authored-by: serge-sans-paille <sguelton@mozilla.com> Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2023-11-02[Modules] Fix ModuleDeclState transition when module is used as a regular ↵Fangrui Song1-18/+21
identifier (#71134) `ModuleDeclState` is incorrectly changed to `NamedModuleImplementation` for `struct module {}; void foo(module a);`. This is mostly benign but leads to a spurious warning after #69555. A real world example is: ``` // pybind11.h class module_ { ... }; using module = module_; // tensorflow void DefineMetricsModule(pybind11::module main_module); // `module main_module);` incorrectly changes `ModuleDeclState` to `NamedModuleImplementation` #include <algorithm> // spurious warning ```
2023-10-07[clang][Lex][NFC] Make some local variables constTimm Bäder1-2/+2
2023-10-05[Lex] Handle repl_input_end in Preprocessor::LexTokensUntilEOF()Jonas Hahnfeld1-1/+2
This fixes many unit tests when trying to enable IncrementalExtensions by default for testing purposes. Differential Revision: https://reviews.llvm.org/D158415
2023-10-05[Lex] Introduce Preprocessor::LexTokensUntilEOF()Jonas Hahnfeld1-0/+11
This new method repeatedly calls Lex() until end of file is reached and optionally fills a std::vector of Tokens. Use it in Clang's unit tests to avoid quite some code duplication. Differential Revision: https://reviews.llvm.org/D158413
2023-09-29[clang] NFCI: Use `FileEntryRef` in `SourceManager::overrideFileContents()`Jan Svoboda1-2/+1
2023-09-29[clang] NFCI: Use `FileEntryRef` in `ASTReader::GetHeaderFileInfo()`Jan Svoboda1-2/+2
This is the `ASTReader` counterpart to PR #67383.
2023-09-27[clang][NFC] Preprocessor only needs const LangOptions (#66874)Timm Baeder1-1/+1
2023-09-20Re-apply "[Parse] Split incremental-extensions" (#66446)Ben Barham1-0/+4
Re-applies #65683 with a fix to always run `Actions.ActOnEndOfTranslationUnit` regardless of incremental processing.
2023-09-13Revert "[Parse] Split incremental-extensions" (#66281)Ben Barham1-4/+0
This reverts commit c2fb112021529c635cccd8bb9d846b2c64fc291d, which breaks: ``` lldb-api.commands/expression/diagnostics.TestExprDiagnostics.py lldb-api.lang/objc/modules.TestObjCModules.py lldb-api.lang/objc/modules-incomplete.TestIncompleteModules.py lldb-api.lang/objc/modules-non-objc-target.TestObjCModulesNonObjCTarget.py lldb-api.lang/objc/modules-objc-property.TestModulesObjCProperty.py ```
2023-09-11[Parse] Split incremental-extensions (#65683)Ben Barham1-0/+4
The preprocessor `IncrementalProcessing` option was being used to control whether or not to teardown the lexer or run the end of translation unit action. In D127284 this was merged with `-fincremental-extensions`, which also changes top level parsing. Split these again so that the former behavior can be achieved without the latter (ie. to allow managing lifetime without also changing parsing). Resolves rdar://113406310.
2023-03-10Revert "Currently the control of the eval-method is mixed with fast-math."Zahira Ammarguellat1-5/+0
Setting __FLT_EVAL_METHOD__ to -1 with fast-math will set __GLIBC_FLT_EVAL_METHOD to 2 and long double ends up being used for float_t and double_t. This creates some ABI breakage with various C libraries. See details here: https://github.com/llvm/llvm-project/issues/60781 This reverts commit bbf0d1932a3c1be970ed8a580e51edf571b80fd5.
2023-02-16[Modules] Remove -fmodules-tsChuanqi Xu1-5/+5
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-10[C++20] [Modules] [NFC] Add Preprocessor methods for named modules - for ↵Chuanqi Xu1-5/+34
ClangScanDeps (1/4) This patch prepares the necessary interfaces in the preprocessor part for D137527 since we need to recognize if we're in a module unit, the module kinds and the module declaration and the module we're importing in the preprocessor. Differential Revision: https://reviews.llvm.org/D137526
2023-02-08[Lex] Fix -Wunused-variable for LLVM_ENABLE_ASSERTIONS=off builds after D140179Fangrui Song1-1/+1
2023-02-08[-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmasZiqing Luo1-0/+69
Add a pair of clang pragmas: - `#pragma clang unsafe_buffer_usage begin` and - `#pragma clang unsafe_buffer_usage end`, which specify the start and end of an (unsafe buffer checking) opt-out region, respectively. Behaviors of opt-out regions conform to the following rules: - No nested nor overlapped opt-out regions are allowed. One cannot start an opt-out region with `... unsafe_buffer_usage begin` but never close it with `... unsafe_buffer_usage end`. Mis-use of the pragmas will be warned. - Warnings raised from unsafe buffer operations inside such an opt-out region will always be suppressed. This behavior CANNOT be changed by `clang diagnostic` pragmas or command-line flags. - Warnings raised from unsafe operations outside of such opt-out regions may be reported on declarations inside opt-out regions. These warnings are NOT suppressed. - An un-suppressed unsafe operation warning may be attached with notes. These notes are NOT suppressed as well regardless of whether they are in opt-out regions. The implementation maintains a separate sequence of location pairs representing opt-out regions in `Preprocessor`. The `UnsafeBufferUsage` analyzer reads the region sequence to check if an unsafe operation is in an opt-out region. If it is, discard the warning raised from the operation immediately. This is a re-land after I reverting it at 9aa00c8a306561c4e3ddb09058e66bae322a0769. The compilation error should be resolved. Reviewed by: NoQ Differential revision: https://reviews.llvm.org/D140179
2023-02-07Revert "[-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas"Ziqing Luo1-69/+0
This reverts commit aef05b5dc5c566bcaa15b66c989ccb8d2841ac71. It causes a buildbot failure: https://lab.llvm.org/buildbot/#/builders/216/builds/16879/steps/6/logs/stdio
2023-02-07[-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmasZiqing Luo1-0/+69
Add a pair of clang pragmas: - `#pragma clang unsafe_buffer_usage begin` and - `#pragma clang unsafe_buffer_usage end`, which specify the start and end of an (unsafe buffer checking) opt-out region, respectively. Behaviors of opt-out regions conform to the following rules: - No nested nor overlapped opt-out regions are allowed. One cannot start an opt-out region with `... unsafe_buffer_usage begin` but never close it with `... unsafe_buffer_usage end`. Mis-use of the pragmas will be warned. - Warnings raised from unsafe buffer operations inside such an opt-out region will always be suppressed. This behavior CANNOT be changed by `clang diagnostic` pragmas or command-line flags. - Warnings raised from unsafe operations outside of such opt-out regions may be reported on declarations inside opt-out regions. These warnings are NOT suppressed. - An un-suppressed unsafe operation warning may be attached with notes. These notes are NOT suppressed as well regardless of whether they are in opt-out regions. The implementation maintains a separate sequence of location pairs representing opt-out regions in `Preprocessor`. The `UnsafeBufferUsage` analyzer reads the region sequence to check if an unsafe operation is in an opt-out region. If it is, discard the warning raised from the operation immediately. Reviewed by: NoQ Differential revision: https://reviews.llvm.org/D140179
2023-01-14[clang] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-1/+1
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14[clang] Add #include <optional> (NFC)Kazu Hirata1-0/+1
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-20[Clang] Prepare for llvm::Optional becoming std::optional.Benjamin Kramer1-1/+1
The needed tweaks are mostly trivial, the one nasty bit is Clang's usage of OptionalStorage. To keep this working old Optional stays around as clang::CustomizableOptional, with the default Storage removed. Optional<File/DirectoryEntryRef> is replaced with a typedef. I tested this with GCC 7.5, the oldest supported GCC I had around. Differential Revision: https://reviews.llvm.org/D140332
2022-12-18Revert "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to ↵Krzysztof Parzyszek1-2/+1
std::optional" This reverts commit 8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d. The Optional*RefDegradesTo*EntryPtr types want to keep the same size as the underlying type, which std::optional doesn't guarantee. For use with llvm::Optional, they define their own storage class, and there is no way to do that in std::optional. On top of that, that commit broke builds with older GCCs, where std::optional was not trivially copyable (static_assert in the clang sources was failing).
2022-12-17[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optionalKrzysztof Parzyszek1-1/+2
2022-10-27[NFC] [Modules] Rename modules related things in Preprocessor and ↵Chuanqi Xu1-25/+25
AffectingModules Rename module related things according to the consensus in https://discourse.llvm.org/t/rfc-unifying-the-terminology-about-modules-in-clang/66054/ to reduce further confusings. This only renames things I can make sure. It doesn't mean all the names in Preprocessor are correct now.