aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema
AgeCommit message (Collapse)AuthorFilesLines
9 hours[clang][libc++] Fix spelling of "synthesize" (#158523)halbi21-8/+8
There is a tradition to use U.S. English spellings for APIs. For example, it's uninitialized_fill and not uninitialised_fill, specialization not specialisation, etcetera.
11 hours[clang][Diags] Automatically format AP(S)Int values with separators (#161047)Timm Baeder1-2/+1
This adds an `operator<<` overload for `StreamingDiagnostic` that takes an `APInt`/`APSInt` and formats it with default options, including adding separators. This is still an opt-in mechanism since all callers that want to use this feature need to be changed from ```c++ Diag() << toString(MyInt, 10); ``` to ```c++ Diag() << MyInt; ``` This patch contains one example of a diagnostic making use of this.
13 hours[CUDA] Enable variadic argument support in front-end (#161305)Luo, Yuanke1-3/+2
Variadice argument for NVPTX as been support in https://github.com/llvm/llvm-project/commit/486d00eca6b6ab470e8324b52cdf9f32023c1c9a We can enable it in front-end. Co-authored-by: Yuanke Luo <ykluo@birentech.com>
20 hours[Clang] Instantiate variables referenced in `decltype` with an undeduced ↵Corentin Jabot1-2/+3
type. (#161231) Fixes #160497 Fixes #56652 Fixes #116319 Fixes #161196
22 hours[clang][OpenMP] Support for reduction clause with array elements as modifier ↵SunilKuravinakop1-1/+2
(#160846) Changes to support for array elements in reduction clause e.g. "reduction (+:a[1])" --------- Co-authored-by: Sunil Kuravinakop <kuravina@pe31.hpc.amslabs.hpecorp.net>
24 hours[clang][NFC] Remove const_casts from diagnostic emissions (#161211)Timm Baeder3-10/+6
This is apparently not necessary anymore. Not sure when exactly it changed though.
26 hours[Clang] Fixes __builtin_is_implicit_lifetime for types with deleted ctrs ↵Corentin Jabot1-7/+10
(#161163) We failed to check that the trivial constructor where eligible (this implies non deleted). Fixes #160610
33 hours[clang] fix code synthesis context depth limit logic (#161103)Matheus Izvekov1-45/+43
This makes the instantation depth limit be checked whenever the code synthesis context is pushed, not only when creating a InstantiatingTemplate RAII object. Also fix the note suggesting the user increases `-ftemplate-depth` so it is printed even in a SFINAE context.
33 hours[clang] treat deduced-as-dependent as undeduced for constant template ↵Matheus Izvekov1-1/+1
parameters (#161099) The AutoType's deduced-as-dependent mechanism is not really used for constant template parameters, but this is currently harmless to ignore because when dealing which such types, they will have been transformed, turning them back to plain undeduced AutoTypes. This should be NFC for current main users, but https://github.com/llvm/llvm-project/pull/141776 will depend on this.
34 hours[Clang][OpenMP][LoopTransformations] Implement "#pragma omp fuse" loop ↵Walter J.T.V3-28/+847
transformation directive and "looprange" clause (#139293) This change implements the fuse directive, `#pragma omp fuse`, as specified in the OpenMP 6.0, along with the `looprange` clause in clang. This change also adds minimal stubs so flang keeps compiling (a full implementation in flang of this directive is still pending). --------- Co-authored-by: Roger Ferrer Ibanez <roger.ferrer@bsc.es>
3 days[clang] fix transformation of subst constant template parameter nodes (#161029)Matheus Izvekov4-209/+123
This simplifies those transforms a lot, removing a bunch of workarounds which were introducing problems. The transforms become independent of the template instantiator, so they are moved to TreeTransform instead. Fixes #131342 This PR was already reviewed and approved at https://github.com/llvm/llvm-project/pull/160777, but I accidentally merged that into another PR, instead of main.
3 days[clang] simplify placeholder type deduction for constant template parameters ↵Matheus Izvekov2-55/+44
(#160439) This makes the deduction for dependent types operate in more similar ways to the non-dependent one, such as when matching template template parameters, making errors in those generate similar diagnostics to the non-dependent ones. This also removes some superfluous implicit casts, simplifying the resulting AST a little bit.
5 days[Clang][FIX] Fix type qualifiers on vector builtins (#160185)Joseph Huber1-16/+74
Summary: These were not stripping qualifiers when using them to infer the types, leading to errors when mixiing const and non-const.
5 days[LifetimeSafety] Implement support for lifetimebound attribute (#158489)Utkarsh Saxena3-72/+14
Add support for `lifetimebound` attributes in the lifetime safety analysis to track loans from function parameters to return values. Implemented support for `lifetimebound` attributes on function parameters This change replaces the single `AssignOriginFact` with two separate operations: `OriginFlowFact` and `KillOriginFact`. The key difference is in semantics: * Old `AssignOriginFact`: Replaced the destination origin's loans entirely with the source origin's loans. * New `OriginFlowFact`: Can now optionally merge the source origin's loans to the destination's existing loans. * New `KillOriginFact`: Clears all loans from an origin. For function calls with `lifetimebound` parameters, we kill the the return value' origin first then use `OriginFlowFact` to accumulate loans from multiple parameters into the return value's origin - enabling tracking multiple lifetimebound arguments. - Added a new `LifetimeAnnotations.h/cpp` to provide helper functions for inspecting and inferring lifetime annotations - Moved several functions from `CheckExprLifetime.cpp` to the new file to make them reusable The `lifetimebound` attribute is a key mechanism for expressing lifetime dependencies between function parameters and return values. This change enables the lifetime safety analysis to properly track these dependencies, allowing it to detect more potential dangling reference issues.
5 days[clang] simplify constant template parameter type deduction for partial ↵Matheus Izvekov1-22/+5
ordering (#160433) This simplifies things a little bit. This is mostly NFCish, except the reference type deduction workaround now applies in partial ordering as well, but we don't have any test cases and any reason to suspect this is significant.
5 daysImplements isnan() HLSL intrinsic for DXIL and SPIR-V targets. (#157733)Dan Brown1-1/+2
Addresses #99132.
5 days[clang][Sema] Accept gnu format attributes (#160255)Xing Guo2-13/+11
This patch teaches clang accepts gnu_printf, gnu_scanf, gnu_strftime and gnu_strfmon. These attributes are aliases for printf, scanf, strftime and strfmon. Ref: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html Fixes: #16219 --------- Co-authored-by: Sirraide <aeternalmail@gmail.com>
5 days[Clang][AMDGPU] Defer amdgcn.*to_lds builtins size diagnostics (#160140)Juan Manuel Martinez Caamaño1-2/+4
Before, the diagnostic was emitted immediately, as soon as the error was detected. This is problematic during the host compilation, since the compiler performs semantic analysis of `__device__` functions with the host's target attributes. A solution for this is to use `SemaRef.targetDiag` to defer the diagnostic. The diagnostic will then be printed only if the function is emitted. The test included in this patch highlights a second problem: we cannot compile a file having a call to `__builtin_amdgcn_load_to_lds` on a `__device__` function since we typecheck the signature. The issue is that, `__shared__ void*` on X86 doesn't translate to `addrspace(3) void*`, so the compilation fails. Fixes: SWDEV-555501
6 days[Clang] Constexpr Structured Bindings : The easy parts (#160337)Corentin Jabot1-50/+36
This implements the easy parts of P2686R5. Ie allowing constexpr structured binding of structs and arrays. References to constexpr variables / support for tuple is left for a future PR. Until we implement the whole thing, the feature is not enabled as an extension in older language modes. Trying to use it as a tuple does produce errors but not meaningful ones. We could add a better diagnostic if we fail to complete the implementation before the end of the clang 22 cycle.
6 days[Clang] Change masked load / store builtin interface to take scalar pointer ↵Joseph Huber1-29/+13
(#156063) Summary: Right now these enformce alignment, which isn't convenient for the user on platforms that support unaligned accesses. The options are to either permit passing the alignment manually, or just assume it's unaligned unless the user specifies it. I've added https://github.com/llvm/llvm-project/pull/156057 which should make the requiested alignment show up on the intrinsic if the user passed `__builtin_assume_aligned`, however that's only with optimizations. This shouldn't cause issues unless the backend categorically decides to reject an unaligned access.
6 days[Clang] [Sema] Fix -Wdouble-promotion in C++ list-initialization (#159992)Marcel Jacobse1-1/+13
Resolves https://github.com/llvm/llvm-project/issues/33409. The information `IsListInit` is already passed to function `CheckImplicitConversion` for another use-case which makes adding a condition for the double-promotion case simple. Also adds tests, both for the changed list-initialization case as well as for normal explicit casts which already would have passed before this PR. These negative tests are added directly next to the positive tests in `warn-double-promotion.c` or for the C++-specific cases in a new .cpp version of that file.
6 days[CIR][OpenACC] Implement pointer/array recipe destructors (#160189)Erich Keane1-4/+15
After previous implementation, I discovered that we were both doing arrays incorrectly for recipes, plus didn't get the pointer allocations done correctly. This patch is the first of a few in a series that attempts to make sure we get all pointers/arrays correct. This patch is limited to just 'private' and destructors, which simplifies the review significantly. Destructors are simply looped through and called at each level. The 'recipe-decl' is the 'least bounded' (that is, the type of the expression, in the type of `int[5] i; #pragma acc parallel private(i[1])`, the type of the `recipe-decl` is `int`. This allows us to do init/destruction at the element level. This patch also adds infrastructure for the rest of the series of private (for the init section), as well as extensive testing for 'private', with a lot of 'TODO' locations. Future patches will fill these in, but at the moment, there is an NYI warning for bounds, so a number of tests are updated to handle that.
6 days[Clang] Add diagnostic for why std::is_abstract is false (#156199)Sebastian Proell1-0/+73
Explain why a type is not abstract. Handles arrays, refs, unions, pointers, and functions. If the non-abstract type has abstract base classes, point out that their pure virtual methods must have been overridden. Adds onto #141911
7 days[HLSL][NFC] Builtin type declaration builder cleanup (#160375)Helena Kotas1-18/+6
Replace early exit from builder methods with assert - they should be not called on a completed record. Also removes commented-out code.
7 days[HLSL] Enable InitList code to handle zero sized structs (#160355)Sarah Spall1-0/+3
Enable InitList code to handle zero sized structs; this includes structs with no fields and those with only unnamed bitfields. Closes #157920
7 days[os_log] Fix a CodeGen crash that occurs when arguments of struct, class, or ↵Akira Hatanaka1-5/+18
complex types are passed to _builtin_os_log_format (#158744) This change fixes the crash in clang's CodeGen by erroring out in Sema if those arguments are passed. rdar://139824423
7 days[HLSL] Add support for the HLSL matrix type (#159446)Farzon Lotfi2-1/+102
fixes #109839 This change is really simple. It creates a matrix alias that will let HLSL use the existing clang `matrix_type` infra. The only additional change was to add explict alias for the typed dimensions of 1-4 inclusive matricies available in HLSL. Testing therefore is limited to exercising the alias, sema errors, and basic codegen. future work will add things like constructors and accessors. The main difference in this attempt is the type printer and less of an emphasis on tests where things overlap with existing `matrix_type` testing like cast behavior.
7 days[HLSL] avoid unnamed bit fields when dealing with InitLists in HLSL (#159212)Sarah Spall1-2/+6
In HLSL Init List code avoid initializing unnamed bitfields and avoid initializing using unnamed bit fields. Add tests. Closes #157922
7 days[clang] Format "array is too large" diagnostics with separators (#160260)Timm Baeder3-3/+11
We only display this diagnostic with large numbers, so add the separators. Not sure if `295'147'905'179'352'825'841` is much better than `295147905179352825841` but I think it would be nice to have separators in more diagnostics.
7 days[Sema][AArch64] Emit error for mismatched VLs on streaming mode transitions ↵Mary Kassayova1-4/+24
(#159131) Update Sema::checkCall to handle the case where a call involves a streaming mode transition and passes or returns scalable vector types. Previously, Clang always issued a warning in this case, noting that the streaming and non-streaming vector lengths may differ at runtime. With this change: - if both `-msve-vector-bits` and `-msve-streaming-vector-bits` are specified and produce different fixed VL values, Clang now emits an error rather than a warning - If either flag is missing or vector lengths are equal, the diagnostic remains a warning
8 days[SemaHLSL] Correct descriptor range overflow validation (#159475)Finn Plummer1-16/+13
This pr corrects the validation behaviour to allow valid root signatures of the form: `DescriptorTable(CBV(b0, offset = 4294967294), CBV(b1))` which will append a range onto the location of `UINT_MAX`, which is valid. Resolves: https://github.com/llvm/llvm-project/issues/159478.
8 days[NFC][Clang] Fix typo memody->memory (#160141)Juan Manuel Martinez Caamaño1-1/+1
Fix typo memody->memory
8 days[Clang] Add vector gather / scatter builtins to clang (#157895)Joseph Huber1-3/+104
Summary: This patch exposes `__builtin_masked_gather` and `__builtin_masked_scatter` to clang. These map to the underlying intrinsic relatively cleanly, needing only a level of indirection to take a vector of indices and a base pointer to a vector of pointers.
9 days[clang] fix using enum redecl in template regression (#159996)Matheus Izvekov1-2/+3
This fixes a regression reported here: https://github.com/llvm/llvm-project/pull/155313#issuecomment-3315883183 Since this regression was never released, there are no release notes.
9 days[Clang] Fix an error-recovery crash after d1a80dea (#159976)Younan Zhang1-0/+2
d1a80dea tried to ensure a TypeSourceInfo for a destructor name. However, we don't actually have one during error recovery, so we should bail in that case. No release note, since it's a regression and a backport could improve the stability of clangd. Fixes https://github.com/llvm/llvm-project/issues/159630
11 days[modules] Fix assert on Clang module import from the global module fragment. ↵Naveen Seth Hanig1-1/+6
(#159771) Fixes #159768. When building a named module interface with `-fmodules` enabled, importing a Clang module from inside the global module fragment causes Clang to crash only on assertion builds. This fixes the assert and extends the test coverage.
11 days[clang] diagnose invalid std::tuple_size sizes (#159677)Matheus Izvekov1-6/+19
This makes sure the tuple sizes remain within implementation limits, and this doesn't cause the compiler to crash later, as the tuple size is assumed to fit within an UnsignedOrNone. Fixes #159563
11 days[Clang] Rename elementwise builtins to `clzg` and `ctzg` (#157128)Joseph Huber1-2/+2
Summary: The added bit counting builtins for vectors used `cttz` and `ctlz`, which is consistent with the LLVM naming convention. However, these are clang builtins and implement exactly the `__builtin_ctzg` and `__builtin_clzg` behavior. It is confusing to people familiar with other other builtins that these are the only bit counting intrinsics named differently. This includes the additional operation for the undefined zero case, which was added as a `clzg` extension.
11 days[Clang][NFC] Remove duplicated specialization of ↵Corentin Jabot1-27/+0
`llvm::DenseMapInfo<llvm::FoldingSetNodeID>` (#159718) In preparation of #141776
12 days[HLSL] Make sure global resources and resource arrays cannot be assigned to ↵Helena Kotas2-0/+34
(#157772) Global resources are read-only. The compiler needs to report an error when somebody attempts to assign a value to a global resource, a global resource array element or the whole array. Test update in `static-local-ctor.hlsl` includes the use of the llvm-cxxfilt tool which takes care of demangling of function names for a more readable test baseline. Closes #154390
12 days[clang] check constant template parameters in dependent contexts (#159463)Matheus Izvekov1-3/+2
This patch makes sure constant template parameters are checked even in dependent contexts. This can for example diagnose narrowings earlier, but this is permitted as these templates would have no valid instantiations.
12 days[clang] [OpenMP] New OpenMP 6.0 - Parsing and Sema support for groupprivate ↵Ritanya-B-Bharadwaj2-15/+133
(#158134)
12 days[OpenMP 5.2] New syntax for 'uses_allocators' clause (#157025)Urvi Rav1-4/+6
This patch updates the parsing changes to handle the new syntax of the `uses_allocators` clause as defined in OpenMP 5.2(Section 6.8). ``` // Case 1: Allocator without traits // < 5.2 → error // ≥ 5.2 → OK, empty traits set #pragma omp target teams uses_allocators(cgroup_alloc) // Case 2: Allocator with traits // Old syntax (< 5.2): #pragma omp target teams uses_allocators(cgroup_alloc(cgroup_traits)) // New syntax (≥ 5.2): #pragma omp target teams uses_allocators(traits(cgroup_traits) : cgroup_alloc) // Case 3: Multiple allocators // Old syntax (< 5.2), comma-separated: #pragma omp target teams uses_allocators(cgroup_alloc(cgroup_traits), aligned_alloc(aligned_traits)) // New syntax (≥ 5.2), semicolon-separated: #pragma omp target teams uses_allocators(traits(cgroup_traits) : cgroup_alloc; traits(aligned_traits) : aligned_alloc) ``` --------- Co-authored-by: urvi-rav <urvi.rav@hpe.com>
13 days[clang][HeuristicResolver] Default argument heuristic for template template ↵Nathan Ridge1-0/+19
parameters (#156404) Fixes https://github.com/clangd/clangd/issues/2478
13 days[clang] Avoid warnings about enum mismatch in ternary expressions. NFC. ↵Martin Storsjö2-8/+10
(#159338) This avoids the following kind of warning when built with GCC: ../../clang/lib/Sema/SemaStmtAttr.cpp: In function ‘clang::Attr* ProcessStmtAttribute(clang::Sema&, clang::Stmt*, const clang::ParsedAttr&, clang::SourceRange)’: ../../clang/lib/Sema/SemaStmtAttr.cpp:677:30: warning: enumerated mismatch in conditional expression: ‘clang::diag::<unnamed enum>’ vs ‘clang::diag::<unnamed enum>’ [-Wenum-compare] 676 | S.Diag(A.getLoc(), A.isRegularKeywordAttribute() | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 677 | ? diag::err_keyword_not_supported_on_targe | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 678 | : diag::warn_unhandled_ms_attribute_ignore ) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ These enums are non-overlapping, but due they are defined in different enum scopes due to how they are generated with tablegen.
13 days[HLSL] Remove resource constructors with binding (#157008)Helena Kotas3-48/+1
Removes resource constructors that take binding information per proposal update https://github.com/llvm/wg-hlsl/pull/336. The constructors are replaced by static `__createFromBinding` and `__createFromImplicitBinding` methods on the resource class.
13 days[clang] Do not diagnose conflicting types for cfi_unchecked_callee (#157762)PiJoules1-0/+17
Clang would complain about conflicting types between a function declaration and definition if the declaraion was marked with the attribute but the definition wasn't. Do not treat this as an error. It should only be necessary to mark the declaration with the attribute.
13 daysFix crash in 'malloc' referring to function without a argument (#159371)Erich Keane1-1/+5
As reported in #159080, patch #68059 didn't correctly check for the argument count of the target function from malloc to ensure it has an argument. This patch corrects that check. Fixes: #159080 --------- Co-authored-by: Sergei Barannikov <barannikov88@gmail.com>
13 days[Clang] Fix an incorrect assertion in `Sema::CheckAddressOfOperand` (#159314)Corentin Jabot1-2/+3
Not all non-type template arguments are modeled as NonTypeTemplateParmDecl. Fixes #151531
13 days[win][clang] Align scalar deleting destructors with MSABI (#139566)Mariya Podchishchaeva2-10/+29
While working on vector deleting destructors support ([GH19772](https://github.com/llvm/llvm-project/issues/19772)), I noticed that MSVC produces different code in scalar deleting destructor body depending on whether class defined its own operator delete. In MSABI deleting destructors accept an additional implicit flag parameter allowing some sort of flexibility. The mismatch I noticed is that whenever a global operator delete is called, i.e. `::delete`, in the code produced by MSVC the implicit flag argument has a value that makes the 3rd bit set, i.e. "5" for scalar deleting destructors "7" for vector deleting destructors. Prior to this patch, clang handled `::delete` via calling global operator delete direct after the destructor call and not calling class operator delete in scalar deleting destructor body by passing "0" as implicit flag argument value. This is fine until there is an attempt to link binaries compiled with clang with binaries compiled with MSVC. The problem is that in binaries produced by MSVC the callsite of the destructor won't call global operator delete because it is assumed that the destructor will do that and a destructor body generated by clang will never do. This patch removes call to global operator delete from the callsite and add additional check of the 3rd bit of the implicit parameter inside of scalar deleting destructor body. --------- Co-authored-by: Tom Honermann <tom@honermann.net>