Commit Graph

95899 Commits

Author SHA1 Message Date
Fangrui Song 3f18f7c007 [clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
With C++17 there is no Clang pedantic warning or MSVC C5051.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D131346
2022-08-08 09:12:46 -07:00
Aaron Ballman e640250454 Update the C status page from the latest working draft
WG14 N3047 is the last C working draft before the document goes out
for committee ballot, so this should be the last of the C2x compiler
features to be added.
2022-08-08 11:30:49 -04:00
Chris Bieneman fc470013d1 [Docs] Add HLSL ResourceType documentation
Along with the new documentation this also re-organizes the HLSL docs
to a subdirectory. The hope is to continue to expand this documentation
as the HLSL implementation advances.

Differential Revision: https://reviews.llvm.org/D130794
2022-08-08 09:06:38 -05:00
Benjamin Kramer 99a5a029e6 [ASTMatchers] Replace hand-coded copy of std::apply with the real C++17 function. NFCI 2022-08-08 14:08:04 +02:00
Nathan James 7042417ef1
[NFC][clang] Bring `and_present` and `if_present` casting functions to clang namespace
This should enable simpler migration when the `and_nonnull` and `or_null` functions are deprecated.
2022-08-08 08:38:50 +01:00
Ashay Rane d1bb3016dd
[mlir] fix `add_tablegen()` macro to allow installing mlir-pdll
Prior to this patch, the `add_tablegen()` macro in
llvm/cmake/modules/TableGen.cmake added the install rule only if
`project` matched `LLVM` or `MLIR`.  This patch adds an optional
`DESTINATION` argument, which, if non-empty, decides whether (and where)
to install the tablegen tool, thus eliminating the need for
project-specific overrides.  This patch also updates all other
invocations of the `add_tablegen()` macro.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D131282
2022-08-07 15:48:38 -07:00
Sergei Barannikov 87dc7d4b61
[clang][CodeGen] Factor out Swift ABI hooks (NFCI)
Swift calling conventions stands out in the way that they are lowered in
mostly target-independent manner, with very few customization points.
As such, swift-related methods of ABIInfo do not reference the rest of
ABIInfo and vice versa.
This change follows interface segregation principle; it removes
dependency of SwiftABIInfo on ABIInfo. Targets must now implement
SwiftABIInfo separately if they support Swift calling conventions.

Almost all targets implemented `shouldPassIndirectly` the same way. This
de-facto default implementation has been moved into the base class.

`isSwiftErrorInRegister` used to be virtual, now it is not. It didn't
accept any arguments which could have an effect on the returned value.
This is now a static property of the target ABI.

Reviewed By: rusyaev-roman, inclyc

Differential Revision: https://reviews.llvm.org/D130394
2022-08-08 00:23:23 +08:00
Kazu Hirata 7542e72188 Use llvm::is_contained (NFC) 2022-08-07 00:16:17 -07:00
YingChi Long 1f54006bca
[clang][docs] use `Fixes` instead of `This fixes` in ReleaseNotes [NFC] 2022-08-07 12:42:15 +08:00
Shilei Tian e21202dac1 [Clang][OpenMP] Fix the issue that `llvm.lifetime.end` is emitted too early for variables captured in linear clause
Currently if an OpenMP program uses `linear` clause, and is compiled with
optimization, `llvm.lifetime.end` for variables listed in `linear` clause are
emitted too early such that there could still be uses after that. Let's take the
following code as example:
```
// loop.c
int j;
int *u;

void loop(int n) {
  int i;
  for (i = 0; i < n; ++i) {
    ++j;
    u = &j;
  }
}
```
We compile using the command:
```
clang -cc1 -fopenmp-simd -O3 -x c -triple x86_64-apple-darwin10 -emit-llvm loop.c -o loop.ll
```
The following IR (simplified) will be generated:
```
@j = local_unnamed_addr global i32 0, align 4
@u = local_unnamed_addr global ptr null, align 8

define void @loop(i32 noundef %n) local_unnamed_addr {
entry:
  %j = alloca i32, align 4
  %cmp = icmp sgt i32 %n, 0
  br i1 %cmp, label %simd.if.then, label %simd.if.end

simd.if.then:                                     ; preds = %entry
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %j)
  store ptr %j, ptr @u, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %j)
  %0 = load i32, ptr %j, align 4
  store i32 %0, ptr @j, align 4
  br label %simd.if.end

simd.if.end:                                      ; preds = %simd.if.then, %entry
  ret void
}
```
The most important part is:
```
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %j)
  %0 = load i32, ptr %j, align 4
  store i32 %0, ptr @j, align 4
```
`%j` is still loaded after `@llvm.lifetime.end.p0(i64 4, ptr nonnull %j)`. This
could cause the backend incorrectly optimizes the code and further generates
incorrect code. The root cause is, when we emit a construct that could have
`linear` clause, it usually has the following pattern:
```
EmitOMPLinearClauseInit(S)
{
  OMPPrivateScope LoopScope(*this);
  ...
  EmitOMPLinearClause(S, LoopScope);
  ...
  (void)LoopScope.Privatize();
  ...
}
EmitOMPLinearClauseFinal(S, [](CodeGenFunction &) { return nullptr; });
```
Variables that need to be privatized are added into `LoopScope`, which also
serves as a RAII object. When `LoopScope` is destructed and if optimization is
enabled, a `@llvm.lifetime.end` is also emitted for each privatized variable.
However, the writing back to original variables in `linear` clause happens after
the scope in `EmitOMPLinearClauseFinal`, causing the issue we see above.

A quick "fix" seems to be, moving `EmitOMPLinearClauseFinal` inside the scope.
However, it doesn't work. That's because the local variable map has been updated
by `LoopScope` such that a variable declaration is mapped to the privatized
variable, instead of the actual one. In that way, the following code will be
generated:
```
  %0 = load i32, ptr %j, align 4
  store i32 %0, ptr %j, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %j)
```
Well, now the life time is correct, but apparently the writing back is broken.

In this patch, a new function `OMPPrivateScope::restoreMap` is added and called
before calling `EmitOMPLinearClauseFinal`. This can make sure that
`EmitOMPLinearClauseFinal` can find the orignal varaibls to write back.

Fixes #56913.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D131272
2022-08-06 16:50:37 -04:00
Tom Stellard d2b158e29e clang/cmake: Drop use of llvm-config for LLVM install discovery
This has been deprecated for a while, since D51714 in 2018.

Remove it in favor of using CMake's find_package() function.

Reviewed By: phosek, mgorny

Differential Revision: https://reviews.llvm.org/D128777
2022-08-06 16:22:59 -04:00
Aarush Bhat a6cb8419b1
clang: fix typo availbility
- Fixes [[ https://github.com/llvm/llvm-project/issues/56787 | #56787 ]].

I am fixing the spelling of availability.

I am unsure if this change will have any side effects. If someone can
help on how to check if it has any side effects, I can test those out as
well.

Reviewed By: inclyc

Differential Revision: https://reviews.llvm.org/D131277
2022-08-07 03:44:55 +08:00
Kazu Hirata c8e6ebd74e Use value instead of getValue (NFC) 2022-08-06 11:21:39 -07:00
Aaron Ballman 486a3c4662 Update the status of some more C DRs
Update some of the C99-era DRs starting in the 300s.
2022-08-06 11:53:40 -04:00
Tobias Hieta b1356504e6
[LLVM] Update C++ standard to 17
Also make the soft toolchain requirements hard. This allows
us to use C++17 features in LLVM now.

If we find patterns with C++17 that improve readability
it should be recommended in the coding standards.

Reviewed By: jhenderson, cor3ntin, MaskRay

Differential Revision: https://reviews.llvm.org/D130689
2022-08-06 09:42:10 +02:00
Jun Zhang 786b503f66
[Clang][Lex] Extend HeaderSearch::LookupFile to control OpenFile behavior.
In the case of static compilation the file system is pretty much read-only
and taking a snapshot of it usually is sufficient. In the interactive C++
case the compilation is longer and people can create and include files, etc.
In that case we often do not want to open files or cache failures unless is
absolutely necessary.

This patch extends the original API call by forwarding some optional flags,
so we can continue use it in the previous way with no breakage.
Signed-off-by: Jun Zhang <jun@junz.org>

Differential Revision: https://reviews.llvm.org/D131241
2022-08-06 11:36:02 +08:00
Argyrios Kyrtzidis 7b12e561ac [test/Modules/cxx20-export-import.cpp] Pre-clean the modules cache directory of the test, NFC 2022-08-05 17:27:43 -07:00
Nico Weber 3fbbf28173 unbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV=OFF after 6635f48e4a
See revision b8b7a9dcdc for prior art.
2022-08-05 19:50:23 -04:00
Xiang Li 549542b494 [HLSL] emit-obj when set output.
When not set output, set default output to stdout.
When set output with -Fo and no -fcgl, set -emit-obj to generate dx container.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D130858
2022-08-05 16:27:17 -07:00
Joseph Huber 3b52341116 [CUDA] Fix output name being replaced in device-only mode
When performing device only compilation, there was an issue where
`cubin` outputs were being renamed to `cubin` despite the user's name.
This is required in a normal compilation flow as the Nvidia tools only
understand specific filenames instead of checking magic bytes for some
unknown reason. We do not want to perform this transformation when the
user is performing device only compilation.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D131278
2022-08-05 19:08:41 -04:00
Argyrios Kyrtzidis 6635f48e4a [Serialization] Remove `ORIGINAL_PCH_DIR` record
Use of `ORIGINAL_PCH_DIR` record has been superseeded by making PCH/PCM files with relocatable paths at write time.
Removing this record is useful for producing an output-path-independent PCH file and enable sharing of the same PCH file even
when it was intended for a different output path.

Differential Revision: https://reviews.llvm.org/D131124
2022-08-05 15:40:33 -07:00
Ben Langmuir fb89cc0ddb [clang][modules] Don't depend on sharing FileManager during module build
Sharing the FileManager between the importer and the module build should
only be an optimization. Add a cc1 option -fno-modules-share-filemanager
to allow us to test this. Fix the path to modulemap files, which
previously depended on the shared FileManager when using path mapped to
an external file in a VFS.

Differential Revision: https://reviews.llvm.org/D131076
2022-08-05 12:24:40 -07:00
Ben Langmuir d038bb196c [clang] Fix redirection behaviour for cached FileEntryRef
In 6a79e2ff19 we changed Filemanager::getEntryRef() to return the
redirecting FileEntryRef instead of looking through the redirection.
This commit fixes the case when looking up a cached file path to also
return the redirecting FileEntryRef. This mainly affects the behaviour
of calling getNameAsRequested() on the resulting entry ref.

Differential Revision: https://reviews.llvm.org/D131273
2022-08-05 12:23:38 -07:00
Jack Kirk 3e0e5568a6 [CUDA] Fixed sm version constrain for __bmma_m8n8k128_mma_and_popc_b1.
As stated in
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-wmma-mma:
".and operation in single-bit wmma requires sm_80 or higher."

tra@: Fixed a bug in builtins-nvptx-mma.py test generator and regenerated the tests.

Differential Revision: https://reviews.llvm.org/D131265
2022-08-05 12:14:06 -07:00
Aaron Ballman 4bc9e60306 Removing redundant code; NFC
The same predicate is checked on line 12962 just above the removed code.
2022-08-05 09:17:20 -04:00
Chuanqi Xu 809b416641 [NFC] Requires x86-registered-target for test/pr56919.cpp 2022-08-05 16:46:38 +08:00
Balázs Kéri 501faaa0d6 [clang][analyzer] Add more wide-character functions to CStringChecker
Support for functions wmempcpy, wmemmove, wmemcmp is added to the checker.
The same tests are copied that exist for the non-wide versions, with
non-wide functions and character types changed to the wide version.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D130470
2022-08-05 10:32:53 +02:00
Chuanqi Xu 230d6f93aa [Coroutines] Remove lifetime intrinsics for spliied allocas in coroutine frames
Closing https://github.com/llvm/llvm-project/issues/56919

It is meaningless to preserve the lifetime markers for the spilled
allocas in the coroutine frames and it would block some optimizations
too.
2022-08-05 14:50:43 +08:00
Xiang Li b2c9ff7273 [NFC][HLSL] Fix build error caused missing typo update.
setHLSLFnuctionAttributes to setHLSLFunctionAttributes.

Differential Revision: https://reviews.llvm.org/D131240
2022-08-04 23:20:25 -07:00
Xiang Li 6134629af0 [NFC][HLSL] Fix typo in CGHLSLRuntime.
Change setHLSLFnuctionAttributes to setHLSLFunctionAttributes.

Differential Revision: https://reviews.llvm.org/D131238
2022-08-04 23:08:40 -07:00
Timm Bäder d1942855c4 [clang] Consider array filler in MaybeElementDependentArrayfiller()
Any InitListExpr may have an array filler and since we may be evaluating
the array filler as well, we need to take into account that the array
filler expression might make the InitListExpr element dependent.

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

Differential Revision: https://reviews.llvm.org/D131155
2022-08-05 06:47:49 +02:00
Timm Bäder 8b74074731 [clang][sema] Fix collectConjunctionTerms()
Consider:

A == 5 && A != 5

IfA is 5, the old collectConjunctionTerms() would call itself again for
the LHS (which it ignores), then the RHS (which it also ignores) and
then just return without ever adding anything to the Terms array.

Differential Revision: https://reviews.llvm.org/D131070
2022-08-05 06:45:32 +02:00
Xiang Li 906e41f4e3 [HLSL] clang codeGen for HLSLShaderAttr.
Translate HLSLShaderAttr to IR level.
 1. Skip mangle for hlsl entry functions.
 2. Add function attribute for hlsl entry functions.

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D124752
2022-08-04 21:23:57 -07:00
Ellis Hoag 6f4c3c0f64 [InstrProf][attempt 2] Add new format for -fprofile-list=
In D130807 we added the `skipprofile` attribute. This commit
changes the format so we can either `forbid` or `skip` profiling
functions by adding the `noprofile` or `skipprofile` attributes,
respectively. The behavior of the original format remains
unchanged.

Also, add the `skipprofile` attribute when using
`-fprofile-function-groups`.

This was originally landed as https://reviews.llvm.org/D130808 but was
reverted due to a Windows test failure.

Differential Revision: https://reviews.llvm.org/D131195
2022-08-04 17:12:56 -07:00
Richard Smith 73b62f8135 Fix parsing of comma fold-expressions as the operand of a C-style cast. 2022-08-04 17:08:08 -07:00
Xiang Li 8a27a2f89f [HLSL] Support -E option for HLSL.
-E option will set entry function for hlsl.
The format is -E entry_name.

To avoid conflict with existing option with name 'E', add an extra prefix '--'.

A new field HLSLEntry is added to TargetOption.
To share code with HLSLShaderAttr, entry function will be add HLSLShaderAttr attribute too.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D124751
2022-08-04 16:54:19 -07:00
Matt Arsenault c5b36ab1d6 AMDGPU/clang: Remove dead code
The order has to be a constant and should be enforced by the builtin
definition. The fallthrough behavior would have been broken anyway.

There's still an existing issue/assert if you try to use garbage for the
ordering. The IRGen should be broken, but we also hit another assert
before that.

Fixes issue 56832
2022-08-04 19:02:56 -04:00
Leonard Chan 33171df9cc Revert "[clang][Darwin] Always set the default C++ Standard Library to libc++"
This reverts commit c5ccb78ade.

We're seeing darwin-stdlib.cpp fail on our linux, mac, and windows
builders:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8806821020552676065/overview
2022-08-04 22:56:32 +00:00
Corentin Jabot a1a71b7dc9 [Clang] Fix capture of values initialized by bitfields
This fixes a regression introduced in 127bf44

Differential Revision: https://reviews.llvm.org/D131202
2022-08-04 23:58:47 +02:00
Zakk Chen 010f329803 [RISCV][Clang] Support policy function for all vector segment load.
We will switch all UndefValue to PoisonValue in follow up patches.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D126750
2022-08-04 17:47:24 +00:00
Sam Estep 8611a77ee7 [clang][dataflow] Analyze method bodies
This patch adds the ability to context-sensitively analyze method bodies, by moving `ThisPointeeLoc` from `DataflowAnalysisContext` to `Environment`, and adding code in `pushCall` to set it.

Reviewed By: ymandel, sgatev, xazax.hun

Differential Revision: https://reviews.llvm.org/D131170
2022-08-04 17:45:47 +00:00
Sam Estep 0eaecbbc23 [clang][dataflow] Handle return statements
This patch adds a `ReturnLoc` field to the `Environment`, serving a similar to the `ThisPointeeLoc` field in the `DataflowAnalysisContext`. It then uses that (along with a new `VisitReturnStmt` method in `TransferVisitor`) to handle non-`void`-returning functions in context-sensitive analysis.

Reviewed By: ymandel, sgatev

Differential Revision: https://reviews.llvm.org/D130600
2022-08-04 17:42:19 +00:00
David Green 8c30f4a5ab [AArch64] Always allow the __bf16 type
We would like to make the ACLE NEON and SVE intrinsics more useable by
gating them on the target, not by ifdef preprocessor macros. In order to
do this the types they use need to be available. This patches makes
__bf16 always available under AArch64 not just when the bf16
architecture feature is present. This bringing it in-line with GCC. In
subsequent patches the NEON bfloat16x8_t and SVE svbfloat16_t types
(along with bfloat16_t used in arm_sve.h) will be made unconditional
too.

The operations valid on the types are still very limited. They can be
used as a storage type, but the intrinsics used for convertions are
still behind an ifdef guard in arm_neon.h/arm_bf16.h.

Differential Revision: https://reviews.llvm.org/D130973
2022-08-04 18:35:27 +01:00
Fangrui Song 88501dc749 [Sema] -Wformat: support C23 format specifier %b %B
Close #56885: WG14 N2630 added %b to fprintf/fscanf and recommended %B for
fprintf. This patch teaches -Wformat %b for the printf/scanf family of functions
and %B for the printf family of functions.

glibc 2.35 and latest Android bionic added %b/%B printf support. From
https://www.openwall.com/lists/libc-coord/2022/07/ no scanf support is available
yet.

Like GCC, we don't test library support.

GCC 12 -Wformat -pedantic emits a warning:

> warning: ISO C17 does not support the ‘%b’ gnu_printf format [-Wformat=]

The behavior is not ported.

Note: `freebsd_kernel_printf` uses %b differently.

Reviewed By: aaron.ballman, dim, enh

Differential Revision: https://reviews.llvm.org/D131057
2022-08-04 10:26:31 -07:00
Eric Li 5659908f4c [clang][dataflow][NFC] Resize vector directly with ctor
Differential Revision: https://reviews.llvm.org/D131177
2022-08-04 13:12:37 -04:00
Eric Li 18034aee63 [clang][dataflow][NFC] Convert mutable vector references to ArrayRef
`transferBlock` and `computeBlockInputState` only read the
`BlockStates` vector for the predecessor block(s), and do not need to
mutate any of the contents. Only `runTypeErasedDataflowAnalysis`
writes into the `vector`, so simply down to an `ArrayRef`.
2022-08-04 13:12:37 -04:00
Nico Weber 0eb7d86f58 Revert "[InstrProf] Add new format for -fprofile-list="
This reverts commit b692312ca4.
Breaks tests on Windows, see https://reviews.llvm.org/D130808#3699952
2022-08-04 13:04:59 -04:00
Ellis Hoag b692312ca4 [InstrProf] Add new format for -fprofile-list=
In D130807 we added the `skipprofile` attribute. This commit
changes the format so we can either `forbid` or `skip` profiling
functions by adding the `noprofile` or `skipprofile` attributes,
respectively. The behavior of the original format remains
unchanged.

Also, add the `skipprofile` attribute when using
`-fprofile-function-groups`.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D130808
2022-08-04 08:49:43 -07:00
Chelsea Cassanova bcf6ffb87e Reland "[lldb/Fuzzer] Add fuzzer for expression evaluator"
This reverts commit d959324e1e.

The target_include_directories in the clang-fuzzer CMake files
are set to PRIVATE instead of PUBLIC to prevent the clang buildbots
from breaking when symlinking clang into llvm.

The expression evaluator fuzzer itself has been modified to prevent a
bug that occurs when running it without a target.
2022-08-04 11:47:06 -04:00
Ellis Hoag 12e78ff881 [InstrProf] Add the skipprofile attribute
As discussed in [0], this diff adds the `skipprofile` attribute to
prevent the function from being profiled while allowing profiled
functions to be inlined into it. The `noprofile` attribute remains
unchanged.

The `noprofile` attribute is used for functions where it is
dangerous to add instrumentation to while the `skipprofile` attribute is
used to reduce code size or performance overhead.

[0] https://discourse.llvm.org/t/why-does-the-noprofile-attribute-restrict-inlining/64108

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D130807
2022-08-04 08:45:27 -07:00
Eric Li 54d24eae98 [clang][dataflow][NFC] Fix outdated comment on getStableStorageLocation
Follow-up to D129097.

It is no longer a requirement that the `QualType` passed to to
`DataflowAnalysisContext::getStableStorageLocation()` is not null. A
null type pass as an argument is only applicable as the pointee type
of a `std::nullptr_t` pointer.

Differential Revision: https://reviews.llvm.org/D131109
2022-08-04 11:15:14 -04:00
YingChi Long 282d4755c3
[clang] change `auto` to `Expr` in last commit [NFC] 2022-08-04 21:15:45 +08:00
YingChi Long f417583f31
[clang] format string checking for conpile-time evaluated str literal
This patch enhances clang's ability to check compile-time determinable
string literals as format strings, and can give FixIt hints at literals
(unlike gcc). Issue https://github.com/llvm/llvm-project/issues/55805
mentiond two compile-time string cases. And this patch partially fixes
one.

```
constexpr const char* foo() {
  return "%s %d";
}
int main() {
   printf(foo(), "abc", "def");
   return 0;
}
```

This patch enables clang check format string for this:

```
<source>:4:24: warning: format specifies type 'int' but the argument has type 'const char *' [-Wformat]
  printf(foo(), "abc", "def");
         ~~~~~         ^~~~~
<source>:2:42: note: format string is defined here
constexpr const char *foo() { return "%s %d"; }
                                         ^~
                                         %s
1 warning generated.
```

Reviewed By: aaron.ballman

Signed-off-by: YingChi Long <me@inclyc.cn>

Differential Revision: https://reviews.llvm.org/D130906
2022-08-04 21:07:30 +08:00
Kadir Cetinkaya df48e3fbcc
Revert "[clang] Pass FoundDecl to DeclRefExpr creator for operator overloads"
This reverts commit 4e94f66531.
See https://reviews.llvm.org/D129973#3698969 for reasoning.
2022-08-04 12:14:43 +02:00
Matt Jacobson c8b2f3f51b [ObjC] type method metadata `_imp`, messenger routine at callsite with program address space
On targets with non-default program address space (e.g., Harvard
architectures), clang crashes when emitting Objective-C method metadata,
because the address of the method IMP cannot be bitcast to i8*. It similarly
crashes at messenger callsite with a failed bitcast.

Define the _imp field instead as i8 addrspace(1)* (or whatever the target's
program address space is). And in getMessageSendInfo(), create signatureType by
specifying the program address space.

Add a regression test using the AVR target. Test failed previously and passes
now. Checked codegen of the test for x86_64-apple-darwin19.6.0 and saw no
difference, as expected.

Reviewed By: rjmccall, dylanmckay

Differential Revision: https://reviews.llvm.org/D112113
2022-08-04 05:40:32 -04:00
Corentin Jabot 127bf44385 [Clang][C++20] Support capturing structured bindings in lambdas
This completes the implementation of P1091R3 and P1381R1.

This patch allow the capture of structured bindings
both for C++20+ and C++17, with extension/compat warning.

In addition, capturing an anonymous union member,
a bitfield, or a structured binding thereof now has a
better diagnostic.

We only support structured bindings - as opposed to other kinds
of structured statements/blocks. We still emit an error for those.

In addition, support for structured bindings capture is entirely disabled in
OpenMP mode as this needs more investigation - a specific diagnostic indicate the feature is not yet supported there.

Note that the rest of P1091R3 (static/thread_local structured bindings) was already implemented.

at the request of @shafik, i can confirm the correct behavior of lldb wit this change.

Fixes https://github.com/llvm/llvm-project/issues/54300
Fixes https://github.com/llvm/llvm-project/issues/54300
Fixes https://github.com/llvm/llvm-project/issues/52720

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D122768
2022-08-04 10:12:53 +02:00
Phoebe Wang 6f867f9102 [X86] Support ``-mindirect-branch-cs-prefix`` for call and jmp to indirect thunk
This is to address feature request from https://github.com/ClangBuiltLinux/linux/issues/1665

Reviewed By: nickdesaulniers, MaskRay

Differential Revision: https://reviews.llvm.org/D130754
2022-08-04 15:12:15 +08:00
Dominic Chen bbf1900571 [clang][Headers] Avoid compiler warnings in builtin headers
While debugging module support using -Wsystem-headers, we discovered that if
-Werror, and -Wundef or -Wmacro-redefined are specified, they can cause errors
to be generated in these builtin headers.

Differential Revision: https://reviews.llvm.org/D130800
2022-08-03 17:56:17 -07:00
Louis Dionne c5ccb78ade [clang][Darwin] Always set the default C++ Standard Library to libc++
Newer SDKs don't even provide libstdc++ headers, so it's effectively
never valid to build for libstdc++ unless the user explicitly asks
for it (in which case they will need to provide include paths and more).
2022-08-03 15:40:27 -04:00
Corentin Jabot a274219600 Revert "[Clang][C++20] Support capturing structured bindings in lambdas"
This reverts commit 44f2baa380.

Breaks self builds and seems to have conformance issues.
2022-08-03 21:00:29 +02:00
Aaron Ballman c9edf843fc Error instead of assert when making a _BitInt vector
We already correctly rejected:
typedef __attribute__((vector_size(16))) _BitInt(4) Ty;

but we would assert with:
typedef __attribute__((ext_vector_type(4))) _BitInt(4) Ty;

Now we issue the same error in both cases.
2022-08-03 14:05:09 -04:00
Corentin Jabot 44f2baa380 [Clang][C++20] Support capturing structured bindings in lambdas
This completes the implementation of P1091R3 and P1381R1.

This patch allow the capture of structured bindings
both for C++20+ and C++17, with extension/compat warning.

In addition, capturing an anonymous union member,
a bitfield, or a structured binding thereof now has a
better diagnostic.

We only support structured bindings - as opposed to other kinds
of structured statements/blocks. We still emit an error for those.

In addition, support for structured bindings capture is entirely disabled in
OpenMP mode as this needs more investigation - a specific diagnostic indicate the feature is not yet supported there.

Note that the rest of P1091R3 (static/thread_local structured bindings) was already implemented.

at the request of @shafik, i can confirm the correct behavior of lldb wit this change.

Fixes https://github.com/llvm/llvm-project/issues/54300
Fixes https://github.com/llvm/llvm-project/issues/54300
Fixes https://github.com/llvm/llvm-project/issues/52720

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D122768
2022-08-03 20:00:01 +02:00
isuckatcs 10a7ee0bac [analyzer] Fix for the crash in #56873
In ExprEngine::bindReturnValue() we cast an SVal to DefinedOrUnknownSVal,
however this SVal can also be Undefined, which leads to an assertion failure.

Fixes: #56873

Differential Revision: https://reviews.llvm.org/D130974
2022-08-03 19:25:02 +02:00
Ben Langmuir 6a79e2ff19 [clang] Add FileEntryRef::getNameAsRequested()
As progress towards having FileManager::getFileRef() return the path
as-requested by default, return a FileEntryRef that can use
getNameAsRequested() to retrieve this path, with the ultimate goal that
this should be the behaviour of getName() and clients should explicitly
request the "external" name if they need to (see comment in
FileManager::getFileRef). For now, getName() continues to return the
external path by looking through the redirects.

For now, the new function is only used in unit tests.

Differential Revision: https://reviews.llvm.org/D131004
2022-08-03 09:41:08 -07:00
Jennifer Yu a7bca18bc5 Fix assert during the call to getCanonicalDecl.
https://github.com/llvm/llvm-project/issues/56884

The root problem is in isOpenMPRebuildMemberExpr, it is only need to rebuild
for field expression.  No need for member function call.

The fix is to check field for member expression and skip rebuild for member
function call.

Differential Revision: https://reviews.llvm.org/D131024
2022-08-03 09:14:28 -07:00
Yitzhak Mandelbaum 692e03039d [clang][dataflow] Add cache of `ControlFlowContext`s for function decls.
This patch modifies context-sensitive analysis of functions to use a cache,
rather than recreate the `ControlFlowContext` from a function decl on each
encounter. However, this is just step 1 (of N) in adding support for a
configurable map of "modeled" function decls (see issue #56879). The map will go
from the actual function decl to the `ControlFlowContext` used to model it. Only
functions pre-configured in the map will be modeled in a context-sensitive way.

We start with a cache because it introduces the desired map, while retaining the
current behavior. Here, functions are mapped to their actual implementations
(when available).

Differential Revision: https://reviews.llvm.org/D131039
2022-08-03 15:17:49 +00:00
Erich Keane bf6db18e52 Fix char8_t in C mode regression from fb65b179
When doing that NFC refactor, I'd messed up how char8_t was reported,
which resulted in it being considered a 'future' keyword, without the
corresponding diagnostic, which lead to an assert.  This patch corrects
the char8_t to ONLY be future in C++ mode.
2022-08-03 07:15:30 -07:00
Erich Keane fb65b17932 [NFCI] Refactor how KeywordStatus is calculated
The getKeywordStatus function is a horrible mess of inter-dependent 'if'
statements that depend significantly on the ORDER of the checks.  This
patch removes the dependency on order by checking each set-flag only
once.

It does this by looping through each of the set bits, and checks each
individual flag for its effect, then combines them at the end.

This might slow down startup performance slightly, as there are only a
few hundred keywords, and a vast majority will only get checked 1x
still.

This patch ALSO removes the KEYWORD_CONCEPTS flag, because it has since
become synonymous with C++20.

Differential Revision: https://reviews.llvm.org/D131007
2022-08-03 06:41:43 -07:00
Jonas Paulsson 84831bdfed [SystemZ] Make 128 bit integers be aligned to 8 bytes.
The SystemZ ABI says that 128 bit integers should be aligned to only 8 bytes.

Reviewed By: Ulrich Weigand, Nikita Popov

Differential Revision: https://reviews.llvm.org/D130900
2022-08-03 15:39:54 +02:00
Timm Bäder f4b9c0735e [clang][NFC] Try to fix the docs build 2022-08-03 10:52:02 +02:00
Timm Bäder 11e52ecf74 [clang] Short-circuit trivial constructors when evaluating arrays
VisitCXXConstructExpr() will later do something similar, but for large
arrays, we should try to do it once an not for every element.

Fixes #56774

Differential Revision: https://reviews.llvm.org/D130791
2022-08-03 10:38:15 +02:00
Stanislav Gatev 817dd5e3fd [clang][dataflow] Rename member to make it clear that it isn't stable
Rename `DataflowAnalysisContext::getStableStorageLocation(QualType)`
to `createStorageLocation`, to make it clear that it doesn't return
a stable storage location.

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

Reviewed-by: ymandel, xazax.hun, gribozavr2
2022-08-03 06:25:02 +00:00
Stanislav Gatev c44c71843f [clang][dataflow] Make the type of the post visit callback consistent
Make the types of the post visit callbacks in `transferBlock` and
`runTypeErasedDataflowAnalysis` consistent.

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

Reviewed-by: ymandel, xazax.hun, gribozavr2
2022-08-03 05:58:38 +00:00
Nicolai Hähnle f7872cdce1 CommandLine: add and use cl::SubCommand::get{All,TopLevel}
Prefer using these accessors to access the special sub-commands
corresponding to the top-level (no subcommand) and all sub-commands.

This is a preparatory step towards removing the use of ManagedStatic:
with a subsequent change, these global instances will be moved to
be regular function-scope statics.

It is split up to give downstream projects a (albeit short) window in
which they can switch to using the accessors in a forward-compatible
way.

Differential Revision: https://reviews.llvm.org/D129118
2022-08-02 23:49:16 +02:00
Roy Jacobson 508c431ed9 [SemaCXX] Validate destructor is valid for dependent classes
We didn't check that a destructor's name matches the directly enclosing class if the class was dependent.
I enabled the check we already had for non-dependent types, which seems to work. Added appropriate tests.

Fixes GitHub issue #56772

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D130936
2022-08-02 21:50:54 +03:00
Yuanfang Chen 92c1bc6158 [CodeGen][inlineasm] assume the flag output of inline asm is boolean value
GCC inline asm document says that
"... the general rule is that the output variable must be a scalar
integer, and the value is boolean."

Commit e5c37958f9 lowers flag output of
inline asm on X86 with setcc, hence it is guaranteed that the flag
is of boolean value. Clang does not support ARM inline asm flag output
yet so nothing need to be worried about ARM.

See "Flag Output" section at
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#OutputOperands

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

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D129954
2022-08-02 11:49:01 -07:00
Zakk Chen bb99d4b11d [RISCV][Clang] Support policy functions for Vector Mask Instructions.
We will switch all UndefValue to PoisonValue in follow up patches.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D126749
2022-08-02 17:27:57 +00:00
Zakk Chen dffdca85ec [RISCV][Clang] Support policy functions for Vector Reduction
Instructions.

We will switch all UndefValue to PoisonValue in follow up patches.

Thanks for Kito to help on verification with their interanl testsuite.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D126748
2022-08-02 17:27:56 +00:00
Zakk Chen 9caf2cc05c [RISCV][Clang] Support policy functions for Vector Comparison
Instructions.

We will switch all UndefValue to PoisonValue in follow up patches.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D126746
2022-08-02 17:27:56 +00:00
Zakk Chen 7eddeb9e99 [RISCV][Clang] Support policy functions for vmerge, vfmerge and
vcompress.

We will switch all UndefValue to PoisonValue in follow up patches.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D126745
2022-08-02 17:27:55 +00:00
Zakk Chen b1b22b4a85 [RISCV][Clang] Support policy functions for vneg, vnot, vncvt, vwcvt,
vwcvtu, vfabs and vfneg.

We will switch all UndefValue to PoisonValue in follow up patches.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D126744
2022-08-02 17:27:55 +00:00
Alok Kumar Sharma 5ec6ea3dfd [clang][OpenMP][DebugInfo] Mark OpenMP generated functions as artificial
The Clang compiler generates internal functions for OpenMP. Current
patch marks these functions as artificial.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D111521
2022-08-02 21:24:46 +05:30
Aaron Ballman c783ca0de1 Revert "Missing tautological compare warnings due to unary operators"
This reverts commit 0cc3c184c7.

The changes did not account for templated code where one instantiation
may trigger the diagnostic but other instantiations will not, as in:
```
template <int I, class T>
void foo(int x) {
    bool b1 = (x & sizeof(T)) == 8;
    bool b2 = (x & I) == 8;
    bool b3 = (x & 4) == 8;
}

void run(int x) {
    foo<4, int>(8);
}
```
2022-08-02 09:39:36 -04:00
Fangrui Song afb785f511 [Driver] Remove Separate form for XRay options
Supporting something like `-fxray-instruction-threshold= 1` is not intended.
2022-08-02 00:47:37 -07:00
Purva-Chaudhari 168d4e2945 Handles failing driver tests of clang
Added support for incremental mode 8 and 28 ie. `frontend::EmitBC:` and `frontend::PrintPreprocessedInput:`
Added supporting clang tests to test in clang-repl mode

Reviewed By: v.g.vassilev

Differential Revision: https://reviews.llvm.org/D125946
2022-08-02 12:29:26 +05:30
Chuanqi Xu 6d10733d44 [C++20] [Modules] Handle initializer for Header Units
Previously when we add module initializer, we forget to handle header
units. This results that we couldn't compile a Hello World Example with
Header Units. This patch tries to fix this.

Reviewed By: iains

Differential Revision: https://reviews.llvm.org/D130871
2022-08-02 11:24:46 +08:00
Chuanqi Xu 39cfde2366 Revert "[C++20] [Modules] Handle initializer for Header Units"
This reverts commit db6152ad66.

This commit fails in ppc64. Since we want to backport it to 15.x. So
revert it now to keep the patch complete.
2022-08-02 11:09:38 +08:00
Fangrui Song 29f852a151 [Driver] Remove deprecated -fsanitize-coverage-{black,white}list= 2022-08-01 19:39:25 -07:00
Fangrui Song 0bb3aafbd5 [docs] Regenerate clang/docs/ClangCommandLineReference.rst
Also update -ftime-trace='s help to fix a recommonmark error.
2022-08-01 19:31:25 -07:00
Chuanqi Xu db6152ad66 [C++20] [Modules] Handle initializer for Header Units
Previously when we add module initializer, we forget to handle header
units. This results that we couldn't compile a Hello World Example with
Header Units. This patch tries to fix this.

Reviewed By: iains

Differential Revision: https://reviews.llvm.org/D130871
2022-08-02 10:27:02 +08:00
Alex Brachet 9bf6eccae1 [clang] Only run test on x86 2022-08-02 00:56:05 +00:00
Ben Langmuir 98cf745a03 [clang] Only modify FileEntryRef names that are externally remapped
As progress towards having FileEntryRef contain the requested name of
the file, this commit narrows the "remap" hack to only apply to paths
that were remapped to an external contents path by a VFS. That was
always the original intent of this code, and the fact it was making
relative paths absolute was an unintended side effect.

Differential Revision: https://reviews.llvm.org/D130935
2022-08-01 15:45:51 -07:00
Alex Brachet 6b3fa58fde [clang] Make test agnostic to file seperator character 2022-08-01 22:12:04 +00:00
Alex Brachet 71f2d5c2d1 [clang] Re-enable test after marking it XFAIL
This test had to be disabled because ps4 targets don't support
-fuse-ld. Preferably, this should just be unsupported for ps4
targets. However no such lit feature exists so I have just gone
ahead and set the target explicitly. Moreover, this needs
to create a terminal link step, either an executable or shared
object to get the link error. With the change to the explicit
target I've had to also add -nostartfiles -nostdlib so that
clang doesn't pull crt files into the link which may not be
present. Again, this would likely be solved if this test
was unsupported for the one platform that disables -fuse-ld
2022-08-01 22:09:13 +00:00
Ben Langmuir b4c6dc2e66 [clang] Update code that assumes FileEntry::getName is absolute NFC
It's an accident that we started return asbolute paths from
FileEntry::getName for all relative paths. Prepare for getName to get
(closer to) return the requested path. Note: conceptually it might make
sense for the dependency scanner to allow relative paths and have the
DependencyConsumer decide if it wants to make them absolute, but we
currently document that it's absolute and I didn't want to change
behaviour here.

Differential Revision: https://reviews.llvm.org/D130934
2022-08-01 14:48:37 -07:00
Alex Brachet 4b8f375c9f [clang] Temporarily expect failure from test 2022-08-01 21:11:21 +00:00
Alex Brachet 9028966a71 [clang] Don't create executable in test 2022-08-01 20:59:40 +00:00
Alex Brachet 1ccded0fc1 [clang] Fix build when targeting ps4
-fuse-ld is not available for ps4 targets
2022-08-01 20:31:01 +00:00
Alex Brachet 5fd03b00ee [Driver] Re-run lld with --reproduce when it crashes
This was discussed on https://discourse.llvm.org/t/rfc-generating-lld-reproducers-on-crashes/58071/12

When lld crashes, or errors when -gen-reproducer=error
and -fcrash-diagnostics=all clang will re-run lld with
--reproduce=$temp_file for easily reproducing the
crash/error.

Differential Revision: https://reviews.llvm.org/D120175
2022-08-01 20:01:01 +00:00
Zakk Chen 8e51917b39 [RISCV][Clang] Add tests for all supported policy functions. (NFC)
In order to make the review easier, I split a lot of tests from
https://reviews.llvm.org/D126742

Reviewed By: rogfer01

Differential Revision: https://reviews.llvm.org/D126743
2022-08-01 17:42:43 +00:00
Zakk Chen 71fd66161d [RISCV][Clang] Support RVV policy functions.
1. Add policy functions support and tests for vadd, vmv, vfmv and all load
   instructions except segment load. I didn't add all combination of policy
   functions in test because it seem not to make sense.
2. Rename HasUnMaskedOverloaded to SupportOverloading.
3. vmv.s.x for ta policy could not have overloaded API.
4. This patch does not support all operations, I will have other follow-up
   patches support all.

[RFC] https://github.com/riscv-non-isa/rvv-intrinsic-doc/pull/137

Reviewed By: kito-cheng, fakepaper56, fakepaper56

Differential Revision: https://reviews.llvm.org/D126742
2022-08-01 17:32:08 +00:00
Gabriel Ravier 5674a3c880 Fixed a number of typos
I went over the output of the following mess of a command:

(ulimit -m 2000000; ulimit -v 2000000; git ls-files -z |
 parallel --xargs -0 cat | aspell list --mode=none --ignore-case |
 grep -E '^[A-Za-z][a-z]*$' | sort | uniq -c | sort -n |
 grep -vE '.{25}' | aspell pipe -W3 | grep : | cut -d' ' -f2 | less)

and proceeded to spend a few days looking at it to find probable typos
and fixed a few hundred of them in all of the llvm project (note, the
ones I found are not anywhere near all of them, but it seems like a
good start).

Differential Revision: https://reviews.llvm.org/D130827
2022-08-01 13:13:18 -04:00
Chris Bieneman 5dbb92d8cd [HLSL] CodeGen HLSL Resource annotations
HLSL Resource types need special annotations that the backend will use
to build out metadata and resource annotations that are required by
DirectX and Vulkan drivers in order to provide correct data bindings
for shader exeuction.

This patch adds some of the required data for unordered-access-views
(UAV) resource binding into the module flags. This data will evolve
over time to cover all the required use cases, but this should get
things started.

Depends on D130018.

Differential Revision: https://reviews.llvm.org/D130019
2022-08-01 11:19:43 -05:00
Simon Pilgrim b978fa2844 OffloadBundler.cpp - fix Wdocumentation warnings. NFC.
Fix param list instead of embedding \p tag
2022-08-01 15:24:47 +01:00
Dominik Adamski d90b7bf2c5 Add support for lowering simd if clause to LLVM IR
Scope of changes:
  1) Added new function to generate loop versioning
  2) Added support for if clause to applySimd function
  2) Added tests which confirm that lowering is successful

If ifCond is specified, then collapsed loop is duplicated and if branch
is added. Duplicated loop is executed if simd ifCond is evaluated to false.

Reviewed By: Meinersbur

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

Signed-off-by: Dominik Adamski <dominik.adamski@amd.com>
2022-08-01 04:43:32 -05:00
Frederic Cambus 892e6e2200 [clang] Update Clang version from 15 to 16 in scan-build.1.
Similar to D110763.
2022-08-01 10:34:55 +02:00
Chuanqi Xu 834a878367 [C++2b] [Modules] Handle HaveModules with C++2b
Closing https://github.com/llvm/llvm-project/issues/56803. The root
cause for this bug is that we lack a good method to detect the language
mdoe when parsing the command line. There is a FIXME too. Dut to we lack
a good solution now, keep the workaround.
2022-08-01 16:06:34 +08:00
Serge Pavlov 2bb7c54621 [Clang] Remove unused parameter. NFC
BinaryOperator::getFPFeatures get parameter, which is not used. Similar
methods of other AST nodes do not have any parameter.
2022-08-01 14:53:13 +07:00
David Green ef9df0dc00 [ARM] Simplify ArchGuard predicates in arm_neon.h.
__ARM_ARCH >= 8 is implied by defined(__aarch64__), so we don't need to
guard against both together.
2022-08-01 08:20:23 +01:00
Fangrui Song dc900eeaf2 [test] Fix threadlocal_address.cpp after D129833
Older Darwin does not support thread_local:

error: thread-local storage is not supported for the current target
  thread_local int j = 0;
2022-07-31 23:49:33 -07:00
Chuanqi Xu 39dd8dcf20 [NFC] Fix test failure in windows 2022-08-01 14:14:02 +08:00
Chuanqi Xu bacdf80f42 Use @llvm.threadlocal.address intrinsic to access TLS variable
This is successor for D125291. This revision would try to use
@llvm.threadlocal.address in clang to access TLS variable. The reason
why the OpenMP tests contains a lot of change is that they uses
utils/update_cc_test_checks.py to update their tests.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D129833
2022-08-01 11:05:00 +08:00
Sunho Kim 773d51ce3b [clang-repl] XFAIL windows properly in simple-exception test case.
We don't have proper exception support in LLJIT on windows yet. We have to xfail windows machine, but the previous check missed out some targets.
2022-08-01 09:06:35 +09:00
Kazu Hirata 71336d03f1 Use llvm::any_of (NFC) 2022-07-31 15:17:08 -07:00
Kazu Hirata ed29930519 [Sema] Remove an unused forward declaration (NFC) 2022-07-31 15:17:00 -07:00
Jun Zhang 9caee577ef
[clang-repl] Fix incorrect return code
Without this patch, clang-repl incorrectly pass some tests when there's
error occured.

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

Differential Revision: https://reviews.llvm.org/D130422
2022-07-31 19:07:05 +08:00
Jun Zhang 3da1395383
[CodeGen][NFC] Use isa_and_nonnull instead of explicit check
Signed-off-by: Jun Zhang <jun@junz.org>
2022-07-31 13:03:24 +08:00
Sunho Kim a8f2e24e48 [clang-repl] Disable building when LLVM_STATIC_LINK_CXX_STDLIB is ON.
We have seen random symbol not found "__cxa_throw" error in fuschia build bots and out-of-tree users. The understanding have been that they are built without exception support, but it turned out that these platforms have LLVM_STATIC_LINK_CXX_STDLIB ON so that they link libstdc++ to llvm statically. The reason why this is problematic for clang-repl is that by default clang-repl tries to find symbols from symbol table of executable and dynamic libraries loaded by current process. It needs to load another libstdc++, but the platform that had LLVM_STATIC_LINK_CXX_STDLIB turned on is usally those with missing or obsolate shared libstdc++ in the first place -- trying to load it again would be destined to fail eventually with a risk to introuduce mixed libstdc++ versions.

A proper solution that doesn't take a workaround is statically link the same libstdc++ by clang-repl side, but this is not possible with old JIT linker runtimedyld. New just-in-time linker JITLink handles this relatively well, but it's not availalbe in majority of platforms. For now, this patch just disables the building of clang-repl when LLVM_STATIC_LINK_CXX_STDLIB is ON and removes the "__cxa_throw" check in exception unittest as well as reverting previous exception check flag patch.

Reviewed By: v.g.vassilev

Differential Revision: https://reviews.llvm.org/D130788
2022-07-31 05:42:57 +09:00
Kazu Hirata 16eaeaded5 Use is_contained (NFC) 2022-07-30 10:35:54 -07:00
Simon Pilgrim 91d9b7b407 DependencyScanningTool.h - fix Wdocumentation warning. NFC. 2022-07-30 11:00:35 +01:00
Simon Pilgrim b3fd44dd6a Sema.h - fix Wdocumentation warnings. NFC. 2022-07-30 11:00:16 +01:00
Kazu Hirata 873888c179 Use is_sorted (NFC) 2022-07-29 21:18:42 -07:00
Kazu Hirata e5a1ccbf25 Use value instead of getValue (NFC) 2022-07-29 21:18:41 -07:00
Kazu Hirata a948117088 [clang] Use has_value instead of value (NFC) 2022-07-29 21:18:39 -07:00
Weverything fb7fa27f92 Preserve qualifiers when getting fully qualified type
15f3cd6bfc moved the handling of UsingType
to a later point in the function getFullyQualifiedType.  This moved it
after the removal of an ElaboratedType and its qualifiers.  However,
the qualifiers were not added back, causing the fully qualified type to
have a qualifier mismatch with the original type.  Make sure the
qualifers are added before continuing to fully qualify the type.
2022-07-29 19:42:54 -07:00
Shafik Yaghmour a0d6105162 [Clang] Fix handling of Max from getValueRange(...) in IntExprEvaluator::VisitCastExpr(...)
This is a follow-up to D130058 to fix how we handle the Max value we obtain from
getValueRange(...) in IntExprEvaluator::VisitCastExpr(...) which in the case of
an enum that contains an enumerator with the max integer value will overflow by
one.

The fix is to decrement the value of Max and use slt and ult for comparison Vs
sle and ule.`

Differential Revision: https://reviews.llvm.org/D130811
2022-07-29 19:17:42 -07:00
Aiden Grossman afb4efd3bc Fix lack of cc1 flag in llvmcmd sections when assertions are enabled
Currently when assertions are enabled, the cc1 flag is not
inserted into the llvmcmd section of object files with embedded
bitcode. This deviates from the normal behavior where this is
the first flag that is inserted. This error stems from incorrect
use of the function generateCC1CommandLine() which requires
manually adding in the -cc1 flag which is currently not done.

Reviewed By: jansvoboda11

Differential Revision: https://reviews.llvm.org/D130620
2022-07-29 18:51:48 -07:00
Sunho Kim 32f59b34b6 [clang-repl] Add missing link component.
OrcJIT was missing in LLVM_LINK_COMPONENTS.
2022-07-30 08:00:15 +09:00
Argyrios Kyrtzidis 944a86de7c [ASTWriter] Provide capability to output a PCM/PCH file that does not write out information about its output path
This is useful to enable sharing of the same PCH file even when it's intended for a different output path.

The only information this option disables writing is for `ORIGINAL_PCH_DIR` record which is treated as optional and (when present) used as fallback for resolving input file paths relative to it.

Differential Revision: https://reviews.llvm.org/D130710
2022-07-29 15:21:54 -07:00
Sunho Kim 65c9265f41 [clang-repl] Disable exectuion unitests on unsupported platform by lljit instance test.
The method used in 4191d661c7 was fragile because it didn't consider cross-platform builds and rely on enlisting unsupported targets. Uses the host-supports-jit mechanism to make an escape path. This should fix buildbot failures happening in upstream as well as out-of-tree.
2022-07-30 07:18:04 +09:00
Sam Estep a6ddc68487 [clang][dataflow] Handle multiple context-sensitive calls to the same function
This patch enables context-sensitive analysis of multiple different calls to the same function (see the `ContextSensitiveSetBothTrueAndFalse` example in the `TransferTest` suite) by replacing the `Environment` copy-assignment with a call to the new `popCall` method, which  `std::move`s some fields but specifically does not move `DeclToLoc` and `ExprToLoc` from the callee back to the caller.

To enable this, the `StorageLocation` for a given parameter needs to be stable across different calls to the same function, so this patch also improves the modeling of parameter initialization, using `ReferenceValue` when necessary (for arguments passed by reference).

This approach explicitly does not work for recursive calls, because we currently only plan to use this context-sensitive machinery to support specialized analysis models we write, not analysis of arbitrary callees.

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D130726
2022-07-29 19:40:19 +00:00
skc7 09c4121123 Revert "Revert "[Clang][Attribute] Introduce maybe_undef attribute for function arguments which accepts undef values""
This reverts commit 4e1fe96.

Reverting this commit and fix the tests that caused failures due to
a35c64c.
2022-07-29 19:07:07 +00:00
Amy Kwan 4e1fe968c9 Revert "[Clang][Attribute] Introduce maybe_undef attribute for function arguments which accepts undef values"
This reverts commit a35c64ce23.

Reverting this commit as it causes various failures on LE and BE PPC bots.
2022-07-29 13:28:48 -05:00
Fangrui Song 7430894a65 Replace Optional::hasValue with has_value or operator bool. NFC 2022-07-29 10:57:25 -07:00
Sunho Kim 4191d661c7 [clang-repl] Disable execution unittests on unsupported platforms.
After the intoduction of global destructor support, there is a possiblity to run invalid instructions in the destructor of Interpreter class. Completely disable tests in platforms with failing test cases.

Differential Revision: https://reviews.llvm.org/D130786
2022-07-30 02:28:03 +09:00
Aaron Ballman d8352abd3a Diagnose use of _Noreturn on a struct/union field
C99 6.7.4p2 clarifies that a function specifier can only be used in the
declaration of a function. _Noreturn is a function specifier, so it is
a constraint violation to write it on a structure or union field, but
we missed that case.

Fixes #56800
2022-07-29 13:18:44 -04:00
Corentin Jabot ad16268f13 [Clang] Do not check for underscores in isAllowedInitiallyIDChar
isAllowedInitiallyIDChar is only used with non-ASCII codepoints,
which are handled by isAsciiIdentifierStart.
To make that clearer, remove the check for _ from
isAllowedInitiallyIDChar, and assert on ASCII - to ensure neither
_ or $ are passed to this function.

Reviewed By: tahonermann, aaron.ballman

Differential Revision: https://reviews.llvm.org/D130750
2022-07-29 17:46:38 +02:00
Erich Keane b25902736c [NFCI] Propagate MLTAL through more concepts in prep of deferred inst.
In preperation of the deferred instantation progress, this patch
propagates the multi-level template argument lists further through the
API to reduce the size of that patch.
2022-07-29 05:54:04 -07:00
Florian Hahn fbe022f189
[Libcalls] Add tests with maytrap & non-errno for math libcalls. 2022-07-29 13:45:34 +01:00
Rainer Orth bf3714884a [clang][Driver] Handle SPARC -mcpu=native etc.
To make use of SPARC support in `getHostCPUName` as implemented by D130272
<https://reviews.llvm.org/D130272>, this patch uses it to handle
`-mcpu=native` and `-mtune=native`.  To match GCC, this patch rejects
`-march` instead of silently treating it as a no-op.

Tested on `sparcv9-sun-solaris2.11` and checking that those options are
passed on as `-target-cpu` resp. `-tune-cpu` as expected.

Differential Revision: https://reviews.llvm.org/D130273
2022-07-29 09:27:09 +02:00
Rainer Orth 9b1897bbd0 [Driver] Use libatomic for 32-bit SPARC atomics support on Linux
This is the Linux/sparc64 equivalent to D118021
<https://reviews.llvm.org/D118021>, necessary to provide an external
implementation of atomics on 32-bit SPARC which LLVM cannot inline even
with `-mcpu=v9` or an equivalent default.

Tested on `sparc64-unknown-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D130569
2022-07-29 09:19:38 +02:00
Chuanqi Xu 4d9251bd78 [C++20] [Modules] Merge same concept decls in global module fragment
According to [basic.def.odr]p14, the same redeclarations in different TU
but not attached to a named module are allowed. But we didn't take care
of concept decl for this condition. This patch tries to fix this
problem.

Reviewed By: ilya-biryukov

Differention Revision: https://reviews.llvm.org/D130614
2022-07-29 10:50:27 +08:00
skc7 a35c64ce23 [Clang][Attribute] Introduce maybe_undef attribute for function arguments which accepts undef values
Add the ability to put __attribute__((maybe_undef)) on function arguments.
Clang codegen introduces a freeze instruction on the argument.

Differential Revision: https://reviews.llvm.org/D130224
2022-07-29 02:27:26 +00:00
Chris Bieneman cc47db6737 [HLSL] Add HLSLResource attribute
HLSL Resource objects will have restrictions on use and codegen
requirements. This patch is fairly minimal just adding the attribute
with no spellings since it will only be attached by the
HLSLExternalSemaSource.

Depends on D1300017.

Differential Revision: https://reviews.llvm.org/D130018
2022-07-28 20:54:51 -05:00
sstwcw 60e12068ff [clang-format] Handle Verilog attributes
Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D128709
2022-07-29 00:38:30 +00:00
sstwcw c88719483c [clang-format] Handle Verilog case statements
These statements are like switch statements in C, but without the 'case'
keyword in labels.

How labels are parsed.  In UnwrappedLineParser, the program tries to
parse a statement every time it sees a colon.  In TokenAnnotator, a
colon that isn't part of an expression is annotated as a label.

The token type `TT_GotoLabelColon` is added.  We did not include Verilog
in the name because we thought we would eventually have to fix the
problem that case labels in C can't contain ternary conditional
expressions and we would use that token type.

The style is like below.  Labels are on separate lines and indented by
default.  The linked style guide also has examples where labels and the
corresponding statements are on the same lines.  They are not supported
for now.

https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md

```
case (state_q)
  StIdle:
    state_d = StA;
  StA: begin
    state_d = StB;
  end
endcase
```

Differential Revision: https://reviews.llvm.org/D128714
2022-07-29 00:38:30 +00:00
sstwcw b67ee18e85 [clang-format] Handle Verilog user-defined primitives
Differential Revision: https://reviews.llvm.org/D128713
2022-07-29 00:38:30 +00:00
sstwcw 6db0c18b1a [clang-format] Handle Verilog modules
Now things inside hierarchies like modules and interfaces are
indented.  When the module header spans multiple lines, all except the
first line are indented as continuations.  We added the property
`IsContinuation` to mark lines that should be indented this way.

In order that the colons inside square brackets don't get labeled as
`TT_ObjCMethodExpr`, we added a check to only use this type when the
language is not Verilog.

Differential Revision: https://reviews.llvm.org/D128712
2022-07-29 00:38:30 +00:00
sstwcw 67480b360c [clang-format] Handle Verilog blocks
Now stuff inside begin-end blocks get indented.

Some tests are moved into FormatTestVerilog.Block from
FormatTestVerilog.If because they have nothing to do with if statements.

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D128711
2022-07-29 00:38:30 +00:00
sstwcw f93182a887 [clang-format] Handle Verilog numbers and operators
Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D126845
2022-07-29 00:38:29 +00:00