Commit Graph

47511 Commits

Author SHA1 Message Date
Alex Brachet 9ec7272fc5 Revert "[Driver][Fuchsia] Add default linker flags"
This reverts commit 5dfc8ebee5.
2022-09-30 14:54:48 +00:00
Alex Brachet 5dfc8ebee5 [Driver][Fuchsia] Add default linker flags
Differential Revision: https://reviews.llvm.org/D132416
2022-09-30 14:07:41 +00:00
Roy Jacobson 894c0e94f9 Revert "[Clang] Fix variant crashes from GH58028, GH57370"
This reverts commit 9706bb3165, some CI workers complain about the test.
2022-09-30 11:24:46 +03:00
Roy Jacobson bd1bb8cd42 [Clang] define __cpp_named_character_escapes
Define the feature test macro for named character escapes.
I assume this was not done because it was implemented before formally accepted, right? cxx_status says the paper is implemented.

Reviewed By: cor3ntin

Differential Revision: https://reviews.llvm.org/D134898
2022-09-30 11:13:18 +03:00
Roy Jacobson 9706bb3165 [Clang] Fix variant crashes from GH58028, GH57370
Fixes a null dereference in some diagnostic issuing code.

Closes https://github.com/llvm/llvm-project/issues/57370
Closes https://github.com/llvm/llvm-project/issues/58028

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D134885
2022-09-30 11:09:02 +03:00
Michał Górny 924996e0a0 [clang] [Driver] Disable default configs via envvar during testing
Add support for a CLANG_NO_DEFAULT_CONFIG envvar that works like
the --no-default-config option when set to a non-empty value.  Use it
to disable loading system configuration files during the test suite
runs.

Configuration files can change the driver behavior in extensive ways,
and it is neither really possible nor feasible to account for or undo
the effects of even the most common configuration uses.  Therefore,
the most reasonable option seems to be to ignore configuration files
while running the majority of tests (with the notable exception of tests
for configuration file support).

Due to the diversity of ways that %clang is used in the test suite,
including using it to copy or symlink the clang executable, as well to
call -cc1 and -cc1as modes, it is not feasible to pass the explicit
options to disable config loading either.  Using an environment variable
has the advantage of being easily applied across the test suite
and easily unset for default configuration file loading tests.

Differential Revision: https://reviews.llvm.org/D134905
2022-09-30 09:11:50 +02:00
Timm Bäder 1ecaa617e7 [clang][Interp] Handle enums
Handle DeclRefExprs of enum types. They are otherwise handled like
integers.

Differential Revision: https://reviews.llvm.org/D134020
2022-09-30 08:18:14 +02:00
Michał Górny 052da736e5 [clang] [test] Use --implicit-check-not in config-file3 tests
Thanks to Fangrui Song for the suggestion.
2022-09-30 08:02:57 +02:00
Xiang Li 10d6a34ef6 [NFC] Use %clang_cc1 2022-09-29 14:26:01 -07:00
Xiang Li e09a6f37d5 [NFC] Move cc1 test out of Driver test 2022-09-29 14:19:12 -07:00
Joshua Batista be07c80cf7 [HLSL] add ceil library function
This change exposes the ceil library function for HLSL,
excluding long, int, and long long doubles.
Ceil is supported for all scalar, vector, and matrix types.

Long and long long double support is missing in this patch because those types
don't exist in HLSL. Int is missing because the ceil function only works on floating type arguments.

The full documentation of the HLSL ceil function is available here:
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-ceil

Reviewed By: python3kgae

Differential Revision: https://reviews.llvm.org/D134319
2022-09-29 14:03:30 -07:00
Siu Chi Chan cecb0e98d4 [HIP] stop forcing the lang std in the driver
D103221 changed HIP's default to C++14, removing the driver logic to
force it into a different std.

Change-Id: I9f5220a7456687039b0bd3b3574f3124d3cc7665

Differential Revision: https://reviews.llvm.org/D134314

Change-Id: I40513f2ebe93ee53ea95c8bb3cc704487d970263
2022-09-29 16:18:29 -04:00
Roy Jacobson 6523814c4e [Clang] P1169R4: static operator()
Implements 'P1169R4: static operator()' from C++2b.

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

