Commit Graph

1870 Commits

Author SHA1 Message Date
Alexander Kornienko
b73cd5ec71 Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)"
This reverts commit 924701311a. Causes compilation
errors on valid code, see
https://github.com/llvm/llvm-project/pull/77768#issuecomment-1908062472.

(cherry picked from commit 6e4930c67508a90bdfd756f6e45417b5253cd741)
2024-01-29 14:57:23 -08:00
Andrey Ali Khan Bolshakov
5518a9d767
[c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (#78041)
Previously committed as 9e08e51a20, and
reverted because a dependency commit was reverted, then committed again
as 4b574008ae and reverted again because
"dependency commit" 5a391d38ac was
reverted. But it doesn't seem that 5a391d38ac was a real dependency
for this.

This commit incorporates 4b574008ae and
18e093faf7 by Richard Smith (@zygoloid),
with some minor fixes, most notably:

- `UncommonValue` renamed to `StructuralValue`

- `VK_PRValue` instead of `VK_RValue` as default kind in lvalue and
member pointer handling branch in
`BuildExpressionFromNonTypeTemplateArgumentValue`;

- handling of `StructuralValue` in `IsTypeDeclaredInsideVisitor`;

- filling in `SugaredConverted` along with `CanonicalConverted`
parameter in `Sema::CheckTemplateArgument`;

- minor cleanup in
`TemplateInstantiator::transformNonTypeTemplateParmRef`;

- `TemplateArgument` constructors refactored;

- `ODRHash` calculation for `UncommonValue`;

- USR generation for `UncommonValue`;

- more correct MS compatibility mangling algorithm (tested on MSVC ver.
19.35; toolset ver. 143);

- IR emitting fixed on using a subobject as a template argument when the
corresponding template parameter is used in an lvalue context;

- `noundef` attribute and opaque pointers in `template-arguments` test;

- analysis for C++17 mode is turned off for templates in
`warn-bool-conversion` test; in C++17 and C++20 mode, array reference
used as a template argument of pointer type produces template argument
of UncommonValue type, and
`BuildExpressionFromNonTypeTemplateArgumentValue` makes
`OpaqueValueExpr` for it, and `DiagnoseAlwaysNonNullPointer` cannot see
through it; despite of "These cases should not warn" comment, I'm not
sure about correct behavior; I'd expect a suggestion to replace `if` by
`if constexpr`;

- `temp.arg.nontype/p1.cpp` and `dr18xx.cpp` tests fixed.
2024-01-21 21:28:57 +01:00
Aaron Ballman
997ffce43c [C23] Implement N2490, Remove trigraphs??!
This follows the same implementation logic as with C++ and is
compatible with the GCC behavior in C.

Trigraphs are enabled by default in -std=c* conformance modes before
C23, but are disabled in GNU and Microsoft modes as well as in C23 or
later.
2024-01-21 13:20:56 -05:00
Vlad Serebrennikov
9eb0f86c27
[clang] Implement CWG1878 "operator auto template" (#78103)
C++14 introduced deduced return type for regular functions, but shortly after [CWG1878](https://wg21.link/cwg1878) was filed and resolved to disallow deduced return types in conversion function templates. So this patch diagnoses such usage of deduced return type in C++14 mode onwards.

Fixes #51776
2024-01-20 12:23:08 +04:00
Mital Ashok
924701311a
[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)
Closes #77638, #24186

Rebased from <https://reviews.llvm.org/D156032>, see there for more
information.

Implements wording change in [CWG2137](https://wg21.link/CWG2137) in the
first commit.

This also implements an approach to [CWG2311](https://wg21.link/CWG2311)
in the second commit, because too much code that relies on `T{ T_prvalue}` 
being an elision would break. Because that issue is still open and
the CWG issue doesn't provide wording to fix the issue, there may be
different behaviours on other compilers.
2024-01-19 21:10:51 +01:00
Vlad Serebrennikov
f4fbbebb5e
[clang] Add test for CWG1807 (#77637)
The test checks that objects in arrays are destructed in reverse order during stack unwinding.

This patch is trying to establish a precedent how codegen tests for C++ defect report test suite should be written. Refer to PR for exact reasoning.
2024-01-18 17:14:25 +04:00
cor3ntin
4e64159c86
[Clang] Implement CWG2598: Union of non-literal types (#78195)
A union is considered a literal type unless it has no non-literal
member.

This resolves CWG2096 (which makes unions with literal members literal)
and CWG2598 (empty unions are literal types).

Fixes #77924
2024-01-17 06:16:12 +01:00
Vlad Serebrennikov
91b53a2c79
[clang] Add tests for DRs about complete-class context (#77444)
[P1787](https://wg21.link/p1787): The intent for CWG2335 (contra those of the older CWG1890, CWG1626, CWG1255, and CWG287) is supported by retaining the unrestricted forward lookup in complete-class contexts (despite current implementation behavior for non-templates).

Wording: The declaration set is the result of a single search in the scope of C for N from immediately after the class-specifier of C if P is in a complete-class context of C or from P otherwise. [Drafting note: The plan for CWG2335 is to describe forbidden dependency cycles among the complete-class contexts of a class. — end drafting note] ([class.member.lookup]/4)

Complete-class context is described in [class.mem.general] [p7](http://eel.is/c++draft/class#mem.general-7) and
[p8](http://eel.is/c++draft/class#mem.general-8). In this patch I add tests only for CWG issues that fall under current definition of complete-class context, because I'm not sure how CWG1255 and CWG287 are going to work. That's why I skip over them, but mark CWG1308 as superseded by CWG1330.
2024-01-14 02:27:01 +04:00
Vlad Serebrennikov
d8cd55414f
[clang] Add test for CWG1350 (#78040)
Test is based on [P0136R1](https://wg21.link/p0136r1) wording instead of proposed resolution in the issue itself.

This patch also expands related CWG1573 test with an additional test case. Existing `3.9` status of 1573 is still relevant even with this new test case.
2024-01-14 02:19:25 +04:00
Corentin Jabot
9d97247e26 [clang] Fix color consistency in C paper tracking web page 2024-01-11 10:23:37 +01:00
Corentin Jabot
33e5db6e04 [clang] Improve colors in status tracking web pages.
Use a consistent, more pastel color for unknown status
in papers and issues tracking pages
2024-01-11 10:21:51 +01:00
Vlad Serebrennikov
d0918a20d2
[clang] Add tests for CWG1800-1804 (#77509)
Covers C++ core issues 1800, 1801, 1802, 1803, 1804.
2024-01-10 12:51:04 +04:00
Vlad Serebrennikov
c7d404ea72
[clang] Update cxx_dr_status.html (#77372)
This patch updates `cxx_dr_status.html` to bring it in sync with Core Issues List Revision 113.
2024-01-09 14:52:05 +04:00
Artem Dergachev
ef3f476097 [attributes][analyzer] Implement [[clang::suppress]] - suppress static analysis warnings.
The new attribute can be placed on statements in order to suppress
arbitrary warnings produced by static analysis tools at those statements.

Previously such suppressions were implemented as either informal comments
(eg. clang-tidy `// NOLINT:`) or with preprocessor macros (eg.
clang static analyzer's `#ifdef __clang_analyzer__`). The attribute
provides a universal, formal, flexible and neat-looking suppression mechanism.

Implement support for the new attribute in the clang static analyzer;
clang-tidy coming soon.

The attribute allows specifying which specific warnings to suppress,
in the form of free-form strings that are intended to be specific to
the tools, but currently none are actually supported; so this is also
going to be a future improvement.

Differential Revision: https://reviews.llvm.org/D93110
2023-12-13 18:09:16 -08:00
DonatNagyE
c873f77e87
[analyzer] Move alpha checker EnumCastOutOfRange to optin (#67157)
The checker EnumCastOutOfRange verifies the (helpful, but not
standard-mandated) design rule that integer to enum casts should not
produce values that don't have a corresponding enumerator. As it was
improved and cleaned up by recent changes, this commit renames it from
`alpha.cplusplus.EnumCastOutOfRange` to `optin.core.EnumCastOutOfRange`
to reflect that it's no longer alpha quality.

As this checker handles a basic language feature (which is also present
in plain C), I moved it to a "core" subpackage within "optin".

In addition to the renaming, this commit cleans up the documentation in
`checkers.rst` and adds the new example code to a test file to ensure
that it's indeed producing the behavior claimend in the documentation.
2023-12-12 16:29:37 +01:00
Vlad Serebrennikov
57eb2054e3 [clang][NFC] Fill in historical data on when C++ DRs 2000-2799 were fixed 2023-12-09 11:12:54 +03:00
Vlad Serebrennikov
c79f94d851 [clang][NFC] Fill in historical data on when C++ DRs 700-1999 were fixed 2023-12-08 00:38:42 +03:00
Tom Honermann
53b4689006
[Clang] Mark WG14 N2939 (Identifier Syntax Fixes) as available in Clang 15 (#74666)
WG14 N2939 (Identifier Syntax Fixes) corrects a grammar issue in the C
standard but does not otherwise change intended behavior. This change
updates the C23 status to note this paper as implemented as of Clang 15;
the release in which support for N2836 (Identifier Syntax using Unicode
Standard Annex 31) was implemented.
2023-12-07 12:40:46 -05:00
Vlad Serebrennikov
94708fbc0f [clang][NFC] Fill in historical data on when C++ DRs 600-699 were fixed 2023-12-05 17:16:10 +03:00
Vlad Serebrennikov
e77bfaaf9d [clang][NFC] Fill in historical data on when C++ DRs 500-599 were fixed 2023-12-05 00:42:13 +03:00
Vlad Serebrennikov
f9afe4049a [clang][NFC] Fill in historical data on when C++ DRs 400-499 were fixed 2023-12-04 15:15:40 +03:00
Vlad Serebrennikov
599cba3e7c [clang][NFC] Fill in historical data on when C++ DRs 300-399 were fixed 2023-12-03 16:48:53 +03:00
Vlad Serebrennikov
2f9c922a12 [clang][NFC] Fill in historical data on when C++ DRs 200-299 were fixed 2023-12-02 21:25:00 +03:00
cor3ntin
f40d25151c
[Clang] Implement P2308R1 - Template Parameter Initialization. (#73103)
https://wiki.edg.com/pub/Wg21kona2023/StrawPolls/p2308r1.html

This implements P2308R1 as a DR and resolves CWG2459, CWG2450 and
CWG2049.


Fixes #73666
Fixes #58434 
Fixes #41227
Fixes #49978
Fixes #36296
2023-12-01 17:44:22 +01:00
Vlad Serebrennikov
289fe74ddb [clang][NFC] Fill in historical data on when C++ DRs 100-199 were fixed 2023-12-01 13:43:22 +03:00
Vlad Serebrennikov
bf2e05c7fb [clang][NFC] Fill in historical data on when C++ DR 1-99 were fixed 2023-11-30 02:25:15 +03:00
cor3ntin
1cbd52f791
[Clang] Implement P2864R2 Remove Deprecated Arithmetic Conversion on Enumerations (#73105)
https://isocpp.org/files/papers/P2864R2.pdf
2023-11-29 21:27:17 +01:00
cor3ntin
fdefe88bff
[Clang] Improve support for expression messages in static_assert (#73234)
- Support non-member functions and callable objects for size and data().
We previously tried to (badly) pick the best overload ourselves, in a
way that would only support member functions. We now leave clang
construct an unresolved member expression and call that, properly
performing overload resolution with callable objects and static
functions, consistent with the logic for `get` calls for structured
bindings.
- Support UDLs as message expression.
- Add tests and mark CWG2798 as resolved
2023-11-28 04:28:57 +01:00
Aaron Ballman
8bd06d5b65
[C23] Complete support for WG14 N2508 (#71398)
In Clang 16, we implemented the ability to add a label at the end of a
compound statement. These changes complete the implementation by
allowing a label to be followed by a declaration in C.

Note, this seems to have fixed an issue with some OpenMP stand-alone
directives not being properly diagnosed as per:
https://www.openmp.org/spec-html/5.1/openmpsu19.html#x34-330002.1.3
(The same requirement exists in OpenMP 5.2 as well.)
2023-11-20 10:52:11 -05:00
Corentin Jabot
e70d2a45ea [Clang] Add the list of papers approved in Kona
This is a rather short list that does not include the list
of resolvded CWG issues, which is rather long (P3046).

Some of the links are currently invalid as they have yet to be
publicly published.
2023-11-11 09:03:49 -10:00
Vlad Serebrennikov
a9070f22a2 [clang][NFC] Refactor CXXConstructExpr::ConstructionKind
This patch converts `CXXConstructExpr::ConstructionKind` into a scoped enum in namespace scope, making it eligible for forward declaring. This is useful in cases like annotating bit-fields with `preferred_type`.
2023-11-05 16:38:45 +03:00
zijunzhao
3694697003 [clang] Implement C23 <stdckdint.h>
https://github.com/llvm/llvm-project/issues/62248

Reviewed By: yabinc, aaron.ballman, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D157331
2023-10-17 00:51:21 +00:00
Aaron Ballman
2ef158752a Update Clang's Getting Involved page
* Downplay cfe-commits as a place where design discussion happens.
  Instead, call it out as a place for historical information.
* Add a link to Discord
* Add a link to Office Hours
2023-10-15 09:41:39 -04:00
Viktor Cseh
0e246bb675 [clang][analyzer] Add C++ array delete checker
This checker reports cases where an array of polymorphic objects are
deleted as their base class. Deleting an array where the array's static
type is different from its dynamic type is undefined.

Since the checker is similar to DeleteWithNonVirtualDtorChecker, I
refactored that checker to support more detection types.

This checker corresponds to the SEI Cert rule EXP51-CPP: Do not delete
an array through a pointer of the incorrect type.

Differential Revision: https://reviews.llvm.org/D158156
2023-10-10 09:37:02 +01:00
Guillot Tony
13ffc61a42 [C2X] N3007 Type inference for object definitions
Re-landing 5d78b78c85 which was reverted.

This patches implements the auto keyword from the N3007 standard
specification.
This allows deducing the type of the variable like in C++:
```
auto nb = 1;
auto chr = 'A';
auto str = "String";
```
The list of statements which allows the usage of auto:

    * Basic variables declarations (int, float, double, char, char*...)
    * Macros declaring a variable with the auto type

The list of statements which will not work with the auto keyword:

    * auto arrays
    * sizeof(), alignas()
    * auto parameters, auto return type
    * auto as a struct/typedef member
    * uninitialized auto variables
    * auto in an union
    * auto as a enum type specifier
    * auto casts
    * auto in an compound literals

Differential Revision: https://reviews.llvm.org/D133289
2023-10-05 12:16:00 -04:00
Aaron Ballman
dc1000d5b2 Revert "[C2X] N3007 Type inference for object definitions"
This reverts commit 5d78b78c85.

Reverting due to the failure found by:
https://lab.llvm.org/buildbot/#/builders/245/builds/14999
2023-10-05 08:52:12 -04:00
Guillot Tony
5d78b78c85 [C2X] N3007 Type inference for object definitions
This patches implements the auto keyword from the N3007 standard
specification.
This allows deducing the type of the variable like in C++:
```
auto nb = 1;
auto chr = 'A';
auto str = "String";
```
The list of statements which allows the usage of auto:

    * Basic variables declarations (int, float, double, char, char*...)
    * Macros declaring a variable with the auto type

The list of statements which will not work with the auto keyword:

    * auto arrays
    * sizeof(), alignas()
    * auto parameters, auto return type
    * auto as a struct/typedef member
    * uninitialized auto variables
    * auto in an union
    * auto as a enum type specifier
    * auto casts
    * auto in an compound literals

Differential Revision: https://reviews.llvm.org/D133289
2023-10-05 08:11:02 -04:00
Vlad Serebrennikov
e0cb340f8e
[clang] Bump latest release to 17 for C++ DR Status page (#67996)
`make_cxx_dr_status` has a hardcoded number of the latest release, for the purpose of determining whether a particular DR is available to users or not yet. I'm bumping it to 17.
2023-10-02 22:05:36 +04:00
Vlad Serebrennikov
c2fd3ebe83
[clang] Add test for CWG2267 (#67931)
https://cplusplus.github.io/CWG/issues/2267.html
Related: #63416
2023-10-02 20:00:41 +04:00
Vlad Serebrennikov
1a3a1d9674
[clang] Add check for duplicates to make_cxx_dr_status script (#67969)
While working on #67965, I stumbled upon the fact that `make_cxx_dr_status` script doesn't check for duplicated comment (last comment wins), so I added this check.

It even found another instance of duplicated comment: CWG1223 was marked as CWG1227. I fixed status of the former.
2023-10-02 18:34:37 +04:00
Vlad Serebrennikov
0e87f6f8c2
[clang] Add test for CWG1341 (#67965)
https://cplusplus.github.io/CWG/issues/1341.html
https://wg21.link/p0683r1
2023-10-02 18:21:49 +04:00
Corentin Jabot
af4751738d [C++] Implement "Deducing this" (P0847R7)
This patch implements P0847R7 (partially),
CWG2561 and CWG2653.

Reviewed By: aaron.ballman, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D140828
2023-10-02 14:33:02 +02:00
David Spickett
604a231881 [clang][www] Change 'clang-test' to 'check-clang' on the hacking webpage
This change is https://reviews.llvm.org/D49549 ported to the monorepo layout.

Patch by Arnaud Coomans.

Patch title and message:
```
Change 'clang-test' to 'check-clang' on the hacking webpage

The command to run tests was previously changed from 'clang-test' to 'check-clang'; with 'clang-test' remaining available as a legacy alias (see git-svn-id: https://reviews.llvm.org/rC159483 91177308-0d34-0410-b5e6-96231b3b80d8).

This commit changes the www documentation accordingly.
```
2023-09-21 08:42:57 +00:00
Corentin Jabot
a041572353 Let the c(xx)_status pages reflect that clang 17 is released 2023-09-19 20:28:45 +02:00
Aaron Ballman
1db6b127a1 [C23] Remove N2713 from the list
This paper was obsoleted by the changes in N3138 and US-045
2023-09-14 12:08:51 -04:00
Christopher Di Bella
8f3b0b4171 [clang] adds __reference_constructs_from_temporary
This is information that the compiler already has, and should be exposed
so that the library doesn't need to reimplement the exact same
functionality.

Differential Revision: https://reviews.llvm.org/D135341
2023-09-13 23:51:43 +00:00
Christopher Di Bella
dfd1d8d505 Revert "adds __reference_constructs_from_temporary"
I'm reverting this on principle, since it didn't get the Phabricator
approval I thought it had (only an informal LGTM). Will re-apply once
it has been properly approved.

This reverts commit e1bfeb6bcc.
2023-09-11 23:44:50 +00:00
Christopher Di Bella
e1bfeb6bcc adds __reference_constructs_from_temporary
This is information that the compiler already has, and should be exposed
so that the library doesn't need to reimplement the exact same
functionality.

Differential Revision: https://reviews.llvm.org/D135341
2023-09-11 23:14:08 +00:00
Aaron Ballman
ec70337d13 Correct minimum Visual Studio version requirements
We bumped the requirements to MSVC 2019 16.7 in 2022:
https://discourse.llvm.org/t/rfc-increasing-the-gcc-and-clang-requirements-to-support-c-17-in-llvm/59983
but missed updating these docs.
2023-09-06 15:18:55 -04:00
Aaron Ballman
a02f9a7756 Revert "[clang] Enable sized deallocation by default in C++14 onwards"
This reverts commit 2916b125f6.

Reverting due to failures on:
https://lab.llvm.org/buildbot/#/builders/216/builds/26407
https://lab.llvm.org/staging/#/builders/247/builds/5659
http://45.33.8.238/win/83485/step_7.txt
2023-08-29 09:36:59 -04:00