Commit Graph

3807 Commits

Author SHA1 Message Date
Fangrui Song 9f07256a51 [Driver] -p: change from unused warning to error for most targets
AIX and OpenBSD seem to use -p. For most targets (at least FreeBSD and Linux),
-p is legacy (GCC freebsd has a warning). We don't want the uses to grow, so
making -p an alias for -pg is not recommended. I think the uses are small.

Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D138255
2022-12-02 18:57:48 +00:00
KAWASHIMA Takahiro 498abe27dc [clang][docs] Correct floating point option explanations
Explanations for options of floating point are updated to match
the `RenderFloatingPointOptions` function in
`clang/lib/Driver/ToolChains/Clang.cpp`.

Missing explanations are also added.

Differential Revision: https://reviews.llvm.org/D138117
2022-12-02 17:50:13 +09:00
Erich Keane d5fc931ba7 Remove some trailing WS from the release notes 2022-12-01 13:37:19 -08:00
Shafik Yaghmour ef10f81985 [Clang] Adjust assert from Sema::BuildCXXTypeConstructExpr
Currently Sema::BuildCXXTypeConstructExpr asserts that list initialization must
mean we have an InitListExpr as well. We have several cases of valid code the
result in CXXTemporaryObjectExpr in the AST instead for list initialization.
Commit 1ae689c seems to indicate that this is not unexpected, although may be a
design issue

This fixes:

  https://github.com/llvm/llvm-project/issues/58302
  https://github.com/llvm/llvm-project/issues/58753
  https://github.com/llvm/llvm-project/issues/59100

Differential Revision: https://reviews.llvm.org/D138947
2022-12-01 09:40:18 -08:00
Corentin Jabot 9221bedfd7 Revert "Implement CWG2631"
This reverts commit 26fa17ed29.
This reverts commit 4403c4f9e7.

There is still an ODR issue causing linker errors, investigating.
2022-11-30 16:03:05 +01:00
Aaron Ballman 11e51d9dfc Remove 'modindex' from the Clang docs
This was added in the initial commit to use Sphinx ~12 years ago, but
is a dead link in our docs. Removing it and the python bits that appear
to be unused.
2022-11-30 09:37:49 -05:00
Aaron Ballman bb1eca6bbb Fix Clang sphinx build
This addresses the issue found by:
https://lab.llvm.org/buildbot/#/builders/92/builds/36449
2022-11-30 07:52:59 -05:00
Sara Bellei 3ae07a4372 [clang-repl] Add basic documentation about clang-repl
Differential revision: https://reviews.llvm.org/D138698
2022-11-30 12:30:33 +00:00
Corentin Jabot 4403c4f9e7 [Clang] Remove conflict markers from ReleaseNotes 2022-11-30 11:27:16 +01:00
Corentin Jabot 26fa17ed29 Implement CWG2631
Implement https://cplusplus.github.io/CWG/issues/2631.html.

Immediate calls in default arguments and defaults members
are not evaluated.

Instead, we evaluate them when constructing a
`CXXDefaultArgExpr`/`BuildCXXDefaultInitExpr`.

The immediate calls are executed by doing a
transform on the initializing expression.

Note that lambdas are not considering subexpressions so
we do not need to transform them.

As a result of this patch, unused default member
initializers are not considered odr-used, and
errors about members binding to local variables
in an outer scope only surface at the point
where a constructor is defined.

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

Differential Revision: https://reviews.llvm.org/D136554
2022-11-30 11:25:01 +01:00
Mike Rice 530eb263c0 [clang] Add serialization for loop hint annotation tokens
When late parsed templates are used with PCH tokens are serialized. The
existing code does not handle annotation tokens which can occur due to
various pragmas.

This patch implements the serialization for annot_pragma_loop_hint.

This also enables use of OpenMP pragmas and #pragma unused which do not
need special serialization of the PtrData field.

Fixes https://github.com/llvm/llvm-project/issues/39504

Differential Revision: https://reviews.llvm.org/D138453
2022-11-29 10:51:11 -08:00
Shafik Yaghmour 54be300f7e [Clang] Fix Sema::ClassifyName so that it classifies EnumConstantDecl as NonType when they are brought into scope via using enum
Currently Sema::ClassifyName(...) in some cases when an enumerator is brought
into scope via using enum during lookup it can end up being classified as an
OverloadSet. It looks like this was never accounted for when using enum support
was implemented and we need to add a check to allow an EnumConstantDecl to be
classified as NonType even when it is a class member.

