aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ASTWriter.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-04-28[clang][NFC] Convert DeclUpdateKind to scoped enumVlad Serebrennikov1-45/+57
2025-04-19[clang] Use llvm::unique (NFC) (#136469)Kazu Hirata1-2/+1
2025-04-19[clang] llvm::append_range (NFC) (#136440)Kazu Hirata1-2/+2
2025-04-18[OpenACC] Switch Clang to use the Flang 'appertainment' rules for cla… ↵Erich Keane1-0/+1
(#135372) …uses The Flang implemenation of OpenACC uses a .td file in the llvm/Frontend directory to determine appertainment in 4 categories: -Required: If this list has items in it, the directive requires at least 1 of these be present. -AllowedExclusive: Items on this list are all allowed, but only 1 from the list may be here (That is, they are exclusive of eachother). -AllowedOnce: Items on this list are all allowed, but may not be duplicated. Allowed: Items on this list are allowed. Note th at the actual list of 'allowed' is all 4 of these lists together. This is a draft patch to swtich Clang over to use those tables. Surgery to get this to happen in Clang Sema was somewhat reasonable. However, some gaps in the implementations are obvious, the existing clang implementation disagrees with the Flang interpretation of it. SO, we're keeping a task list here based on what gets discovered. Changes to Clang: - [x] Switch 'directive-kind' enum conversions to use tablegen See ff1a7bddd9435b6ae2890c07eae60bb07898bbf5 - [x] Switch 'clause-kind' enum conversions to use tablegen See ff1a7bddd9435b6ae2890c07eae60bb07898bbf5 - [x] Investigate 'parse' test differences to see if any new disagreements arise. - [x] Clang/Flang disagree as to whether 'collapse' can be multiple times on a loop. Further research showed no prose to limit this, and the comment on the clang implementation said "no good reason to allow", so no standards justification. - [x] Clang/Flang disagree whether 'num_gangs' can appear >1 on a compute/combined construct. This ended up being an unjustified restriction. - [x] Clang/Flang disagree as to the list of required clauses on a 'set' construct. My research shows that Clang mistakenly included 'if' in the list, and that it should be just 'default_async', 'device_num', and 'device_type'. - [x] Order of 'at least one of' diagnostic has changed. Tests were updated. - [x] Ensure we are properly 'de-aliasing' clause names in appertainment checks? - [x] What is 'shortloop'? 'shortloop' seems to be an old non-standard extension that isn't supported by flang, but is parsed for backward compat reasons. Clang won't parse, but we at least have a spot for it in the clause list. - [x] Implemented proposed change for 'routine' gang/worker/vector/seq. (see issue 539) - [x] Implement init/shutdown can only have 1 'if' (see issue 540) - [x] Clang/Flang disagree as to whether 'tile' is permitted more than once on a 'loop' or combined constructs (Flang prohibits >1). I see no justification for this in the standard. EDIT: I found a comment in clang that I did this to make SOMETHING around duplicate checks easier. Discussion showed we should actually have a better behavior around 'device_type' and duplicates, so I've since implemented that. - [x] Clang/Flang disagree whether 'gang', 'worker', or 'vector' may appear on the same construct as a 'seq' on a 'loop' or 'combined'. There is prose for this in 2022: (a gang, worker, or vector clause may not appear if a 'seq' clause appears). EDIT: These don't actually disagree, but aren't in the .td file, so I restored the existing code to do this. - [x] Clang/Flang disagree on whether 'bind' can appear >1 on a 'routine'. I believe line 3096 (A bind clause may not bind to a routine name that has a visible bind clause) makes this limitation (Flang permits >1 bind). we discussed and decided this should have the same rules as worker/vector/etc, except without the 'exactly 1 of' rule (so no dupes in individual sections). - [x] Clang/Flang disagree on whether 'init'/'shutdown' can have multiple 'device_num' clauses. I believe there is no supporting prose for this limitation., We decided that `device_num` should only happen 1x. - [x] Clang/Flang disagree whether 'num_gangs' can appear >1 on a 'kernels' construct. Line 1173 (On a kernels construct, the num_gangs clause must have a single argument) justifies limiting on a per-arguement basis, but doesn't do so for multiple num_gangs clauses. WE decided to do this with the '1-per-device-type' region for num_gangs, num_workers, and vector_length, see openacc bug here: https://github.com/OpenACC/openacc-spec/issues/541 Changes to Flang: - [x] Clang/Flang disgree on whether 'atomic' can take an 'if' clause. This was added in OpenACC3.3_Next See #135451 - [x] Clang/Flang disagree on whether 'finalize' can be allowed >1 times on a 'exit_data' construct. see #135415. - [x] Clang/Flang disagree whether 'if_present' should be allowed >1 times on a 'host_data'/'update' construct. see #135422 - [x] Clang/Flang disagree on whether 'init'/'shutdown' can have multiple 'device_type' clauses. I believe there is no supporting prose for this limitation. - [ ] SEE change for num_gangs/etc above. Changes that need discussion/research:
2025-04-17[Modules] Fix the inconsistency of which `Decl` should be serialized for an ↵Volodymyr Sapsai1-3/+5
identifier. (#135887) Fixes the assertion failure > Assertion failed: (DeclIDs.contains(D) && "Declaration not emitted!"), function getDeclID, file ASTWriter.cpp, line 6873. We prepare to serialize a `Decl` by adding it to `DeclIDs` in `ASTWriter::GetDeclRef`. But the checks before this call aren't the same as when we are actually serializing a `Decl` in `ASTIdentifierTableTrait::EmitData` and `ASTWriter::WriteIdentifierTable`. That's how we can end up serializing a `Decl` not present in `DeclIDs` and hitting the assertion. With the assertions disabled clang crashes when trying to use a deserialized null `Decl`. Fix by making the code checks before `ASTWriter::GetDeclRef` call similar to those we have before the serialization. rdar://139319683
2025-04-17Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵yronglin1-4/+4
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-16[Modules] Fix an identifier hiding a function-like macro definition. (#135471)Volodymyr Sapsai1-5/+11
We emit a macro definition only in a module defining it. But it means that if another module has an identifier with the same name as the macro, the users of such module won't be able to use the macro anymore. Fix by storing that an identifier has a macro definition that's not in a current module (`MacroDirectivesOffset == 0`). This way `IdentifierLookupVisitor` knows not to stop at the first module with an identifier but to keep checking included modules for the actual macro definition. Fixes issue #32040. rdar://30258278
2025-04-16Revert "[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵Michael Buch1-4/+4
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-4/+4
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-13Support '-fmodule-file-home-is-cwd' for C++ modules. (#135147)Michael Park1-33/+36
2025-04-04[OpenACC] Implement 'modifier-list' sema/ASTerichkeane1-3/+4
OpenACC 3.3-NEXT has changed the way tags for copy, copyin, copyout, and create clauses are specified, and end up adding a few extras, and permits them as a list. This patch encodes these as bitmask enum so they can be stored succinctly, but still diagnose reasonably.
2025-04-03[clang] NFC: introduce UnsignedOrNone as a replacement for ↵Matheus Izvekov1-1/+1
std::optional<unsigned> (#134142) This introduces a new class 'UnsignedOrNone', which models a lite version of `std::optional<unsigned>`, but has the same size as 'unsigned'. This replaces most uses of `std::optional<unsigned>`, and similar schemes utilizing 'int' and '-1' as sentinel. Besides the smaller size advantage, this is simpler to serialize, as its internal representation is a single unsigned int as well.
2025-04-01[clang] improved preservation of template keyword (#133610)Matheus Izvekov1-2/+0
2025-03-26[Serialization] Avoid iterating Dense{Map,Set} to break determinismChuanqi Xu1-1/+1
in ASTWriter It is bad to iterate Dense{Map,Set} in ASTWriter. Since the order in Dense{Map, Set} is not stable. It may cause the produced BMI differ even if we run the compiler twice without modifying any other thing.
2025-03-21Reland: [clang] preserve class type sugar when taking pointer to member ↵Matheus Izvekov1-1/+1
(#132401) Original PR: #130537 Originally reverted due to revert of dependent commit. Relanding with no changes. This changes the MemberPointerType representation to use a NestedNameSpecifier instead of a Type to represent the base class. Since the qualifiers are always parsed as nested names, there was an impedance mismatch when converting these back and forth into types, and this led to issues in preserving sugar. The nested names are indeed a better match for these, as the differences which a QualType can represent cannot be expressed syntatically, and they represent the use case more exactly, being either dependent or referring to a CXXRecord, unqualified. This patch also makes the MemberPointerType able to represent sugar for a {up/downcast}cast conversion of the base class, although for now the underlying type is canonical, as preserving the sugar up to that point requires further work. As usual, includes a few drive-by fixes in order to make use of the improvements.
2025-03-21[OpenACC] Finish implementing 'routine' AST/Sema.erichkeane1-0/+7
This is the last item of the OpenACC 3.3 spec. It includes the implicit-name version of 'routine', plus significant refactorings to make the two work together. The implicit name version is represented as an attribute on the function call. This patch also implements the clauses for the implicit-name version, as well as the A.3.4 warning.
2025-03-21[OpenMP 6.0] Parse/Sema support for reduction over private variable with ↵CHANDRA GHALE1-0/+4
reduction clause. (#129938) Initial Parse/Sema support for reduction over private variable with reduction clause. Section 7.6.10 in in OpenMP 6.0 spec. - list item in a reduction clause can now be private in the enclosing context. - Added support for _original-sharing-modifier_ with reduction clause. --------- Co-authored-by: Chandra Ghale <ghale@pe31.hpc.amslabs.hpecorp.net>
2025-03-20Revert "Reland: [clang] preserve class type sugar when taking pointer to ↵Matheus Izvekov1-1/+1
member" (#132280) Reverts llvm/llvm-project#132234 Needs to be reverted due to dependency. This blocks reverting another PR, see here: https://github.com/llvm/llvm-project/pull/131965#issuecomment-2741619498
2025-03-20Reland: [clang] preserve class type sugar when taking pointer to member ↵Matheus Izvekov1-1/+1
(#132234) Original PR: #130537 Reland after updating lldb too. This changes the MemberPointerType representation to use a NestedNameSpecifier instead of a Type to represent the base class. Since the qualifiers are always parsed as nested names, there was an impedance mismatch when converting these back and forth into types, and this led to issues in preserving sugar. The nested names are indeed a better match for these, as the differences which a QualType can represent cannot be expressed syntatically, and they represent the use case more exactly, being either dependent or referring to a CXXRecord, unqualified. This patch also makes the MemberPointerType able to represent sugar for a {up/downcast}cast conversion of the base class, although for now the underlying type is canonical, as preserving the sugar up to that point requires further work. As usual, includes a few drive-by fixes in order to make use of the improvements.
2025-03-20Revert "[clang] improve class type sugar preservation in pointers to ↵Matheus Izvekov1-1/+1
members" (#132215) Reverts llvm/llvm-project#130537 This missed updating lldb, which we didn't notice due to lack of pre-commit CI.
2025-03-20[clang] improve class type sugar preservation in pointers to members (#130537)Matheus Izvekov1-1/+1
This changes the MemberPointerType representation to use a NestedNameSpecifier instead of a Type to represent the class. Since the qualifiers are always parsed as nested names, there was an impedance mismatch when converting these back and forth into types, and this led to issues in preserving sugar. The nested names are indeed a better match for these, as the differences which a QualType can represent cannot be expressed syntactically, and it also represents the use case more exactly, being either dependent or referring to a CXXRecord, unqualified. This patch also makes the MemberPointerType able to represent sugar for a {up/downcast}cast conversion of the base class, although for now the underlying type is canonical, as preserving the sugar up to that point requires further work. As usual, includes a few drive-by fixes in order to make use of the improvements, and removing some duplications, for example CheckBaseClassAccess is deduplicated from across SemaAccess and SemaCast.
2025-03-14[clang][modules] Introduce new `ModuleCache` interface (#131193)Jan Svoboda1-6/+6
This PR adds new `ModuleCache` interface to Clang's implicitly-built modules machinery. The main motivation for this change is to create a second implementation that uses a more efficient kind of `llvm::AdvisoryLock` during dependency scanning. In addition to the lock abstraction, the `ModuleCache` interface also manages the existing `InMemoryModuleCache` instance. I found that compared to keeping these separate/independent, the code is a bit simpler now, since these are two tightly coupled concepts. I can envision a more efficient implementation of the `InMemoryModuleCache` for the single-process case too, which will be much easier to implement with the current setup. This is not intended to be a functional change.
2025-03-11[clang][modules] NFC: Remove unused function parameterJan Svoboda1-3/+2
2025-03-11[clang] [OpenMP] New OpenMP 6.0 self_maps clause (#129888)Ritanya-B-Bharadwaj1-0/+2
Initial parsing/sema support for self maps in map and requirement clause [Sections 7.9.6 and 10.5.1.6 in OpenMP 6.0 spec]
2025-03-10[OpenACC] Implement 'bind' ast/sema for 'routine' directiveerichkeane1-1/+11
The 'bind' clause allows the renaming of a function during code generation. There are a few rules about when this can/cannot happen, and it takes either a string or identifier (previously mis-implemetned as ID-expression) argument. Note there are additional rules to this in the implicit-function routine case, but that isn't implemented in this patch, as implicit-function routine is not yet implemented either.
2025-03-06[OpenACC] Implement 'nohost' construct AST/Semaerichkeane1-1/+1
'nohost' is only valid on routine, and states that the compiler shouldn't compile this routine for the host. It has no arguments, so no checking is required besides putting it in the AST.
2025-03-06[OpenACC] implement AST/Sema for 'routine' construct with argumenterichkeane1-0/+1
The 'routine' construct has two forms, one which takes the name of a function that it applies to, and another where it implicitly figures it out based on the next declaration. This patch implements the former with the required restrictions on the name and the function-static-variables as specified. What has not been implemented is any clauses for this, any of the A.3.4 warnings, or the other form.
2025-03-03[OpenACC] Implement 'declare' construct AST/Semaerichkeane1-2/+13
The 'declare' construct is the first of two 'declaration' level constructs, so it is legal in any place a declaration is, including as a statement, which this accomplishes by wrapping it in a DeclStmt. All clauses on this have a 'same scope' requirement, which this enforces as declaration context instead, which makes it possible to implement these as a template. The 'link' and 'device_resident' clauses are also added, which have some similar/small restrictions, but are otherwise pretty rote. This patch implements all of the above.
2025-02-26[Clang] Add BuiltinTemplates.td to generate code for builtin templates (#123736)Nikolas Klauser1-5/+3
This makes it significantly easier to add new builtin templates, since you only have to modify two places instead of a dozen or so. The `BuiltinTemplates.td` could also be extended to generate documentation from it in the future.
2025-02-18[Clang][P1061] Consolidate ResolvedUnpexandedPackExpr into ↵Jason Rice1-1/+0
FunctionParmPackExpr (#125394) This merges the functionality of ResolvedUnexpandedPackExpr into FunctionParmPackExpr. I also added a test to show that https://github.com/llvm/llvm-project/issues/125103 should be fixed with this. I put the removal of ResolvedUnexpandedPackExpr in its own commit. Let me know what you think. Fixes #125103
2025-02-16[Serialization] Remove getMacroID (#127413)Kazu Hirata1-8/+0
The last use was removed in: commit ee977933f7df9cef13cc06ac7fa3e4a22b72e41f Author: Richard Smith <richard-llvm@metafoo.co.uk> Date: Fri May 1 21:22:17 2015 +0000
2025-02-06[clang][OpenMP] New OpenMP 6.0 assumption clause, 'no_openmp_constructs' ↵David Pagan1-0/+3
(#125933) Add initial parsing/sema support for new assumption clause so clause can be specified. For now, it's ignored, just like the others. Added support for 'no_openmp_construct' to release notes. Testing - Updated appropriate LIT tests. - Testing: check-all
2025-01-30[Serialization] Migrate away from PointerUnion::dyn_cast (NFC) (#124884) ↵Kazu Hirata1-1/+1
(#125024) Note that PointerUnion::dyn_cast has been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> Literal migration would result in dyn_cast_if_present (see the definition of PointerUnion::dyn_cast), but this patch uses dyn_cast because we expect Subject to be nonnull.
2025-01-29[Clang][P1061] Add stuctured binding packs (#121417)Jason Rice1-0/+1
This is an implementation of P1061 Structure Bindings Introduce a Pack without the ability to use packs outside of templates. There is a couple of ways the AST could have been sliced so let me know what you think. The only part of this change that I am unsure of is the serialization/deserialization stuff. I followed the implementation of other Exprs, but I do not really know how it is tested. Thank you for your time considering this. --------- Co-authored-by: Yanzuo Liu <zwuis@outlook.com>
2025-01-28[clang] Extend diagnose_if to accept more detailed warning information, take ↵Nikolas Klauser1-1/+1
2 (#119712) This is take two of #70976. This iteration of the patch makes sure that custom diagnostics without any warning group don't get promoted by `-Werror` or `-Wfatal-errors`. This implements parts of the extension proposed in https://discourse.llvm.org/t/exposing-the-diagnostic-engine-to-c/73092/7. Specifically, this makes it possible to specify a diagnostic group in an optional third argument.
2025-01-22Revert "[Modules] Delay deserialization of preferred_name attribute at r… ↵Ilya Biryukov1-11/+5
(#122726)" This reverts commit c3ba6f378ef80d750e2278560c6f95a300114412. We are seeing performance regressions of up to 40% on some compilations with this patch, we will investigate and reland after fixing performance issues.
2025-01-22[C++20] [Modules] Make sure vtable are generated for explicit template ↵Chuanqi Xu1-0/+2
instantiation definition (#123871) Close https://github.com/llvm/llvm-project/issues/123719 The reason is, we thought the external explicit template instantiation declaration as the external definition incorrectly.
2025-01-17[C++20] [Modules] Makes sure internal declaration won't be found by other TU ↵Chuanqi Xu1-61/+164
(#123059) Close https://github.com/llvm/llvm-project/issues/61427 And this is also helpful to implement https://github.com/llvm/llvm-project/issues/112294 partially. The implementation strategy mimics https://github.com/llvm/llvm-project/pull/122887. This patch split the internal declarations from the general lookup table so that other TU can't find the internal declarations.
2025-01-17[Modules] Delay deserialization of preferred_name attribute at r… (#122726)Viktoriia Bakalova1-5/+11
…ecord level. This fixes the incorrect diagnostic emitted when compiling the following snippet ``` // string_view.h template<class _CharT> class basic_string_view; typedef basic_string_view<char> string_view; template<class _CharT> class __attribute__((__preferred_name__(string_view))) basic_string_view { public: basic_string_view() { } }; inline basic_string_view<char> foo() { return basic_string_view<char>(); } // A.cppm module; #include "string_view.h" export module A; // Use.cppm module; #include "string_view.h" export module Use; import A; ``` The diagnostic is ``` string_view.h:11:5: error: 'basic_string_view<char>::basic_string_view' from module 'A.<global>' is not present in definition of 'string_view' provided earlier ``` The underlying issue is that deserialization of the `preferred_name` attribute triggers deserialization of `basic_string_view<char>`, which triggers the deserialization of the `preferred_name` attribute again (since it's attached to the `basic_string_view` template). The deserialization logic is implemented in a way that prevents it from going on a loop in a literal sense (it detects early on that it has already seen the `string_view` typedef when trying to start its deserialization for the second time), but leaves the typedef deserialization in an unfinished state. Subsequently, the `string_view` typedef from the deserialized module cannot be merged with the same typedef from `string_view.h`, resulting in the above diagnostic. This PR resolves the problem by delaying the deserialization of the `preferred_name` attribute until the deserialization of the `basic_string_view` template is completed. As a result of deferring, the deserialization of the `preferred_name` attribute doesn't need to go on a loop since the type of the `string_view` typedef is already known when it's deserialized.
2025-01-17[C++20] [Modules] Support module level lookup (#122887) (#123281)Chuanqi Xu1-60/+232
Close https://github.com/llvm/llvm-project/issues/90154 This patch is also an optimization to the lookup process to utilize the information provided by `export` keyword. Previously, in the lookup process, the `export` keyword only takes part in the check part, it doesn't get involved in the lookup process. That said, previously, in a name lookup for 'name', we would load all of declarations with the name 'name' and check if these declarations are valid or not. It works well. But it is inefficient since it may load declarations that may not be wanted. Note that this patch actually did a trick in the lookup process instead of bring module information to DeclarationName or considering module information when deciding if two declarations are the same. So it may not be a surprise to me if there are missing cases. But it is not a regression. It should be already the case. Issue reports are welcomed. In this patch, I tried to split the big lookup table into a lookup table as before and a module local lookup table, which takes a combination of the ID of the DeclContext and hash value of the primary module name as the key. And refactored `DeclContext::lookup()` method to take the module information. So that a lookup in a DeclContext won't load declarations that are local to **other** modules. And also I think it is already beneficial to split the big lookup table since it may reduce the conflicts during lookups in the hash table. BTW, this patch introduced a **regression** for a reachability rule in C++20 but it was false-negative. See 'clang/test/CXX/module/module.interface/p7.cpp' for details. This patch is not expected to introduce any other regressions for non-c++20-modules users since the module local lookup table should be empty for them.
2025-01-16Revert "[C++20] [Modules] Support module level lookup (#122887)"Chuanqi Xu1-213/+60
This reverts commit 7201cae106260aeb3e9bbbb7d5291ff30f05076a.
2025-01-15[clang][Serialization] Add the missing block info (#122976)Steven Wu1-0/+2
HEADER_SEARCH_ENTRY_USAGE and VFS_USAGE were missing from the block info block. Add the missing info so `llvm-bcanalyzer` can read them correctly.
2025-01-15[C++20] [Modules] Support module level lookup (#122887)Chuanqi Xu1-60/+213
Close https://github.com/llvm/llvm-project/issues/90154 This patch is also an optimization to the lookup process to utilize the information provided by `export` keyword. Previously, in the lookup process, the `export` keyword only takes part in the check part, it doesn't get involved in the lookup process. That said, previously, in a name lookup for 'name', we would load all of declarations with the name 'name' and check if these declarations are valid or not. It works well. But it is inefficient since it may load declarations that may not be wanted. Note that this patch actually did a trick in the lookup process instead of bring module information to DeclarationName or considering module information when deciding if two declarations are the same. So it may not be a surprise to me if there are missing cases. But it is not a regression. It should be already the case. Issue reports are welcomed. In this patch, I tried to split the big lookup table into a lookup table as before and a module local lookup table, which takes a combination of the ID of the DeclContext and hash value of the primary module name as the key. And refactored `DeclContext::lookup()` method to take the module information. So that a lookup in a DeclContext won't load declarations that are local to **other** modules. And also I think it is already beneficial to split the big lookup table since it may reduce the conflicts during lookups in the hash table. BTW, this patch introduced a **regression** for a reachability rule in C++20 but it was false-negative. See 'clang/test/CXX/module/module.interface/p7.cpp' for details. This patch is not expected to introduce any other regressions for non-c++20-modules users since the module local lookup table should be empty for them. --- On the API side, this patch unfortunately add a maybe-confusing argument `Module *NamedModule` to `ExternalASTSource::FindExternalVisibleDeclsByName()`. People may think we can get the information from the first argument `const DeclContext *DC`. But sadly there are declarations (e.g., namespace) can appear in multiple different modules as a single declaration. So we have to add additional information to indicate this.
2025-01-13[clang][OpenMP] Add 'align' modifier for 'allocate' clause (#121814)David Pagan1-1/+3
The 'align' modifier is now accepted in the 'allocate' clause. Added LIT tests covering codegen, PCH, template handling, and serialization for 'align' modifier. Added support for align-modifier to release notes. Testing - New allocate modifier LIT tests. - OpenMP LIT tests. - check-all
2025-01-09[OpenACC] Implement 'device' and 'host' clauses for 'update'erichkeane1-2/+12
These two clauses just take a 'var-list' and specify where the variables should be copied from/to. This patch implements the AST nodes for them and ensures they properly take a var-list.
2025-01-08[OpenACC] Enable 'self' sema for 'update' constructerichkeane1-3/+10
The 'self' clause is an unfortunately difficult one, as it has a significantly different meaning between 'update' and the other constructs. This patch introduces a way for the 'self' clause to work as both. I considered making this two separate AST nodes (one for 'self' on 'update' and one for the others), however this makes the automated macros/etc for supporting a clause break. Instead, 'self' has the ability to act as either a condition or as a var-list clause. As this is the only one of its kind, it is implemented all within it. If in the future we have more that work like this, we should consider rewriting a lot of the macros that we use to make clauses work, and make them separate ast nodes.
2025-01-06[OpenACC] Implement 'default_async' semaerichkeane1-1/+6
A fairly simple one, only valid on the 'set' construct, this clause takes an int expression. Most of the work was already done as a part of parsing, so this patch ends up being a lot of infrastructure.
2025-01-06[clang] Do not serialize function definitions without a body (#121550)Alejandro Álvarez Ayllón1-0/+8
An instantiated templated function definition may not have a body due to parsing errors inside the templated function. When serializing, an assert is triggered inside `ASTRecordWriter::AddFunctionDefinition`. The instantiation may happen on an intermediate module. The test case was reduced from `mp-units`.
2024-12-19[OpenACC] Implement 'device_num' clause sema for 'init'/'shutdown'erichkeane1-1/+6
This is a very simple sema implementation, and just required AST node plus the existing diagnostics. This patch adds tests and adds the AST node required, plus enables it for 'init' and 'shutdown' (only!)
2024-12-16[OpenACC] Implement 'use_device' clause AST/Semaerichkeane1-1/+6
This is a clause that is only valid on 'host_data' constructs, and identifies variables which it should use the current device address. From a Sema perspective, the only thing novel here is mild changes to how ActOnVar works for this clause, else this is very much like the rest of the 'var-list' clauses.