aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendActions.cpp
AgeCommit message (Collapse)AuthorFilesLines
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
2023-06-16[NFC] Fix potential dereferencing of null return value.Sindhu Chittireddy1-0/+2
Replace getAs with castAs and add assert if needed. Differential Revision: https://reviews.llvm.org/D152977
2023-05-09[Sema] Lambdas are not part of immediate context for deductionIlya Biryukov1-0/+2
This commit implements [temp.deduct]p9. Test updates include: - New notes in `cxx1y-init-captures.cpp`, `lambda-expressions.cpp` and 'warn-unused-lambda-capture.cpp'. This seems to be caused by diagnosing errors earlier (during deduction) that were previously surfaced later (during instantiation). - New error `lambda-unevaluated.cpp` is in line with [temp.deduct]p9. Reviewed By: erichkeane, #clang-language-wg Differential Revision: https://reviews.llvm.org/D148802
2023-04-05[NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copyManna, Soumi1-1/+1
Reported by Coverity: AUTO_CAUSES_COPY Unnecessary object copies can affect performance Inside FrontendActions.cpp file, In clang::DumpModuleInfoAction::ExecuteAction(): Using the auto keyword without an & causes the copy of an object of type pair. Inside ComputeDependence.cpp file, In clang::computeDependence(clang::OverloadExpr *, bool, bool, bool): Using the auto keyword without an & causes the copy of an object of type TemplateArgumentLoc. Reviewed By: erichkeane, aaron.ballman Differential Revision: https://reviews.llvm.org/D147574
2023-03-30[NFC] Fix potential for use-after-free in DumpModuleInfoActionMariya Podchishchaeva1-4/+2
Since each `DumpModuleInfoAction` can now contain a pointer to a `raw_ostream`, saving there a poiter that owned by a local `unique_ptr` may cause use-after-free. Clarify ownership and save a `shared_ptr` inside of `DumpModuleInfoAction` instead. Found by static analyzer. Reviewed By: tahonermann, aaron.ballman Differential Revision: https://reviews.llvm.org/D146412
2023-03-29re-land [C++20][Modules] Introduce an implementation module.Iain Sandoe1-0/+2
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-27Revert "[C++20][Modules] Introduce an implementation module."Mitch Phillips1-2/+0
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-0/+2
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-1/+3
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-16[Modules] Remove -fmodules-tsChuanqi Xu1-5/+0
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-01[Module] Respect `-fno-pch-timestamps` when building modulesSteven Wu1-1/+2
Always respect the FrontendOption to not include timestamps in PCH or Modules when `-fno-pch-timestamps` is specified. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D141632
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-11-18[C++20] [Modules] Remove unmaintained Header ModuleChuanqi Xu1-71/+0
Currently there is a -emit-header-module mode, which can combine several headers together as a module interface. However, this breaks our assumption (for standard c++ modules) about module interface. The module interface should come from a module interface unit. And if it is a header, it should be a header unit. And currently we have no ideas to combine several headers together. So I think this mode is an experimental one and it is not maintained and it is not used. So it will be better to remove them. Reviewed By: Bigcheese, dblaikie, bruno Differential Revision: https://reviews.llvm.org/D137609
2022-11-17[clang] Use InMemoryModuleCache for readASTFileControlBlock NFCBen Langmuir1-4/+6
When a pcm has already been loaded from disk, reuse it from the InMemoryModuleCache in readASTFileControlBlock. This avoids potentially reading it again. As noted in the FIXME, ideally we would also add the module to the cache if it will be used again later, but that could modify its build state and we do not have enough context currenlty to know if it's correct. Differential Revision: https://reviews.llvm.org/D138160
2022-11-14[C++20] [Modules] Emit Macro Definition in -module-file-info actionChuanqi Xu1-0/+14
It is helpful to know whih macro definition is emitted in the module file without openning it directly. And this is not easy to be tested with the lit test. So this patch add the facility to emit macro definitions in `-module-file-info` action. And this should be innnocent for every other cases.
2022-10-04Implement DR2565: Invalid types in the parameter-declaration-clause of aErich Keane1-0/+2
requires-expression As reported: https://github.com/llvm/llvm-project/issues/57487 We properly treated a failed instantiation of a concept as a unsatisified constraint, however, we need to do this at the 'requires clause' level as well. This ensures that the parameters on a requires clause that fail instantiation will cause a satisfaction failure. This patch implements this by running requires parameter clause instantiation under a SFINAE trap, then stores any such failure as a requirement failure, so it can be diagnosed later.
2022-09-03[clang] Qualify auto in range-based for loops (NFC)Kazu Hirata1-2/+2
2022-08-05[Serialization] Remove `ORIGINAL_PCH_DIR` recordArgyrios Kyrtzidis1-5/+2
Use of `ORIGINAL_PCH_DIR` record has been superseeded by making PCH/PCM files with relocatable paths at write time. Removing this record is useful for producing an output-path-independent PCH file and enable sharing of the same PCH file even when it was intended for a different output path. Differential Revision: https://reviews.llvm.org/D131124
2022-07-29[ASTWriter] Provide capability to output a PCM/PCH file that does not write ↵Argyrios Kyrtzidis1-2/+5
out information about its output path This is useful to enable sharing of the same PCH file even when it's intended for a different output path. The only information this option disables writing is for `ORIGINAL_PCH_DIR` record which is treated as optional and (when present) used as fallback for resolving input file paths relative to it. Differential Revision: https://reviews.llvm.org/D130710
2022-07-13[lldb] Add image dump pcm-info commandDave Lee1-1/+2
Add `pcm-info` to the `target module dump` subcommands. This dump command shows information about clang .pcm files. This command effectively runs `clang -module-file-info` and produces identical output. The .pcm file format is tightly coupled to the clang version. The clang embedded in lldb is not guaranteed to match the version of the clang executable available on the local system. There have been times when I've needed to view the details about a .pcm file produced by lldb's embedded clang, but because the clang executable was a slightly different version, the `-module-file-info` invocation failed. With this command, users can inspect .pcm files generated by lldb too. Differential Revision: https://reviews.llvm.org/D129456
2022-05-26[Tooling/DependencyScanning & Preprocessor] Refactor dependency scanning to ↵Argyrios Kyrtzidis1-3/+4
produce pre-lexed preprocessor directive tokens, instead of minimized sources This is a commit with the following changes: * Remove `ExcludedPreprocessorDirectiveSkipMapping` and related functionality Removes `ExcludedPreprocessorDirectiveSkipMapping`; its intended benefit for fast skipping of excluded directived blocks will be superseded by a follow-up patch in the series that will use dependency scanning lexing for the same purpose. * Refactor dependency scanning to produce pre-lexed preprocessor directive tokens, instead of minimized sources Replaces the "source minimization" mechanism with a mechanism that produces lexed dependency directives tokens. * Make the special lexing for dependency scanning a first-class feature of the `Preprocessor` and `Lexer` This is bringing the following benefits: * Full access to the preprocessor state during dependency scanning. E.g. a component can see what includes were taken and where they were located in the actual sources. * Improved performance for dependency scanning. Measurements with a release+thin-LTO build shows ~ -11% reduction in wall time. * Opportunity to use dependency scanning lexing to speed-up skipping of excluded conditional blocks during normal preprocessing (as follow-up, not part of this patch). For normal preprocessing measurements show differences are below the noise level. Since, after this change, we don't minimize sources and pass them in place of the real sources, `DependencyScanningFilesystem` is not technically necessary, but it has valuable performance benefits for caching file `stat`s along with the results of scanning the sources. So the setup of using the `DependencyScanningFilesystem` during a dependency scan remains. Differential Revision: https://reviews.llvm.org/D125486 Differential Revision: https://reviews.llvm.org/D125487 Differential Revision: https://reviews.llvm.org/D125488
2022-05-26[Tooling/DependencyScanning] Rename refactorings towards transitioning ↵Argyrios Kyrtzidis1-4/+4
dependency scanning to use pre-lexed preprocessor directive tokens This is first of a series of patches for making the special lexing for dependency scanning a first-class feature of the `Preprocessor` and `Lexer`. This patch only includes NFC renaming changes to make reviewing of the functionality changing parts easier. Differential Revision: https://reviews.llvm.org/D125484
2022-05-05Reimplement `__builtin_dump_struct` in Sema.Richard Smith1-0/+2
Compared to the old implementation: * In C++, we only recurse into aggregate classes. * Unnamed bit-fields are not printed. * Constant evaluation is supported. * Proper conversion is done when passing arguments through `...`. * Additional arguments are supported and are injected prior to the format string; this directly supports use with `fprintf`, for example. * An arbitrary callable can be passed rather than only a function pointer. In particular, in C++, a function template or overload set is acceptable. * All text generated by Clang is printed via `%s` rather than directly; this avoids issues where Clang's pretty-printing output might itself contain a `%` character. * Fields of types that we don't know how to print are printed with a `"*%p"` format and passed by address to the print function. * No return value is produced. Reviewed By: aaron.ballman, erichkeane, yihanaa Differential Revision: https://reviews.llvm.org/D124221
2022-03-28Add HLSL Language Option and PreprocessorChris Bieneman1-0/+1
Bringing in HLSL as a language as well as language options for each of the HLSL language standards. While the HLSL language is unimplemented, this patch adds the HLSL-specific preprocessor defines which enables testing of the command line options through the driver. Reviewed By: pete, rnk Differential Revision: https://reviews.llvm.org/D122087
2022-03-25[C++20][Modules][HU 1/5] Introduce header units as a module type.Iain Sandoe1-0/+17
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
2022-02-23Silence some "not all control paths return a value" warnings; NFCAaron Ballman1-0/+1
2022-02-23[Modules] Add module structure output to -module-file-info.Iain Sandoe1-2/+101
It is useful to be able to visualise the C++20 modules content of a PCM file both for inspection and for testing. In particular, when adding more module types to support C++20 Partitions and Header Units, we would like to be able to confirm that the output PCM has the intended structure. The existing scheme for dumping data is restricted to the content of the AST file control block, which does not include structural data beyond imports. The change here makes use of the AST unit that is set up by BeginSourceFile to query for the information on the primary and sub-modules. We can then inspect each of these in turn, accounting for Global, Private, Imported and Exported modules/fragments and then showing the sub-stucture of the main module(s). The disadvantage of this mechanism is that it has no easy method to control the granularity of the output. Perhaps more detailed inspection would be better handled by a stand-alone module inspection tool. Differential Revision: https://reviews.llvm.org/D119823
2022-01-24[Templight] Don't display empty strings for names of unnamed template parametersKristóf Umann1-13/+82
Patch originally by oktal3000: https://github.com/mikael-s-persson/templight/pull/40 When a template parameter is unnamed, the name of -templight-dump might return an empty string. This is fine, they are unnamed after all, but it might be more user friendly to at least describe what entity is unnamed. Differential Revision: https://reviews.llvm.org/D115521
2022-01-18[clang][lex] NFC: Simplify calls to `LookupFile`Jan Svoboda1-2/+1
The `{HeaderSearch,Preprocessor}::LookupFile()` functions take an out-parameter `const DirectoryLookup *&`. Most callers end up creating a `const DirectoryLookup *` variable that's otherwise unused. This patch changes the out-parameter from reference to a pointer, making it possible to simply pass `nullptr` to the function without the ceremony. Reviewed By: ahoppen Differential Revision: https://reviews.llvm.org/D117312
2021-11-19[clang][NFC] Inclusive terms: replace some uses of sanity in clangZarko Todorovski1-1/+1
Rewording of comments to avoid using `sanity test, sanity check`. Reviewed By: aaron.ballman, Quuxplusone Differential Revision: https://reviews.llvm.org/D114025
2021-09-09[clang-scan-deps] Add an API for clang dependency scanner to performAkira Hatanaka1-0/+14
module lookup by name alone This removes the need to create a fake source file that imports a module. rdar://64538073 Differential Revision: https://reviews.llvm.org/D109485
2021-06-17Frontend: Respect -fno-temp-file when creating a PCHZachary Henkel1-1/+2
When creating a PCH file the use of a temp file will be dictated by the presence or absence of the -fno-temp-file flag. Creating a module file will always use a temp file via the new ForceUseTemporary flag. This fixes bug 50033.
2021-06-14[clang][deps] Handle precompiled headers' AST filesJan Svoboda1-0/+21
The `PreprocessOnlyAction` doesn't support loading the AST file of a precompiled header. This is problematic for dependency scanning, since the `#include` manufactured for the PCH is treated as textual. This means the PCH contents get scanned with each TU, which is redundant. Moreover, dependencies of the PCH end up being considered dependency of the TU. To handle AST file of PCH properly, this patch creates new `FrontendAction` that behaves the same way `PreprocessorOnlyAction` does, but treats the manufactured PCH `#include` as a normal compilation would (by not claiming it only uses a preprocessor and creating the default AST consumer). The AST file is now reported as a file dependency of the TU. Depends on D103519. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D103524
2021-05-17[clang][modules] Build inferred modulesMichael Spencer1-1/+2
This patch enables explicitly building inferred modules. Effectively a cherry-pick of https://github.com/apple/llvm-project/pull/699 authored by @Bigcheese with libclang and dependency scanner changes omitted. Contains the following changes: 1. [Clang] Fix the header paths in clang::Module for inferred modules. * The UmbrellaAsWritten and NameAsWritten fields in clang::Module are a lie for framework modules. For those they actually are the path to the header or umbrella relative to the clang::Module::Directory. * The exception to this case is for inferred modules. Here it actually is the name as written, because we print out the module and read it back in when implicitly building modules. This causes a problem when explicitly building an inferred module, as we skip the printing out step. * In order to fix this issue this patch adds a new field for the path we want to use in getInputBufferForModule. It also makes NameAsWritten actually be the name written in the module map file (or that would be, in the case of an inferred module). 2. [Clang] Allow explicitly building an inferred module. * Building the actual module still fails, but make sure it fails for the right reason. Split from D100934. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D102491
2021-04-06[SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag ↵Abhina Sreeskantharajan1-1/+1
instead of OF_Text Problem: On SystemZ we need to open text files in text mode. On Windows, files opened in text mode adds a CRLF '\r\n' which may not be desirable. Solution: This patch adds two new flags - OF_CRLF which indicates that CRLF translation is used. - OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and uses CRLF translation. Developers should now use either the OF_Text or OF_TextWithCRLF for text files and OF_None for binary files. If the developer doesn't want carriage returns on Windows, they should use OF_Text, if they do want carriage returns on Windows, they should use OF_TextWithCRLF. So this is the behaviour per platform with my patch: z/OS: OF_None: open in binary mode OF_Text : open in text mode OF_TextWithCRLF: open in text mode Windows: OF_None: open file with no carriage return OF_Text: open file with no carriage return OF_TextWithCRLF: open file with carriage return The Major change is in llvm/lib/Support/Windows/Path.inc to only set text mode if the OF_CRLF is set. ``` if (Flags & OF_CRLF) CrtOpenFlags |= _O_TEXT; ``` These following files are the ones that still use OF_Text which I left unchanged. I modified all these except raw_ostream.cpp in recent patches so I know these were previously in Binary mode on Windows. ./llvm/lib/Support/raw_ostream.cpp ./llvm/lib/TableGen/Main.cpp ./llvm/tools/dsymutil/DwarfLinkerForBinary.cpp ./llvm/unittests/Support/Path.cpp ./clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp ./clang/lib/Frontend/CompilerInstance.cpp ./clang/lib/Driver/Driver.cpp ./clang/lib/Driver/ToolChains/Clang.cpp Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D99426
2021-03-24[OpenCL] Added distinct file extension for C++ for OpenCL.Anastasia Stulova1-0/+1
Files compiled with C++ for OpenCL mode can now have a distinct file extension - clcpp, then clang driver picks the compilation mode automatically (-x clcpp) without the use of -cl-std=clc++. Differential Revision: https://reviews.llvm.org/D96771
2021-03-19[SystemZ][z/OS] Distinguish between text and binary files on z/OSAbhina Sreeskantharajan1-25/+30
This patch consists of the initial changes to help distinguish between text and binary content correctly on z/OS. I would like to get feedback from Windows users on setting OF_None for all ToolOutputFiles. This seems to have been done as an optimization to prevent CRLF translation on Windows in the past. Reviewed By: zibi Differential Revision: https://reviews.llvm.org/D97785
2021-02-23Revert "Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, ↵Duncan P. N. Exon Smith1-1/+1
and DirectoryName, NFC" This (mostly) reverts 32c501dd88b62787d3a5ffda7aabcf4650dbe3cd. Hit a case where this causes a behaviour change, perhaps the same root cause that triggered the revert of a40db5502b2515a6f2f1676b5d7a655ae0f41179 in 7799ef7121aa7d59f4bd95cdf70035de724ead6f. (The API changes in DirectoryEntry.h have NOT been reverted as a number of subsequent commits depend on those.) https://reviews.llvm.org/D90497#2582166
2021-01-26Frontend: Fix layering between create{,Default}OutputFile, NFCDuncan P. N. Exon Smith1-14/+7
Fix layering between `CompilerInstance::createDefaultOutputFile` and the two versions of `createOutputFile`. - Add missing configuration flags to `createDefaultOutputFile` so that GeneratePCHAction and GenerateModuleFromModuleMapAction can use it. They previously promised that temporary files were turned on; now `createDefaultOutputFile` handles that logic. - Lift the logic handling `InFile` and `Extension` to `createDefaultOutputFile`, since it's only the callers of that function that are using it. - Rename the deeper of the two `createOutputFile`s to `createOutputFileImpl` and make it private to `CompilerInstance` (to prove that no one else is using it). - Sink the logic for adding to `CompilerInstance::OutputFiles` down to `createOutputFileImpl`, allowing two "optional" (but always used) `std::string*` out parameters to be removed. - Instead of passing a `std::error_code` out parameter into `createOutputFileImpl`, have it return `Expected<>`. - As a drive-by, inline `CompilerInstance::addOutputFile` into its only caller, `createOutputFileImpl`. Clean layering makes it easier for a future commit to extract `createOutputFileImpl` out of `CompilerInstance`. Differential Revision: https://reviews.llvm.org/D93248
2021-01-21[ASTReader] Allow controlling separately whether validation should be ↵Argyrios Kyrtzidis1-1/+1
disabled for a PCH vs a module file This addresses an issue with how the PCH preable works, specifically: 1. When using a PCH/preamble the module hash changes and a different cache directory is used 2. When the preamble is used, PCH & PCM validation is disabled. Due to combination of #1 and #2, reparsing with preamble enabled can end up loading a stale module file before a header change and using it without updating it because validation is disabled and it doesn’t check that the header has changed and the module file is out-of-date. rdar://72611253 Differential Revision: https://reviews.llvm.org/D95159
2020-12-02Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and ↵Duncan P. N. Exon Smith1-1/+1
DirectoryName, NFC Push `FileEntryRef` and `DirectoryEntryRef` further, using it them `Module::Umbrella`, `Module::Header::Entry`, and `Module::DirectoryName::Entry`. - Add `DirectoryEntryRef::operator const DirectoryEntry *` and `OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr`, to get the same "degrades to `DirectoryEntry*` behaviour `FileEntryRef` enjoys (this avoids a bunch of churn in various clang tools). - Fix the `DirectoryEntryRef` constructor from `MapEntry` to take it by `const&`. Note that we cannot get rid of the `...AsWritten` names leveraging the new classes, since these need to be as written in the `ModuleMap` file and the module directory path is preprended for the lookup in the `FileManager`. Differential Revision: https://reviews.llvm.org/D90497
2020-11-17[Frontend] Add flag to allow PCM generation despite compiler errorsBen Barham1-2/+8
As with precompiled headers, it's useful for indexers to be able to continue through compiler errors in dependent modules. Resolves rdar://69816264 Reviewed By: akyrtzi Differential Revision: https://reviews.llvm.org/D91580
2020-11-11Suppress printing template arguments that match default templateRichard Smith1-1/+4
arguments of types by default. This somewhat improves the worst-case printing of types like std::string, std::vector, etc., where many irrelevant default arguments can be included in the type as printed if we've lost the type sugar.
2020-10-20clang/Frontend: Use MemoryBufferRef in FrontendInputFile (and remove ↵Duncan P. N. Exon Smith1-2/+3
SourceManager::getBuffer) In order to drop the final callers to `SourceManager::getBuffer`, change `FrontendInputFile` to use `Optional<MemoryBufferRef>`. Also updated the "unowned" version of `SourceManager::createFileID` to take a `MemoryBufferRef` (it now calls `MemoryBuffer::getMemBuffer`, which creates a `MemoryBuffer` that does not own the buffer data). Differential Revision: https://reviews.llvm.org/D89427
2020-10-19Lexer: Update the Lexer to use MemoryBufferRef, NFCDuncan P. N. Exon Smith1-1/+1
Update `Lexer` / `Lexer::Lexer` to use `MemoryBufferRef` instead of `MemoryBuffer*`. Callers that were acquiring a `MemoryBuffer*` via `SourceManager::getBuffer` were updated, such that if they checked `Invalid` they use `getBufferOrNone` and otherwise `getBufferOrFake`. Differential Revision: https://reviews.llvm.org/D89398
2020-10-14clang/Frontend: Mostly stop using SourceManager::getBuffer, NFCDuncan P. N. Exon Smith1-6/+4
Update clang/lib/Frontend to use a `MemoryBufferRef` from `getBufferOrFake` instead of `MemoryBuffer*` from `getBuffer`, with the exception of `FrontendInputFile`, which I'm leaving for later. Differential Revision: https://reviews.llvm.org/D89409