Differential Revision: https://reviews.llvm.org/D133659
2022-09-29 23:03:26 +03:00
Fangrui Song 3a79f1caa9 [Driver][test] Restore %clang -cc1 in test/Driver
This partially reverts commit 1609a5d771 (the
test/Driver part). We want to discourage %clang_cc1 and clang -cc1 in
test/Driver. The clang -cc1 uses in hlsl/offload/etc are not good examples.
2022-09-29 12:21:57 -07:00
Michał Górny 1609a5d771 [clang] [test] Use %clang_cc1 substitution consistently
Use the `%clang_cc1` substitution consistently across the test suite,
replacing inline `%clang -cc1` invocations, except for one Preprocessor
test where this is causing breakage.  This is necessary to ensure that
additional parameters passed via `%clang` do not interfere with `-cc1`
that must always be passed as the first command-line argument.

Remove the additional substitution blocking `%clang_cc1` use in Driver
tests.  It has been added in 2013 and was supposed to prevent tests
calling `clang -cc1` from being added to Driver.  The state of the test
suite proves that it did not succeed at all.

Differential Revision: https://reviews.llvm.org/D134880
2022-09-29 20:59:00 +02:00
Michał Górny 74085ebfb6 [llvm] [lit] Move %clang_dxc substitution from clang/test
Move the `%clang_dxc` substitution from local definition in clang/test
to lit's `llvm/config.py` module where all other driver definitions
are found.  This improves consistency and makes it easier to control
global clang options.

Differential Revision: https://reviews.llvm.org/D134871
2022-09-29 20:59:00 +02:00
Michał Górny 063e17d8b0 [clang] [Driver] More flexible rules for loading default configs
Change the default config file loading logic to be more flexible
and more readable at the same time.  The new algorithm focuses on four
locations, in order:

1. <triple>-<mode>.cfg using real driver mode
2. <triple>-<mode>.cfg using executable suffix
3. <triple>.cfg + <mode>.cfg using real driver mode
4. <triple>.cfg + <mode>.cfg using executable suffix

This is meant to preserve reasonable level of compatibility with
the existing use, while introducing more flexibility and making the code
simpler.  Notably:

1. In this layout, the actual target triple is normally respected,
   and e.g. in `-m32` build the `x86_64-*` configs will never be used.

2. Both real driver mode (preferable) and executable suffix are
   supported.  This permits correctly handling calls with explicit
   `--driver-mode=` while at the same time preserving compatibility
   with the existing code.

3. The first two locations provide users with the ability to override
   configuration per specific target+mode combinaton, while the next two
   make it possible to independently specify per-target and per-mode
   configuration.

4. All config file locations are applicable independently of whether
   clang is started via a prefixed executable, or bare `clang`.

5. If the target is not explicitly specified and the executable prefix
   does not name a valid triple, it is used instead of the actual target
   triple for backwards compatibility.

This is particularly meant to address Gentoo's use case for
configuration files: to configure the default runtimes (i.e. `-rtlib=`,
`-stdlib=`) and `--gcc-install-dir=` for all the relevant drivers,
as well as to make it more convenient for users to override `-W` flags
to test compatibility with future versions of Clang easier.

Differential Revision: https://reviews.llvm.org/D134337
2022-09-29 20:58:59 +02:00
Roy Jacobson 013012b99a [Clang][NFC] Add missing feature macros to lexer test 2022-09-29 21:16:29 +03:00
Tim Northover e62b3a9375 Unwind-tables: move back to original logic outline for kind.
There are lots of options interacting in complex ways here, and when moving to
`getDefaultUnwindTableLevel` I had refactored this and changed behaviour in
some cases. So this reverts the basic structure of the logic back to the
original, while leaving the hook in the new style.
2022-09-29 13:39:06 +01:00
Timm Bäder f444a7cc16 Revert "[clang][Interp] Handle enums"
This reverts commit c090295916.

One of the test cases fails. Revert this until I know a way to make it
work reliably.
2022-09-29 13:45:52 +02:00
David Green e6171e87e1 [Clang][Arm] Fix fp16 return error tests under AArch64/Arm. NFC
The -fallow-half-arguments-and-returns option was removed in
59528e4bdb27ed4ab3, replaced with an always-on target option under
AArch64/Arm. There are two tests - fp16-sema.c and renderscripts.rs that
test that an error is produced for __fp16 function args/returns, which
are now expected to pass for Arm/AArch64. i.e they no longer give the
same error as before on native Arm/AArch64 machines. Alter the targets
of those tests to compensate.
2022-09-29 12:16:13 +01:00
Timm Bäder 84f1df8aac [clang][Interp] Properly destruct allocated Records
We are otherwise leaking some memory the records might allocate
themselves.