This fixes:
  https://github.com/llvm/llvm-project/issues/58057
  https://github.com/llvm/llvm-project/issues/59014
  https://github.com/llvm/llvm-project/issues/54746

Differential Revision: https://reviews.llvm.org/D138091
2022-11-29 10:39:21 -08:00
Aaron Ballman 7b5d5250be Fix Clang sphinx build
This addresses the issue found by:
https://lab.llvm.org/buildbot/#/builders/92/builds/36372
2022-11-29 12:01:25 -05:00
Corentin Jabot b12aea6659 [Clang] Implement CWG2654: Un-deprecation of compound volatile assignments
Reviewed By: #clang-language-wg, erichkeane

Differential Revision: https://reviews.llvm.org/D138918
2022-11-29 17:15:39 +01:00
Roy Jacobson 13c3228835 [Clang] Implement LWG3823 for __is_aggregate
LWG3823 says that arrays of incomplete types are aggregates. Fix the clang builtin to match that.

Closes https://github.com/llvm/llvm-project/issues/59002

Reviewed By: cjdb

Differential Revision: https://reviews.llvm.org/D138603
2022-11-29 14:57:47 +02:00
Roy Jacobson 3faf1f17a5 [Clang] Implement static operator[]
After accepted in Kona, update the code to accept static operator[] as well.

No big code changes: accept this operator as static in SemaDeclCXX, update AST call generation in SemaOverload and update feature macros + tests accordingly.

Reviewed By: cor3ntin, erichkeane, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D138387
2022-11-29 12:39:52 +02:00
Erich Keane 07008a8df5 CWG2635: Disallow constrained structured bindings.
CWG2635 prohibits adding a constraint to a structured as a defect
report.  This patch implements that restriction.

Differential Revision: https://reviews.llvm.org/D138852
2022-11-28 14:41:14 -08:00
Corentin Jabot 5607fc002d [Clang] Permit static constexpr variables in constexpr functions
This implement the C++23 paper P2647R1 (adopted in Kona)

Reviewed By: #clang-language-wg, erichkeane

Differential Revision: https://reviews.llvm.org/D138851
2022-11-28 21:38:31 +01:00
Luke Nihlen afd800fc56 [clang] Require parameter pack to be last argument in concepts.
Fixes GH48182.
2022-11-28 18:40:19 +00:00
Erich Keane 9061928ebb Stop accepting 'bool' in a concept declaration as an extension.
We no longer support the concepts-ts flag for this release, so stop
supporting this concepts-ts compat extension as well.
2022-11-28 10:22:54 -08:00
Balazs Benics dbb94b415a [analyzer] Remove the unused LocalCheckers.h header 2022-11-28 13:08:38 +01:00
Balazs Benics 097ce76165 [analyzer] Deprecate FAM analyzer-config, recommend -fstrict-flex-arrays instead
By default, clang assumes that all trailing array objects could be a
FAM. So, an array of undefined size, size 0, size 1, or even size 42 is
considered as FAMs for optimizations at least.

One needs to override the default behavior by supplying the
`-fstrict-flex-arrays=<N>` flag, with `N > 0` value to reduce the set of
FAM candidates. Value `3` is the most restrictive and `0` is the most
permissive on this scale.

0: all trailing arrays are FAMs
1: only incomplete, zero and one-element arrays are FAMs
2: only incomplete, zero-element arrays are FAMs
3: only incomplete arrays are FAMs

If the user is happy with consdering single-element arrays as FAMs, they
just need to remove the
`consider-single-element-arrays-as-flexible-array-members` from the
command line.
Otherwise, if they don't want to recognize such cases as FAMs, they
should specify `-fstrict-flex-arrays` anyway, which will be picked up by
CSA.

Any use of the deprecated analyzer-config value will trigger a warning
explaining what to use instead.
The `-analyzer-config-help` is updated accordingly.

Depends on D138657

Reviewed By: xazax.hun

