summaryrefslogtreecommitdiff
path: root/clang/lib/AST
AgeCommit message (Collapse)Author
2025-11-22[Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - Allow AVX512 ↵NagaChaitanya Vellanki
VPSHUFBITQMB intrinsics to be used in constexpr (#168100) Resolves #161337
2025-11-22[clang][bytecode][NFC] Remove VariableScope::emitDestruction (#169148)Timm Baeder
destroyLocals() does the same thing.
2025-11-22 [Clang][X86] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow ↵stomfaig
VPERMILPD/S variable mask intrinsics to be used in constexpr (#168861) Allowing VPERMILPD/S intrinsics to be used in constexpr Closes #167878
2025-11-22[clang][X86] Allow VALIGND/Q element-shift intrinsics in constexpr ↵Muhammad Abdul
evaluation (#168206) Fixes #167681
2025-11-22[clang][bytecode] Don't call getThis() on the bottom function frame (#169044)Timm Baeder
We can't access the calling frame in that case. Fixes https://github.com/llvm/llvm-project/issues/169032
2025-11-21Revert "Reland [MS][clang] Add support for vector deleting destructors" ↵Zequan Wu
(#169116) This reverts 4d10c1165442cbbbc0017b48fcdd7dae1ccf3678 and its two dependent commits: e6b9805b574bb5c90263ec7fbcb94df76d2807a4 and c243406a695ca056a07ef4064b0f9feee7685320, see discussion in https://github.com/llvm/llvm-project/pull/165598#issuecomment-3563825509.
2025-11-21[AST] Construct iterator_range with the conversion constructor (NFC) (#169004)Kazu Hirata
This patch simplifies iterator_range construction with the conversion constructor.
2025-11-21[Clang] Fix handling of explicit parameters in `SemaLambda` (#168558)Willem Kaufmann
Previously, the presence of an explicit parameter list was detected by querying `getNumTypeObjects()` from the `Declarator` block of the lambda definition. This breaks for lambdas which do not have a parameter list but _do_ have a trailing return type; that is, both of ``` []() -> int { return 0; }; [] -> int { return 0; }; ``` would return `true` when inspecting `LambdaExpr::hasExplicitParameters()`. Fix this by instead querying the `LParenLoc()` from the `Declarator`'s `FunctionTypeInfo`. If `isValid() == true`, then an explicit parameter list must be present, and if it is `false`, then it is not. This commit also adds `hasExplicitParameters` as an attribute to a `LambdaExpr`'s JSON AST dump. A new test (`ast-dump-lambda-json.cpp`) is also added to validate the fix and presence of the new attribute in the output. `ast-dump-expr-json.cpp` is also updated to validate the new attribute. Fixes https://github.com/llvm/llvm-project/issues/168452.
2025-11-21[clang][TypePrinter] Replace AppendScope with printNestedNameSpecifier (#168534)Michael Buch
In debug-info we soon have the need to print names using the full scope of the entity (see discussion in https://github.com/llvm/llvm-project/pull/159592). Particularly, when a structure is scoped inside a function, we'd like to emit the name as `func()::foo`. `CGDebugInfo` uses the `TypePrinter` to print type names into debug-info. However, `TypePrinter` stops (and ignores) `DeclContext`s that are functions. I.e., it would just print `foo`. Ideally it would behave the same way `printNestedNameSpecifier` does. The FIXME in https://github.com/llvm/llvm-project/blob/47c1aa4cef638c97b74f3afb7bed60e92bba1f90/clang/lib/AST/TypePrinter.cpp#L1520-L1521 motivated this patch. See https://github.com/llvm/llvm-project/pull/168533 for how this will be used by `CGDebugInfo`. The plan is to introduce a new `PrintingPolicy` that prints anonymous entities using their full scope (including function/anonymous scopes) and the mangling number.
2025-11-20[X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow ↵sskzakaria
AVX512 mask predicate intrinsics to be used in constexpr (#165054) Enables constexpr evaluation for the following AVX512 Instrinsics: ``` _mm_movepi8_mask _mm256_movepi8_mask _mm512_movepi8_mask _mm_movepi16_mask _mm256_movepi16_mask _mm512_movepi16_mask _mm_movepi32_mask _mm256_movepi32_mask _mm512_movepi32_mask _mm_movepi64_mask _mm256_movepi64_mask _mm512_movepi64_mask ``` Part of #162072
2025-11-20[clang][bytecode] Implement case ranges (#168418)marius doerner
Fixes #165969 Implement GNU case ranges for constexpr bytecode interpreter.
2025-11-19[HLSL][TableGen] Add `__hlsl_resource_t` to known built-in function types ↵Helena Kotas
(#163465) This change adds resource handle type `__hlsl_resource_t` to the list of types recognized in the Clang's built-in functions prototype string. HLSL has built-in resource classes and some of them have many methods, such as [Texture2D](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-texture2d). Most of these methods will be implemented by built-in functions that will take resource handle as an argument. This change enables us to move from generic `void(...)` prototype string for these methods and explicit argument checking in `SemaHLSL.cpp` to a prototype string with explicit argument types. Argument checking in `SemaHLSL.cpp` can be reduced to handle just the rules that cannot be expressed in the prototype string (for example verifying that the offset value in `__builtin_hlsl_buffer_update_counter` is `1` or `-1`). In order to make this work, we now allow conversions from attributed resource handle type such as `__hlsl_resource_t [[hlsl::resource_class(UAV)]] [[hlsl::contained_type(float)]]` to a plain non-attributed `__hlsl_resource_t` type.
2025-11-19[OpenACC][CIR] Fix atomic-capture single-line-postfix (#168717)Erich Keane
In my last patch, it became clear during code review that the postfix operation was actually a read THEN update, not update/read like other single line versions. It wasn't clear at the time how much additional work this would be to make postfix work correctly (and they are a bit of a 'special' thing in codegen anyway), so this patch adds some functionality to sense this and special-cases it when generating the statement info for capture.
2025-11-19[OpenACC][CIR] Implement 'atomic capture' lowering (#168422)Erich Keane
The 'atomic capture' variant of the `atomic` construct accepts either a single statement, or a compound statement containing two statements. Each of the statements it accepts meet a form of the previous read/write/update forms, or is a combination of two. The IR node for atomic capture takes two separate other acc.atomics, plus a terminator. This patch implements all of the lowering for these. Note: This gets the postfix-increment/decrement wrong, but the effort to do so is enough that I believe we can do that in a followup patch, so I'll be doing so in the next patch.
2025-11-19[Clang][X86] allow VPERMILPD/S imm intrinsics to be used in constexpr (#168044)stomfaig
Resolves #166529
2025-11-19[AllocToken] Fix and clarify -falloc-token-max=0 (#168689)Marco Elver
The option -falloc-token-max=0 is supposed to be usable to override previous settings back to the target default max tokens (SIZE_MAX). This did not work for the builtin: ``` | executed command: clang -cc1 [..] -nostdsysteminc -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify clang/test/SemaCXX/alloc-token.cpp -falloc-token-max=0 | clang: llvm/lib/Support/AllocToken.cpp:38: std::optional<uint64_t> llvm::getAllocToken(AllocTokenMode, const AllocTokenMetadata &, uint64_t): Assertion `MaxTokens && "Must provide non-zero max tokens"' failed. ``` Fix it by also picking the default if "0" is passed. Improve the documentation to be clearer what the value of "0" means.
2025-11-18Implement a more seamless way to provide missing functions on z/OS (#167703)Sean Perry
In this PR I'm changing the way we provide the missing functions like strnlen() on z/OS from the separate header file to a wrapper around the system headers that declare these functions. This will be less intrusive. --------- Co-authored-by: Zibi Sarbinowski <zibi@ca.ibm.com>
2025-11-18[Headers][X86] Allow AVX512 masked arithmetic ss/sd intrinsics to be used in ↵woruyu
constexpr (#162816) This PR just resolves ss/sd part of AVX512 masked arithmetic intrinsics of #160559.
2025-11-18[clang][bytecode] Fix fallthrough to switch labels (#168484)Timm Baeder
We need to fallthrough here in case we're not jumping to the labels. This is only needed in expression contexts.
2025-11-17[X86] Add constexpr support for addsub intrinsics (#167512)Ahmed Nour
Recent commits (7fe069121b57a, 53ddeb493529a) marked several x86 intrinsics as constexpr in headers without providing the necessary constant evaluation support in the compiler backend. This caused compilation failures when attempting to use these intrinsics in constant expressions. Resolves #166814 Resolves #161203
2025-11-17[X86][Clang] Add AVX512 kunpck intrinsics to be used in constexp (#167683)Ahmed Nour
Resolves #166976
2025-11-17[clang][bytecode] Check pointers in GetPtrField{,Pop} (#167335)Timm Baeder
The pointer needs to point to a record. Fixes https://github.com/llvm/llvm-project/issues/166371
2025-11-15[Clang] Add __builtin_bswapg (#162433)clf
Add a new builtin function __builtin_bswapg. It works on any integral types that has a multiple of 16 bits as well as a single byte. Closes #160266
2025-11-14[clang][bytecode][NFC] Check pointer types in canClassify() (#168069)Timm Baeder
And return true. Also make those two functions const.
2025-11-14[clang][bytecode] Adjust pointers when moving them (#168053)Timm Baeder
When calling Block::movePointersTo(), the two blocks might have different metadata sizes, which causes the final pointer to be incorrect and point to garbage. Adjust the pointer base and offset accordingly. Fixes https://github.com/llvm/llvm-project/issues/168018
2025-11-14[clang] Fix -Wparentheses warning [NFC]Mikael Holmen
Without this gcc warns like ../../clang/lib/AST/ExprConstant.cpp:4091:63: warning: suggest parentheses around '&&' within '||' [-Wparentheses] 4091 | (SrcVal.isVector() && SrcVal.getVectorLength() == 1) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ 4092 | "Not a valid HLSLAggregateSplatCast."); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2025-11-14[clang][bytecode] Don't outright reject dynamic casts (#167517)Timm Baeder
Just delegate to the subexpr instead for now.
2025-11-14[clang][bytecode][NFC] Limit pointer and array ops to integer indices (#168022)Timm Baeder
AluOpcode includes fixed point as well, which isn't possible here.
2025-11-14[clang][bytecode] Print field descriptor in Pointer::print() (#168002)Timm Baeder
This is almost always useful information and ::print() is debug-only code.
2025-11-13[Clang] Add constexpr support for AVX512 permutexvar intrinsics (#167802)NagaChaitanya Vellanki
Resolves #167476
2025-11-13Reland [MS][clang] Add support for vector deleting destructors (#165598)Mariya Podchishchaeva
MSVC supports an extension allowing to delete an array of objects via pointer whose static type doesn't match its dynamic type. This is done via generation of special destructors - vector deleting destructors. MSVC's virtual tables always contain a pointer to the vector deleting destructor for classes with virtual destructors, so not having this extension implemented causes clang to generate code that is not compatible with the code generated by MSVC, because clang always puts a pointer to a scalar deleting destructor to the vtable. As a bonus the deletion of an array of polymorphic object will work just like it does with MSVC - no memory leaks and correct destructors are called. This patch will cause clang to emit code that is compatible with code produced by MSVC but not compatible with code produced with clang of older versions, so the new behavior can be disabled via passing -fclang-abi-compat=21 (or lower). This is yet another attempt to land vector deleting destructors support originally implemented by https://github.com/llvm/llvm-project/pull/133451. This PR contains fixes for issues reported in the original PR as well as fixes for issues related to operator delete[] search reported in several issues like https://github.com/llvm/llvm-project/pull/133950#issuecomment-2787510484 https://github.com/llvm/llvm-project/issues/134265 Fixes https://github.com/llvm/llvm-project/issues/19772
2025-11-13[clang][bytecode] Fix diagnosing subtration of zero-size pointers (#167839)Timm Baeder
We need to get the element type size at bytecode generation time to check. We also need to diagnose this in the LHS == RHS case.
2025-11-12[Clang][NFC] Fix a typo in FunctionDecl (#167677)Younan Zhang
Found it while looking at other stuffs.
2025-11-11[Clang] Generalize interp__builtin_ia32_shuffle_generic to handle single op ↵TelGome
permute shuffles. (#167236) This patch extends `interp__builtin_ia32_shuffle_generic` and `evalShuffleGeneric` to handle both 2-argument and 3-argument patterns, replacing specialized shuffle functions with the unified handler. Resolves #166342
2025-11-11[Headers][X86] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow ↵Ye Tian
PALIGNR byte shift intrinsics to be used in constexpr (#162005) Fixes #160509
2025-11-11[clang][bytecode] Mark CXXDefaultInitExprs in InitLink chain (#166395)Timm Baeder
So we know before _what_ entry in the chain we need to look for the InitList. Fixes https://github.com/llvm/llvm-project/issues/166171
2025-11-10[Clang][ASTImporter] Implement AST import for CXXParenListInitExpr, ↵ganenkokb-yandex
SubstNonTypeTemplateParmPackExpr, PseudoObjectExpr (#160904) Add new visit functions to ASTImporter for CXXParenListInitExpr, SubstNonTypeTemplateParmPackExpr and PseudoObjectExpr. On CTU analysis there are lot of "cannot import unsupported AST node" for CXXParenListInitExpr, SubstNonTypeTemplateParmPackExpr and PseudoObjectExpr. Problem occurred after full support of Concepts in importer.
2025-11-10[clang][bytecode] Check source pointer for bitcast validity (#166907)Timm Baeder
Unfortunately this is more dynamic than anticipated. Fixes https://github.com/llvm/llvm-project/issues/165006
2025-11-08[clang][bytecode] Fix a std::optional<bool> mishap (#167091)Timm Baeder
This is about the value saved in the std::optional, not about whether the optional has a value at all.
2025-11-08[clang][bytecode] Avoid copies with elidable CXXConstructExprs (#166931)Timm Baeder
To fix the newly added cwg6.cpp.
2025-11-07[OpenMP][Clang] Add parser/semantic support for dyn_groupprivate clause ↵Kevin Sala Penades
(#152651) This PR adds support for the `dyn_groupprivate` clause, which will be part of OpenMP 6.1. This feature allows users to request dynamic shared memory on target regions. --------- Co-authored-by: Krzysztof Parzyszek <Krzysztof.Parzyszek@amd.com>
2025-11-07Revert "Ignore trailing NullStmts in StmtExprs for GCC compatibility." (#166036)KaiWeng
This reverts commit b1e511bf5a4c702ace445848b30070ac2e021241. https://github.com/llvm/llvm-project/issues/160243 Reverting because the GCC C front end is incorrect. --------- Co-authored-by: Jim Lin <jim@andestech.com>
2025-11-07[X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add ↵Roberto Turrado Camblor
AVX512 KTEST/KORTEST intrinsics to be used in constexpr (#166103) Add AVX512 KTEST/KORTEST intrinsics to be used in constexpr. Fixes #162051
2025-11-07[clang][bytecode] Dummy variables can have pointers to them (#166908)Timm Baeder
at the point when they become proper globals.
2025-11-06[clang][AST] Do not try to handle irrelevant cases in ↵Sergej Salnikov
writeBareSourceLocation (#166588) `writeBareSourceLocation` is always called on either `Expanded` or `Spelling` location, in any on those cases the `SM.getSpellingLineNumber(Loc) == SM.getExpansionLineNumber(Loc) == SM.getLineNumber(Loc)`.
2025-11-06[HLSL] add support for HLSLAggregateSplatCast and HLSLElementwiseCast to ↵Sarah Spall
constant expression evaluator (#164700) Add support to handle these casts in the constant expression evaluator. - HLSLAggregateSplatCast - HLSLElementwiseCast - HLSLArrayRValue Add tests Closes #125766 Closes #125321
2025-11-06Revert "Add dump info for VarDecl"Aaron Ballman
This reverts commit 831a8b55cafe6c139beb0f6d88ab32a71bdfd1ca. Other test need to be updated too
2025-11-06Add dump info for VarDeclAaron Ballman
A VarDecl can either be a declaration, a definition, or a tentative definition. This dumps that information because it turned out to be useful for a discussion trying to understand a difference in behavior between C and C++.
2025-11-06[clang][ExprConst] Handle dependent switch case statements (#166533)Timm Baeder
By rejecting them. Fixes https://github.com/llvm/llvm-project/issues/165555
2025-11-05[clang][bytecode] Check types when loading values (#165385)Timm Baeder
We need to allow BitCasts between pointer types to different prim types, but that means we need to catch the problem at a later stage, i.e. when loading the values. Fixes https://github.com/llvm/llvm-project/issues/158527 Fixes https://github.com/llvm/llvm-project/issues/163778