Commit Graph

94013 Commits

Author SHA1 Message Date
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