Differential Revision: https://reviews.llvm.org/D138659
2022-11-25 10:24:56 +01:00
Balazs Benics 3648175839 [analyzer] Consider single-elem arrays as FAMs by default
According to my measurement in https://reviews.llvm.org/D108230#3933232,
it seems like there is no drawback to enabling this analyzer-config by default.

Actually, enabling this by default would make it consistent with the
codegen of clang, which according to `-fstrict-flex-arrays`, assumes
by default that all trailing arrays could be FAMs, let them be of size
undefined, zero, one, or anything else.

Speaking of `-fstrict-flex-arrays`, in the next patch I'll deprecate
the analyzer-config FAM option in favor of that flag. That way, CSA will
always be in sync with what the codegen will think of FAMs.

So, if a new codebase sets `-fstrict-flex-arrays` to some value above 0,
CSA will also make sure that only arrays of the right size will be
considered as FAMs.

Reviewed By: xazax.hun

Differential Revision: https://reviews.llvm.org/D138657
2022-11-25 10:24:56 +01:00
Fangrui Song 987b49395c [PPC] Undefine __ppc64__ to match GCC
GCC only defines `__ppc64__` for darwin while the darwin support has been
removed from llvm-project. The existence of `__ppc64__` makes some software
think we are compiling for big-endian PowerPC Mac; also it lures users to write
code which is not portable to GCC.

It is straightforward if a distro wants to keep the macro: add
`-D__ppc64__=1` to a Clang configuration file.

Reviewed By: thesamesam, nemanjai

Differential Revision: https://reviews.llvm.org/D137511
2022-11-22 17:01:39 -08:00
KAWASHIMA Takahiro 93591851d8 [clang][docs] Correct indent of option explanation
Indentation is significant for Sphinx. Lines with indentation after
a `.. option::` line are treated as explanations of the option.
2022-11-22 10:40:56 +09:00
KAWASHIMA Takahiro 2a0919b965 [clang][docs] Remove an unnecessary space 2022-11-22 10:40:55 +09:00
KAWASHIMA Takahiro 799b6b9f31 [clang][docs] Use `option` directive in User's Manual
Sphinx has the `option` directive. Most option descriptions
in `clang/docs/UsersManual.rst` used it but some didn't.
This commit changes the remaining option descriptions to use
the `option` directive. This makes a consistent view in HTML.

The `option` directive automatically creates a cross-reference target.
So labeling by `.. _opt_XXX:` is almost unnecessary. However, options
with and without `no-` (e.g. `-fno-show-column`/`-fshow-column`)
cannot be distinguish for the cross-reference. So some required
`.. _opt_XXX:` directives are kept unremoved.

Differential Revision: https://reviews.llvm.org/D138088
2022-11-22 10:40:54 +09:00
Saleem Abdulrasool b78d5380da parse: process GNU and standard attributes on top-level decls
We would previously reject valid input where GNU attributes preceded the
standard attributes on top-level declarations. A previous attribute
handling change had begun rejecting this whilst GCC does honour this
layout. In practice, this breaks use of `extern "C"` attributed
functions which use both standard and GNU attributes as experienced by
the Swift runtime.

Objective-C deserves an honourable mention for requiring some additional
special casing. Because attributes on declarations and definitions
differ in semantics, we need to replicate some of the logic for
detecting attributes to declarations to which they appertain cannot be
attributed. This should match the existing case for the application of
GNU attributes to interfaces, protocols, and implementations.

Take the opportunity to split out the tooling tests into two cases: ones
which process macros and ones which do not.

Special thanks to Aaron Ballman for the many hints and extensive rubber
ducking that was involved in identifying the various places where we
accidentally dropped attributes.

Differential Revision: https://reviews.llvm.org/D137979
Fixes: #58229
Reviewed By: aaron.ballman, arphaman
2022-11-21 22:34:50 +00:00
John Brawn 9e3264ab20 [FPEnv] Enable strict fp for AArch64 in clang
The AArch64 target now has the necessary support for strict fp, so
enable it in clang.

