aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/ChainedIncludesSource.cpp
AgeCommit message (Collapse)AuthorFilesLines
14 days[clang] Initialize the file system explicitly (#158381)Jan Svoboda1-0/+1
This PR is a part of the effort to make the VFS used in the compiler more explicit and consistent. Instead of creating the VFS deep within the compiler (in `CompilerInstance::createFileManager()`), clients are now required to explicitly call `CompilerInstance::createVirtualFileSystem()` and provide the base VFS from the outside. This PR also helps in breaking up the dependency cycle where creating a properly configured `DiagnosticsEngine` requires a properly configured VFS, but creating properly configuring a VFS requires the `DiagnosticsEngine`. Both `CompilerInstance::create{FileManager,Diagnostics}()` now just use the VFS already in `CompilerInstance` instead of taking one as a parameter, making the VFS consistent across the instance sub-object.
2025-08-01NFC: Clean up of IntrusiveRefCntPtr construction from raw pointers. (#151782)James Y Knight1-11/+12
This commit handles the following types: - clang::ExternalASTSource - clang::TargetInfo - clang::ASTContext - clang::SourceManager - clang::FileManager Part of cleanup #151026
2025-07-31NFC: Clean up of IntrusiveRefCntPtr construction from raw pointers. (#151545)James Y Knight1-4/+3
Handles clang::DiagnosticsEngine and clang::DiagnosticIDs. For DiagnosticIDs, this mostly migrates from `new DiagnosticIDs` to convenience method `DiagnosticIDs::create()`. Part of cleanup https://github.com/llvm/llvm-project/issues/151026
2025-07-15[clang][modules] Serialize `CodeGenOptions` (#146422)Jan Svoboda1-2/+3
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-05-22Reapply "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Jan Svoboda1-2/+2
(#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-2/+2
(#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-2/+2
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-01[clang][frontend] Require invocation to construct `CompilerInstance` (#137668)Jan Svoboda1-3/+2
This PR makes it so that `CompilerInvocation` needs to be provided to `CompilerInstance` on construction. There are a couple of benefits in my view: * Making it impossible to mis-use some `CompilerInstance` APIs. For example there are cases, where `createDiagnostics()` was called before `setInvocation()`, causing the `DiagnosticEngine` to use the default-constructed `DiagnosticOptions` instead of the intended ones. * This shrinks `CompilerInstance`'s state space. * This makes it possible to access **the** invocation in `CompilerInstance`'s constructor (to be used in a follow-up).
2025-04-28[clang] Hide the `TargetOptions` pointer from `CompilerInvocation` (#106271)Jan Svoboda1-1/+1
This PR hides the reference-counted pointer that holds `TargetOptions` from the public API of `CompilerInvocation`. This gives `CompilerInvocation` an exclusive control over the lifetime of this member, which will eventually be leveraged to implement a copy-on-write behavior. There are two clients that currently share ownership of that pointer: * `TargetInfo` - This was refactored to hold a non-owning reference to `TargetOptions`. The options object is typically owned by the `CompilerInvocation` or by the new `CompilerInstance::AuxTargetOpts` for the auxiliary target. This needed a bit of care in `ASTUnit::Parse()` to keep the `CompilerInvocation` alive. * `clangd::PreambleData` - This was refactored to exclusively own the `TargetOptions` that get moved out of the `CompilerInvocation`.
2024-09-19[clang] Tidy uses of raw_string_ostream (NFC)Youngsuk Kim1-1/+1
As specified in the docs, 1) raw_string_ostream is always unbuffered and 2) the underlying buffer may be used directly ( 65b13610a5226b84889b923bae884ba395ad084d for further reference ) * Don't call raw_string_ostream::flush(), which is essentially a no-op. * Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection.
2022-09-02[NFC] Make MultiplexExternalSemaSource own sourcesChris Bieneman1-30/+9
This change refactors the MuiltiplexExternalSemaSource to take ownership of the underlying sources. As a result it makes a larger cleanup of external source ownership in Sema and the ChainedIncludesSource. Reviewed By: aaron.ballman, aprantl Differential Revision: https://reviews.llvm.org/D133158
2021-01-21[ASTReader] Allow controlling separately whether validation should be ↵Argyrios Kyrtzidis1-5/+6
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-02-21clang/Modules: Finish renaming CompilerInstance::ModuleManager, NFC.Volodymyr Sapsai1-1/+1
Follow-up to 20d51b2f14ac4488f684f8fc57cb0ba718a6b91d, rename the setter to make it consistent with the getter. Also fixed a few comments along the way, didn't try to find all references to a module manager. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D74939
2019-11-15Avoid including Builtins.h in Preprocessor.hReid Kleckner1-0/+1
Builtins are rarely if ever accessed via the Preprocessor. They are typically found on the ASTContext, so there should be no performance penalty to using a pointer indirection to store the builtin context.
2019-08-14[Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-1/+1
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
2019-03-09Modules: Rename MemoryBufferCache to InMemoryModuleCacheDuncan P. N. Exon Smith1-4/+4
Change MemoryBufferCache to InMemoryModuleCache, moving it from Basic to Serialization. Another patch will start using it to manage module build more explicitly, but this is split out because it's mostly mechanical. Because of the move to Serialization we can no longer abuse the Preprocessor to forward it to the ASTReader. Besides the rename and file move, that means Preprocessor::Preprocessor has one fewer parameter and ASTReader::ASTReader has one more. llvm-svn: 355777
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-12-04PTH-- Remove feature entirely-Erich Keane1-1/+0
When debugging a boost build with a modified version of Clang, I discovered that the PTH implementation stores TokenKind in 8 bits. However, we currently have 368 TokenKinds. The result is that the value gets truncated and the wrong token gets picked up when including PTH files. It seems that this will go wrong every time someone uses a token that uses the 9th bit. Upon asking on IRC, it was brought up that this was a highly experimental features that was considered a failure. I discovered via googling that BoostBuild (mostly Boost.Math) is the only user of this feature, using the CC1 flag directly. I believe that this can be transferred over to normal PCH with minimal effort: https://github.com/boostorg/build/issues/367 Based on advice on IRC and research showing that this is a nearly completely unused feature, this patch removes it entirely. Note: I considered leaving the build-flags in place and making them emit an error/warning, however since I've basically identified and warned the only user, it seemed better to just remove them. Differential Revision: https://reviews.llvm.org/D54547 Change-Id: If32744275ef1f585357bd6c1c813d96973c4d8d9 llvm-svn: 348266
2018-07-30Remove trailing spaceFangrui Song1-3/+3
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
2017-06-29Teach ASTReader how to read only the Preprocessor state from an AST file, ↵Richard Smith1-1/+1
not the ASTContext state. We use this when running a preprocessor-only action on an AST file in order to avoid paying the runtime cost of loading the extra information. llvm-svn: 306760
2017-01-06Reapply "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase ↵David Blaikie1-1/+1
and CodeCompleteConsumer" Aleksey Shlypanikov pointed out my mistake in migrating an explicit unique_ptr to auto - I was expecting the function returned a unique_ptr, but instead it returned a raw pointer - introducing a leak. Thanks Aleksey! This reapplies r291184, reverted in r291249. llvm-svn: 291270
2017-01-06Revert "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and ↵David Blaikie1-1/+1
CodeCompleteConsumer" Caused a memory leak reported by asan. Reverting while I investigate. This reverts commit r291184. llvm-svn: 291249
2017-01-05IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and ↵David Blaikie1-1/+1
CodeCompleteConsumer llvm-svn: 291184
2017-01-05Use shared_ptr instead of IntrusiveRefCntPtr for ModuleFileExtensionDavid Blaikie1-1/+1
The intrusiveness wasn't needed here, so this simplifies/clarifies the ownership model. llvm-svn: 291150
2016-08-25Refactor to remove the assumption that we know the name of the module we're ↵Richard Smith1-1/+1
emitting at the point when we create a PCHGenerator (with the C++ modules TS, we find that out part way through parsing the input). llvm-svn: 279766
2016-07-18[NFC] Header cleanupMehdi Amini1-0/+1
Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
2016-07-17Attempt to work around MSVC rejects-valid, round 2.Richard Smith1-2/+5
llvm-svn: 275730
2016-07-17PR28589: attempt to work around MSVC rejects-valid.Richard Smith1-1/+2
llvm-svn: 275727
2016-07-16Reimplement ExternalSemaSource delegation in terms ofRichard Smith1-120/+36
MultiplexExternalSemaSource to remove one of the places that needs updating every time the ExternalSemaSource interface changes. llvm-svn: 275653
2016-07-13[PCH/preamble] Make sure that if the preamble/PCH was serialized with errors ↵Argyrios Kyrtzidis1-1/+1
that we set diagnostic engine state appropriately. Otherwise there can be a crash with CFG analysis warnings doing work on invalid AST. Fixes crash of rdar://26224134 llvm-svn: 275313
2016-04-08revert SVN r265702, r265640Saleem Abdulrasool1-2/+1
Revert the two changes to thread CodeGenOptions into the TargetInfo allocation and to fix the layering violation by moving CodeGenOptions into Basic. Code Generation is arguably not particularly "basic". This addresses Richard's post-commit review comments. This change purely does the mechanical revert and will be followed up with an alternate approach to thread the desired information into TargetInfo. llvm-svn: 265806
2016-04-07Basic: thread CodeGenOptions into TargetInfoSaleem Abdulrasool1-1/+2
This threads CodeGenOptions into the TargetInfo hierarchy. This is motivated by ARM which can change some target information based on the EABI selected (-meabi). Similar options exist for other platforms (e.g. MIPS) and thus is generally useful. NFC. llvm-svn: 265640
2015-11-03Introduce module file extensions to piggy-back data onto module files.Douglas Gregor1-1/+4
Introduce the notion of a module file extension, which introduces additional information into a module file at the time it is built that can then be queried when the module file is read. Module file extensions are identified by a block name (which must be unique to the extension) and can write any bitstream records into their own extension block within the module file. When a module file is loaded, any extension blocks are matched up with module file extension readers, that are per-module-file and are given access to the input bitstream. Note that module file extensions can only be introduced by programmatic clients that have access to the CompilerInvocation. There is only one such extension at the moment, which is used for testing the module file extension harness. As a future direction, one could imagine allowing the plugin mechanism to introduce new module file extensions. llvm-svn: 251955
2015-08-06Rename the non-coding style conformant functions in namespace BuiltinsEric Christopher1-1/+1
to match the rest of their brethren and reformat the bits that need it. llvm-svn: 244186
2015-08-05function_ref-ize ExternalASTSource::FindExternalLexicalDecl and remove itsRichard Smith1-7/+6
useless return value. Switch to using it directly when completing the redeclaration chain for an anonymous declaration, and reduce the set of declarations that we load in the process to just those of the right kind. llvm-svn: 244161
2015-07-17Make the clang module container format selectable from the command line.Adrian Prantl1-1/+1
- introduces a new cc1 option -fmodule-format=[raw,obj] with 'raw' being the default - supports arbitrary module container formats that libclang is agnostic to - adds the format to the module hash to avoid collisions - splits the old PCHContainerOperations into PCHContainerWriter and a PCHContainerReader. Thanks to Richard Smith for reviewing this patch! llvm-svn: 242499
2015-06-22Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko1-1/+1
llvm-svn: 240353
2015-06-22Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-1/+1
The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
2015-06-20Introduce a PCHContainerOperations interface (NFC).Adrian Prantl1-9/+13
A PCHContainerOperations abstract interface provides operations for creating and unwrapping containers for serialized ASTs (precompiled headers and clang modules). The default implementation is RawPCHContainerOperations, which uses a flat file for the output. The main application for this interface will be an ObjectFilePCHContainerOperations implementation that uses LLVM to wrap the module in an ELF/Mach-O/COFF container to store debug info alongside the AST. rdar://problem/20091852 llvm-svn: 240225
2015-04-11Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko1-1/+1
Summary: The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix Reviewers: dblaikie Reviewed By: dblaikie Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D8926 llvm-svn: 234678
2015-03-24[modules] Deserialize CXXCtorInitializer list for a constructor lazily.Richard Smith1-0/+5
Previously we'd deserialize the list of mem-initializers for a constructor when we deserialized the declaration of the constructor. That could trigger a significant amount of unnecessary work (pulling in all base classes recursively, for a start) and was causing problems for the modules buildbot due to cyclic deserializations. We now deserialize these on demand. This creates a certain amount of duplication with the handling of CXXBaseSpecifiers; I'll look into reducing that next. llvm-svn: 233052
2015-02-25Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-10/+6
llvm-svn: 230454
2015-02-25Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-6/+10
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. This reapplies r230044 with a fixed configure+make build and updated dependencies and testcase requirements. Over the last iteration this version adds - missing target requirements for testcases that specify an x86 triple, - a missing clangCodeGen.a dependency to libClang.a in the make build. rdar://problem/19104245 llvm-svn: 230423
2015-02-24Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-10/+6
This reverts commit r230305. Off to fix another round of missing dependencies on various platforms. llvm-svn: 230309
2015-02-24Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-6/+10
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 3. llvm-svn: 230305
2015-02-21Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-10/+6
This reverts commit 230099. The Linux configure+make build variant still needs some work. llvm-svn: 230103
2015-02-20Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-6/+10
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 2. llvm-svn: 230089
2015-02-20Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-10/+6
This reverts commit r230067. Investigating another batch of problems found by the bots. llvm-svn: 230073
2015-02-20Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-6/+10
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. llvm-svn: 230067
2015-02-20Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-10/+6
This reverts commit r230044 while dealing with buildbot breakage. Conflicts: test/Modules/module_container.m llvm-svn: 230052