Commit Graph

93683 Commits

Author SHA1 Message Date
Jun Zhang 5b38292d5d
[NFC] Use range based loop.
Signed-off-by: Jun Zhang <jun@junz.org>

Differential Revision: https://reviews.llvm.org/D122657
2022-03-30 22:44:34 +08:00
wangpc cebbfd3d25 [RISCV] Add index check for vset/vget
Index of vset/vget must be a constant integer and be
located in right range.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D122629
2022-03-30 19:29:13 +08:00
Aaron Ballman cf4a67bcbb Don't diagnostic atomic object access as UB in an unevaluated context
We started diagnosing this situation with a more clear diagnostic
message, but it was pointed out that unevaluated contexts don't really
have the undefined behavior property as there is no runtime access
involved.

This augments the changes in https://reviews.llvm.org/D122656 to not
diagnose in an unevaluated context.
2022-03-30 07:12:49 -04:00
Nikita Popov 8a72391f60 [IR] Require intrinsic struct return type to be anonymous
This is an alternative to D122376. Rather than working around the
problem, this patch requires that struct return types in intrinsics
are anonymous/literal and adds auto-upgrade code to convert
existing uses of intrinsics with named struct types.

This ensures that the mapping between intrinsic name and
intrinsic function type is actually bijective, as it is supposed
to be.

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

Differential Revision: https://reviews.llvm.org/D122471
2022-03-30 09:51:24 +02:00
Markus Böck e59335e891 [clang][DR] Add test for DR1227 and mark it as complete
DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1227

This DR has been implemented in Clang as far back as I could check. This patch simply adds a test and comment to mark it as complete.

Differential Revision: https://reviews.llvm.org/D122682
2022-03-30 09:25:52 +02:00
Zakk Chen 10b2760da0 Revert "[RISCV] Add policy operand for masked compare and vmsbf/vmsif/vmsof IR"
This reverts commit 10fd2822b7.

I have a better implementation for those operations without the
additional policy operand.
masked compare and vmsbf/vmsif/vmsof are always tail agnostic so we could
assume undef maskedoff is mask agnostic.

Differential Revision: https://reviews.llvm.org/D122455
2022-03-29 18:05:33 -07:00
Akira Hatanaka 6ec79a15cb Remove -O1 from command line of nrvo.cpp
Also, check that NRVO currently isn't performed in test25. The checks
were accidentally removed when https://reviews.llvm.org/D122425 disabled
inlining.
2022-03-29 15:53:36 -07:00
Chris Bieneman 94189b42cc [HLSL] Fix MSFT Attribute parsing, add numthreads
HLSL uses Microsoft-style attributes `[attr]`, which clang mostly
ignores. For HLSL we need to handle known Microsoft attributes, and to
maintain C/C++ as-is we ignore unknown attributes.