Differential Revision: https://reviews.llvm.org/D138143
2022-11-21 16:02:54 +00:00
Erich Keane eb4373abe8 Remove -cc1 -fconcepts-ts flag
The -fconcepts-ts flag has been deprecated for 5 releases now, so just
remove it, concepts is supported in C++20 mode.
2022-11-21 06:31:29 -08:00
Alexandre Ganea 49e483d3d6 [CodeView] Replace GHASH hasher by BLAKE3
Previously, we used SHA-1 for hashing the CodeView type records.
SHA-1 in `GloballyHashedType::hashType()` is coming top in the profiles. By simply replacing with BLAKE3, the link time is reduced in our case from 15 sec to 13 sec. I am only using MSVC .OBJs in this case. As a reference, the resulting .PDB is approx 2.1GiB and .EXE is approx 250MiB.

Differential Revision: https://reviews.llvm.org/D137101
2022-11-19 15:17:42 -05:00
Chi Chun Chen 6d076780a8 [OpenMP][NFC] Claim thread_limit clause in target directive 2022-11-17 00:44:44 -06:00
Richard Smith 9e52db1827 When we run out of source locations, try to produce useful information
indicating why we ran out.
2022-11-16 14:36:16 -08:00
Serge Pavlov 1f67dc8b7c [Driver] Enable nested configuration files
Users may partition parameters specified by configuration file and put
different groups into separate files. These files are inserted into the
main file using constructs `@file`. Relative file names in it are
resolved relative to the including configuration file and this is not
convenient in some cases. A configuration file, which resides in system
directory, may need to include a file with user-defined parameters and
still provide default definitions if such file is absent.

To solve such problems, the option `--config=` is allowed inside
configuration files. Like `@file` it results in insertion of
command-line arguments but the algorithm of file search is different and
allows overriding system definitions with user ones.

Differential Revision: https://reviews.llvm.org/D136354
2022-11-16 13:32:27 +07:00
Björn Schäpers cb01befda5 [clang-format][NFC] Improve documentation of FixNamespaceComments
Fixes https://github.com/llvm/llvm-project/issues/55162
2022-11-16 07:02:10 +01:00
Björn Schäpers 40c1476e3a [clang-format][NFC] Improve documentation on ReflowComments
Fixes https://github.com/llvm/llvm-project/issues/58403

Differential Revision: https://reviews.llvm.org/D137865
2022-11-16 07:02:10 +01:00
Shafik Yaghmour 9332ddfba6 [Clang] Extend the number of case Sema::CheckForIntOverflow covers
Currently Sema::CheckForIntOverflow misses several case that other compilers
diagnose for overflow in integral constant expressions. This includes the
arguments of a CXXConstructExpr as well as the expressions used in an
ArraySubscriptExpr, CXXNewExpr and CompoundLiteralExpr.

This fixes https://github.com/llvm/llvm-project/issues/58944

Differential Revision: https://reviews.llvm.org/D137897
2022-11-15 12:07:03 -08:00
Chuanqi Xu de034cf313 [NFC] Fix the typo and the format in the StandardCPlusPlusModules
document
2022-11-15 22:53:43 +08:00
Luca Di Sera 5c67cf0a7f Add clang_CXXMethod_isMoveAssignmentOperator to libclang
The new method is a wrapper of `CXXMethodDecl::isMoveAssignmentOperator` and
can be used to recognized move-assignment operators in libclang.

An export for the function, together with its documentation, was added to
"clang/include/clang-c/Index.h" with an implementation provided in
"clang/tools/libclang/CIndex.cpp". The implementation was based on
similar `clang_CXXMethod.*` implementations, following the same
structure but calling `CXXMethodDecl::isMoveAssignmentOperator` for its
main logic.

The new symbol was further added to "clang/tools/libclang/libclang.map"
to be exported, under the LLVM16 tag.

"clang/tools/c-index-test/c-index-test.c" was modified to print a
specific tag, "(move-assignment operator)", for cursors that are
recognized by `clang_CXXMethod_isMoveAssignmentOperator`.
A new regression test file,
"clang/test/Index/move-assignment-operator.cpp", was added to ensure
whether the correct constructs were recognized or not by the new function.

The "clang/test/Index/get-cursor.cpp" regression test file was updated
as it was affected by the new "(move-assignment operator)" tag.

A binding for the new function was added to libclang's python's
bindings, in "clang/bindings/python/clang/cindex.py", adding a new
method for `Cursor`, `is_move_assignment_operator_method`.
An accompanying test was added to
`clang/bindings/python/tests/cindex/test_cursor.py`, testing the new
function with the same methodology as the corresponding libclang test.

