aboutsummaryrefslogtreecommitdiff
path: root/clang/docs
AgeCommit message (Collapse)AuthorFilesLines
12 days[Clang][Sema] Retain the expanding index for unevaluated type constraints ↵Younan Zhang1-0/+2
(#109518) (This continues the effort of #86265, fixing another piece of issue in constraint evaluation on variadic lambdas.) We need the depth of the primary template parameters for constraint substitution. To that end, we avoided substituting type constraints by copying the constraint expression when instantiating a template. This, however, has left an issue in that for lambda's parameters, they can reference outer template packs that would be expanded in the process of an instantiation, where these parameters would make their way into the constraint evaluation, wherein we have no other way to expand them later in evaluation. For example, template <class... Ts> void foo() { bar([](C<Ts> auto value) {}...); } The lambda references a pack `Ts` that should be expanded when instantiating `foo()`. The `Ts` along with the constraint expression would not be transformed until constraint evaluation, and at that point, we would have no chance to expand `Ts` anyhow. This patch takes an approach that transforms `Ts` from an unexpanded TemplateTypeParmType into a SubstTemplateTypeParmType with the current pack substitution index, such that we could use that to expand the type during evaluation. Fixes #101754
12 days[Clang] Implement CWG 2707 "Deduction guides cannot have a trailing ↵Younan Zhang1-0/+3
requires-clause" (#110473) Closes https://github.com/llvm/llvm-project/issues/98595
12 days[clang][x86] Add constexpr support for all remaining TBM intrinsics (#110515)Simon Pilgrim1-1/+1
BEXTRI is already handled, so we just need to tag the rest of the intrinsics, which are all expanded to generic patterns. As these are expanded I felt it better to test against the equivalent pattern instead of the final result (I intend to take the same approach for BMI/BMI2 cases).
12 days[rtsan] Update docs to include run-time flags (#110296)Chris Apple1-0/+70
12 days[clang][x86] Add constexpr support for BZHI intrinsics (#110508)Simon Pilgrim1-0/+1
12 days[clang][x86] Add constexpr support for LZCNT/TZCNT intrinsics (#110499)Simon Pilgrim1-0/+6
12 days[clang][ItaniumMangle] Mangle friend function templates with a constr… ↵Viktoriia Bakalova1-0/+1
(#110247) …aint that depends on a template parameter from an enclosing template as members of the enclosing class. Such function templates should be considered member-like constrained friends per [temp.friend]p9 and https://github.com/itanium-cxx-abi/cxx-abi/issues/24#issuecomment-934977198).
12 days[clang][analyzer] Move 'alpha.core.PointerSub' checker into ↵Balázs Kéri1-43/+43
'security.PointerSub' (#107596)
14 days[ItaniumMangle] Add substitutions for record types when mangling vtables ↵tcwzxx1-0/+1
(#109970) Fix #108015 The `mangleNameOrStandardSubstitution` function does not add the RD type into the substitution, which causes the mangling of the \<base type\> to be incorrect. Rename `mangleNameOrStandardSubstitution` to `mangleCXXRecordDecl` and add `Record` as a substitution
2024-09-28Revert "[clang][test] add testing for the AST matcher reference" (#110354)Julian Schmidt4-5747/+2272
Reverts llvm/llvm-project#110258 The commit caused a timeout for clang-arm64-windows-msvc: https://lab.llvm.org/buildbot/#/builders/161/builds/2385 and it looks like my commit is at fault.
2024-09-27[HLSL] Implementation of the elementwise fmod builtin (#108849)Zhengxing li2-0/+4
This change add the elementwise fmod builtin to support HLSL function 'fmod' in clang for #99118 Builtins.td - add the fmod builtin CGBuiltin.cpp - lower the builtin to llvm FRem instruction hlsl_intrinsics.h - add the fmod api SemaChecking.cpp - add type checks for builtin SemaHLSL.cpp - add HLSL type checks for builtin clang/docs/LanguageExtensions.rst - add the builtin in *Elementwise Builtins* clang/docs/ReleaseNotes.rst - announce the builtin
2024-09-27[clang][test] add testing for the AST matcher reference (#110258)Julian Schmidt4-2272/+5747
## Problem Statement Previously, the examples in the AST matcher reference, which gets generated by the Doxygen comments in `ASTMatchers.h`, were untested and best effort. Some of the matchers had no or wrong examples of how to use the matcher. ## Solution This patch introduces a simple DSL around Doxygen commands to enable testing the AST matcher documentation in a way that should be relatively easy to use. In `ASTMatchers.h`, most matchers are documented with a Doxygen comment. Most of these also have a code example that aims to show what the matcher will match, given a matcher somewhere in the documentation text. The way that the documentation is tested, is by using Doxygen's alias feature to declare custom aliases. These aliases forward to `<tt>text</tt>` (which is what Doxygen's `\c` does, but for multiple words). Using the Doxygen aliases is the obvious choice, because there are (now) four consumers: - people reading the header/using signature help - the Doxygen generated documentation - the generated HTML AST matcher reference - (new) the generated matcher tests This patch rewrites/extends the documentation such that all matchers have a documented example. The new `generate_ast_matcher_doc_tests.py` script will warn on any undocumented matchers (but not on matchers without a Doxygen comment) and provides diagnostics and statistics about the matchers. The current statistics emitted by the parser are: ```text Statistics: doxygen_blocks : 519 missing_tests : 10 skipped_objc : 42 code_snippets : 503 matches : 820 matchers : 580 tested_matchers : 574 none_type_matchers : 6 ``` The tests are generated during building, and the script will only print something if it found an issue with the specified tests (e.g., missing tests). ## Description DSL for generating the tests from documentation. TLDR: ``` \header{a.h} \endheader <- zero or more header \code int a = 42; \endcode \compile_args{-std=c++,c23-or-later} <- optional, the std flag supports std ranges and whole languages \matcher{expr()} <- one or more matchers in succession \match{42} <- one or more matches in succession \matcher{varDecl()} <- new matcher resets the context, the above \match will not count for this new matcher(-group) \match{int a = 42} <- only applies to the previous matcher (not to the previous case) ``` The above block can be repeated inside a Doxygen command for multiple code examples for a single matcher. The test generation script will only look for these annotations and ignore anything else like `\c` or the sentences where these annotations are embedded into: `The matcher \matcher{expr()} matches the number \match{42}.`. ### Language Grammar [] denotes an optional, and <> denotes user-input ``` compile_args j:= \compile_args{[<compile_arg>;]<compile_arg>} matcher_tag_key ::= type match_tag_key ::= type || std || count || sub matcher_tags ::= [matcher_tag_key=<value>;]matcher_tag_key=<value> match_tags ::= [match_tag_key=<value>;]match_tag_key=<value> matcher ::= \matcher{[matcher_tags$]<matcher>} matchers ::= [matcher] matcher match ::= \match{[match_tags$]<match>} matches ::= [match] match case ::= matchers matches cases ::= [case] case header-block ::= \header{<name>} <code> \endheader code-block ::= \code <code> \endcode testcase ::= code-block [compile_args] cases ``` ### Language Standard Versions The 'std' tag and '\compile_args' support specifying a specific language version, a whole language and all of its versions, and thresholds (implies ranges). Multiple arguments are passed with a ',' separator. For a language and version to execute a tested matcher, it has to match the specified '\compile_args' for the code, and the 'std' tag for the matcher. Predicates for the 'std' compiler flag are used with disjunction between languages (e.g. 'c || c++') and conjunction for all predicates specific to each language (e.g. 'c++11-or-later && c++23-or-earlier'). Examples: - `c` all available versions of C - `c++11` only C++11 - `c++11-or-later` C++11 or later - `c++11-or-earlier` C++11 or earlier - `c++11-or-later,c++23-or-earlier,c` all of C and C++ between 11 and 23 (inclusive) - `c++11-23,c` same as above ### Tags #### `type`: **Match types** are used to select where the string that is used to check if a node matches comes from. Available: `code`, `name`, `typestr`, `typeofstr`. The default is `code`. - `code`: Forwards to `tooling::fixit::getText(...)` and should be the preferred way to show what matches. - `name`: Casts the match to a `NamedDecl` and returns the result of `getNameAsString`. Useful when the matched AST node is not easy to spell out (`code` type), e.g., namespaces or classes with many members. - `typestr`: Returns the result of `QualType::getAsString` for the type derived from `Type` (otherwise, if it is derived from `Decl`, recurses with `Node->getTypeForDecl()`) **Matcher types** are used to mark matchers as sub-matcher with 'sub' or as deactivated using 'none'. Testing sub-matcher is not implemented. #### `count`: Specifying a 'count=n' on a match will result in a test that requires that the specified match will be matched n times. Default is 1. #### `std`: A match allows specifying if it matches only in specific language versions. This may be needed when the AST differs between language versions. #### `sub`: The `sub` tag on a `\match` will indicate that the match is for a node of a bound sub-matcher. E.g., `\matcher{expr(expr().bind("inner"))}` has a sub-matcher that binds to `inner`, which is the value for the `sub` tag of the expected match for the sub-matcher `\match{sub=inner$...}`. Currently, sub-matchers are not tested in any way. ### What if ...? #### ... I want to add a matcher? Add a Doxygen comment to the matcher with a code example, corresponding matchers and matches, that shows what the matcher is supposed to do. Specify the compile arguments/supported languages if required, and run `ninja check-clang-unit` to test the documentation. #### ... the example I wrote is wrong? The test-failure output of the generated test file will provide information about - where the generated test file is located - which line in `ASTMatcher.h` the example is from - which matches were: found, not-(yet)-found, expected - in case of an unexpected match: what the node looks like using the different `type`s - the language version and if the test ran with a windows `-target` flag (also in failure summary) #### ... I don't adhere to the required order of the syntax? The script will diagnose any found issues, such as `matcher is missing an example` with a `file:line:` prefix, which should provide enough information about the issue. #### ... the script diagnoses a false-positive issue with a Doxygen comment? It hopefully shouldn't, but if you, e.g., added some non-matcher code and documented it with Doxygen, then the script will consider that as a matcher documentation. As a result, the script will print that it detected a mismatch between the actual and the expected number of failures. If the diagnostic truly is a false-positive, change the `expected_failure_statistics` at the top of the `generate_ast_matcher_doc_tests.py` file. Fixes #57607 Fixes #63748
2024-09-27Revert "[clang][test] add testing for the AST matcher reference (#94248)"Julian Schmidt4-5747/+2272
This reverts commit 097ada2fcb607be09da94a0d11f627a3759a10de.
2024-09-27[clang][test] add testing for the AST matcher reference (#94248)Julian Schmidt4-2272/+5747
## Problem Statement Previously, the examples in the AST matcher reference, which gets generated by the doxygen comments in `ASTMatchers.h`, were untested and best effort. Some of the matchers had no or wrong examples of how to use the matcher. ## Solution This patch introduces a simple DSL around doxygen commands to enable testing the AST matcher documentation in a way that should be relatively easy to use. In `ASTMatchers.h`, most matchers are documented with a doxygen comment. Most of these also have a code example that aims to show what the matcher will match, given a matcher somewhere in the documentation text. The way that the documentation is tested, is by using doxygen's alias feature to declare custom aliases. These aliases forward to `<tt>text</tt>` (which is what doxygen's `\c` does, but for multiple words). Using the doxygen aliases is the obvious choice, because there are (now) four consumers: - people reading the header/using signature help - the doxygen generated documentation - the generated html AST matcher reference - (new) the generated matcher tests This patch rewrites/extends the documentation such that all matchers have a documented example. The new `generate_ast_matcher_doc_tests.py` script will warn on any undocumented matchers (but not on matchers without a doxygen comment) and provides diagnostics and statistics about the matchers. The current statistics emitted by the parser are: ```text Statistics: doxygen_blocks : 519 missing_tests : 10 skipped_objc : 42 code_snippets : 503 matches : 820 matchers : 580 tested_matchers : 574 none_type_matchers : 6 ``` The tests are generated during building and the script will only print something if it found an issue (compile failure, parsing issues, the expected and actual number of failures differs). ## Description DSL for generating the tests from documentation. TLDR: ``` \header{a.h} \endheader <- zero or more header \code int a = 42; \endcode \compile_args{-std=c++,c23-or-later} <- optional, the std flag supports std ranges and whole languages \matcher{expr()} <- one or more matchers in succession \match{42} <- one or more matches in succession \matcher{varDecl()} <- new matcher resets the context, the above \match will not count for this new matcher(-group) \match{int a = 42} <- only applies to the previous matcher (not to the previous case) ``` The above block can be repeated inside a doxygen command for multiple code examples for a single matcher. The test generation script will only look for these annotations and ignore anything else like `\c` or the sentences where these annotations are embedded into: `The matcher \matcher{expr()} matches the number \match{42}.`. ### Language Grammar [] denotes an optional, and <> denotes user-input ``` compile_args j:= \compile_args{[<compile_arg>;]<compile_arg>} matcher_tag_key ::= type match_tag_key ::= type || std || count || sub matcher_tags ::= [matcher_tag_key=<value>;]matcher_tag_key=<value> match_tags ::= [match_tag_key=<value>;]match_tag_key=<value> matcher ::= \matcher{[matcher_tags$]<matcher>} matchers ::= [matcher] matcher match ::= \match{[match_tags$]<match>} matches ::= [match] match case ::= matchers matches cases ::= [case] case header-block ::= \header{<name>} <code> \endheader code-block ::= \code <code> \endcode testcase ::= code-block [compile_args] cases ``` ### Language Standard Versions The 'std' tag and '\compile_args' support specifying a specific language version, a whole language and all of its versions, and thresholds (implies ranges). Multiple arguments are passed with a ',' separator. For a language and version to execute a tested matcher, it has to match the specified '\compile_args' for the code, and the 'std' tag for the matcher. Predicates for the 'std' compiler flag are used with disjunction between languages (e.g. 'c || c++') and conjunction for all predicates specific to each language (e.g. 'c++11-or-later && c++23-or-earlier'). Examples: - `c` all available versions of C - `c++11` only C++11 - `c++11-or-later` C++11 or later - `c++11-or-earlier` C++11 or earlier - `c++11-or-later,c++23-or-earlier,c` all of C and C++ between 11 and 23 (inclusive) - `c++11-23,c` same as above ### Tags #### `type`: **Match types** are used to select where the string that is used to check if a node matches comes from. Available: `code`, `name`, `typestr`, `typeofstr`. The default is `code`. - `code`: Forwards to `tooling::fixit::getText(...)` and should be the preferred way to show what matches. - `name`: Casts the match to a `NamedDecl` and returns the result of `getNameAsString`. Useful when the matched AST node is not easy to spell out (`code` type), e.g., namespaces or classes with many members. - `typestr`: Returns the result of `QualType::getAsString` for the type derived from `Type` (otherwise, if it is derived from `Decl`, recurses with `Node->getTypeForDecl()`) **Matcher types** are used to mark matchers as sub-matcher with 'sub' or as deactivated using 'none'. Testing sub-matcher is not implemented. #### `count`: Specifying a 'count=n' on a match will result in a test that requires that the specified match will be matched n times. Default is 1. #### `std`: A match allows specifying if it matches only in specific language versions. This may be needed when the AST differs between language versions. #### `sub`: The `sub` tag on a `\match` will indicate that the match is for a node of a bound sub-matcher. E.g., `\matcher{expr(expr().bind("inner"))}` has a sub-matcher that binds to `inner`, which is the value for the `sub` tag of the expected match for the sub-matcher `\match{sub=inner$...}`. Currently, sub-matchers are not tested in any way. ### What if ...? #### ... I want to add a matcher? Add a doxygen comment to the matcher with a code example, corresponding matchers and matches, that shows what the matcher is supposed to do. Specify the compile arguments/supported languages if required, and run `ninja check-clang-unit` to test the documentation. #### ... the example I wrote is wrong? The test-generation script will try to compile your example code before it continues. This makes finding issues with your example code easier because the test-failures are much more verbose. The test-failure output of the generated test file will provide information about - where the generated test file is located - which line in `ASTMatcher.h` the example is from - which matches were: found, not-(yet)-found, expected - in case of an unexpected match: what the node looks like using the different `type`s - the language version and if the test ran with a windows `-target` flag (also in failure summary) #### ... I don't adhere to the required order of the syntax? The script will diagnose any found issues, such as `matcher is missing an example` with a `file:line:` prefix, which should provide enough information about the issue. #### ... the script diagnoses a false-positive issue with a doxygen comment? It hopefully shouldn't, but if you, e.g., added some non-matcher code and documented it with doxygen, then the script will consider that as a matcher documentation. As a result, the script will print that it detected a mismatch between the actual and the expected number of failures. If the diagnostic truly is a false-positive, change the `expected_failure_statistics` at the top of the `generate_ast_matcher_doc_tests.py` file. Fixes #57607 Fixes #63748
2024-09-27[alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker ↵Ryosuke Niwa1-0/+21
for CheckedPtr/CheckedRef (#108352) This PR introduces new WebKit checker to warn a member variable that is a raw reference or a raw pointer to an object, which is capable of creating a CheckedRef/CheckedPtr.
2024-09-26[clang] implement current direction of CWG2765 for string literal ↵Richard Smith1-0/+18
comparisons in constant evaluation (#109208) Track the identity of each string literal object produced by evaluation with a global version number. Accept comparisons between literals of the same version, and between literals of different versions that cannot possibly be placed in overlapping storage. Treat the remaining comparisons as non-constant. --------- Co-authored-by: Timm Baeder <tbaeder@redhat.com> Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2024-09-26[analyzer] Moving TaintPropagation checker out of alpha (#67352)Daniel Krupp2-237/+239
This commit moves the **alpha.security.taint.TaintPropagation** and **alpha.security.taint.GenericTaint** checkers to the **optin.taint** optional package. These checkers were stabilized and improved by recent commits thus they are ready for production use.
2024-09-25Reapply "Deprecate the `-fbasic-block-sections=labels` option." (#110039)Rahman Lavaee1-5/+7
This reapplies commit 1911a50fae8a441b445eb835b98950710d28fc88 with a minor fix in lld/ELF/LTO.cpp which sets Options.BBAddrMap when `--lto-basic-block-sections=labels` is passed.
2024-09-25Revert "Deprecate the `-fbasic-block-sections=labels` option. (#107494)"Kazu Hirata1-7/+5
This reverts commit 1911a50fae8a441b445eb835b98950710d28fc88. Several bots are failing: https://lab.llvm.org/buildbot/#/builders/190/builds/6519 https://lab.llvm.org/buildbot/#/builders/3/builds/5248 https://lab.llvm.org/buildbot/#/builders/18/builds/4463
2024-09-25Deprecate the `-fbasic-block-sections=labels` option. (#107494)Rahman Lavaee1-5/+7
This feature is supported via the newer option `-fbasic-block-address-map`. Using the old option still works by delegating to the newer option, while a warning is printed to show deprecation.
2024-09-25Reland: [clang] Diagnose dangling issues for the "Container<GSLPointer>" ↵Haojian Wu1-0/+2
case. #107213 (#108344) This relands #107213, with with fixes to address false positives (`make_optional(nullptr)`).
2024-09-24Revert "[clang][CodeGen] Zero init unspecified fields in initializers in C" ↵Eli Friedman1-23/+0
(#109898) Reverts llvm/llvm-project#97121 Causing failures on LNT bots; log shows a crash in ConstStructBuilder::BuildStruct.
2024-09-24[clang][CodeGen] Zero init unspecified fields in initializers in C (#97121)yabinc1-0/+23
When an initializer is provided to a variable, the Linux kernel relied on the compiler to zero-initialize unspecified fields, as clarified in https://www.spinics.net/lists/netdev/msg1007244.html. But clang doesn't guarantee this: 1. For a union type, if an empty initializer is given, clang only initializes bytes for the first field, left bytes for other (larger) fields are marked as undef. Accessing those undef bytes can lead to undefined behaviors. 2. For a union type, if an initializer explicitly sets a field, left bytes for other (larger) fields are marked as undef. 3. When an initializer is given, clang doesn't zero initialize padding. So this patch makes the following change: 1. In C, when an initializer is provided for a variable, zero-initialize undef and padding fields in the initializer. 2. Document the change in LanguageExtensions.rst. As suggested in https://github.com/llvm/llvm-project/issues/78034#issuecomment-2183437928, the change isn't required by C23, but it's standards conforming to do so. Fixes: https://github.com/llvm/llvm-project/issues/97459
2024-09-24[clang] fix assert in ADL finding entity in the implicit global module (#109882)Matheus Izvekov1-2/+5
This adds to the assert the implicit global module case as in module purview. Fixes #109879
2024-09-24[OpenMP][Docs] Update OpenMP release notes with 'omp scope' (#109752)David Pagan1-0/+1
Release notes: added 'omp scope' directive to "OpenMP Support" section of "What's New in Clang"
2024-09-23[OpenMP][Docs] Update OpenMP supported features table (#109726)David Pagan1-1/+1
OpenMP features table: updated scope directive status from 'worked on' to 'done' in section OpenMP 5.1 Implementation Details.
2024-09-23[clang] Apply the [[gsl::Owner]] or [[gsl::Pointer]] attributes to the STL ↵Haojian Wu1-0/+3
template specialization declarations. (#109653) Fixes #109442
2024-09-23[clang] Lifetime of locals must end before musttail call (#109255)Oliver Stannard1-0/+9
The lifetimes of local variables and function parameters must end before the call to a [[clang::musttail]] function, instead of before the return, because we will not have a stack frame to hold them when doing the call. This documents this limitation, and adds diagnostics to warn about some code which is invalid because of it.
2024-09-22[Clang] Add __builtin_common_type (#99473)Nikolas Klauser2-0/+43
This implements the logic of the `common_type` base template as a builtin alias. If there should be no `type` member, an empty class is returned. Otherwise a specialization of a `type_identity`-like class is returned. The base template (i.e. `std::common_type`) as well as the empty class and `type_identity`-like struct are given as arguments to the builtin.
2024-09-21Revert "[Clang][Sema] Refactor collection of multi-level template argument ↵Martin Storsjö1-3/+0
lists (#106585)" This reverts commit cdd71d61664b63ae57bdba9ee0d891f78ef79c07 (and 30adb43c897a45c18d7dd163fb4ff40c915fc488). This change broke compiling Qt, see https://github.com/llvm/llvm-project/pull/106585#issuecomment-2365309463 for details.
2024-09-21[Driver][Sparc] Default to -mcpu=v9 for 32-bit Linux/sparc64 (#109278)Rainer Orth1-0/+5
While working on supporting PR #109101 on Linux/sparc64, I was reminded that `clang -m32` still defaults to generating V8 code, although the 64-bit kernel requires a V9 CPU. This patch corrects that. Tested on `sparc64-unknown-linux-gnu`, `x86_64-pc-linux-gnu`, `sparcv9-sun-solaris2.11`, and `amd64-pc-solaris2.11`.
2024-09-20[Clang][Sema] Refactor collection of multi-level template argument lists ↵Krystian Stasiowski1-0/+3
(#106585) Currently, clang rejects the following explicit specialization of `f` due to the constraints not being equivalent: ``` template<typename T> struct A { template<bool B> void f() requires B; }; template<> template<bool B> void A<int>::f() requires B { } ``` This happens because, in most cases, we do not set the flag indicating whether a `RedeclarableTemplate` is an explicit specialization of a member of an implicitly instantiated class template specialization until _after_ we compare constraints for equivalence. This patch addresses the issue (and a number of other issues) by: - storing the flag indicating whether a declaration is a member specialization on a per declaration basis, and - significantly refactoring `Sema::getTemplateInstantiationArgs` so we collect the right set of template argument in all cases. Many of our declaration matching & constraint evaluation woes can be traced back to bugs in `Sema::getTemplateInstantiationArgs`. This change/refactor should fix a lot of them. It also paves the way for fixing #101330 and #105462 per my suggestion in #102267 (which I have implemented on top of this patch but will merge in a subsequent PR).
2024-09-20[Clang] prevented assertion failure by handling integral to boolean ↵Oleksandr T.1-0/+1
conversions for boolean vectors (#108657) Fixes #108326
2024-09-20[AST] Ensure getRawCommentsForAnyRedecl() does not miss any redecl with a ↵Nathan Ridge1-0/+2
comment (#108475) The previous implementation had a bug where, if it was called on a Decl later in the redecl chain than `LastCheckedDecl`, it could incorrectly skip and overlook a Decl with a comment. The patch addresses this by only using `LastCheckedDecl` if the input Decl `D` is on the path from the first (canonical) Decl to `LastCheckedDecl`. An alternative that was considered was to start the iteration from the (canonical) Decl, however this ran into problems with the modelling of explicit template specializations in the AST where the canonical Decl can be unusual. With the current solution, if no Decls were checked yet, we prefer to check the input Decl over the canonical one. Fixes https://github.com/llvm/llvm-project/issues/108145
2024-09-20[C++20] [Modules] Offer -fmodules-embed-all-files option (#107194)Chuanqi Xu1-0/+38
See https://discourse.llvm.org/t/rfc-modules-should-we-embed-sources-to-the-bmi/81029 for details. Close https://github.com/llvm/llvm-project/issues/72383
2024-09-19[clang] Fix python comparison to None (#94014)Eisuke Kawashima1-4/+4
from PEP8 (https://peps.python.org/pep-0008/#programming-recommendations): > Comparisons to singletons like None should always be done with is or is not, never the equality operators. Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2024-09-19Remove clang-pseudo (#109154)Aaron Ballman2-6/+0
The functionality is incomplete and the authors have since shifted gears to other work, so this is effectively unmaintained. The original design document for clang-pseudo can be found at: https://docs.google.com/document/d/1eGkTOsFja63wsv8v0vd5JdoTonj-NlN3ujGF0T7xDbM/edit in case anyone wishes to pick this project back up again in the future. Original RFC: https://discourse.llvm.org/t/removing-pseudo-parser/71131/
2024-09-19[Clang] Fix -ast-dump-decl-types crashes on concepts (#108142)ofAlpaca1-0/+2
Resolve #94928 This PR adds `if (TD->getTemplateDecl())` to prevent `InnerD` becoming `nullptr`, suggested by @firstmoonlight. I also add `-ast-dump-decl-types` option and declare type `CHECK` to the testcase `clang/test/AST/ast-dump-concepts.cpp`. --------- Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2024-09-18[HLSL] Implement elementwise popcount (#108121)Sarah Spall2-0/+2
Add new elementwise popcount builtin to support HLSL function 'countbits'. elementwise popcount only accepts integer types. Add hlsl intrinsic 'countbits' Closes #99094
2024-09-18Remove clang-rename (#108988)Aaron Ballman3-6/+2
clang-rename has largely been superseded by clangd and this project hasn't received much attention in many years. Further, our documentation on it still claims it's in very early stages of development despite being ~10 years old. One of the primary people driving the tool has mentioned that they don't believe there is a reason to continue to support it unless it's still being actively used (https://reviews.llvm.org/D148439#4303202) and I've found no evidence to suggest that is the case. Original RFC: https://discourse.llvm.org/t/rfc-time-to-deprecate-remove-clang-rename/70707
2024-09-18[Clang] Avoid transforming lambdas when rebuilding immediate expressions ↵Younan Zhang1-1/+2
(#108693) When rebuilding immediate invocations inside `RemoveNestedImmediateInvocation()`, we employed a `TreeTransform` to exercise the traversal. The transformation has a side effect that, for template specialization types, their default template arguments are substituted separately, and if any lambdas are present, they will be transformed into distinct types than those used to instantiate the templates right before the `consteval` handling. This resulted in `B::func()` getting redundantly instantiated for the case in question. Since we're also in an immediate evaluation context, the body of `foo()` would also get instantiated, so we end up with a spurious friend redefinition error. Like what we have done in `ComplexRemove`, this patch also avoids the lambda's transformation in TemplateInstantiator if we know we're rebuilding immediate calls. In addition, this patch also consolidates the default argument substitution logic in `CheckTemplateArgumentList()`. Fixes #107175
2024-09-18[clang][Sema] Fix assertion in `tryDiagnoseOverloadedCast` (#108021)Alejandro Álvarez Ayllón1-0/+2
Fixed an assertion failure in debug mode, and potential crashes in release mode, when diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter. For instance ``` template<typename> struct StringTrait {}; template< int N > struct StringTrait< const char[ N ] > { typedef char CharType; static const MissingIntT length = N - 1; }; class String { public: template <typename T> String(T& str, typename StringTrait<T>::CharType = 0); }; class Exception { public: Exception(String const&); }; void foo() { throw Exception("some error"); } ``` `Exception(String const&)` is a matching constructor for `Exception` from a `const char*`, via an implicit conversion to `String`. However, the instantiation of the `String` constructor will fail because of the missing type `MissingIntT` inside the specialization of `StringTrait`. When trying to emit a diagnosis, `tryDiagnoseOverloadedCast` expects not to have a matching constructor, but there is; it just could not be instantiated.
2024-09-17[Clang] Propagate elide safe context through ↵Yuxuan Chen1-1/+4
[[clang::coro_await_elidable_argument]] (#108474)
2024-09-17[Clang] Reject `this void` explicit object parameters (CWG2915) (#108817)Mital Ashok1-0/+3
https://cplusplus.github.io/CWG/issues/2915.html Previously, `struct A { void f(this void); };` was accepted with `A::f` being a member function with no non-object arguments, but it was still a little wonky because it was still considered an explicit object member function. Now, this is rejected immediately. This applies to any language mode with explicit object parameters as this is a DR (C++23 and C++26)
2024-09-17[ast-matcher] Fixed a crash when traverse lambda expr with invalid captures ↵Congcong Cai1-0/+2
(#108689) Fixes: #106444
2024-09-16[clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and ↵Haojian Wu1-0/+2
`[[clang::lifetimebound]]` are used together. (#108280) In the GSL analysis, we don't track the `this` object if the conversion is not from gsl::owner to gsl pointer, we want to be conservative here to avoid triggering false positives. Fixes #108272
2024-09-16[Clang] handle invalid close location in static assert declaration (#108701)Oleksandr T.1-1/+1
Fixes #108687
2024-09-15[CGData] Clang Options (#90304)Kyungwoo Lee1-0/+33
This adds new Clang flags to support codegen (CG) data: - `-fcodegen-data-generate{=path}`: This flag passes `-codegen-data-generate` as a boolean to the LLVM backend, causing the raw CG data to be emitted into a custom section. Currently, for LLD MachO only, it also passes `--codegen-data-generate-path=<path>` so that the indexed CG data file can be automatically produced at link time. For linkers that do not yet support this feature, `llvm-cgdata` can be used manually to merge this CG data in object files. - `-fcodegen-data-use{=path}`: This flag passes `-codegen-data-use-path=<path>` to the LLVM backend, enabling the use of specified CG data to optimistically outline functions. - The default `<path>` is set to `default.cgdata` when not specified. This depends on https://github.com/llvm/llvm-project/pull/108733. This is a patch for https://discourse.llvm.org/t/rfc-enhanced-machine-outliner-part-2-thinlto-nolto/78753.
2024-09-14[ast matcher][NFC] fix typo in release noteCongcong Cai1-1/+1
2024-09-14[C++20] [Modules] Warn for importing implementation partition unit in ↵Chuanqi Xu1-0/+2
interface units (#108493) Recently, there are multiple false positive issue reports about the reachability of implementation partition units: - https://github.com/llvm/llvm-project/issues/105882 - https://github.com/llvm/llvm-project/issues/101348 - https://lists.isocpp.org/core/2024/08/16232.php And according to our use experience for modules, we find it is a pretty good practice to not import implementation partition units in the interface units. It can help developers to have a pretty good mental model for when to use an implementation partition unit: that any unit in the module but not in the module interfaces can be in the implementation partition unit. So I think it is good to add the diagnostics.