Differential Revision: https://reviews.llvm.org/D134054
2022-09-29 12:50:56 +02:00
Timm Bäder c090295916 [clang][Interp] Handle enums
Handle DeclRefExprs of enum types. They are otherwise handled like
integers.

Differential Revision: https://reviews.llvm.org/D134020
2022-09-29 12:50:56 +02:00
Timm Bäder ee2e414d66 [clang][Interp] Handle sizeof()
Implement visiting UnaryExprOrTypeTraitExprs to handle sizeof()
expressions.

Differential Revision: https://reviews.llvm.org/D133934
2022-09-29 12:50:55 +02:00
David Green 123064dc39 [Clang][Arm] Convert -fallow-half-arguments-and-returns to a target option. NFC
This cc1 option -fallow-half-arguments-and-returns allows __fp16 to be
passed by argument and returned, without giving an error. It is
currently always enabled for Arm and AArch64, by forcing the option in
the driver. This means any cc1 tests (especially those needing
arm_neon.h) need to specify the option too, to prevent the error from
being emitted.

This changes it to a target option instead, set to true for Arm and
AArch64. This allows the option to be removed. Previously it was implied
by -fnative_half_arguments_and_returns, which is set for certain
languages like open_cl, renderscript and hlsl, so that option now too
controls the errors. There were are few other non-arm uses of
-fallow-half-arguments-and-returns but I believe they were unnecessary.
The strictfp_builtins.c tests were converted from __fp16 to _Float16 to
avoid the issues.

Differential Revision: https://reviews.llvm.org/D133885
2022-09-29 11:00:32 +01:00
Michael Platings dba8fced96 Fix frint ACLE intrinsic names
Although the instruction names begin "frint", the ACLE spec states that
the intrinsic names begin "__rint", without the "f".

Differential Revision: https://reviews.llvm.org/D134824
2022-09-29 09:13:07 +01:00
Fangrui Song 04a65d62a0 Revert D134638 "[Clang][LoongArch] Add inline asm support for constraints k/m/ZB/ZC"
This reverts commit b7baddc755.

Broke CodeGen/X86/callbr-asm-kill.mir
We shall pay attention when adding new constraints.
2022-09-29 00:54:56 -07:00
Fangrui Song 08af5ba371 [Driver] Add --config= as canonical spelling of --config
Driver options usually use `Joined` instead of `Separate`. It is also weird that
`--config-system-dir=`/etc exist while `--config=` did not exist.

Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D134790
2022-09-29 00:38:12 -07:00
Weining Lu b7baddc755 [Clang][LoongArch] Add inline asm support for constraints k/m/ZB/ZC
k: A memory operand whose address is formed by a base register and
(optionally scaled) index register.

m: A memory operand whose address is formed by a base register and
offset that is suitable for use in instructions with the same
addressing mode as st.w and ld.w.

ZB: An address that is held in a general-purpose register. The offset
is zero.

ZC: A memory operand whose address is formed by a base register and
offset that is suitable for use in instructions with the same
addressing mode as ll.w and sc.w.