The current release note, `clang/docs/ReleaseNotes.rst`, was modified to
report the new addition under the "libclang" section.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D137246
2022-11-14 15:21:36 +01:00
Joshua Batista a5d14f757b Add builtin_elementwise_sin and builtin_elementwise_cos
Add codegen for llvm cos and sin elementwise builtins
The sin and cos elementwise builtins are necessary for HLSL codegen.
Tests were added to make sure that the expected errors are encountered
when these functions are given inputs of incompatible types.
The new builtins are restricted to floating point types only.

Reviewed By: craig.topper, fhahn

Differential Revision: https://reviews.llvm.org/D135011
2022-11-10 23:30:27 -08:00
Anastasiia Lukianenko f6b252978c [clang-format] Add BreakBeforeInlineASMColon configuration
If true, colons in ASM parameters will be placed after line breaks.

true:
asm volatile("string",
                     :
                     : val);

false:
asm volatile("string", : : val);

Differential Revision: https://reviews.llvm.org/D91950
2022-11-10 22:31:09 +01:00
Timm Bäder e1b88c8a09 [clang] Only use major version in resource dir
This causes unnecessary churn for downstreams.

For the full discussion, see https://discourse.llvm.org/t/should-we-continue-embed-the-full-llvm-version-in-lib-clang/62094

Differential Revision: https://reviews.llvm.org/D125860
2022-11-10 15:02:03 +01:00
Chuanqi Xu 04fb3e3de7 [C++20] [Modules] Document the behavior about reserved module names
We would diagnose about the reserved names in b8ceb9f4e4. And the
patch documents about the related behaviors.
2022-11-10 16:43:50 +08:00
Aaron Ballman b7104442dd Fix Clang sphinx build
This addresses the issue found by:
https://lab.llvm.org/buildbot/#/builders/92/builds/35350
2022-11-09 09:19:24 -05:00
Victor Campos 9d1ff787e5 [AArch64] Add support for the Cortex-X3 CPU
Cortex-X3 is an Armv9-A AArch64 CPU.

This patch introduces support for Cortex-X3.

Technical Reference Manual: https://developer.arm.com/documentation/101593/latest

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D136589
2022-11-09 11:33:48 +00:00
Freddy Ye 84a18a260e [X86] Support -march=sierraforest, grandridge, graniterapids.
Reviewed By: skan, pengfei, MaskRay

Differential Revision: https://reviews.llvm.org/D137153
2022-11-09 16:56:03 +08:00
Björn Schäpers 41a09a07ce [clang-format][NFCish] Alphabetical sort Format.(h|pp)
I've:
- Sorted the members of FormatStyle alphabetical. The enums and structs
  are kept close to the member.
- Sorted the yaml io functions, based on the type they operate on.
- Sorted the initializers in getLLVMStyle(), except that penalities are
  kept at the end.
- Sorted the io of FormatStyle, this changes the --dump-config behavior.
- Moved the deprecated options into the only input case, this also
  changes --dump-config, it does not put the not directly used options
  in the .clang-format anymore.
- Sorted the comparisons in operator==.
- Added WhiteSpaceMacros in operator==, I've not actively looked if all
  other members are compared.
- This showed flawed tests (or in my opinion a flawed io operation, but
  that is another discussion and change).

Differential Revision: https://reviews.llvm.org/D137409
2022-11-08 21:46:15 +01:00
Chi Chun Chen 445a2ab605 [OpenMP][NFC] Unclaim iterators in 'map' clause and motion clauses 2022-11-08 11:43:07 -06:00
Rageking8 94738a5ac3 Fix duplicate word typos; NFC
This revision fixes typos where there are 2 consecutive words which are
duplicated. There should be no code changes in this revision (only
changes to comments and docs). Do let me know if there are any
undesirable changes in this revision. Thanks.
2022-11-08 07:21:23 -05:00
haoyuintel 13f83365cd [Driver] Add -fsample-profile-use-profi
This patch enable `-sample-profile-use-profi` in Clang frontend as user-facing
feature. By using this patch, we can use the cflag of `-fsample-profile-use-profi`
instead of `-mllvm -sample-profile-use-profi`.

Reviewed By: hans, MaskRay

Differential Revision: https://reviews.llvm.org/D136846
2022-11-08 15:51:38 +08:00