aboutsummaryrefslogtreecommitdiff
path: root/clang/test
AgeCommit message (Collapse)AuthorFilesLines
105 min.[clang][HLSL] Add sign intrinsic part 3 (#101989)Tim Gymnich2-0/+173
partially fixes #70078 ### Changes - Implemented `sign` clang builtin - Linked `sign` clang builtin with `hlsl_intrinsics.h` - Added sema checks for `sign` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp` - Add codegen for `sign` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp` - Add codegen tests to `clang/test/CodeGenHLSL/builtins/sign.hlsl` - Add sema tests to `clang/test/SemaHLSL/BuiltIns/sign-errors.hlsl` ### Related PRs - https://github.com/llvm/llvm-project/pull/101987 - https://github.com/llvm/llvm-project/pull/101988 ### Discussion - Should there be a `usign` intrinsic that handles the unsigned cases?
3 hours[clang] fix half && bfloat16 convert node expr codegen (#89051)JinjinLi8681-0/+25
Data type conversion between fp16 and bf16 will generate fptrunc and fpextend nodes, but they are actually bitcast nodes.
9 hoursReland [asan][windows] Eliminate the static asan runtime on windows (#107899)Charlie Barto1-6/+4
This reapplies 8fa66c6ca7272268747835a0e86805307b62399c ([asan][windows] Eliminate the static asan runtime on windows) for a second time. That PR bounced off the tests because it caused failures in the other sanitizer runtimes, these have been fixed by only building interception, sanitizer_common, and asan with /MD, and continuing to build the rest of the runtimes with /MT. This does mean that any usage of the static ubsan/fuzzer/etc runtimes will mean you're mixing different runtime library linkages in the same app, the interception, sanitizer_common, and asan runtimes are designed for this, however it does result in some linker warnings. Additionally, it turns out when building in release-mode with LLVM_ENABLE_PDBs the build system forced /OPT:ICF. This totally breaks asan's "new" method of doing "weak" functions on windows, and so /OPT:NOICF was explicitly added to asan's link flags. --------- Co-authored-by: Amy Wishnousky <amyw@microsoft.com>
10 hours[z/OS] Set the default arch for z/OS to be arch10 (#89854)Sean Perry1-0/+16
The default arch level on z/OS is arch10. Update the code so z/OS has arch10 without changing the default for zLinux.
10 hoursRevert "[Clang][Sema] Use the correct lookup context when building ↵Nikita Popov1-13/+11
overloaded 'operator->' in the current instantiation (#104458)" This reverts commit 3cdb30ebbc18fa894d3bd67aebcff76ce7c741ac. Breaks clang bootstrap.
11 hours[CUDA/HIP] propagate -cuid to a host-only compilation. (#107483)Artem Belevich1-0/+40
Right now we're bailing out too early, and `-cuid` does not get set for the host-only compilations.
11 hours[HLSL] Implement support for HLSL intrinsic - select (#107129)Sarah Spall2-0/+173
Implement support for HLSL intrinsic select. This would close issue #75377
12 hoursFix implicit conversion rank ordering (#106811)Chris B1-15/+13
DXC prefers dimension-preserving conversions over precision-losing conversions. This means a double4 -> float4 conversion is preferred over a double4 -> double3 or double4 -> double conversion.
13 hours[analyzer] fix crash on binding to symbolic region with `void *` type (#107572)Pavel Skripkin1-0/+12
As reported in https://github.com/llvm/llvm-project/pull/103714#issuecomment-2295769193. CSA crashes on trying to bind value to symbolic region with `void *`. This happens when such region gets passed as inline asm input and engine tries to bind `UnknownVal` to that region. Fix it by changing type from void to char before calling `GetElementZeroRegion`
13 hours[Clang][Sema] Use the correct lookup context when building overloaded ↵Krystian Stasiowski1-11/+13
'operator->' in the current instantiation (#104458) Currently, clang erroneously rejects the following: ``` struct A { template<typename T> void f(); }; template<typename T> struct B { void g() { (*this)->template f<int>(); // error: no member named 'f' in 'B<T>' } A* operator->(); }; ``` This happens because `Sema::ActOnStartCXXMemberReference` does not adjust the `ObjectType` parameter when `ObjectType` is a dependent type (except when the type is a `PointerType` and the class member access is the `->` form). Since the (possibly adjusted) `ObjectType` parameter (`B<T>` in the above example) is passed to `Parser::ParseOptionalCXXScopeSpecifier`, we end up looking up `f` in `B` rather than `A`. This patch fixes the issue by identifying cases where the type of the object expression `T` is a dependent, non-pointer type and: - `T` is the current instantiation and lookup for `operator->` finds a member of the current instantiation, or - `T` has at least one dependent base case, and `operator->` is not found in the current instantiation and using `ASTContext::DependentTy` as the type of the object expression when the optional _nested-name-specifier_ is parsed. Fixes #104268.
14 hoursFix codegen for transparent_union function params (#104816)Lei Huang2-67/+108
Update codegen for func param with transparent_union attr to be that of the first union member. This is a followup to #101738 to fix non-ppc codegen and closes #76773.
17 hours[AArch64] Implement NEON vamin/vamax intrinsics (#99041)Momchil Velikov3-0/+176
This patch implements the intrinsics of the form floatNxM_t vamin[q]_fN(floatNxM_t vn, floatNxM_t vm); floatNxM_t vamax[q]_fN(floatNxM_t vn, floatNxM_t vm); as defined in https://github.com/ARM-software/acle/pull/324 --------- Co-authored-by: Hassnaa Hamdi <hassnaa.hamdi@arm.com>
17 hoursRevert "Reapply "[Clang][CWG1815] Support lifetime extension of temporary ↵Martin Storsjö9-175/+21
created by aggregate initialization using a default member initializer" (#97308)" This reverts commit 45c8766973bb3bb73dd8d996231e114dcf45df9f and 049512e39d96995cb373a76cf2d009a86eaf3aab. This change triggers failed asserts on inputs like this: struct a { } constexpr b; class c { public: c(a); }; class B { public: using d = int; struct e { enum { f } g; int h; c i; d j{}; }; }; B::e k{B::e::f, int(), b}; Compiled like this: clang -target x86_64-linux-gnu -c repro.cpp clang: ../../clang/lib/CodeGen/CGExpr.cpp:3105: clang::CodeGen::LValue clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(const clang::DeclRefExpr*): Assertion `(ND->isUsed(false) || !isa<VarDecl>(ND) || E->isNonOdrUse() || !E->getLocation().isValid()) && "Should not use decl without marking it used!"' failed.
18 hours[clang][analyzer] Fix #embed crash (#107764)Nicolas van Kempen1-0/+12
Fix #107724.
18 hours[NFC][clang] Fix clang version in the test for the implementation of cwg1815 ↵yronglin1-1/+1
(#107838) This PR fix the clang version in https://github.com/llvm/llvm-project/pull/97308 . Signed-off-by: yronglin <yronglin777@gmail.com>
21 hours[analyzer] Remove overzealous "No dispatcher registered" assertion (#107294)vabridgers1-0/+13
Random testing revealed it's possible to crash the analyzer with the command line invocation: clang -cc1 -analyze -analyzer-checker=nullability empty.c where the source file, empty.c is an empty source file. ``` clang: <root>/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:56: void clang::ento::CheckerManager::finishedCheckerRegistration(): Assertion `Event.second.HasDispatcher && "No dispatcher registered for an event"' failed. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ Stack dump: 0. Program arguments: clang -cc1 -analyze -analyzer-checker=nullability nullability-nocrash.c #0 ... ... #7 <addr> clang::ento::CheckerManager::finishedCheckerRegistration() #8 <addr> clang::ento::CheckerManager::CheckerManager(clang::ASTContext&, clang::AnalyzerOptions&, clang::Preprocessor const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::ArrayRef<std::function<void (clang::ento::CheckerRegistry&)>>) ``` This commit removes the assertion which failed here, because it was logically incorrect: it required that if an Event is handled by some (enabled) checker, then there must be an **enabled** checker which can emit that kind of Event. It should be OK to disable the event-producing checkers but enable an event-consuming checker which has different responsibilities in addition to handling the events. Note that this assertion was in an `#ifndef NDEBUG` block, so this change does not impact the non-debug builds. Co-authored-by: Vince Bridgers <vince.a.bridgers@ericsson.com>
22 hours[Clang] Don't assert non-empty packs for FunctionParmPackExprs (#107561)Younan Zhang2-13/+26
`FunctionParmPackExpr`s are peculiar in that they have to be of unexpanded dependency while they don't introduce any unexpanded packs. So this patch rules them out in the non-empty pack assertion in `DiagnoseUnexpandedParameterPack()`. There was a fix #69224, but that turned out to be insufficient. I also moved the separate tests to a pre-existing file. Fixes https://github.com/llvm/llvm-project/issues/86361
22 hours[Clang][RISCV] Recognize unsupport target feature by supporting ↵Piyou Chen1-0/+12
isValidFeatureName (#106495) This patch makes unsupported target attributes emit a warning and ignore the target attribute during semantic checks. The changes include: 1. Adding the RISCVTargetInfo::isValidFeatureName function. 2. Rejecting non-full-arch strings in the handleFullArchString function. 3. Adding test cases to demonstrate the warning behavior.
23 hours[Clang] C++20 Coroutines: Introduce Frontend Attribute ↵Yuxuan Chen3-0/+101
[[clang::coro_await_elidable]] (#99282) This patch is the frontend implementation of the coroutine elide improvement project detailed in this discourse post: https://discourse.llvm.org/t/language-extension-for-better-more-deterministic-halo-for-c-coroutines/80044 This patch proposes a C++ struct/class attribute `[[clang::coro_await_elidable]]`. This notion of await elidable task gives developers and library authors a certainty that coroutine heap elision happens in a predictable way. Originally, after we lower a coroutine to LLVM IR, CoroElide is responsible for analysis of whether an elision can happen. Take this as an example: ``` Task foo(); Task bar() { co_await foo(); } ``` For CoroElide to happen, the ramp function of `foo` must be inlined into `bar`. This inlining happens after `foo` has been split but `bar` is usually still a presplit coroutine. If `foo` is indeed a coroutine, the inlined `coro.id` intrinsics of `foo` is visible within `bar`. CoroElide then runs an analysis to figure out whether the SSA value of `coro.begin()` of `foo` gets destroyed before `bar` terminates. `Task` types are rarely simple enough for the destroy logic of the task to reference the SSA value from `coro.begin()` directly. Hence, the pass is very ineffective for even the most trivial C++ Task types. Improving CoroElide by implementing more powerful analyses is possible, however it doesn't give us the predictability when we expect elision to happen. The approach we want to take with this language extension generally originates from the philosophy that library implementations of `Task` types has the control over the structured concurrency guarantees we demand for elision to happen. That is, the lifetime for the callee's frame is shorter to that of the caller. The ``[[clang::coro_await_elidable]]`` is a class attribute which can be applied to a coroutine return type. When a coroutine function that returns such a type calls another coroutine function, the compiler performs heap allocation elision when the following conditions are all met: - callee coroutine function returns a type that is annotated with ``[[clang::coro_await_elidable]]``. - In caller coroutine, the return value of the callee is a prvalue that is immediately `co_await`ed. From the C++ perspective, it makes sense because we can ensure the lifetime of elided callee cannot exceed that of the caller if we can guarantee that the caller coroutine is never destroyed earlier than the callee coroutine. This is not generally true for any C++ programs. However, the library that implements `Task` types and executors may provide this guarantee to the compiler, providing the user with certainty that HALO will work on their programs. After this patch, when compiling coroutines that return a type with such attribute, the frontend checks that the type of the operand of `co_await` expressions (not `operator co_await`). If it's also attributed with `[[clang::coro_await_elidable]]`, the FE emits metadata on the call or invoke instruction as a hint for a later middle end pass to elide the elision. The original patch version is https://github.com/llvm/llvm-project/pull/94693 and as suggested, the patch is split into frontend and middle end solutions into stacked PRs. The middle end CoroSplit patch can be found at https://github.com/llvm/llvm-project/pull/99283 The middle end transformation that performs the elide can be found at https://github.com/llvm/llvm-project/pull/99285
26 hours[C++20] [Modules] Treat constexpr/consteval member function as implicitly inlineChuanqi Xu1-0/+12
Close https://github.com/llvm/llvm-project/issues/107673
36 hours[clang][bytecode] Fix a variable scope problem with continue/break jumps ↵Timm Baeder1-13/+19
(#107738) Cleaning up _all_ the scopes is a little too much. Only clean up until the point here we started the scope relevant for the break/continue statement.
39 hoursReapply "[Clang][CWG1815] Support lifetime extension of temporary created by ↵yronglin9-21/+175
aggregate initialization using a default member initializer" (#97308) The PR reapply https://github.com/llvm/llvm-project/pull/92527. Implemented CWG1815 and fixed the bugs mentioned in the comments of https://github.com/llvm/llvm-project/pull/92527 and https://github.com/llvm/llvm-project/pull/87933. The reason why the original PR was reverted was that errors might occur during the rebuild. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
47 hours[clang][bytecode] Implement logical operators for vector type (#107678)yronglin1-0/+90
Implement `&&`, `||` logical operators for vector type. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2 days[clang] Implement CWG2398 provisional TTP matching to class templates (#94981)Matheus Izvekov1-7/+43
This extends default argument deduction to cover class templates as well, applying only to partial ordering, adding to the provisional wording introduced in https://github.com/llvm/llvm-project/pull/89807. This solves some ambuguity introduced in P0522 regarding how template template parameters are partially ordered, and should reduce the negative impact of enabling `-frelaxed-template-template-args` by default. Given the following example: ```C++ template <class T1, class T2 = float> struct A; template <class T3> struct B; template <template <class T4> class TT1, class T5> struct B<TT1<T5>>; // #1 template <class T6, class T7> struct B<A<T6, T7>>; // #2 template struct B<A<int>>; ``` Prior to P0522, `#2` was picked. Afterwards, this became ambiguous. This patch restores the pre-P0522 behavior, `#2` is picked again.
3 days[clang][bytecode] Fix two-pointer-style std::initializer_lists (#107682)Timm Baeder1-0/+55
The first pointer needs to point to the first element of the underlying array. This requires some changes to how we handle array expansion
3 days[clang][bytecode] Implement using operator new/operator delete (#107679)Timm Baeder1-0/+14
Reuse the __builtin_operator_{new,delete} implementations.
3 days[clang][bytecode] Implement __builtin_operator{new,delete} (#107672)Timm Baeder1-0/+112
3 days[clang][bytecode] Allow continuing when discarded MemberExpr Base fails ↵Timm Baeder1-0/+18
(#107231) We don't need the value in this case, since we're discarding it anyway. Allow continuing the interpretation but note the side effect.
3 days[-Wunsafe-buffer-usage] Fix a bug in "warning libc functions (#101583)"ziqingluo-901-1/+2
The commit d7dd2c468fecae871ba67e891a3519c758c94b63 crashes for such an example: ``` void printf() { printf(); } ``` Because it assumes `printf` must have arguments. This commit fixes this issue. (rdar://117182250)
3 days[AMDGPU] Add target intrinsic for s_buffer_prefetch_data (#107293)Stanislav Mekhanoshin2-0/+24
3 days[clang][rtsan] Add realtime_sanitizer to Features.def (#106650)Chris Apple1-0/+12
Allows us to introduce the scoped disabler in #106736
4 daysclang/AMDGPU: Update test message orderMatt Arsenault2-5/+7
Order of atomic expansion remarks is backwards since 100d9b89947bb1d42af20010bb594fa4c02542fc
4 days[analyzer] Model constructor initializer for an array member (#107537)Arseniy Zaostrovnykh2-12/+70
Bind the array member to the compound region associated with the initializer list, e.g.: class C { int arr[2]; C() : arr{1, 2} {} }; C c; This change enables correct values in `c.arr[0]` and `c.arr[1]` CPP-5647
4 days[MC] Emit a jump table size section (#101962)Nabeel Omer1-0/+5
This patch will make LLVM emit a new section .llvm_jump_table_sizes containing tuples of (jump table address, entry count) in object files. This section is useful for tools that need to statically reconstruct the control flow of executables. At the moment this is only enabled by default for the PS5 target.
4 days[clang] Pass -c to clang in test/Driver/Ofast.cNico Weber1-9/+9
Without this, `-###` prints the linker invocation as well, which can lead to `-Wno-msvc-not-found` warnings on Windows bots that don't have MSVC on path, causing the test to fail. Since the test isn't trying to test linker-related things, just pass `-c`. See discussion on #98736.
4 days[clang][bytecode] Implement comparsion operators for vector type (#107258)yronglin1-4/+208
Implement ==, !=, <, <=, >, >= comparsion operators for vector type. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
4 days[Clang][AArch64] Add customisable immediate range checking to NEON (#100278)SpencerAbson32-781/+7010
This patch moves NEON immediate argument specification and checking to the system currently shared by both SVE and SME. In its current form, the TableGen definition of a NEON intrinsic cannot control how its immediate arguments are range-checked, this information must be inferred from the name of the intrinsic by NeonEmitter, which also assumes that any NEON instruction will only ever receive a single immediate argument. For SVE/SME instrinsics, this information is more conveniently supplied in the TableGen definition. As a result, for each immediate argument, NEON instructions must define - The index of the immediate argument to be checked - The type of immediate range check to be performed, (e.g., ImmCheckShiftRight) - The index of the argument whose type defines the context of this immediate check (base type, vector size). - **Difference from SVE/SME** If this definition generates a polymorphic NEON builtin, the base type defined by this argument is overwritten by that of the type code supplied to the overloaded builtin call. This third argument is omitted in some cases due to this. Here is an example for [`vfma_laneq`](https://developer.arm.com/architectures/instruction-sets/intrinsics/#f:@navigationhierarchiessimdisa=[Neon]&q=vfma_laneq) - The immediate is supplied in argument 3 - The immediate is used as an index into the lanes of argument 2 - So we must perform an immediate check on argument 3, based on the type information of argument 2. - `ImmCheck<3, ImmCheckLaneIndex, 2>` During this work, we discovered that the existing immediate range-checking system was largely untested, which made it difficult to make reliable progress. Missing tests have been added to verify this implementation against all intrinsics which take constrained immediate arguments. All test immediate range checking tests for NEON intrinsics are moved to a dedicated directory `clang/test/Sema/aarch64-neon-immediate-ranges/`.
4 days[clang] Emit -Wdangling diagnoses for cases where a gsl-pointer is construct ↵Haojian Wu1-0/+28
from a gsl-owner object in a container. (#104556) The warning is not emitted for the case `string_view c = std::vector<std::string>({""}).at(0);` because we bail out during the visit of the LHS at [this point](https://github.com/llvm/llvm-project/blob/5d2c324fea2d7cf86ec50e4bb6b680acf89b2ed5/clang/lib/Sema/CheckExprLifetime.cpp#L341-L343) in the code. This bailout was introduced in [this commit](https://github.com/llvm/llvm-project/commit/bcd0798c47ca865f95226859893016a17402441e) to address a false positive with `vector<vector::iterator>({""}).at(0);`. This PR refines that fix by ensuring that, for initialization involving a gsl-pointer, we only consider constructor calls that take the gsl-owner object. Fixes #100384.
4 days[HLSL] Apply resource attributes to the resource type rather than the handle ↵Helena Kotas10-81/+83
member (#107160) Converts existing resource attributes `[[hlsl::resource_class(..)]]` and `[[is_rov]]` from declaration attributes to type attributes. During type attribute processing all HLSL resource type attributes are validated and collected by `SemaHLSL` (`SemaHLSL::handleResourceTypeAttr`). At the end of the declaration they are be combined into a single `HLSLAttributedResourceType` instance (`SemaHLSL::ProcessResourceTypeAttributes`) that wraps the original type and stores all of the necessary information about the resource. `SemaHLSL` will also need to short-term-store the `TypeLoc` information for the newly created type that will be grabbed by `TypeSpecLocFiller` soon after it is created. Updates all places that expected resource attributes on declarations like resource binding diagnostic, builtin types in HLSLExternalSemaSource, or codegen. Also includes implementation of `TreeTransform<Derived>::TransformHLSLAttributedResourceType` that enables the use of attributed resource types inside templates. Fixes #104861 Part 2/2
4 daysRe-land "[-Wunsafe-buffer-usage] Warning Libc functions (#101583)"ziqingluo-903-3/+185
Revert commit 23457964392d00fc872fa6021763859024fb38da, and re-land with a new flag "-Wunsafe-buffer-usage-in-libc-call" for the new warning. (rdar://117182250)
4 days[AMDGPU] Add target intrinsic for s_prefetch_data (#107133)Stanislav Mekhanoshin1-1/+25
4 days[sanitizer] Delay sanitizer args parsing (#107280)Evgenii Stepanov2-2/+4
Delay sanitizer arg parsing until after -Xclang flags are forwarded to the clang command line. This allows the check in hasTargetFeatureMTE to pick up manually specified target feature, and enables the following: -march=armv8-a -Xclang -target-feature -Xclang +mte -fsanitize=memtag-stack
4 days[clang] Check inline defs when emitting speculative vtable (#100785)Fabian Parzefall1-7/+18
Clang should only emit an available_externally vtable when there are no unused virtual inline functions. Currently, if such such a function is declared without inline inside the class, but is defined inline outside the class, Clang might emit the vtable as available_externally. This happens because Clang only considers the declarations of vtable entries, but not the definitions. This patch addresses this by inspecting the definitions in addition to the declarations.
4 days[Clang] Fix crash with `source_location` in lambda declarators. (#107411)cor3ntin1-0/+23
Parsing lambdas require pushing a declaration context for the lambda, so that parameters can be attached to it, before its trailing type is parsed. DAt that point, partially-parsed lambda don't have a name that can be computed for then. This would cause source_location::current() to crash when use in the decltype of a lambda(). We work around this by producing a source_location for an enclosing scope in that scenario. Fixes #67134
5 days[Clang][Parser] Accept P2741R3 (static_assert with user-generated message) ↵Mital Ashok5-5/+38
in C++11 as an extension (#102044) Added a new `-Wpre-c++26-compat` warning for when this feature is used in C++26 and a `-Wc++26-extensions` warning for when this is used in C++11 through C++23. --------- Co-authored-by: cor3ntin <corentinjabot@gmail.com>
5 daysFix handling of FP-classify where the last arg fails to converterichkeane1-0/+4
The last argument of an FP-classify function was checked for vailidity as an expression, but we never ensured that the usual unary conversions/etc properly resulted in a valid value. Thus, when we got the value, it was null, so we had a null dereference. This patch instead fails out/marks the function call as invalid if the argument is incorrect. I DID consider just allowing it to continue, but the result was an extraneous error about how the last argument wasn't a float (in this case, it was an overload set). Fixes: #107411
5 daysReland "[clang] Add nuw attribute to GEPs (#105496)" (#107257)Hari Limaye89-1100/+1100
Add nuw attribute to inbounds GEPs where the expression used to form the GEP is an addition of unsigned indices. Relands #105496, which was reverted because it exposed a miscompilation arising from #98608. This is now fixed by #106512.
5 days[Clang] Add __builtin_is_within_lifetime to implement P2641R4's ↵Mital Ashok2-0/+524
std::is_within_lifetime (#91895) [P2641R4](https://wg21.link/P2641R4) This new builtin function is declared `consteval`. Support for `-fexperimental-new-constant-interpreter` will be added in a later patch. --------- Co-authored-by: cor3ntin <corentinjabot@gmail.com>
5 days[Clang] CWG2749: relational operators involving pointers to void (#93046)Mital Ashok3-12/+53
https://cplusplus.github.io/CWG/issues/2749.html This DR's effects are backported to C++98. Does not affect C where integral constant expressions cannot involve pointers. --------- Co-authored-by: Vlad Serebrennikov <serebrennikov.vladislav@gmail.com> Co-authored-by: cor3ntin <corentinjabot@gmail.com>
5 days[Clang] Warn with -Wpre-c23-compat instead of -Wpre-c++17-compat for u8 ↵Mital Ashok1-0/+1
character literals in C23 (#97210) Co-authored-by: cor3ntin <corentinjabot@gmail.com>