To utilize this new code path, this change adds the HLSL `numthreads`
attribute.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D122627
2022-03-29 17:17:19 -05:00
Vince Bridgers fe8b2236ef [analyzer] Fix "RhsLoc and LhsLoc bitwidth must be same"
clang: <root>/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:727:
void assertEqualBitWidths(clang::ento::ProgramStateRef,
  clang::ento::Loc, clang::ento::Loc): Assertion `RhsBitwidth ==
  LhsBitwidth && "RhsLoc and LhsLoc bitwidth must be same!"'

This change adjusts the bitwidth of the smaller operand for an evalBinOp
as a result of a comparison operation. This can occur in the specific
case represented by the test cases for a target with different pointer
sizes.

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D122513
2022-03-29 17:08:19 -05:00
Zixu Wang d1d34bafef [clang][extract-api] Add Objective-C protocol support
Add support for Objective-C protocol declarations in ExtractAPI.

Depends on D122446

Differential Revision: https://reviews.llvm.org/D122511
2022-03-29 14:44:49 -07:00
Vitaly Buka 122638d97d [msan] Add link to the lifetime definition
Differential Revision: https://reviews.llvm.org/D122685
2022-03-29 14:42:36 -07:00
James Y Knight 8f66f13719 Fix memory leak in [Clang] Implement __builtin_source_location.
Fixes: d614874900
2022-03-29 17:32:59 -04:00
Zixu Wang 9b36e126fd [clang][extract-api] Add Objective-C interface support
Add support for Objective-C interface declarations in ExtractAPI.

Depends on D122495

Differential Revision: https://reviews.llvm.org/D122446
2022-03-29 14:29:39 -07:00
Chris Bieneman dfde354958 NFC. Fixing warnings from adding DXContainer
Adds DXContainer to switch statements in Clang and LLDB to silence
warnings.
2022-03-29 14:46:24 -05:00
Markus Böck c1e614c8eb [clang][DR] Test and mark DR1305 as complete
DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1305

This DR has always been implemented in all clang versions as far back as I could go. This patch basically just adds a test with the needed comments to mark it as complete.

Differential Revision: https://reviews.llvm.org/D122674
2022-03-29 20:45:49 +02:00
wangyihan de7cd3ccf5 [Clang][CodeGen]Remove anonymous tag locations
Remove anonymous tag locations, powered by 'PrintingPolicy',
@aaron.ballman once suggested removing this extra information in
https://reviews.llvm.org/D122248
struct:

  struct S {
    int a;
    struct /* Anonymous*/ {
      int x;
    } b;
    int c;
  };

Before:

  struct S {
    int a = 0
      struct S::(unnamed at ./builtin_dump_struct.c:20:3) {
        int x = 0
      }
    int c = 0
  }

After:

struct S {
  int a = 0
    struct S::(unnamed) {
      int x = 0
    }
  int c = 0
}

Differntial Revision: https://reviews.llvm.org/D122670
2022-03-29 11:38:29 -07:00
Chris Bieneman 7a94a032f0 NFC. Fixing rebase error
Somehow managed to get a double-assignment in there. Thanks @erichkeane
for pointing it out!
2022-03-29 13:19:06 -05:00
wangyihan 6c32075d29 [Clang][doc][NFC]Remove duplicate items in ReleaseNotes
Remove duplicate items in ReleaseNotes for __builtin_dump_struct, the
code changes int patch https://reviews.llvm.org/D122248

Differential Revision: https://reviews.llvm.org/D122668
2022-03-29 10:30:34 -07:00
Zixu Wang 15bf0e5673 [clang][extract-api] Use correct language info from inputs
The current way of getting the `clang::Language` from `LangOptions` does
not handle Objective-C correctly because `clang::Language::ObjC` does
not correspond to any `LangStandard`. This patch passes the correct
`Language` from the frontend input information.

Differential Revision: https://reviews.llvm.org/D122495
2022-03-29 10:06:08 -07:00
Aaron Ballman 43b34c981a Fix a test failure.
This amends 3c84e4a0db which had an
unsaved change when committed.
2022-03-29 12:27:23 -04:00
Aaron Ballman 3c84e4a0db [C11] Improve the diagnostic when accessing a member of an atomic struct
Member access for an atomic structure or union is unconditional
undefined behavior (C11 6.5.2.3p5). However, we would issue a confusing
error message about the base expression not being a structure or union
type.

GCC issues a warning for this case. Clang now warns as well, but the
warning is defaulted to an error because the actual access is still
unsafe.

This fixes Issue 54563.
2022-03-29 12:14:36 -04:00
Johannes Doerfert 95ea3e86bb [OpenMP] Regenerate the check lines for 2 tests
Somehow those check lines were mostly untested prefixes and the ones we
were looking for have been removed. Simple cleanup.
2022-03-29 10:00:03 -05:00
Chris Bieneman 5b6207f3cd [ADT] Flesh out HLSL raytracing environments
Fleshing this out now allows me to rely on enum math to translate
values rather than having to translate the off cases.

I should have added this in the first pass, but wasn't thinking about
it.
2022-03-29 09:43:03 -05:00
serge-sans-paille f5c666742f [doc] Rely on tblgen to dump supported options value when generating doc
It was already the case for CLI help, also support it for rst output. As a side
effect remove redundant (and sometime inconsistent!) value help from HelpText in
clang/Driver/Options.td.

Differential Revision: https://reviews.llvm.org/D122378
2022-03-29 12:25:33 +02:00
Sven van Haastregt de30408b3b [OpenCL] opencl-c.h: remove a/b/c/i/p/n/v arg names
This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" any single-letter identifiers.

Continues the direction set out in D119560.
2022-03-29 10:16:27 +01:00
Markus Böck 984554f846 [clang][DR] Test and mark DR1479 as complete
DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1479

Clang has implemented this DR as far back as I could go on compiler explorer (3.0). This patch simply adds a test case and needed comments for the update script to mark it as complete.

Differential Revision: https://reviews.llvm.org/D122620
2022-03-29 09:28:32 +02:00
luxufan a5900401b1 [RISCV][test] Make PATH empty when testing --gcc-toolchain is multilib_riscv_elf_sdk
Due to D79842, clang dirver would search possible tool name in both possible
locations, then moving to the next name. The gcc toolchain `llvm-project/clang/test/Driver/
Inputs/multilib_riscv_elf_sdk` don't have a `riscv64-unknown-elf-ld` executable in
`llvm-project/clang/test/Driver/Inputs/multilib_riscv_elf_sdk/bin/`. So when searching
`riscv64-unknown-elf-ld`, if there is a `riscv64-unknown-elf-ld` in `PATH`, the
test would fail.

This patch makes the `PATH` empty when testing it.

Differential Revision: https://reviews.llvm.org/D122588
2022-03-29 14:51:23 +08:00
Paul Kirth 90cb325abd Revert "[misexpect] Re-implement MisExpect Diagnostics"
This reverts commit 2add3fbd97.
2022-03-29 06:20:30 +00:00
Paul Kirth 6c77972bac Revert "[docs][misexpect][NFC] Fix malformed table in docs"
This reverts commit a427e18896.
2022-03-29 06:19:53 +00:00
Ben Shi 50de68bc2f [Driver][AVR] Emit proper warnings for different options
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D122524
2022-03-29 12:05:21 +08:00
Phoebe Wang cd26190a10 [X86][regcall] Support passing / returning structures
Currently, the regcall calling conversion in Clang doesn't match with
ICC when passing / returning structures. https://godbolt.org/z/axxKMKrW7

This patch tries to fix the problem to match with ICC.

Reviewed By: LuoYuanke

Differential Revision: https://reviews.llvm.org/D122104
2022-03-29 11:29:57 +08:00
Chenbing Zheng d9ef6ad05f [RISCV] [NFC] add some tests for overloaded intrinsics of FP16
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D122564
2022-03-29 10:00:20 +08:00
Paul Kirth a427e18896 [docs][misexpect][NFC] Fix malformed table in docs
Reviewed By: abrachet

Differential Revision: https://reviews.llvm.org/D122623
2022-03-29 00:14:07 +00:00
Roland McGrath 1a963d3278 [Driver] Make -moutline-atomics default for aarch64-fuchsia targets
This makes Fuchsia consistent with Linux on AArch64.

Reviewed By: abrachet

Differential Revision: https://reviews.llvm.org/D122613
2022-03-28 16:51:55 -07:00
Paul Kirth 2add3fbd97 [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-03-28 23:30:04 +00:00
James Y Knight d614874900 [Clang] Implement __builtin_source_location.
This builtin returns the address of a global instance of the
`std::source_location::__impl` type, which must be defined (with an
appropriate shape) before calling the builtin.

It will be used to implement std::source_location in libc++ in a
future change. The builtin is compatible with GCC's implementation,
and libstdc++'s usage. An intentional divergence is that GCC declares
the builtin's return type to be `const void*` (for
ease-of-implementation reasons), while Clang uses the actual type,
`const std::source_location::__impl*`.

In order to support this new functionality, I've also added a new
'UnnamedGlobalConstantDecl'. This artificial Decl is modeled after
MSGuidDecl, and is used to represent a generic concept of an lvalue
constant with global scope, deduplicated by its value. It's possible
that MSGuidDecl itself, or some of the other similar sorts of things
in Clang might be able to be refactored onto this more-generic
concept, but there's enough special-case weirdness in MSGuidDecl that
I gave up attempting to share code there, at least for now.

Finally, for compatibility with libstdc++'s <source_location> header,
I've added a second exception to the "cannot cast from void* to T* in
constant evaluation" rule. This seems a bit distasteful, but feels
like the best available option.

Reviewers: aaron.ballman, erichkeane

Differential Revision: https://reviews.llvm.org/D120159
2022-03-28 18:29:02 -04:00
Pierre d'Herbemont c8048c7c42 [attributes] Generalize attribute 'enforce_tcb' to Objective-C methods.
Calling an ObjC method from a C function marked with the 'enforce_tcb'
attribute did not produce a warning. Now it does, and on top of that
Objective-C methods can participate in TCBs themselves.

Differential Revision: https://reviews.llvm.org/D122343
2022-03-28 15:08:47 -07:00
Aaron Puchert 1721d52a62 Let clang-repl link privately against Clang components
First of all, this is the convention: all other tools have their
dependencies private. While it does not have an effect on linking
(there is no linking against executables), it does have an effect
on exporting: having the targets private allows installing the tools
without the libraries in a statically linked build, or a build against
libclang-cpp.so.

Reviewed By: v.g.vassilev

Differential Revision: https://reviews.llvm.org/D122546
2022-03-28 23:53:53 +02:00
owenca eee536dd31 [clang-format] Don't format qualifiers in PPDirective
Fixes #54513

Differential Revision: https://reviews.llvm.org/D122548
2022-03-28 14:28:14 -07:00
Chris Bieneman d394f9f897 Add HLSL Language Option and Preprocessor
Bringing in HLSL as a language as well as language options for each of
the HLSL language standards.

While the HLSL language is unimplemented, this patch adds the
HLSL-specific preprocessor defines which enables testing of the command
line options through the driver.

Reviewed By: pete, rnk

Differential Revision: https://reviews.llvm.org/D122087
2022-03-28 16:16:17 -05:00
Emil Kieri 577827cbbf [flang][driver] Make --version and -version consistent with clang
This patch makes -version valid, and --version invalid, for
flang-new -fc1. The invocation
  flang-new --version
remains valid. This behaviour is consistent with clang
(and with clang -cc1 and clang -cc1as).

Previously, flang-new -fc1 accepted --version (as per Options.td), but
the frontend driver acutally checks for -version. As a result,
  flang-new -fc1 --version
triggered no action, emitted no message, and stalled waiting for
standard input.

Fixes #51438

Reviewed By: PeteSteinfeld, awarzynski

Differential Revision: https://reviews.llvm.org/D122542
2022-03-28 22:53:17 +02:00
Nico Weber 67aea3b65c [clang] Make Driver tests pass when running with temp dir containing "crt"
In a recent run, temp files got created in /tmp/lit-tmp-2wcrtcx1/foo-xxx.o.
Since the tmp path contained "crt", this made a few tests fail:
http://45.33.8.238/linux/72221/step_7.txt

Not allowing '/' as path of the file name prevents this.

Differential Revision: https://reviews.llvm.org/D122547
2022-03-28 16:06:43 -04:00
Chris Bieneman c5e54e2752 Add clang DirectX target support
This change adds a stub DirectX target for clang to enable targeting
dxil targets.

Reviewed By: pete

Differential Revision: https://reviews.llvm.org/D122085
2022-03-28 15:00:50 -05:00
Volodymyr Sapsai a621b0af9c [clang][NFC] Remove unused parameter in `Sema::ActOnDuplicateDefinition`. 2022-03-28 12:07:28 -07:00
Aaron Ballman ca844ab01c Fix template instantiation of UDLs
Previously, we would instantiate the UDL by marking the function as
referenced and potentially binding to a temporary; this skipped
transforming the call when the UDL was dependent on a template
parameter.

Now, we defer all the work to instantiating the call expression for the
UDL. This ensures that constant evaluation occurs at compile time
rather than deferring until runtime.

Fixes Issue 54578.
2022-03-28 14:46:53 -04:00
Eric Li a29fd4d4da [libTooling] Fix indentation. NFC. 2022-03-28 18:34:45 +00:00
Joseph Huber fceea4e110 [OpenMP] Fix library path missing when using OpenMP
The changes in D122444 caused OpenMP programs built with the
LLVM_ENABLE_RUNTIMES options to stop finding the libraries. We generally
expect to link against the libraries associated with the clang
installation itself but we no longer implicitly included that directory.
This patch adds in the include path of the clang installations library
to ensure we can find them.

Reviewed By: jdoerfert, MaskRay

Differential Revision: https://reviews.llvm.org/D122592
2022-03-28 14:30:35 -04:00
Akira Hatanaka b6dab4ebac Pass -disable-llvm-passes to avoid running llvm passes
Differential Revision: https://reviews.llvm.org/D122425
2022-03-28 11:14:44 -07:00
Fangrui Song 52fa1d1a02 [Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition
Many options (-fsyntax-only, -E, -S, etc) skip the link action phase which the
existing condition does not account for.

Since the code no longer specifies OPT_c, I think a single RUN line about -c
not leading to a warning is sufficient. Adding one for all of -E,
-fsyntax-only, -S would be excessive.

Reviewed By: benshi001

Differential Revision: https://reviews.llvm.org/D122553
2022-03-28 10:27:16 -07:00
Fangrui Song 17ea5bf1d5 Revert "[Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition"
This reverts commit 16524d2f1b.

The test caused some warnings when avr-gcc was not installed.
2022-03-28 10:11:45 -07:00
Fangrui Song 16524d2f1b [Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition
Many options (-fsyntax-only, -E, -S, etc) skip the link action phase which the
existing condition does not account for.

Since the code no longer specifies OPT_c, I think a single RUN line about -c
not leading to a warning is sufficient. Adding one for all of -E,
-fsyntax-only, -S would be excessive.

Reviewed By: benshi001

Differential Revision: https://reviews.llvm.org/D122553
2022-03-28 09:43:36 -07:00
Eric Li e334f044cd [libTooling] Support TransformerResult<void> in consumer callbacks
Support `TransformerResult<void>` in the consumer callback, which
allows generic code to more naturally use the `Transformer` interface
(instead of needing to specialize on `void`).

This also delete the specialization that existed within `Transformer`
itself, instead replacing it with an `std::function` adapter.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D122499
2022-03-28 15:39:46 +00:00
Ranjeet Singh 4df69c1ff1 [ARM] Make testcase warning pattern match more specific
Make the warning more specific as downstream compilers could produce other warnings.

Reviewed By: tstellar

Differential Revision: https://reviews.llvm.org/D122487
2022-03-28 14:44:15 +01:00
Jake Egan f5a9b5cc12 [NFC][tests][AIX] XFAIL test for lack of visibility support
With the addition of `__attribute__((visibility("hidden")))` to the test, the test fails because AIX's current default behaviour is to ignore hidden visibility, so the expected error is not seen. This patch marks the test `XFAIL` on AIX for now.

Reviewed By: cebowleratibm

Differential Revision: https://reviews.llvm.org/D122519
2022-03-28 09:43:48 -04:00
Erich Keane 281b7eeb14 Update www_status/add test for P1972:
This seems to have been implemented/supported correctly back in Clang
10, so update the documentation and add the test from the paper.
2022-03-28 06:31:04 -07:00
Mikhail Goncharov 8a2a966520 Return -no-canonical-prefixes for riskv32/64 test
W/o -no-canonical-prefixes CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
does not match clang output for some setups.

See da62a5c661.
2022-03-28 11:23:14 +02:00
Balázs Kéri c5d83cdca4 [clang][ASTImporter] Fix a bug when importing CXXDefaultInitExpr.
The "in-class initializer" expression should be set in the field of a
default initialization expression before this expression node is created.
The `CXXDefaultInitExpr` objects are created after the AST is loaded and
at import not present in the "To" AST. And the in-class initializers of
the used fields can be missing too, these must be set at import.

This fixes a github issue #54061.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D120824
2022-03-28 10:55:26 +02:00
Fangrui Song c0eb9b4cde Revert D121984 "[RISCV][NFC] Moving RVV intrinsic type related util to llvm/Support"
This reverts commit ad57e10dbc and 1967fd8d5e

llvm/lib/Support/RISCVVIntrinsicUtils.cpp introduced llvm/TableGen includes,
a circular dependency https://llvm.org/docs/CodingStandards.html#library-layering
I think this particular instance is serious and should be reverted.
2022-03-28 01:17:37 -07:00
Iain Sandoe 85b1354098 [C++20][Modules][HU 5/5] Add fdirectives-only mode for preprocessing output.
When the -fdirectives-only option is used together with -E, the preprocessor
output reflects evaluation of if/then/else directives.

As such, it preserves defines and undefs of macros that are still live after
such processing.  The intent is that this output could be consumed as input
to generate considered a C++20 header unit.

We strip out any (unused) defines that come from built-in, built-in-file or
command line; these are re-added when the preprocessed source is consumed.

Differential Revision: https://reviews.llvm.org/D121099
2022-03-28 07:38:22 +01:00
Kito Cheng ad57e10dbc [RISCV][NFC] Moving RVV intrinsic type related util to llvm/Support
This patch is split from https://reviews.llvm.org/D111617, we need those
stuffs on clang, so must moving those stuff to llvm/Support.

Reviewed By: khchen

Differential Revision: https://reviews.llvm.org/D121984
2022-03-28 14:35:28 +08:00
Florian Hahn 8b245ab41d
[Clang,TBAA] Add test cases for nested pointers and TBAA data. 2022-03-27 19:59:37 +01:00
Iain Sandoe d9cea8d3a8 [C++20][Modules][HU 4/5] Handle pre-processed header units.
We wish to support emitting a pre-processed output for an importable
header unit, that can be consumed to produce the same header units as
the original source.

This means that ee need to find the original filename used to produce
the re-preprocessed output, so that it can be assigned as the module
name.  This is peeked from the first line of the pre-processed source
when the action sets up the files.

Differential Revision: https://reviews.llvm.org/D121098
2022-03-27 09:38:06 +01:00
Iain Sandoe f8846229c4 [C++20][Modules][HU 3/5] Emit module macros for header units.
For header units we build the top level module directly from the header
that it represents and macros defined in this TU need to be emitted (when
such a definition is live at the end of the TU).

Differential Revision: https://reviews.llvm.org/D121097
2022-03-26 16:30:40 +00:00
Aaron Ballman bfa2f25d35 [C11] Correct the resulting type for an assignment expression
In C, assignment expressions result in an rvalue whose type is the type
of the lhs of the assignment after it undergoes lvalue to rvalue
conversion. lvalue to rvalue conversion in C strips all qualifiers
including _Atomic.

We used getUnqualifiedType() which does not strip the _Atomic qualifier
when we should have used getAtomicUnqualifiedType(). This corrects the
usage and adds some comments to getUnqualifiedType() to make it more
clear that it does not strip _Atomic and that's on purpose (see C11
6.2.5p27).

This addresses Issue 48742.
2022-03-26 08:03:11 -04:00
Mark de Wever c3b672a34c [Clang][doc] Fix __builtin_assume wording.
D117296 removed wording for __builtin_assume, D120205 restored the
wording, but the last sentence was only partly restored. This restores
the rest of the last sentence.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D122423
2022-03-26 13:02:40 +01:00
Iain Sandoe 0687578728 [C++20][Modules][HU 2/5] Support searching Header Units in user or system search paths.
This is support for the user-facing options to create importable header units
from headers in the user or system search paths (or to be given an absolute path).

This means that an incomplete header path will be passed by the driver and the
lookup carried out using the search paths present when the front end is run.

To support this, we introduce file fypes for c++-{user,system,header-unit}-header.
These terms are the same as the ones used by GCC, to minimise the differences for
tooling (and users).

The preprocessor checks for headers before issuing a warning for
"#pragma once" in a header build.  We ensure that the importable header units
are recognised as headers in order to avoid such warnings.

Differential Revision: https://reviews.llvm.org/D121096
2022-03-26 10:17:17 +00:00
Fangrui Song c37accf0a2 [Option] Avoid using the default argument for the 3-argument hasFlag. NFC
The default argument true is error-prone: I think many would think the
default is false.
2022-03-26 00:57:06 -07:00
Fangrui Song da62a5c661 [Driver][test] Clean up riscv* tests
See `D119309` for the guideline (-target, -no-canonical-prefixes, unneeded -o
with -###).
2022-03-25 23:59:31 -07:00
Joseph Huber 392bb8cf1f [OpenMP] Fix AMDGPU globals test 2022-03-25 23:05:41 -04:00
Joseph Huber 9d3550c517 [OpenMP] Add AMDGPU calling convention to ctor / dtor functions
This patch adds the necessary AMDGPU calling convention to the ctor /
dtor kernels. These are fundamentally device kenels called by the host
on image load. Without this calling convention information the AMDGPU
plugin is unable to identify them.

Depends on D122504

Fixes #54091

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D122515
2022-03-25 22:44:20 -04:00
Joseph Huber 3c6d32ec6c [OpenMP] Make Ctor / Dtor functions have external visibility
The default construction of constructor functions by LLVM tends to make
them have internal linkage. When we call a ctor / dtor function in the
target region we are actually creating a kernel that is called at
registration. Because the ctor is a kernel we need to make sure it's
externally visible so we can actually call it. This prevented AMDGPU
from correctly using constructors while NVPTX could use them simply
because it ignored internal visibility.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D122504
2022-03-25 22:44:17 -04:00
David Blaikie 34b9b1ea48 Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static"
Some functions can end up non-externally visible despite not being
declared "static" or in an unnamed namespace in C++ - such as by having
parameters that are of non-external types.

Such functions aren't mistakenly intended to be defining some function
that needs a declaration. They could be maybe more legible (except for
the operator new example) with an explicit static, but that's a
stylistic thing outside what should be addressed by a warning.

This reapplies 275c56226d - once we figure
out what to do about the change in behavior for -Wnon-c-typedef-for-linkage
(this reverts the revert commit 85ee1d3ca1)

Differential Revision: https://reviews.llvm.org/D121328
2022-03-25 23:53:19 +00:00
Fangrui Song afaefb671f [Driver][Linux] Remove D.Dir+"/../lib" from default search paths for LLVM_ENABLE_RUNTIMES builds
The rule was added in 2014 to support -stdlib=libc++ and -lc++ without
specifying -L, when D.Dir is not a well-known system library directory like
/usr/lib /usr/lib64. This rule turns out to get in the way with (-m32 for
64-bit clang) or (-m64 for 32-bit clang) for Gentoo :
https://github.com/llvm/llvm-project/issues/54515

Nowadays LLVM_ENABLE_RUNTIMES is the only recommended way building libc++ and
LLVM_ENABLE_PROJECTS=libc++ is deprecated. LLVM_ENABLE_RUNTIMES builds libc++
in D.Dir+"/../lib/${triple}/". The rule is unneeded. Also reverts D108286.

Gentoo uses a modified LLVM_ENABLE_RUNTIMES that installs libc++.so in
well-known paths like /usr/lib64 and /usr/lib which are already covered by
nearby search paths.

Implication: if a downstream package needs something like -lLLVM-15git and uses
libLLVM-15git.so not in a well-known path, it needs to supply -L
D.Dir+"/../lib" explicitly (e.g. via LLVMConfig.cmake), instead of relying on
the previous default search path.

Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D122444
2022-03-25 14:56:18 -07:00
Florian Hahn bb9bdef4df
[Clang] Use pattern to match profile metadata in test.
Make the test more robust to slightly different metadata numbering by
using a pattern instead of hard coding the ids.
2022-03-25 21:05:58 +00:00
William S. Moses 89525cbf28 [Clang] Add helper method to determine if a nonvirtual base has an entry in the LLVM struct
This patch adds a helper method to determine if a nonvirtual base has an entry in the LLVM struct. Such a base may not have an entry
if the base does not have any fields/bases itself that would change the size of the struct. This utility method is useful for other frontends (Polygeist) that use Clang as an API to generate code.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D122502
2022-03-25 16:32:12 -04:00
Paul Robinson 6aa0397758 Remove dead code in driver parsing -gsimple-template-names= options
While -g[no-]simple-template-names is a driver option, the fancier
-gsimple-template-names={simple,mangled} option is cc1-only, so code
to handle it in the driver is dead.

Differential Revision: https://reviews.llvm.org/D122503
2022-03-25 13:23:24 -07:00
Sam McCall 57ee624d79 [cmake] Provide CURRENT_TOOLS_DIR centrally, replacing CLANG_TOOLS_DIR
CLANG_TOOLS_DIR holds the the current bin/ directory, maybe with a %(build_mode)
placeholder. It is used to add the just-built binaries to $PATH for lit tests.
In most cases it equals LLVM_TOOLS_DIR, which is used for the same purpose.
But for a standalone build of clang, CLANG_TOOLS_DIR points at the build tree
and LLVM_TOOLS_DIR points at the provided LLVM binaries.

Currently CLANG_TOOLS_DIR is set in clang/test/, clang-tools-extra/test/, and
other things always built with clang. This is a few cryptic lines of CMake in
each place. Meanwhile LLVM_TOOLS_DIR is provided by configure_site_lit_cfg().

This patch moves CLANG_TOOLS_DIR to configure_site_lit_cfg() and renames it:
 - there's nothing clang-specific about the value
 - it will also replace LLD_TOOLS_DIR, LLDB_TOOLS_DIR etc (not in this patch)

It also defines CURRENT_LIBS_DIR. While I removed the last usage of
CLANG_LIBS_DIR in e4cab4e24d, there are LLD_LIBS_DIR usages etc that
may be live, and I'd like to mechanically update them in a followup patch.

Differential Revision: https://reviews.llvm.org/D121763
2022-03-25 20:22:01 +01:00
Corentin Jabot 26e201b796 [Clang] Fix error in Documentation introduced by 3784e8cc [nfc].
The documentation contained extra space.
Also remove https://github.com/llvm/llvm-project/issues/54296
from the list of issues by 3784e8cc as this commit did not
fix it (nor was it supposed to).
2022-03-25 19:38:36 +01:00
Corentin Jabot 3784e8ccfb [Clang] Fix Unevaluated Lambdas
Unlike other types, when lambdas are instanciated,
they are recreated from scratch.
When an unevaluated lambdas appear in the type of a function,
parameter it is instanciated in the wrong declaration context,
as parameters are transformed before the function.

To support lambda in function parameters, we try to
compute whether they are dependant without looking at the
declaration context.

This is a short term stopgap solution to avoid clang
iceing. A better fix might be to inject some kind of
transparent declaration with correctly computed dependency
for function parameters, variable templates, etc.

Fixes https://github.com/llvm/llvm-project/issues/50376
Fixes https://github.com/llvm/llvm-project/issues/51414
Fixes https://github.com/llvm/llvm-project/issues/51416
Fixes https://github.com/llvm/llvm-project/issues/51641
Fixes https://github.com/llvm/llvm-project/issues/54296

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121532
2022-03-25 19:16:45 +01:00
Florian Hahn 171cdba867
[Clang,TBAA] Use pattern for metadata reference in test.
Update the single check line that still had a hard-coded metadata
reference. This makes it more robust to slight changes in the metadata
numbering.
2022-03-25 18:12:39 +00:00
Emil Kieri 35b89bc24c [clang][driver] Disable non-functional --version option for clang -cc1
This patch removes --version as a clang -cc1 option.
  clang --version
and
  clang --cc1 -version
remain valid. This behaviour is consistent with clang -cc1as.

Previously, clang -cc1 accepted both --version and -version, but
only -version was acted upon. The call
  clang -cc1 --version
stalled without any message: --version was an accepted option but
triggered no action, and the driver waited for standard input.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D122344
2022-03-25 19:04:27 +01:00
Nathan James b97f26083b Reland "[ASTMatchers] Output currently processing match and nodes on crash"
This reverts commit cff34ccb60.

This relands commit d89f9e963e
2022-03-25 17:53:58 +00:00
Gulfem Savrun Yeniceri c7f91e227a [InstrProfiling] No runtime hook for unused funcs
CoverageMappingModuleGen generates a coverage mapping record
even for unused functions with internal linkage, e.g.
static int foo() { return 100; }
Clang frontend eliminates such functions, but InstrProfiling pass
still pulls in profile runtime since there is a coverage record.
Fuchsia uses runtime counter relocation, and pulling in profile
runtime for unused functions causes a linker error:
undefined hidden symbol: __llvm_profile_counter_bias.
Since 389dc94d4b, we do not hook profile runtime for the binaries
that none of its translation units have been instrumented in Fuchsia.
This patch extends that for the instrumented binaries that
consist of only unused functions.

Differential Revision: https://reviews.llvm.org/D122336
2022-03-25 17:03:03 +00:00
Yitzhak Mandelbaum a184a0d8aa [clang][dataflow] Add support for disabling warnings on smart pointers.
This patch provides the user with the ability to disable all checked of accesses
to optionals that are the pointees of smart pointers. Since smart pointers are
not modeled (yet), the system cannot distinguish safe from unsafe accesses to
optionals through smart pointers. This results in false positives whenever
optionals are used through smart pointers. The patch gives the user the choice
of ignoring all positivess in these cases.

Differential Revision: https://reviews.llvm.org/D122143
2022-03-25 16:44:34 +00:00
Joseph Huber b9f67d44ba [OpenMP] Replace device kernel linkage with weak_odr
Currently the device kernels all have weak linkage to prevent linkage
errors on multiple defintions. However, this prevents some optimizations
from adequately analyzing them because of the nature of weak linkage.
This patch replaces the weak linkage with weak_odr linkage so we can
statically assert that multiple declarations of the same kernel will
have the same definition.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D122443
2022-03-25 11:29:15 -04:00
Iain Sandoe cf396c56e7 [C++20][Modules] Correct an assert for modules-ts.
When adding the support for modules partitions we added an assert that the
actual status of Global Module Fragments matches the state machine that is
driven by the module; keyword.

That does not apply to the modules-ts case, where there is an implicit GMF.

Differential Revision: https://reviews.llvm.org/D122394
2022-03-25 14:55:13 +00:00
Adam Czachorowski 7e45912618 [clang] Do not crash on arrow operator on dependent type.
There seems to be more than one way to get to that state. I included to
example cases in the test, both were noticed recently.

There is room for improvement, for example by creating RecoveryExpr in
place of the bad initializer, but for now let's stop the crashes.

Differential Revision: https://reviews.llvm.org/D121824
2022-03-25 15:48:08 +01:00
Johannes Doerfert a81fff8afd Reapply "[Intrinsics] Add `nocallback` to the default intrinsic attributes"
This reverts commit c5f789050d and
reapplies 7aea3ea8c3 with additional test
changes.
2022-03-25 09:36:50 -05:00
Aaron Ballman 635dde8117 Fix clang Sphinx build bot 2022-03-25 07:13:26 -04:00
Simon Pilgrim ce2b36e123 [clang] CheckSizelessVectorOperands - use castAs<> instead of getAs<> to avoid dereference of nullptr
Move the only uses of the cast to where they are dereferenced.
2022-03-25 10:23:30 +00:00
Marek Kurdej 311a00c390 [clang-format] Clean up DefinitionBlockSeparatorTest. NFC. 2022-03-25 10:59:46 +01:00
Dávid Bolvanský 520c8ca9d2 [Clang] Added release note for improved -Wunused-but-set-variable warning 2022-03-25 10:45:28 +01:00
Iain Sandoe 6c0e60e884 [C++20][Modules][HU 1/5] Introduce header units as a module type.
This is the first in a series of patches that introduce C++20 importable
header units.

These differ from clang header modules in that:
 (a) they are identifiable by an internal name
 (b) they represent the top level source for a single header - although
     that might include or import other headers.

We name importable header units with the path by which they are specified
(although that need not be the absolute path for the file).

So "foo/bar.h" would have a name "foo/bar.h".  Header units are made a
separate module type so that we can deal with diagnosing places where they
are permitted but a named module is not.

Differential Revision: https://reviews.llvm.org/D121095
2022-03-25 09:17:14 +00:00
Nathan Ridge 56a54910c5 [clang] Propagate requires-clause from constructor template to implicit deduction guide
Fixes https://github.com/clangd/clangd/issues/890

Differential Revision: https://reviews.llvm.org/D113874
2022-03-25 02:46:22 -04:00
Ben Shi b62ea9b38b [AVR] Add more devices
Synchronize device list with avr-gcc 7.3.0 and avrlibc 2.0.0.

Reviewed By: aykevl

Differential Revision: https://reviews.llvm.org/D122401
2022-03-25 01:43:41 +00:00
Akira Hatanaka 350d43f1ef Fix a bug where an extended vector of __fp16 was being converted to a
generic vector type

rdar://86109177
2022-03-24 18:06:10 -07:00
Hubert Tong ce21c926f8 [Clang] Work with multiple pragmas weak before definition
Update `WeakUndeclaredIdentifiers` to hold a collection of weak
aliases per identifier instead of only one.

This also allows the "used" state to be removed from `WeakInfo`
because it is really only there as an alternative to removing
processed map entries, and we can represent that using an empty set
now. The serialization code is updated for the removal of the field.
Additionally, a PCH test is added for the new functionality.

The records are grouped by the "target" identifier, which was already
being used as a key for lookup purposes. We also store only one record
per alias name; combined, this means that diagnostics are grouped by
the "target" and limited to one per alias (which should be acceptable).

Fixes PR28611.
Fixes llvm/llvm-project#28985.

Reviewed By: aaron.ballman, cebowleratibm

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

Co-authored-by: Rachel Craik <rcraik@ca.ibm.com>
Co-authored-by: Jamie Schmeiser <schmeise@ca.ibm.com>
2022-03-24 20:17:49 -04:00
Tom Stellard fed96f31bb Re-commit: Driver: Don't warn on -mbranch-protection when linking
This is a re-commit of 98fd3b3598.  The
newly added test was failing on the bots, and I've fixed the test now so
that it doesn't actually invoke the linker.
2022-03-24 16:57:42 -07:00
Joseph Huber bfda79341b [OpenMP] Add a semantic check for updating hidden or internal values
A previous patch removed the compiler generating offloading entries
for variables that were declared on the device but were internal or
hidden. This allowed us to compile programs but turns any attempt to run
'#pragma omp target update' on one of those variables a silent failure.
This patch adds a check in the semantic analysis for if the user is
attempting the update a variable on the device from the host that is not
externally visible.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D122403
2022-03-24 19:38:30 -04:00
Zixu Wang 826e661a96 [NFC][clang][extract-api] Rename variable
Rename a local variable name to avoid potential ambiguity/conflict for
some compilers.
2022-03-24 15:12:40 -07:00