Differential Revision: https://reviews.llvm.org/D134638
2022-09-29 15:02:08 +08:00
Arthur Eubanks 2f3d7c2cc7 [clang] Add debug info in MicrosoftCXXABI::EmitVirtualMemPtrThunk()
(Probably) fixes https://crbug.com/1355639

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D134825
2022-09-28 22:06:04 -07:00
Martin Sebor a181de452d [clang] handle extended integer constant expressions in _Static_assert (PR #57687)
Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D134311
2022-09-28 13:27:58 -06:00
Yonghong Song 75be0482a2 [clang][DebugInfo] Emit debuginfo for non-constant case value
Currently, clang does not emit debuginfo for the switch stmt
case value if it is an enum value. For example,
  $ cat test.c
  enum { AA = 1, BB = 2 };
  int func1(int a) {
    switch(a) {
    case AA: return 10;
    case BB: return 11;
    default: break;
    }
    return 0;
  }
  $ llvm-dwarfdump test.o | grep AA
  $
Note that gcc does emit debuginfo for the same test case.

This patch added such a support with similar implementation
to CodeGenFunction::EmitDeclRefExprDbgValue(). With this patch,
  $ clang -g -c test.c
  $ llvm-dwarfdump test.o | grep AA
                  DW_AT_name    ("AA")
  $

Differential Revision: https://reviews.llvm.org/D134705
2022-09-28 12:10:48 -07:00
Aaron Ballman 96a79cb308 Fix a tautological comparison bug caught during post-commit
This amends fd874e5fb1 to correctly set
the bit width of a '!' operator to be the same width as an 'int'. This
fixes a failed assertion about unexpected bit widths that was reported
during post-commit testing.
2022-09-28 14:23:28 -04:00
Aaron Ballman 60727d8569 [C2x] implement typeof and typeof_unqual
This implements WG14 N2927 and WG14 N2930, which together define the
feature for typeof and typeof_unqual, which get the type of their
argument as either fully qualified or fully unqualified. The argument
to either operator is either a type name or an expression. If given a
type name, the type information is pulled directly from the given name.
If given an expression, the type information is pulled from the
expression. Recursive use of these operators is allowed and has the
expected behavior (the innermost operator is resolved to a type, and
that's used to resolve the next layer of typeof specifier, until a
fully resolved type is determined.

Note, we already supported typeof in GNU mode as a non-conforming
extension and we are *not* exposing typeof_unqual as a non-conforming
extension in that mode, nor are we exposing typeof or typeof_unqual as
a nonconforming extension in other language modes. The GNU variant of
typeof supports a form where the parentheses are elided from the
operator when given an expression (e.g., typeof 0 i = 12;). When in C2x
mode, we do not support this extension.

Differential Revision: https://reviews.llvm.org/D134286
2022-09-28 13:27:52 -04:00
Nicolas Lesser 4848f3bf2f [C++2a] P0634r3: Down with typename!
This patch implements P0634r3 that removes the need for 'typename' in certain contexts.

For example,

```
template <typename T>
using foo = T::type; // ok
```

This is also allowed in previous language versions as an extension, because I think it's pretty useful. :)

Reviewed By: #clang-language-wg, erichkeane

Differential Revision: https://reviews.llvm.org/D53847
2022-09-28 09:50:19 -07:00
Alan Zhao 6f2b347895 Add missing `struct` keyword to the test p2-2.cpp
While working on D53847, I noticed that this test would fail once we
started recognizing the types in the modified `export` statement [0].
The tests would fail because Clang would emit a "declaration does not
declare anything" diagnostic instead of the expected namespace scope
diagnostic.

I believe that the test is currently incorrectly passing because Clang
doesn't parse the type and therefore doesn't treat the statement as a
declaration. My understanding is that the intention of this test case is
that it wants to export a `struct` type, which I believe requires a
`struct` keyword, even for types with template parameters. With this
change, the only error with these two statements should be the
namespace scope issue.

[0]: https://reviews.llvm.org/D53847?id=462032#inline-1297053

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D134578
2022-09-28 09:48:00 -07:00
Arthur Eubanks 44ad67031c [clang][msan] Turn on -fsanitize-memory-param-retval by default
This eagerly reports use of undef values when passed to noundef
parameters or returned from noundef functions.

This also decreases binary sizes under msan.

To go back to the previous behavior, pass `-fno-sanitize-memory-param-retval`.

Reviewed By: vitalybuka, MaskRay

Differential Revision: https://reviews.llvm.org/D134669
2022-09-28 09:36:39 -07:00
Nathan Sidwell 3d2080683f [clang][DR2621] using enum NAME lookup fix
Although using-enum's grammar is 'using elaborated-enum-specifier',
the lookup for the enum is ordinary lookup (and not the tagged-type
lookup that normally occurs wth an tagged-type specifier).  Thus (a)
we can find typedefs and (b) do not find enum tags hidden by a non-tag
name (the struct stat thing).

This reimplements that part of using-enum handling, to address DR2621,
where clang's behaviour does not match std intent (and other
compilers).

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D134283
2022-09-28 08:50:27 -07:00
River Riddle 50d96f59d0 [TableGen] Track reference locations of Records/RecordVals
This is extremely useful for language tooling as it allows
for providing go-to-def/find-references/etc. for many
more situations than what is currently possible.

Differential Revision: https://reviews.llvm.org/D134087
2022-09-27 23:48:16 -07:00
Jun Zhang 89e56e732d
[Clang] Don't warn if deferencing void pointers in unevaluated context
After https://reviews.llvm.org/D134461, Clang will diagnose a warning if
trying to deference void pointers in C mode. However, this causes a lot
of noises when compiling a 5.19.11 Linux kernel.

This patch reduces the warning by marking deferencing void pointers in
unevaluated context OK, like `sizeof(*void_ptr)`, `typeof(*void_ptr)`
and etc.

Fixes https://github.com/ClangBuiltLinux/linux/issues/1720

Signed-off-by: Jun Zhang <jun@junz.org>

Differential Revision: https://reviews.llvm.org/D134702
2022-09-28 12:30:02 +08:00
Yuanfang Chen c4b79bf083 Fix the test added in 55cd5bc509
It is hard to test the functionality for multiple platforms. Just test it
on Linux as similar patches did in the past.
2022-09-27 16:42:55 -07:00
Yuanfang Chen fbfb4a6359 Fix test after 5839fb6d25
The test is not expected for Windows.
2022-09-27 14:01:13 -07:00
Yuanfang Chen c12c26c176 Fix test after 5839fb6d25
The test is not expected for PS4.
2022-09-27 13:39:56 -07:00
Yuanfang Chen 54967c01d2 [Driver] pass -fjmc to LTO
So the behavior is consistent with non-LTO mode.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D134659
2022-09-27 13:14:16 -07:00
Yuanfang Chen 55cd5bc509 [Driver][PS4] pass -fcrash-diagnostics-dir to LTO
Also refactor the existing code a little bit.

Reviewed By: probinson

Differential Revision: https://reviews.llvm.org/D134673
2022-09-27 13:14:16 -07:00
Yuanfang Chen 5839fb6d25 [Driver] pass -fcrash-diagnostics-dir to LTO
So the behavior is consistent with non-LTO mode.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D134657
2022-09-27 13:14:16 -07:00
Jennifer Yu 30cc712eb6 [Clang][OpenMP] Fix run time crash when use_device_addr is used.
It is data mapping ordering problem.

According omp spec
If one or more map clauses are present, the list item conversions that
are performed for any use_device_ptr or use_device_addr clause occur
after all variables are mapped on entry to the region according to those
map clauses.

The change is to put mapping data for use_device_addr at end of data
mapping array.

Differential Revision: https://reviews.llvm.org/D134556
2022-09-27 11:53:57 -07:00
Qiongsi Wu 86cd353520 [LTO][clang] Using Single Dash Consistently when Passing LTO Options
The following three static functions in `clang/lib/Driver/ToolChains/CommonArgs.cpp`

```
static void renderRpassOptions(...)
static void renderRemarksOptions(...)
static void renderRemarksHotnessOptions(...)
```

use `--plugin-opt` for the plugin option prefix, while the function `tools::addLTOOptions`  uses `-plugin-opt`. This patch makes sure that we only use `-plugin-opt` (single dash) everywhere. It is not clear to me that why we decided to use `--plugin-opt` in https://reviews.llvm.org/D85810. If using `--plugin-opt` is intended, I'd love to hear the reason and I will close this patch.

We intend to followup this patch with a few other patches that teach `clang` to pass plugin options to the AIX linker, which uses a different prefix (`-bplugin_opt:`).

Reviewed By: w2yehia

Differential Revision: https://reviews.llvm.org/D134668
2022-09-27 14:50:41 -04:00
Craig Topper d1ad006a8f [Driver] Prevent Mips specific code from claiming -mabi argument on other targets.
Fixes PR57976.

Reviewed By: erichkeane, arichardson, MaskRay

Differential Revision: https://reviews.llvm.org/D134671
2022-09-27 10:07:20 -07:00
Joseph Huber f50a7c7a26 [LinkerWrapper] Fix optimized debugging builds for NVPTX LTO
The ptxas assembler does not allow the `-g` flag along with
optimizations. Normally this is degraded to line info in the driver, but
when using LTO we did not have this step and the linker wrapper was not
correctly degrading the option. Note that this will not work if the user
does not pass `-g` again to the linker invocation. That will require
setting some flags in the binary to indicate that debugging was used
when building.

This fixes #57990

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D134660
2022-09-27 10:49:17 -05:00