2021 Commits

Author SHA1 Message Date
yronglin
c91e85278c
Revert "[Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros" (#99838)
Reverts llvm/llvm-project#90574
2024-07-22 13:16:51 +08:00
yronglin
e77a01d79a
[Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (#90574)
This PR implement [P3034R1 Module Declarations Shouldn’t be
Macros](https://wg21.link/P3034R1), and refactor the convoluted state
machines in module name lexical analysis.

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2024-07-20 20:41:00 +08:00
Mital Ashok
329e7c80ac
[Clang] [C23] Implement N2653: u8 strings are char8_t[] (#97208)
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2653.htm

Closes #97202

---------

Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2024-07-17 14:14:31 +02:00
cor3ntin
b330d800cb
Reapply [Clang][C++26] Implement "Ordering of constraints involving fold expressions (#99022)
Implement https://isocpp.org/files/papers/P2963R3.pdf
2024-07-17 07:52:40 +02:00
cor3ntin
762a47828e
Revert "[Clang][C++26] Implement "Ordering of constraints involving fold expressions" (#99007)
Reverts llvm/llvm-project#98160

Breaks CI on some architectures
2024-07-16 11:00:27 +02:00
cor3ntin
2448927359
[Clang][C++26] Implement "Ordering of constraints involving fold expressions (#98160)
Implement https://isocpp.org/files/papers/P2963R3.pdf
2024-07-16 10:39:06 +02:00
Aaron Ballman
ac2426e08e [C2y] Claim conformance to WG14 N3232
This is an editorial change, so no tests were added
2024-07-12 10:50:48 -04:00
Aaron Ballman
2c2148de85
[C2y] Add documentation to conform to WG14 N3262; NFC (#98146)
This paper is about whether a copy of a va_list object which was not
produced by calling va_copy is valid to use or not. While this may work
on some targets, we explicitly document it as undefined behavior for all
targets so there's not confusion as to when it's valid or not. It's not
a burden for a user to use va_copy explicitly.
2024-07-12 07:07:27 -04:00
Aaron Ballman
0913547d0e
[C2y] Claim partial conformance to WG14 N3244 (#98525)
This paper had several changes within it, and Clang implements some of
the changes, but not others. This updates the status accordingly.
2024-07-12 06:54:42 -04:00
Aaron Ballman
c22625cb3e
[C2y] Remove support for _Imaginary (#97436)
WG14 N3274 removed _Imaginary from Annex G. Clang has never fully
supported Annex G or _Imaginary, so removal is pretty trivial for us.

Note, we are keeping _Imaginary as a keyword so that we get better
diagnostic behavior. This is still conforming because _I makes it a
reserved identifier, so it's not available for users to use as an
identifier anyway.
2024-07-08 13:43:03 -04:00
Aaron Ballman
ba1d21c7d8
[C2y] Claim conformance to WG14 N3254 (#97581)
The test coverage for this has to lean on LLVM's test coverage for the
actual TBAA behavior, but this demonstrates that Clang emits reasonable
LLVM IR to support this construct. It would be surprising should LLVM
break this pattern given how ubiquitous the pattern is in the wild.

The paper can be found at:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3254.pdf
2024-07-08 09:13:24 -04:00
cor3ntin
e55585fd7b
[Clang] Fix typo in cxx_status.html 2024-07-06 16:18:20 +02:00
Vlad Serebrennikov
788731cdbd
[clang] Implement P3144R2 "Deleting a Pointer to an Incomplete Type..." (#97733)
This patch implements (not yet published)
[P3144R2](https://wiki.edg.com/pub/Wg21stlouis2024/StrawPolls/p3144r2.pdf)
"Deleting a Pointer to an Incomplete Type Should be Ill-formed". Wording
changes (not yet merged into the working draft) read:
> 7.6.2.9 [expr.delete] Delete
> If the object being deleted has incomplete class type at the point of
deletion <del>and the complete class has a
non-trivial destructor or a deallocation function, the behavior is
undefined</del>, <ins>the program is ill-formed</ins>.

We preserve status quo of emitting a warning when deleting a pointer to
incomplete type up to, and including, C++23, but make it ill-formed
since C++26. Same goes for deleting pointers to `void`, which has been
allowed as an extension.
2024-07-05 22:27:04 +04:00
Endre Fülöp
093aaca2b0
[clang][analyzer][doc] Migrate user-related docs from HTML to RST (#97034)
User documentation currently found at https://clang-analyzer.llvm.org is migrated to RST format.

This commit migrates all the relevant content, including suspicious or even clearly outdated parts. These issues will be cleaned up in separate follow-up commits (where the diff is not obscured by the format change). However, a few typos are fixed, and some parts (availability of binary releases, integration with XCode) are marked (with [Legacy] tags) to highlight that they are outdated.

The primary motivation for this change is to update the facts in the docs and make them discoverable from the RST-generated doc-tree as well (many subpages are not accessible at all, as the menu generation for the HTML-based page is not working at all).


This commit migrates all the relevant content, including parts that are
suspicious or even clearly outdated. These issues will be cleaned up in
separate follow-up commits (where the diff is not obscured by the format
change). However, a few typos are fixed and some parts (availability of
binary releases, integration with XCode) are marked (with [Legacy] tags)
to highlight that they are outdated.

The primary motivation for this change is to update the facts in the
docs and make them discoverable from the RST-generated doc-tree as well
(many subpages are not accessible **at all**, as the menu generation for
the HTML based page is not working at all).
2024-07-05 08:16:53 +02:00
Endre Fülöp
3cab132e94
[clang][analyzer][doc] Migrate checkers-related docs from HTML to RST (#97032)
Documentation for the checkers is kept up to date in RST files.
This patch removes duplication by replacing the HTML docs with links to
docs generated from the RST.
2024-07-04 15:02:28 +02:00
Aaron Ballman
aa3c84c85c Clang 19 isn't yet released; NFC
...just updates the colors in the table.
2024-07-03 10:36:12 -04:00
Aaron Ballman
bcb7c38af7
[C23] Add INFINITY and NAN macros to <float.h> (#96659)
This is in support of WG14 N2848 which only define the macros if
an infinity or nan are supported. However, because we support builtins
that can produce an infinity or a NAN, and because we have pragmas
that control infinity or NAN behavior, we always define the macros even
if the user passed -ffinite-math-only on the command line.
2024-07-03 07:23:44 -04:00
Aaron Ballman
b67d557bd3 [C2y] Add -std=c2y and -std=gnu2y
This adds a language standard mode for the latest C standard. While
WG14 is hoping for a three-year cycle, it is not clear that the next
revision of C will be in 2026 and so a flag was not created for c26
specifically.
2024-07-02 07:00:19 -04:00
Aaron Ballman
7888d66af2 [C2y] Add C2y documents to the tracking page
These documents were adopted in the past two meetings; the current
working draft doesn't yet incorporate them however.
2024-07-01 14:17:57 -04:00
Corentin Jabot
101a936bde [Clang] dd the papers adopted in St Louis to the status page 2024-06-29 09:23:41 -05:00
Aaron Ballman
a0869331ec [C11] Remove WG14 N1537 from the status page
This paper was a rewording of WG14 N1485, correcting terminology and
bringing the C11 feature slightly closer in line with the C++11
feature. There is nothing additional to be done or test to conform to
what was specified by WG14 N1537, so we'll remove the entry and lean on
N1485 to track status for atomics.
2024-06-25 14:02:05 -04:00
Aaron Ballman
5e2beed9a1 [C23] Move WG14 N2931 to the TS18661 section
This paper only matters for TS18661-3 integration.
2024-06-25 12:46:41 -04:00
Aaron Ballman
05ca207441 [C23] Update status page regarding FLT_MAX_EXP
N2843 was subsumed by N2882; we could probably consider removing
subsumed entries, but I've been leaving them to help folks looking at
the editor's report from various working drafts and wondering about the
changes.
2024-06-25 12:34:34 -04:00
Aaron Ballman
fb463e154e [C23] Remove WG14 N2379 from the C status page
This paper was adopted at the Oct 2019 meeting in Ithaca, but the
changes from the paper were later removed (editorially) by the C
Floating Point study group due to being incorrect and unnecessary.
2024-06-25 10:34:39 -04:00
Aaron Ballman
2ae0905247 [C23] Claim we do not conform to N2819
This paper clarified the lifetime of compound literal objects in odd
scopes, such as use at function prototype scope.

We do not currently implement this paper, as the new test demonstrates.
2024-06-24 15:09:20 -04:00
Aaron Ballman
d6a3bd1325
Update Clang extension criteria (#96532)
This updates Clang's extension criteria to explicitly mention impacts on
other projects within the monorepo.

These changes were discussed in the following RFC:
https://discourse.llvm.org/t/rfc-require-discussion-of-impact-to-monorepo-stakeholders-when-adding-new-clang-extensions/79613
2024-06-24 15:06:11 -04:00
Aaron Ballman
3e36dfafa0 [C23] Remove WG14 N2660 from the list of papers we track
This paper was a clarification paper that made no normative changes to
the wording, so we can lean on the C99 status for this.
2024-06-24 11:12:18 -04:00
Aaron Ballman
b012ab01cb [C23] Claim conformance to WG14 N3033
Clang has implemented __VA_OPT__ since Clang 12.
2024-06-24 10:52:17 -04:00
Aaron Ballman
6ecb9fd83d [C11] Remove WG14 N1382 from the list of papers to track
This paper proposes only changes to a footnote that had problematic
implications for ABI; the changes were purely editorial.
2024-06-24 10:34:11 -04:00
Aaron Ballman
29e0f04673 [C11] Remove WG14 N1353 from the list of papers to track
Only the first proposed changes in the paper were adopted, and that
wording was changing "operations" into "operators", which is purely an
editorial change.
2024-06-24 10:29:15 -04:00
Aaron Ballman
3ff680a1a5 [C11] Claim we do not conform to WG14 N1285 yet
This also updates the status for C11 to be Partial, and because C17 is
C11 plus DR resolutions, that makes C17 also Partial.
2024-06-24 09:50:37 -04:00
A. Jiang
2151ba0362
[Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (#68846)
List the following C++23-era WG21 papers as Defect Reports in
cxx_status.html as per WG21 meeting minutes.

- [P1949R7](https://wg21.link/p1949r7) (C++ Identifier Syntax using
Unicode Standard Annex 31)
 - [P2156R1](https://wg21.link/p2156r1) (Allow Duplicate Attributes)
- [P2036R3](https://wg21.link/p2036r3) (Change scope of lambda
_trailing-return-type_)
- [P2468R2](https://wg21.link/p2468r2) (The Equality Operator You Are
Looking For)
- [P2327R1](https://wg21.link/p2327r1) (De-deprecating `volatile`
compound operations)
- [P2493R0](https://wg21.link/p2493r0) (Missing feature test macros for
C++20 core papers)
- [P2513R3](https://wg21.link/p2513r3) (`char8_t` Compatibility and
Portability Fix)
- [P2460R2](https://wg21.link/p2460r2) (Relax requirements on `wchar_t`
to match existing practices)
- [P2579R0](https://wg21.link/p2579r0) (Mitigation strategies for
[P2036](https://wg21.link/p2036) ”Changing scope for lambda
_trailing-return-type_”)
2024-06-24 13:16:47 +04:00
Aaron Ballman
918ef312d1 [C99] Claim full conformance to C99
We now believe we know the status of all the proposals that went into
C99. There are three entries marked Partial:

N448 restricted pointers
------------------------
Clang fully conforms to the standard requirements, but LLVM support
could be improved to support more than just restricted pointers used
as function parameters.

N693 complex and imaginary support in <complex.h>
-------------------------------------------------
Clang supports _Complex but not _Imaginary. Clang does not attempt to
implement Annex G, so a lack of _Imaginary is not necessary for
conformance to C99. It's also worth noting that C2y is anticipated to
remove support for _Imaginary (see WG14 N3274 which was adopted at the
June 2024 meeting).

However, support for _Complex requires runtime support and compiler-rt
is not supported on all targets (notably, Windows).

(Doc # unknown) IEC 60559 support
---------------------------------
Clang largely conforms to the requirements in Annex F, but there are
edge cases that are incorrect. However, Clang does not predefine the
__STDC_IEC_559__ macro and so we don't claim to conform to Annex F yet.

Because all three of these partial entries are technically conforming,
it seems reasonable to claim full conformance for C99.
2024-06-21 13:47:57 -04:00
Aaron Ballman
131bc0390d [C99] Claim partial conformance to IEC 60559 support
We intend to support Annex F but there are edge cases we don't handle
properly, such as raising an "invalid" exception when converting some
floating-point values to integers.

This does not add any test coverage as full conformance would require
sufficiently extensive testing that we should consider getting a
third-party test suite such as the one from http://tybor.com/
2024-06-21 13:28:02 -04:00
Aaron Ballman
19470e72e4 [C99] Claim conformance to "more precise aliasing rules via effective type"
We don't have a document number to check our behavior against, but the
document title makes it clear that this is related to optimization
behavior, which doesn't require Clang to change.
2024-06-21 12:48:01 -04:00
Vlad Serebrennikov
2b5d1fb889
[clang] Add test for CWG2811 "Clarify "use" of main" (#96168)
This patch covers
[CWG2811](https://cplusplus.github.io/CWG/issues/2811.html) "Clarify
"use" of main", basically adding a test for `-Wmain`, focusing on usages
of `main` in unevaluated contexts.

To my understanding, the diagnostic message is based on the wording, so
I updated it based on the new wording. I also replaces "ISO C++
requires" with a phrasing that explicitly says "extension".
2024-06-21 13:50:03 +04:00
Vlad Serebrennikov
bc4d50f02d
[clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (#95399)
This patch implements 2024-05-31 resolution of a tentatively ready issue
[CWG2877](https://cplusplus.github.io/CWG/issues/2877.html) "Type-only
lookup for using-enum-declarator", which supersedes earlier
[CWG2621](https://cplusplus.github.io/CWG/issues/2621.html) "Kind of
lookup for `using enum` declarations".

Now we perform type-only lookup (not to be confused with type-only
context) for `elaborated-enum-declarator`. This is the same kind of
lookup that elaborated type specifiers and base specifiers undergo.

I also found out (and fixed) that one of our existing tests claimed that
a dependent type can be used in `elaborated-enum-declarator`, but that's
not the case:
> The
[using-enum-declarator](http://eel.is/c++draft/enum.udecl#nt:using-enum-declarator)
shall designate a non-dependent type with a reachable
[enum-specifier](http://eel.is/c++draft/dcl.enum#nt:enum-specifier)[.](http://eel.is/c++draft/enum.udecl#1.sentence-2)
2024-06-21 13:49:43 +04:00
Vlad Serebrennikov
aed989157d
[clang] Cover CWG issues about export template (#94876)
This PR covers the following Core issues:
[CWG204](https://cplusplus.github.io/CWG/issues/204.html) "Exported
class templates"
[CWG323](https://cplusplus.github.io/CWG/issues/323.html) "Where must
`export` appear?"
[CWG335](https://cplusplus.github.io/CWG/issues/335.html) "Allowing
`export` on template members of nontemplate classes"
[CWG820](https://cplusplus.github.io/CWG/issues/820.html) "Deprecation
of `export`"

I believe the list above is entirety of Core issues that are dedicated
solely to `export template`.

I believe we have two main points of view here, which command what this
PR should do:
1. (easy) Removal of `export template` was done as a defect report in
CWG820, and the rest are effectively superseded by it, because we apply
defect reports retroactively.
2. (harder) Those Core issues are testable individually, so we should
test them for the behavior Core wanted at the time.

This PR implements the first option, making our C++ DR status page
greener.
I think I can be persuaded to go with the second option, if reviewers
have strong preference for it.
2024-06-21 13:49:04 +04:00
Aaron Ballman
6bc71cdd32 [C99] Claim partial conformance to n448
This is the paper that added the 'restrict' keyword. Clang is
conforming to the letter of the standard's requirements, so it would be
defensible for us to claim full support instead. However, LLVM does not
currently support the optimization semantics with restricted local
variables or data members, only with restricted pointers declared in
function parameters. So we're only claiming partial support because we
don't yet take full advantage of what the feature allows.
2024-06-20 13:29:36 -04:00
Aaron Ballman
40a0ad2af3 [C11] Claim conformance to WG14 N3159
This was a roll-up of defect reports that we already test elsewhere, so
no additional test coverage is needed.

DR345: tested by clang/test/C/drs/dr3xx.c
DR344: tested by clang/test/C/drs/dr3xx.c
DR343: tested by clang/test/C/drs/dr3xx.c
DR341: tested by clang/test/C/drs/dr3xx.c
DR340: tested by clang/test/C/drs/dr3xx.c
DR338: tested by clang/test/C/drs/dr338.c
DR336: N/A for the compiler
DR330: N/A for the compiler
DR329: N/A for the compiler
DR328: tested by clang/test/C/drs/dr3xx.c
DR327: editorial
DR326: N/A for the compiler
DR315: tested by clang/test/C/drs/dr3xx.c
2024-06-20 10:26:13 -04:00
Aaron Ballman
b84323cca9 [C11] Remove N1350 and N1394 from the list of documents on the C status page
These papers added Annex K, which is a library component that Clang
doesn't need to do anything to support.
2024-06-20 10:02:22 -04:00
Mariya Podchishchaeva
41c6e43792
Reland [clang][Sema, Lex, Parse] Preprocessor embed in C and C++ (#95802)
This commit implements the entirety of the now-accepted [N3017
-Preprocessor
Embed](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3017.htm) and
its sister C++ paper [p1967](https://wg21.link/p1967). It implements
everything in the specification, and includes an implementation that
drastically improves the time it takes to embed data in specific
scenarios (the initialization of character type arrays). The mechanisms
used to do this are used under the "as-if" rule, and in general when the
system cannot detect it is initializing an array object in a variable
declaration, will generate EmbedExpr AST node which will be expanded by
AST consumers (CodeGen or constant expression evaluators) or expand
embed directive as a comma expression.

This reverts commit
682d461d5a.

---------

Co-authored-by: The Phantom Derpstorm <phdofthehouse@gmail.com>
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
Co-authored-by: cor3ntin <corentinjabot@gmail.com>
Co-authored-by: H. Vetinari <h.vetinari@gmx.com>
2024-06-20 14:38:46 +02:00
Vlad Serebrennikov
993c12b317
[clang] Change style of superseded issues on C++ DR status page (#96051)
This patch changes how superseded issues inherit the color of the issues
that superseded them. Now they reduce the opacity of the color from 1.0
to 0.65, to make them distinguishable. This was requested during the
review of #94876.

That's how it's going to look:

![a1rYVHQ](https://github.com/llvm/llvm-project/assets/12883766/00e624c0-accb-4440-9f9b-4089a157aab2)
2024-06-20 15:54:43 +04:00
Mital Ashok
3ad31e12cc
[Clang] Introduce CXXTypeidExpr::hasNullCheck (#95718)
Used to implement CWG2191 where `typeid` for a polymorphic glvalue only
becomes potentially-throwing if the `typeid` operand was already
potentially throwing or a `nullptr` check was inserted:
https://cplusplus.github.io/CWG/issues/2191.html

Also change `Expr::hasSideEffects` for `CXXTypeidExpr` to check the
operand for side-effects instead of always reporting that there are
side-effects

Remove `IsDeref` parameter of `CGCXXABI::shouldTypeidBeNullChecked`
because it should never return `true` if `!IsDeref` (we shouldn't add a
null check that wasn't there in the first place)
2024-06-17 19:31:54 +02:00
Vlad Serebrennikov
d340f6283a [clang][NFC] Update C++ DR issues list 2024-06-17 00:22:47 +03:00
Vlad Serebrennikov
71e4d70f0b [clang][NFC] Update CWG issues list 2024-06-13 14:37:04 +03:00
Younan Zhang
b53e0854a1
Revert "[clang][NFC] Add a test for CWG2685" (#95389)
I was wrong: The purpose of CWG2685 is to avoid brace elision on string
literals and we should be rejecting the case.

Reverts llvm/llvm-project#95206
2024-06-13 19:28:00 +08:00
Younan Zhang
3475116e2c
[clang][NFC] Add a test for CWG2685 (#95206)
I believe it has been implemented since D139837 "Implements CTAD for
aggregates P1816R0 and P2082R1", so this just claims we have already
supported it.

Plus an update on the dr status page.
2024-06-13 17:45:36 +08:00
Vitaly Buka
682d461d5a
Revert " [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy)" (#95299)
Reverts llvm/llvm-project#68620

Introduce or expose a memory leak and UB, see llvm/llvm-project#68620
2024-06-12 13:14:26 -07:00
Donát Nagy
d9a508db55
[analyzer] Finish moving alpha.core.SizeofPtr to clang-tidy (#95118)
The checker `alpha.core.SizeofPtr` was a very simple checker that did
not rely on path sensitive analysis and was very similar to the (more
complex and refined) clang-tidy check `bugprone-sizeof-expression`.

As there is no reason to maintain two separate implementations for the
same goal (and clang-tidy is more lightweight and accessible than the
Analyzer) I decided to move this functionality from the Static Analyzer
to clang-tidy.

Recently my commit 546c816a529835a4cf89deecff957ea336a94fa2
reimplemented the advantageous parts of `alpha.core.SizeofPtr` within
clang-tidy; now this commit finishes the transfer by deleting
`alpha.core.SizeofPtr`.
2024-06-12 14:26:47 +02:00