Commit Graph

94073 Commits

Author SHA1 Message Date
David Tenty 98d911e01f Revert "Treat `std::move`, `forward`, etc. as builtins."
This reverts commit b27430f9f4 as the
    parent https://reviews.llvm.org/D123345 breaks the AIX CI:

    https://lab.llvm.org/buildbot/#/builders/214/builds/819
2022-04-20 19:14:37 -04:00
David Tenty de6ddaeef3 Revert "Don't treat 'T &forward(T&&)' as builtin."
This reverts commit e43c93dd63 as the
parent https://reviews.llvm.org/D123345 breaks the AIX CI.
2022-04-20 19:14:36 -04:00
Evgeny Mankov c23147106f [clang][CUDA][Windows] Fix compilation error on Windows with `uint32_t __nvvm_get_smem_pointer`
The change fixes https://github.com/llvm/llvm-project/issues/54609 (the second reported issue) by eliminating a compilation error occurring only on Windows while trying to compile any CUDA source file by clang (-x cuda).

[Repro]
clang -x cuda <any_cu_source>

[Error]

__clang_cuda_runtime_wrapper.h:473:
__clang_cuda_intrinsics.h(517,19): error GC871EEFB: unknown type name 'uint32_t'; did you mean 'cuuint32_t'?
__device__ inline uint32_t __nvvm_get_smem_pointer(void *__ptr) {
                          ^
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/include\cuda.h:57:26: note: 'cuuint32_t' declared here
typedef unsigned __int32 cuuint32_t;

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D122897
2022-04-21 00:41:20 +03:00
Nathan James cfb8169059
[clang] Add a raw_ostream operator<< overload for QualType
Under the hood this prints the same as `QualType::getAsString()` but cuts out the middle-man when that string is sent to another raw_ostream.

Also cleaned up all the call sites where this occurs.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D123926
2022-04-20 22:09:05 +01:00
Pengxuan Zheng 38612fbc89 Reland "[COFF, ARM64] Add __break intrinsic"
https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=msvc-170

Reland after fixing the test failure. The failure was due to conflict with a
change (D122983) which was merged right before this patch.

Reviewed By: rnk, mstorsjo

Differential Revision: https://reviews.llvm.org/D124032
2022-04-20 13:01:30 -07:00
serge-sans-paille af7b98c383 [clang-tblgen] Automatically document options values
This is a port of f5c666742f to clang's tablegen,
with a better wording.

Differential Revision: https://reviews.llvm.org/D123682
2022-04-20 22:00:06 +02:00
Pengxuan Zheng bff8356b19 Revert "[COFF, ARM64] Add __break intrinsic"
This reverts commit 8a9b4fb4aa.
2022-04-20 11:57:49 -07:00
Eli Friedman ecc8479a01 Look through calls to std::addressof to compute pointer alignment.
This is sort of a followup to D37310; that basically fixed the same
issue, but then the libstdc++ implementation of <atomic> changed. Re-fix
the the issue in essentially the same way: look through the addressof
operation to find the alignment of the underlying object.

Differential Revision: https://reviews.llvm.org/D123950
2022-04-20 11:30:11 -07:00
Paul Kirth 61e36e87df [safestack] Support safestack in stack size diagnostics
Current stack size diagnostics ignore the size of the unsafe stack.
This patch attaches the size of the static portion of the unsafe stack
to the function as metadata, which can be used by the backend to emit
diagnostics regarding stack usage.

Reviewed By: phosek, mcgrathr

Differential Revision: https://reviews.llvm.org/D119996
2022-04-20 18:29:40 +00:00
Jan Svoboda 340654e0f2 Revert "[clang][lex] NFCI: Use DirectoryEntryRef in HeaderSearch::load*()"
This reverts commit 1d3ba05e4a which caused failures of the VFS/real-path-found-first.m test on Windows build bots.
2022-04-20 20:27:14 +02:00
Jan Svoboda 99cfccdcb3 [clang][lex] NFCI: Use FileEntryRef in ModuleMap::diagnoseHeaderInclusion()
This patch removes uses of the deprecated `DirectoryEntry::getName()` from the `ModuleMap::diagnoseHeaderInclusion()` function by using `{File,Directory}EntryRef` instead.

Reviewed By: bnbarham

Differential Revision: https://reviews.llvm.org/D123856
2022-04-20 20:27:13 +02:00
Pengxuan Zheng 8a9b4fb4aa [COFF, ARM64] Add __break intrinsic
https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=msvc-170

Reviewed By: rnk, mstorsjo

Differential Revision: https://reviews.llvm.org/D124032
2022-04-20 11:20:26 -07:00
Fangrui Song c79e6007ed Revert D119136 "[clang] Implement Change scope of lambda trailing-return-type" and its follow-up
This reverts commit 69dd89fdcb.
This reverts commit 04000c2f92.

The current states breaks libstdc++ usage (https://reviews.llvm.org/D119136#3455423).
The fixup has been reverted as it caused other valid code to be disallowed.
I think we should start from the clean state by reverting all relevant commits.
2022-04-20 10:57:12 -07:00
Dan Liew 3d612a930d [NFC] Avoid unnecessary duplication of code generating diagnostic.
The previous code unneccessarily duplicated the creation of a diagnostic
where the only difference was the `AssignmentAction` being passed.

rdar://88664722

Differential Revision: https://reviews.llvm.org/D124054
2022-04-20 10:50:21 -07:00
Fangrui Song 0f5dbfd29a Revert D123909 "[Clang] Use of decltype(capture) in parameter-declaration-clause"
This reverts commit daa6d7b250.

It breaks valid code like https://reviews.llvm.org/D123909#3461716
2022-04-20 10:32:41 -07:00
Aaron Ballman 9955f14aaf [C2x] Disallow functions without prototypes/functions with identifier lists
WG14 has elected to remove support for K&R C functions in C2x. The
feature was introduced into C89 already deprecated, so after this long
of a deprecation period, the committee has made an empty parameter list
mean the same thing in C as it means in C++: the function accepts no
arguments exactly as if the function were written with (void) as the
parameter list.

This patch implements WG14 N2841 No function declarators without
prototypes (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm)
and WG14 N2432 Remove support for function definitions with identifier
lists (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf).

It also adds The -fno-knr-functions command line option to opt into
this behavior in other language modes.

Differential Revision: https://reviews.llvm.org/D123955
2022-04-20 13:28:15 -04:00
Jun Zhang 9c069374ce
Reland "[Clang][Sema] Fix invalid redefinition error in if/switch/for statement"
This reverts commit 9f075c3d84.
The broken build has alreasy been fixed in D124012, so reland it now.
Signed-off-by: Jun Zhang <jun@junz.org>
2022-04-21 01:18:58 +08:00
Yitzhak Mandelbaum c8f822ad51 [clang][dataflow] Ensure well-formed flow conditions.
Ensure that the expressions associated with terminators are associated with a
value. Otherwise, we can generate degenerate flow conditions, where both
branches share the same condition.

Differential Revision: https://reviews.llvm.org/D123858
2022-04-20 17:01:55 +00:00
Jan Svoboda f43ce5199d [clang][lex] NFCI: Use DirectoryEntryRef in FrameworkCacheEntry
This patch changes the member of `FrameworkCacheEntry` from `const DirectoryEntry *` to `Optional<DirectoryEntryRef>` in order to remove uses of the deprecated `DirectoryEntry::getName()`.

Reviewed By: bnbarham

Differential Revision: https://reviews.llvm.org/D123854
2022-04-20 19:01:02 +02:00
Jan Svoboda ba118f3067 [clang] NFCI: Use DirectoryEntryRef in FrontendAction::BeginSourceFile()
This patch removes use of the deprecated `DirectoryEntry::getName()` from `FrontendAction::BeginSourceFile()`.

Reviewed By: bnbarham

Differential Revision: https://reviews.llvm.org/D123853
2022-04-20 18:54:39 +02:00
Jan Svoboda 1d3ba05e4a [clang][lex] NFCI: Use DirectoryEntryRef in HeaderSearch::load*()
This patch removes uses of the deprecated `DirectoryEntry::getName()` from `HeaderSearch::load*()` functions by using `DirectoryEntryRef` instead.

Note that we bail out in one case and use the also deprecated `FileEntry::getLastRef()`. That's to prevent this patch from growing, and is addressed in a follow-up.

Reviewed By: bnbarham

Differential Revision: https://reviews.llvm.org/D123771
2022-04-20 18:52:27 +02:00
Aaron Ballman 4f843f9a9e Removing some ancient, unused testing functionality
This was last touched 13 years ago in
7a1095f243
and is no longer being maintained.
2022-04-20 11:57:25 -04:00
Paul Robinson dfdb2cc0fb [PS5][NFC] Fix a test with a misplaced -x option 2022-04-20 08:56:50 -07:00
Jun Zhang 9f075c3d84
Revert "[Clang][Sema] Fix invalid redefinition error in if/switch/for statement"
This reverts commit be0905a333.
This patch broke build addressed in https://github.com/llvm/llvm-project/issues/54968
Signed-off-by: Jun Zhang <jun@junz.org>
2022-04-20 23:45:44 +08:00
Arthur Eubanks 19884d62c4 [clang-format] Don't skip PP lines if original line was a PP line when trying to merge lines
Fixes a crash introduced in D123737 where LastNonComment would be null.

Reviewed By: curdeius

Differential Revision: https://reviews.llvm.org/D124036
2022-04-20 08:42:30 -07:00
Paul Robinson a5c847e8cf [PS4][NFC] Rename classes to align with prevailing practice
Rename classes Assemble -> Assembler, Link -> Linker,
for consistency with names other toolchains use.
2022-04-20 08:35:52 -07:00
Aaron Ballman 7d644e1215 [C11/C2x] Change the behavior of the implicit function declaration warning
C89 had a questionable feature where the compiler would implicitly
declare a function that the user called but was never previously
declared. The resulting function would be globally declared as
extern int func(); -- a function without a prototype which accepts zero
or more arguments.

C99 removed support for this questionable feature due to severe
security concerns. However, there was no deprecation period; C89 had
the feature, C99 didn't. So Clang (and GCC) both supported the
functionality as an extension in C99 and later modes.

C2x no longer supports that function signature as it now requires all
functions to have a prototype, and given the known security issues with
the feature, continuing to support it as an extension is not tenable.

This patch changes the diagnostic behavior for the
-Wimplicit-function-declaration warning group depending on the language
mode in effect. We continue to warn by default in C89 mode (due to the
feature being dangerous to use). However, because this feature will not
be supported in C2x mode, we've diagnosed it as being invalid for so
long, the security concerns with the feature, and the trivial
workaround for users (declare the function), we now default the
extension warning to an error in C99-C17 mode. This still gives users
an easy workaround if they are extensively using the extension in those
modes (they can disable the warning or use -Wno-error to downgrade the
error), but the new diagnostic makes it more clear that this feature is
not supported and should be avoided. In C2x mode, we no longer allow an
implicit function to be defined and treat the situation the same as any
other lookup failure.

Differential Revision: https://reviews.llvm.org/D122983
2022-04-20 11:30:12 -04:00
Simon Pilgrim 1226d276b4 [X86][AVX512] Rename avx512popcntdq intrinsics tests files to match *-builtins.c naming convention 2022-04-20 15:12:12 +01:00
Simon Pilgrim 72d4e3dc2d [X86][AVX] Add i386 test coverage to avx2 intrinsic tests 2022-04-20 15:12:12 +01:00
Simon Pilgrim 0140a672a6 [X86][AVX] Add i386 test coverage to avx-vnni intrinsic tests 2022-04-20 15:12:12 +01:00
Simon Pilgrim 2c176f2f1e [X86][AVX] Add i386 test coverage to avx intrinsic tests 2022-04-20 15:12:11 +01:00
Alex Bradbury bea5e88bcf [clang][Sema] Fix typo in checkBuiltinArgument helper
The checkBuiltinArgument helper takes an integer ArgIndex and is
documented as performing normal type-checking on that argument. However,
it mistakenly hardcodes the argument index to zero when retrieving the
argument from the call expression.

This hadn't been noticed previously as all in-tree uses typecheck the
0th argument anyway.
2022-04-20 14:42:41 +01:00
Corentin Jabot 69dd89fdcb [Clang] Fix references to captured variables in dependant context.
D119136 changed how captures are handled in a lambda call operator
declaration, but did not properly handled dependant context,
which led to crash when refering to init-captures in
a trailing return type.

We fix that bug by making transformations more symetric with parsing,
ie. we first create the call operator, then transform the capture,
then compute the type of the lambda call operaror.

This ensures captures exist and have the right type when
we parse a trailing requires-clause / return type.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D124012
2022-04-20 15:35:20 +02:00
Kito Cheng f26c41e8dd [RISCV] Moving RVV intrinsic type related util to clang/Support
We add a new clang library called `clangSupport` for putting those utils which can be used in clang table-gen and other clang component.

We tried to put that into `llvm/Support`, but actually those stuffs only used in clang* and clang-tblgen, so I think that might be better to create `clang/Support`

* clang will used that in https://reviews.llvm.org/D111617.

Reviewed By: khchen, MaskRay, aaron.ballman

Differential Revision: https://reviews.llvm.org/D121984
2022-04-20 21:13:13 +08:00
Joseph Huber ee74abaad7 [OpenMP] Add triple to the linker wrapper job
Summary:
I forgot to add the triple to the linker wrapper job, so we were still
generating code for the unintended platforms.
2022-04-20 08:23:43 -04:00
Sam McCall 4cec789c17 [Testing] Drop clangTesting from clang's public library interface
This was probably not particularly intended to be public, and disallows deps
on gtest which are useful in test helpers.

https://discourse.llvm.org/t/stop-exporting-clangtesting-library/61672

Differential Revision: https://reviews.llvm.org/D123610
2022-04-20 13:28:44 +02:00
Joseph Huber 1dfe0273fd [OpenMP] Add explicit triple to linker wrapper test
Summary:
Some platforms like Mach-O require different handling of section names.
This is not supported on Mac-OS or Windows yet so we shouldn't be
testing the compilation there. Add an explicit triple to the tests.
2022-04-20 07:24:51 -04:00
Simon Pilgrim 3949c2de79 [X86][SSE] Add i386 test coverage to sse2 intrinsic tests 2022-04-20 12:05:10 +01:00
Simon Pilgrim 7c1bff3f7b [X86][FMA4] Add i386 test coverage to fma4 intrinsic tests 2022-04-20 11:14:18 +01:00
Simon Pilgrim ba2e567f04 [X86][SSE] Add i386 test coverage to sse42 intrinsic tests 2022-04-20 11:06:07 +01:00
Simon Pilgrim 90e5c690e2 [X86][SSE] Add i386 test coverage to sse41 intrinsic tests 2022-04-20 11:06:06 +01:00
Sven van Haastregt e67b1b0ccf [OpenCL] Add missing __opencl_c_atomic_scope_device guards
Update opencl-c.h after the specification clarification in
https://github.com/KhronosGroup/OpenCL-Docs/pull/775
2022-04-20 11:02:50 +01:00
Simon Pilgrim b402ea55a8 [X86][SSE] Add i386 test coverage to sse4a intrinsic tests 2022-04-20 10:48:47 +01:00
Simon Pilgrim c86588af65 [X86][SSE] Add i386 test coverage to ssse3 intrinsic tests 2022-04-20 10:44:28 +01:00
Simon Pilgrim 88d61cc6e9 [X86][SSE] Add i386 test coverage to sse3 intrinsic tests 2022-04-20 10:44:28 +01:00
Simon Pilgrim 6574d75b8d [XOP] Add i386 test coverage to xop intrinsic tests 2022-04-20 10:44:27 +01:00
Chen Zheng 3c776c70a7 [PowerPC] add XLC compat builtin __abs
Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D123372
2022-04-20 05:14:22 -04:00
Zakk Chen bd0d126302 [RISCV][Clang][NFC] Update vid intrinsic tests.
Re-run the update_cc_test_checks.py to update expected result.
I'm not sure why those tests are passed before.

Differential Revision: https://reviews.llvm.org/D124062
2022-04-20 01:35:53 -07:00
Konrad Kleine d46fa023ca [clang-format] SortIncludes should support "@import" lines in Objective-C
Fixes [[ https://github.com/llvm/llvm-project/issues/38995 | #38995 ]]

This is an attempt to modify the regular expression to identify
`@import` and `import` alongside the regular `#include`. The challenging
part was not to support `@` in addition to `#` but how to handle
everything that comes after the `include|import` keywords. Previously
everything that wasn't `"` or `<` was consumed. But as you can see in
this example from the issue #38995, there is no `"` or `<` following the
keyword:

```
@import Foundation;
```

I experimented with a lot of fancy and useful expressions in [this
online regex tool](https://regex101.com) only to find out that some
things are simply not supported by the regex implementation in LLVM.

 * For example the beginning `[\t\ ]*` should be replacable by the
   horizontal whitespace character `\h*` but this will break the
   `SortIncludesTest.LeadingWhitespace` test.

That's why I've chosen to come back to the basic building blocks.

The essential change in this patch is the change from this regular
expression:

```
^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">])
        ~                              ~~~~~~~~~~~~~~
        ^                              ^
        |                              |
        only support # prefix not @    |
                                       only support "" and <> as
delimiters
                                       no support for C++ modules and ;
                                       ending. Also this allows for ">
                                       or <" or "" or <> which all seems
                                       either off or wrong.
```

to this:

```
^[\t\ ]*[@#][\t\ ]*(import|include)([^"]*("[^"]+")|[^<]*(<[^>]+>)|[\t\
]*([^;]+;))
        ~~~~                        ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
~~~~~~~~~~~~~~
        ^                                 ^           ^       ^       ^
        |                                 |           |       |       |
        Now support @ and #.            Clearly support "" and <> as
well as an
                                        include name without enclosing
characters.
                                        Allows for no mixture of "> or
<" or
                                        empty include names.

```

Here is how I've tested this patch:

```
ninja clang-Format
ninja FormatTests
./tools/clang/unittests/Format/FormatTests
--gtest_filter=SortIncludesTest*
```

And if that worked I doubled checked that nothing else broke by running
all format checks:

```
./tools/clang/unittests/Format/FormatTests
```

One side effect of this change is it should partially support
[C++20 Module](https://en.cppreference.com/w/cpp/language/modules)
`import` lines without the optional `export` in front. Adding
this can be a change on its own that shouldn't be too hard. I say
partially because the `@` or `#` are currently *NOT* optional in the
regular expression.

I see an opportunity to optimized the matching to exclude `@include` for
example. But eventually these should be caught by the compiler, so...

With my change, the matching group is not at a fixed position any
longer. I decided to
choose the last match (group) that is not empty.

Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D121370
2022-04-20 07:03:35 +00:00
Douglas Yung c952754206 Make tests slightly more flexible for platforms which emit arguments in between some of the expected arguments. 2022-04-19 23:25:22 -07:00
Petr Hosek af21445ea8 [CMake][Fuchsia] Include find-all-symbols in the distribution
This is needed to use clang-include-fixer.

Differential Revision: https://reviews.llvm.org/D124053
2022-04-19 19:27:46 -07:00
Fangrui Song a57d16bf80 [CodeGen] Fix -Wswitch after D116462 2022-04-19 17:33:15 -07:00
Fangrui Song 8b0e7f2293 [CodeGen] Fix -Wswitch after D116462 2022-04-19 17:28:54 -07:00
Vitaly Buka 0d0a99cb96 [msan] Advance before destroying entry
-fsanitize-memory-use-after-dtor reports this memory access.
2022-04-19 16:42:04 -07:00
Paul Robinson 20c873c12f [PS5] Avoid a driver crash
In some cases, an error constructing a compiler or assembler job could
leave the Inputs in a state that the code for constructing the linker
job was not ready for.
2022-04-19 15:55:32 -07:00
Joseph Huber 8c64928887 [OpenMP] Add necessary registered targets for linker wrapper test
Summary:
The linker wrapper needs to use the registered backend to perform LTO.
This was causing problems on the buildbots that didn't support it.
2022-04-19 18:48:58 -04:00
Joseph Huber dbb10f7097 [OpenMP] Fix deleted move constructor failing on some compiles
Summary:
A previous commit added some new errors that were not correctly casted
to an r-value. This doesn't work on some compilers.
2022-04-19 18:40:15 -04:00
Joseph Huber 260c5df2d5 [OpenMP] Add better testing for the linker wrapper
The linker wrapper is used to perform linking and wrapping of embedded
device object files. Currently its internals are not able to be tested
easily. This patch adds the `--dry-run` and `--print-wrapped-module`
options to investigate the link jobs that will be run along with the
wrapped code that will be created to register the binaries.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D124039
2022-04-19 18:37:09 -04:00
Fangrui Song e3cf153522 [Driver][test] Remove unneeded clang from -cc1 CHECK lines
The convention is to omit "clang" for -cc1 CHECK lines and test that -triple is adjacent to -cc1.
2022-04-19 14:58:48 -07:00
Richard Smith 63814be4fa [modules] Merge variable template specializations. 2022-04-19 14:48:42 -07:00
Paul Kirth bac6cd5bf8 [misexpect] Re-implement MisExpect Diagnostics
Reimplements MisExpect diagnostics from D66324 to reconstruct its
original checking methodology only using MD_prof branch_weights
metadata.

New checks rely on 2 invariants:

1) For frontend instrumentation, MD_prof branch_weights will always be
   populated before llvm.expect intrinsics are lowered.

2) for IR and sample profiling, llvm.expect intrinsics will always be
   lowered before branch_weights are populated from the IR profiles.

These invariants allow the checking to assume how the existing branch
weights are populated depending on the profiling method used, and emit
the correct diagnostics. If these invariants are ever invalidated, the
MisExpect related checks would need to be updated, potentially by
re-introducing MD_misexpect metadata, and ensuring it always will be
transformed the same way as branch_weights in other optimization passes.

Frontend based profiling is now enabled without using LLVM Args, by
introducing a new CodeGen option, and checking if the -Wmisexpect flag
has been passed on the command line.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D115907
2022-04-19 21:23:48 +00:00
Yitzhak Mandelbaum eb2131bdba [clang][dataflow] Do not crash on missing `Value` for struct-typed variable init.
Remove constraint that an initializing expression of struct type must have an
associated `Value`. This invariant is not and will not be guaranteed by the
framework, because of potentially uninitialized fields.

Differential Revision: https://reviews.llvm.org/D123961
2022-04-19 20:52:29 +00:00
Alex Langford c57f03415f [clang][Sema] Add flag to LookupName to force C/ObjC codepath
Motivation: The intent here is for use in Swift.
When building a clang module for swift consumption, swift adds an
extension block to the module for name lookup purposes. Swift calls
this a SwiftLookupTable. One purpose that this serves is to handle
conflicting names between ObjC classes and ObjC protocols. They exist in
different namespaces in ObjC programs, but in Swift they would exist in
the same namespace. Swift handles this by appending a suffix to a
protocol name if it shares a name with a class. For example, if you have
an ObjC class named "Foo" and a protocol with the same name, the
protocol would be renamed to "FooProtocol" when imported into swift.

When constructing the previously mentioned SwiftLookupTable, we use
Sema::LookupName to look up name conflicts for the previous problem.
By this time, the Parser has long finished its job so the call to
LookupName gets nullptr for its Scope (TUScope will be nullptr
by this point). The C/ObjC path does not have this problem because it
only uses the Scope in specific scenarios. The C++ codepath uses the
Scope quite extensively and will fail early on if the Scope it gets is
null. In our very specific case of looking up ObjC classes with a
specific name, we want to force sema::LookupName to take the C/ObjC
codepath even if C++ or ObjC++ is enabled.
2022-04-19 12:57:14 -07:00
Denys Petrov e37726beb2 [analyzer] Implemented RangeSet::Factory::castTo function to perform promotions, truncations and conversions.
Summary: Handle casts for ranges working similarly to APSIntType::apply function but for the whole range set. Support promotions, truncations and conversions.
Example:
promotion: char [0, 42] -> short [0, 42] -> int [0, 42] -> llong [0, 42]
truncation: llong [4295033088, 4295033130] -> int [65792, 65834] -> short [256, 298] -> char [0, 42]
conversion: char [-42, 42] -> uint [0, 42]U[4294967254, 4294967295] -> short[-42, 42]

Differential Revision: https://reviews.llvm.org/D103094
2022-04-19 22:34:03 +03:00
Yaxun (Sam) Liu 800f26386c [CUDA][HIP] Fix delete operator for -fopenmp
When new operator is called in OpenMP parallel region,
delete operator is resolved and checked. Due to similar
issue fixed by https://reviews.llvm.org/D121765,
when resolving delete operator, the caller was not
determined correctly, which results in error as
shown in https://godbolt.org/z/jKhd8qKos.

This patch fixes the issue in a similar way as
https://reviews.llvm.org/D121765

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D123976
2022-04-19 14:28:03 -04:00
Jonas Paulsson 4aa5dc15f0 [SystemZ] Handle SystemZ specific inline assembly address operands.
Handle ZQ, ZR, ZS and ZT inline assembly operand constraints.

Review: Ulrich Weigand

Differential Revision: https://reviews.llvm.org/D110267
2022-04-19 16:55:45 +02:00
Tom Ritter 82f3ed9904 [analyzer] Expose Taint.h to plugins
Reviewed By: NoQ, xazax.hun, steakhal

Differential Revision: https://reviews.llvm.org/D123155
2022-04-19 16:55:01 +02:00
Qiongsi Wu 2512a875cc [clang] Adding Platform/Architecture Specific Resource Header Installation Targets
The goal of this patch is to improve distribution build's flexibility to include only applicable header files.

Currently, the clang-resource-headers target contains nearly all the files in clang/lib/Headers. Most of these files are platform specific (e.g. immintrin.h is x86 specific). A distribution build will have to either include all the headers for all the platforms, or not include any headers. For example, if a distribution build for powerpc includes the clang-resource-headers target, it will include all the x86 specific headers, even-though the x86 specific headers cannot be used.

This patch breaks up the clang-resource-headers list to a core list and platform specific lists. With the patch, a distribution build can now include the ppc-resource-headers to include the headers applicable to the powerpc platform.

Specifically, one can now have

cmake ... LLVM_DISTRIBUTION_COMPONENTS="clang;ppc-resource-headers" ... ../llvm
ninja install-distribution then installs the powerpc headers.

Similarly, one can do

cmake ... LLVM_DISTRIBUTION_COMPONENTS="clang;x86-resource-headers" ... ../llvm
to include headers applicable to the x86 platform in a distribution installation.

To implement this behaviour, the patch does two things:
* It breaks up the long files header file list to a core list and platform specific lists.
* It adds numerous platform specific installation targets.

Differential Revision: https://reviews.llvm.org/D123498
2022-04-19 10:10:07 -04:00
David Spickett 218b5c8394 [clang][AArch64] Remove BTI after setjmp from release notes
This is now going into 14.0.2 as
571c7d8f6dae1a8797ae3271c0c09fc648b1940b so will not be
new in clang-15.
2022-04-19 13:49:55 +00:00
Joseph Huber 0f8b8d79af [OpenMP][Docs] Remove old 14.0 release information
Summary:
This patch removes the OpenMP sections in the release notes. These will
be filled once the release is close and implementations are finalized.
2022-04-19 08:45:51 -04:00
Joseph Huber 944b25aee3 [OpenMP] Make Xopenmp-target args compile-only to silence warnings
Summary:
Previously we needed the `Xopenmp-target=` option during the linking
phase so the old offloading driver knew which items to extract and link
for the device. Now that the new driver has become the default this is
no longer necessary and will cause a warning to be emitted for the
unused argument. This should be silenced to avoid noise.
2022-04-19 08:42:43 -04:00
Roy Jacobson 76410040b9 Revert "[Concepts] Fix overload resolution bug with constrained candidates"
This reverts commit 454d1df942.
2022-04-19 07:51:21 -04:00
Balazs Benics 7984189826 [analyzer] Remove HasAlphaDocumentation tablegen enum value
D121387 simplified the doc url generation process, so we no longer need
the HasAlphaDocumentation enum entry. This patch removes that.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D121459
2022-04-19 12:14:27 +02:00
Balazs Benics 744e2a3e22 [analyzer] ClangSA should tablegen doc urls refering to the main doc page
AFAIK we should prefer
https://clang.llvm.org/docs/analyzer/checkers.html to
https://clang-analyzer.llvm.org/{available_checks,alpha_checks}.html

This patch will ensure that the doc urls produced by tablegen for the
ClangSA, will use the new url. Nothing else will be changed.

Reviewed By: martong, Szelethus, ASDenysPetrov

Differential Revision: https://reviews.llvm.org/D121387
2022-04-19 12:14:27 +02:00
Balazs Benics 63c4ca9d14 [analyzer] Turn missing tablegen doc entry of a checker into fatal error
It turns out all checkers explicitly mention the `Documentation<>`.
It makes sense to demand this, so emit a fatal tablegen error if such
happens.

Reviewed By: martong, Szelethus

Differential Revision: https://reviews.llvm.org/D122244
2022-04-19 12:14:27 +02:00
Balazs Benics b7c988811d [analyzer][NFC] Introduce the checker package separator character
Reviewed By: martong, ASDenysPetrov

Differential Revision: https://reviews.llvm.org/D122243
2022-04-19 12:14:27 +02:00
Sven van Haastregt f3ee0afc67 [OpenCL] opencl-c.h: Add const to get_image_num_samples
Align with the `-fdeclare-opencl-builtins` option and other
get_image_* builtins which have the const attribute.

Differential Revision: https://reviews.llvm.org/D122728
2022-04-19 10:16:44 +01:00
Roy Jacobson 454d1df942 [Concepts] Fix overload resolution bug with constrained candidates
When doing overload resolution, we have to check that candidates' parameter types are equal before trying to find a better candidate through checking which candidate is more constrained.
This revision adds this missing check and makes us diagnose those cases as ambiguous calls when the types are not equal.

Fixes GitHub issue https://github.com/llvm/llvm-project/issues/53640

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D123182
2022-04-19 04:45:28 -04:00
Timm Bäder 33ec653055 [clang][lexer] Allow u8 character literal prefixes in C2x
Implement N2418 for C2x.

Differential Revision: https://reviews.llvm.org/D119221
2022-04-19 09:57:51 +02:00
Chuanqi Xu cd149dbf8e [NFC] Remove unused variable 2022-04-19 15:19:40 +08:00
Yaxun (Sam) Liu cac4e2fe25 [CUDA][HIP] Fix gpu.used.external
Rename gpu.used.external as __clang_gpu_used_external as ptxas does not
allow . in global variable name.

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

Reviewed by: Joseph Huber, Artem Belevich

Differential Revision: https://reviews.llvm.org/D123946
2022-04-18 23:10:31 -04:00
Michael Kruse 2d92ee97f1 Reapply "[OpenMP] Refactor OMPScheduleType enum."
This reverts commit af0285122f.

The test "libomp::loop_dispatch.c" on builder
openmp-gcc-x86_64-linux-debian fails from time-to-time.
See #54969. This patch is unrelated.
2022-04-18 21:56:47 -05:00
Michael Kruse af0285122f Revert "[OpenMP] Refactor OMPScheduleType enum."
This reverts commit 9ec501da76.

It may have caused the openmp-gcc-x86_64-linux-debian buildbot to fail.
https://lab.llvm.org/buildbot/#/builders/4/builds/20377
2022-04-18 14:38:31 -05:00
Joseph Huber 15e62062c0 [Clang][Docs] Update information on the new driver now that it's default
Summary:
This patch updates some of the documentation on the new driver now that
it's the default. Also the ABI for embedding these images changed.
2022-04-18 15:05:09 -04:00
Joseph Huber ae23be84cb [OpenMP] Make the new offloading driver the default
Previously an opt-in flag `-fopenmp-new-driver` was used to enable the
new offloading driver. After passing tests for a few months it should be
sufficiently mature to flip the switch and make it the default. The new
offloading driver is now enabled if there is OpenMP and OpenMP
offloading present and the new `-fno-openmp-new-driver` is not present.

The new offloading driver has three main benefits over the old method:
- Static library support
- Device-side LTO
- Unified clang driver stages

Depends on D122683

Differential Revision: https://reviews.llvm.org/D122831
2022-04-18 15:05:09 -04:00
Michael Kruse 9ec501da76 [OpenMP] Refactor OMPScheduleType enum.
The OMPScheduleType enum stores the constants from libomp's internal sched_type in kmp.h and are used by several kmp API functions. The enum values have an internal structure, namely each scheduling algorithm (e.g.) exists in four variants: unordered, orderend, normerge unordered, and nomerge ordered.

This patch (basically a followup to D114940) splits the "ordered" and "nomerge" bits into separate flags, as was already done for the "monotonic" and "nonmonotonic", so we can apply bit flags operations on them. It also now contains all possible combinations according to kmp's sched_type. Deriving of the OMPScheduleType enum from clause parameters has been moved form MLIR's OpenMPToLLVMIRTranslation.cpp to OpenMPIRBuilder to make available for clang as well. Since the primary purpose of the flag is the binary interface to libomp, it has been made more private to LLVMFrontend. The primary interface for generating worksharing-loop using OpenMPIRBuilder code becomes `applyWorkshareLoop` which derives the OMPScheduleType automatically and calls the appropriate emitter function.

While this is mostly a NFC refactor, it still applies the following functional changes:
 * The logic from OpenMPToLLVMIRTranslation to derive the OMPScheduleType also applies to clang. Most notably, it now applies the nonmonotonic flag for non-static schedules by default.
 * In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was previously not applied if the simd modifier was used. I assume this was a bug, since the effect was due to `loop.schedule_modifier()` returning `mlir::omp::ScheduleModifier::none` instead of `llvm::Optional::None`.
 * In OpenMPToLLVMIRTranslation, the nonmonotonic default flag was set even if ordered was specified, in breach to what the comment before citing the OpenMP specification says. I assume this was an oversight.

The ordered flag with parameter was not considered in this patch. Changes will need to be made (e.g. adding/modifying function parameters) when support for it is added. The lengthy names of the enum values can be discussed, for the moment this is avoiding reusing previously existing enum value names such as `StaticChunked` to avoid confusion.

Reviewed By: peixin

Differential Revision: https://reviews.llvm.org/D123403
2022-04-18 14:03:17 -05:00
Richard Smith e43c93dd63 Don't treat 'T &forward(T&&)' as builtin.
This allows the standard library to diagnose it properly. Suppress
warning in libc++ testsuite for unused result of call to std::forward.
2022-04-18 11:11:21 -07:00
Corentin Jabot daa6d7b250 [Clang] Use of decltype(capture) in parameter-declaration-clause
Partially implement the proposed resolution to CWG2569.

D119136 broke some libstdc++ code, as P2036R3, implemented as a DR to
C++11 made ill-formed some previously valid and innocuous code.

We resolve this issue to allow decltype(x) - but not decltype((x)
to appear in the parameter list of a lambda that capture x by copy.

Unlike CWG2569, we do not extend that special treatment to
sizeof/noexcept yet, as the resolution has not been approved yet
and keeping the review small allows a quicker fix of impacted code.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D123909
2022-04-18 15:58:25 +02:00
luxufan 429cbac039 [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified
In the past, `clang --target=riscv64-unknown-linux-gnu -mno-relax -c hello.s` will assemble hello.s without relaxation, but `clang --target=riscv64-unknown-linux-gnu -mno-relax -fno-integrated-as -c hello.s` doesn't pass the `-mno-relax` option to assembler, and assemble with relaxation
This patch pass the -mno-relax option to assembler when -fno-integrated-as is specified.

Differential Revision: https://reviews.llvm.org/D120639
2022-04-18 11:16:41 +08:00
Richard Smith b27430f9f4 Treat `std::move`, `forward`, etc. as builtins.
This is extended to all `std::` functions that take a reference to a
value and return a reference (or pointer) to that same value: `move`,
`forward`, `move_if_noexcept`, `as_const`, `addressof`, and the
libstdc++-specific function `__addressof`.

We still require these functions to be declared before they can be used,
but don't instantiate their definitions unless their addresses are
taken. Instead, code generation, constant evaluation, and static
analysis are given direct knowledge of their effect.

This change aims to reduce various costs associated with these functions
-- per-instantiation memory costs, compile time and memory costs due to
creating out-of-line copies and inlining them, code size at -O0, and so
on -- so that they are not substantially more expensive than a cast.
Most of these improvements are very small, but I measured a 3% decrease
in -O0 object file size for a simple C++ source file using the standard
library after this change.

We now automatically infer the `const` and `nothrow` attributes on these
now-builtin functions, in particular meaning that we get a warning for
an unused call to one of these functions.

In C++20 onwards, we disallow taking the addresses of these functions,
per the C++20 "addressable function" rule. In earlier language modes, a
compatibility warning is produced but the address can still be taken.

The same infrastructure is extended to the existing MSVC builtin
`__GetExceptionInfo`, which is now only recognized in namespace `std`
like it always should have been.

This is a re-commit of
  fc30901096,
  a571f82a50, and
  64c045e25b
which were reverted in
  e75d8b7037
due to a crasher bug where CodeGen would emit a builtin glvalue as an
rvalue if it constant-folds.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D123345
2022-04-17 13:26:16 -07:00
Bill Wendling 7f31b4a917 [randstruct] Enforce using a designated init for a randomized struct
A randomized structure needs to use a designated or default initializer.
Using a non-designated initializer will result in values being assigned
to the wrong fields.

Differential Revision: https://reviews.llvm.org/D123763
2022-04-16 23:24:48 -07:00
Aaron Ballman 7692fc81e0 Revert "[randstruct] Enforce using a designated init for a randomized struct"
This reverts commit aed923b124.

It causes some buildbot test failures.
2022-04-16 11:11:32 -04:00
Aaron Ballman 5a4980cc95 Revert "[randstruct] Force errors for all platforms"
This reverts commit 2a404cdfd8.

It didn't address the built bot failures.

https://lab.llvm.org/buildbot/#/builders/171/builds/13231
https://lab.llvm.org/buildbot/#/builders/186/builds/5520
2022-04-16 11:10:57 -04:00
Vitaly Buka e75d8b7037 Revert "Treat `std::move`, `forward`, and `move_if_noexcept` as builtins."
Revert "Extend support for std::move etc to also cover std::as_const and"
Revert "Update test to handle opaque pointers flag flip."

It crashes on libcxx tests https://lab.llvm.org/buildbot/#/builders/85/builds/8174

This reverts commit fc30901096.
This reverts commit a571f82a50.
This reverts commit 64c045e25b.
2022-04-16 00:27:51 -07:00
Jun Zhang 7fde4e2213
Add some helpers to better check Scope's kind. NFC
Signed-off-by: Jun Zhang <jun@junz.org>
2022-04-16 11:31:40 +08:00
Fangrui Song 468c7b65e5 [test] Test -Werror=foo -Wfoo & -Werror -Wno-error=foo -Wfoo
Clang now matches GCC in the two cases.

D109981 fixed the second case though it did not call out the effect.
2022-04-15 20:14:07 -07:00
Shilei Tian e8760b51ee [Clang][OpenMP] Use bitfields for flags in `OMPAtomicDirective`
As suggested in D120290.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D123862
2022-04-15 21:34:28 -04:00
Joseph Huber 33b604d1c3 [OpenMP] Fix linting diagnostics in the linker wrapper
Summary:
A previous patch had some linter warnings that should've been addressed.
2022-04-15 21:19:29 -04:00
Chris Bieneman 329abac134 Blind stab in the dark to fix a bot failure
*fingers crossed*
2022-04-15 20:12:59 -05:00
Joseph Huber 984a0dc386 [OpenMP] Use new offloading binary when embedding offloading images
The previous patch introduced the offloading binary format so we can
store some metada along with the binary image. This patch introduces
using this inside the linker wrapper and Clang instead of the previous
method that embedded the metadata in the section name.

Differential Revision: https://reviews.llvm.org/D122683
2022-04-15 20:35:26 -04:00