Commit Graph

91177 Commits

Author SHA1 Message Date
Nathan Sidwell b8ff780f20 [clang][NFC] Correct doc markup
Spotted when implementing an extension.
2021-10-13 04:20:15 -07:00
Nathan Sidwell d45526e6c3 [doc][clang] correct version for p0388 implementation
The p0388 patch series took so long, the clang version was incorrect,
and I failed to realize that.
2021-10-13 04:12:07 -07:00
Jan Svoboda 28fa77feeb [clang][modules] Avoid using uninitialized SourceLocation
At this point, `F.ImportLoc` has not been initialized by the `ASTReader` yet and using it leads to an assertion failure.

Introduced in 638c673a8c and 4445135109.
2021-10-13 11:24:01 +02:00
Balazs Benics edde4efc66 [analyzer] Introduce the assume-controlled-environment config option
If the `assume-controlled-environment` is `true`, we should expect `getenv()`
to succeed, and the result should not be considered tainted.
By default, the option will be `false`.

Reviewed By: NoQ, martong

Differential Revision: https://reviews.llvm.org/D111296
2021-10-13 10:50:26 +02:00
Balazs Benics 7fc150309d [analyzer] Bifurcate on getenv() calls
The `getenv()` function might return `NULL` just like any other function.
However, in case of `getenv()` a state-split seems justified since the
programmer should expect the failure of this function.

`secure_getenv(const char *name)` behaves the same way but is not handled
right now.
Note that `std::getenv()` is also not handled.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D111245
2021-10-13 10:50:26 +02:00
Hsiangkai Wang ff3ed78304 Revert "[RISCV] Define _m intrinsics as builtins, instead of macros."
This reverts commit 97f0c63783.

As discussed in https://reviews.llvm.org/D110684, it increased the
compile time and the binary size of clang more than 1%. I reverted
this patch first to think about a better way to do it.
2021-10-13 12:21:51 +08:00
David Blaikie 39093279f2 Improve printing of const variable sized arrays
Follow-on from 40acc0adad with help from
Richard Smith on how to provoke this particular case.
2021-10-12 19:04:53 -07:00
Fangrui Song c2d4fe51bb [X86] Remove little support we had for MPX
GCC 9.1 removed Intel MPX support. Linux kernel removed MPX in 2019.
glibc 2.35 will remove MPX.

Our support is limited: we support assembling of bndmov but not bnd.
Just remove it.

Reviewed By: pengfei, skan

Differential Revision: https://reviews.llvm.org/D111517
2021-10-12 16:18:51 -07:00
Arthur Eubanks b6a8c69554 [NFC] Rename EmitAssemblyHelper new/legacy PM methods
To reflect the fact that the new PM is the default now.

Differential Revision: https://reviews.llvm.org/D111680
2021-10-12 15:41:44 -07:00
Artem Belevich f526ee5b85 [CUDA] Provide address space conversion builtins.
CUDA-11 headers rely on these NVCC builtins.
Despite having `__nv` previx, those are *not* provided by libdevice.

Differential Revision: https://reviews.llvm.org/D111665
2021-10-12 14:56:39 -07:00
Arthur Eubanks 2cadef6537 [clang] Teardown new PM data structures before running codegen pipeline
Do this by refactoring the optimization and codegen pipelines into separate functions.

This saves a tiny bit of memory in non-LTO builds [1].

[1] https://llvm-compile-time-tracker.com/compare.php?from=fbddf22ef72d3c2e9b14e1501841b03380eef12b&to=cd276df52eb6f2b84a8e1efe5318460c6debf82d&stat=max-rss

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D111582
2021-10-12 14:17:11 -07:00
Artem Dergachev f3ec9d8501 [analyzer] Fix non-obvious analyzer warning: Use of zero-allocated memory.
Clarify the message provided when the analyzer catches the use of memory
that is allocated with size zero.

Differential Revision: https://reviews.llvm.org/D111655
2021-10-12 10:41:00 -07:00
Nico Weber 2cc42758a9 [clang/CFG] Don't explicitly add AttributedStmtClass to AlwaysAddList
CFGBuilder::addStmt() implicitly passes AddStmtChoice::AlwaysAdd
to Visit() already, so this should have no behavior change.

Differential Revision: https://reviews.llvm.org/D111570
2021-10-12 13:29:19 -04:00
Kazu Hirata 57b40b5f34 [AST, CodeGen, Driver] Use llvm::is_contained (NFC) 2021-10-12 09:19:49 -07:00
Saiyedul Islam f56548829c [Clang][clang-nvlink-wrapper] Pass nvlink path to the wrapper
Added support of a "--nvlink-path" option in clang-nvlink-wrapper which
takes the path of nvlink binary.

Static Device Library support for OpenMP (D105191) now searches for
nvlink binary and passes its location via this option. In absence
of this option, nvlink binary is searched in locations in PATH.

Differential Revision: https://reviews.llvm.org/D111488
2021-10-12 16:15:52 +00:00
Nathan Sidwell 444ec0957c [clang] p0388 array list initialization overloads
This is the second part of p0388, dealing with overloads of list
initialization to incomplete array types.  It extends the handling
added in D103088 to permit incomplete arrays.  We have to record that
the conversion involved an incomplete array, and so (re-add) a bit flag
into the standard conversion sequence object.  Comparing such
conversion sequences requires knowing (a) the number of array elements
initialized and (b) whether the initialization is of an incomplete array.

This also updates the web page to indicate p0388 is implemented (there
is no feature macro).

Differential Revision: https://reviews.llvm.org/D103908
2021-10-12 07:35:21 -07:00
Nathan Sidwell dcd74716f9 [clang] p0388 conversion to incomplete array
This implements the new implicit conversion sequence to an incomplete
(unbounded) array type.  It is mostly Richard Smith's work, updated to
trunk, testcases added and a few bugs fixed found in such testing.

It is not a complete implementation of p0388.

Differential Revision: https://reviews.llvm.org/D102645
2021-10-12 07:35:20 -07:00
Ahsan Saghir 564e082d09 [PowerPC] Allow MMA built-ins to accept restrict and volatile qualified pointers
This patch allows MMA built-ins on PowerPC to accept restrict
and volatile qualified pointers.

Reviewed By: #powerpc, nemanjai

Differential Revision: https://reviews.llvm.org/D106550
2021-10-12 08:51:50 -05:00
Nico Weber c74ab84ea2 [clang] Omit most AttributedStatements from the CFG
`[[clang::fallthrough]]` has meaning for the CFG, but all other
StmtAttrs we currently have don't. So omit them, as AttributedStatements
with children cause several issues and there's no benefit in including
them.

Fixes PR52103 and PR49454. See PR52103 for details.

Differential Revision: https://reviews.llvm.org/D111568
2021-10-12 09:15:45 -04:00
Jan Svoboda 6a1f50b84a [clang][deps] Prune unused header search paths
To reduce the number of explicit builds of a single module, we can try to squash multiple occurrences of the module with different command-lines (and context hashes) by removing benign command-line options. The greatest contributors to benign differences between command-lines are the header search paths.

In this patch, the lookup cache in `HeaderSearch` is used to identify paths that were actually used when implicitly building the module during scanning. This information is serialized into the unhashed control block of the implicitly-built PCM. The dependency scanner then loads this and may use it to prune the header search paths before computing the context hash of the module and generating the command-line.

We could also prune the header search paths when serializing `HeaderSearchOptions` into the PCM. That way, we could do it only once instead of every load of the PCM file by dependency scanner. However, that would result in a PCM file whose contents don't produce the same context hash as the original build, which is probably highly surprising.

There is an alternative approach to storing extra information into the PCM: wire up preprocessor callbacks to capture the used header search paths on-the-fly during preprocessing of modularized headers (similar to what we currently do for the main source file and textual headers). Right now, that's not compatible with the fact that we do an actual implicit build producing PCM files during dependency scanning. The second run of dependency scanner loads the PCM from the first run, skipping the preprocessing altogether, which would result in different results between runs. We can revisit this approach when we stop building implicitly during dependency scanning.

Depends on D102923.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D102488
2021-10-12 12:39:23 +02:00
jacquesguan 477f5f4fca [RISCV][Clang] Fix RISCV vector header comment.
Reviewed By: khchen

Differential Revision: https://reviews.llvm.org/D111597
2021-10-12 10:26:25 +00:00
Jan Svoboda 4445135109 [clang][lex] Remark on search path usage
For dependency scanning, it would be useful to collect header search paths (provided on command-line via `-I` and friends) that were actually used during preprocessing. This patch adds that feature to `HeaderSearch` along with a new remark that reports such paths as they get used.

Previous version of this patch tried to use the existing `LookupFileCache` to report used paths via `HitIdx`. That doesn't work for `ComputeUserEntryUsage` (which is intended to be called *after* preprocessing), because it indexes used search paths by the file name. This means the values get overwritten when the code contains `#include_next`.

Note that `HeaderSearch` doesn't use `HeaderSearchOptions::UserEntries` directly. Instead, `InitHeaderSearch` pre-processes them (adds platform-specific paths, removes duplicates, removes paths that don't exist) and creates `DirectoryLookup` instances. This means we need a mechanism for translating between those two. It's not possible to go from `DirectoryLookup` back to the original `HeaderSearch`, so `InitHeaderSearch` now tracks the relationships explicitly.

Depends on D111557.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D102923
2021-10-12 12:20:55 +02:00
Sven van Haastregt 544d89e847 [OpenCL] Add atomic_half type builtins
Add atomic_half types and builtins operating on the types from the
cl_ext_float_atomics extension.

Patch by Haonan Yang.

Differential Revision: https://reviews.llvm.org/D109740
2021-10-12 10:45:30 +01:00
Jan Svoboda 1341a2c19e [clang][modules] Default `SourceLocation` parameter in `HeaderSearch::lookupModule`
This fixes an LLDB build failure where the `ImportLoc` argument is missing: https://lab.llvm.org/buildbot#builders/68/builds/19975

This change also makes it possible to drop `SourceLocation()` in `Preprocessor::getCurrentModule`.
2021-10-12 09:58:54 +02:00
Victor Campos 3e7cf33a83 [docs] List support for Armv9-A, Armv9.1-A and Armv9.2-A in LLVM and Clang
Reviewed By: pratlucas

Differential Revision: https://reviews.llvm.org/D110241
2021-10-12 08:41:07 +01:00
Jan Svoboda 638c673a8c [clang][modules] NFC: Propagate import `SourceLocation` into `HeaderSearch::lookupModule`
This patch propagates the import `SourceLocation` into `HeaderSearch::lookupModule`. This enables remarks on search path usage (implemented in D102923) to point to the source code that initiated header search.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D111557
2021-10-12 09:31:51 +02:00
jacquesguan 0608bbd4e8 [RISCV] Rename assembler mnemonic of unordered floating-point reductions for v1.0-rc change
Rename vfredsum and vfwredsum to vfredusum and vfwredusum. Add aliases for vfredsum and vfwredsum.

Reviewed By: luismarques, HsiangKai, khchen, frasercrmck, kito-cheng, craig.topper

Differential Revision: https://reviews.llvm.org/D105690
2021-10-12 06:46:46 +00:00
Yonghong Song a162b67c98 [Clang][Attr] rename btf_tag to btf_decl_tag
Current btf_tag is applied to declaration only.
Per discussion in https://reviews.llvm.org/D111199,
we plan to introduce btf_type_tag attribute for types.
So rename btf_tag to btf_decl_tag to make it easily
differentiable from btf_type_tag.

Differential Revision: https://reviews.llvm.org/D111588
2021-10-11 22:17:17 -07:00
hsmahesha db9c2d7751 [CFE][Codegen] Remove CodeGenFunction::InitTempAlloca()
Sequel patch to https://reviews.llvm.org/D111316

Finally, remove the defintion of CodeGenFunction::InitTempAlloca().

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D111324
2021-10-12 10:04:15 +05:30
hsmahesha f7de6962c8 [CFE][Codegen][In-progress] Remove CodeGenFunction::InitTempAlloca()
Sequel patch to https://reviews.llvm.org/D111293.

Remove call to CodeGenFunction::InitTempAlloca() from OpenMP related
codegen part.

Also remove the metadata `!llvm.access.group` from the updated lit
tests.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D111316
2021-10-12 10:01:46 +05:30
Hsiangkai Wang 97f0c63783 [RISCV] Define _m intrinsics as builtins, instead of macros.
In the original design, we levarage _mt intrinsics to define macros for
_m intrinsics. Such as,

```
__builtin_rvv_vadd_vv_i8m1_mt((vbool8_t)(op0), (vint8m1_t)(op1), (vint8m1_t)(op2), (vint8m1_t)(op3), (size_t)(op4), (size_t)VE_TAIL_AGNOSTIC)
```

However, we could not define generic interface for mask intrinsics any
more due to clang_builtin_alias only accepts clang builtins as its
argument.

In the example,

```
 __rvv_overloaded
 __attribute__((clang_builtin_alias(__builtin_rvv_vadd_vv_i8m1_mt)))
  vint8m1_t vadd(vbool8_t op0, vint8m1_t op1, vint8m1_t op2, vint8m1_t
  op3, size_t op4, size_t op5);
```

op5 is the tail policy argument. When users want to use vadd generic
interface for masked vector add, they need to specify tail policy in the
previous design. In this patch, we define _m intrinsics as clang
builtins to solve the problem.

Differential Revision: https://reviews.llvm.org/D110684
2021-10-12 10:47:55 +08:00
Ahmed Bougacha c30a52852b [Driver] Re-enable aarch64-cpus.c test for arm64-apple.
"darwin" is ambiguous.  When there isn't a better source
of truth (e.g., SDKs), the driver will either interpret it
as "iOS" when cross-compiling to a different architecture,
or "the host" when not.  That's now the case on AS Macs.

Update the test to more explicitly test the OS.
aarch64-mac-cpus.c already tests the mac-specific driver logic.
2021-10-11 18:46:26 -07:00
Haowei Wu 998e067a0a Reland "[clang][Fuchsia] Support availability attr on Fuchsia"
This reland commit 1131b1eb35, which
adds support to __attribute__((availability)) annotation for Fuchsia
platform. This patch also adds '-ffuchsia-api-level' to allow specify
Fuchsia API level from the command line.

Differential Revision: https://reviews.llvm.org/D108592
2021-10-11 18:41:29 -07:00
Haowei Wu b5e8348bf2 Revert "[clang][Fuchsia] Support availability attr on Fuchsia"
This reverts commit 1131b1eb35, which
breaks several llvm bots.
2021-10-11 17:32:38 -07:00
Richard Smith 25b3370ff2 PR52139: Properly handle more kinds of declaration when checking for
usage of an abstract class type within itself.

We were missing handling for deduction guides (which would assert),
friend declarations, and variable templates. We were mishandling inline
variables and other variables defined inside the class definition.

These diagnostics should be downgraded to warnings, or perhaps removed
entirely, once we implement P0929R2.
2021-10-11 16:37:39 -07:00
Yonghong Song c5fb1a0953 Revert "[Clang] Ignore BTFTag attr if used as a type attribute"
This reverts commit b875343873.

Per discussion in https://reviews.llvm.org/D111199, instead to make
existing btf_tag attribute as a type-or-decl attribute, we will
make existing btf_tag attribute as a decl only attribute, and
introduce btf_type_tag as a type only attribute. This will make
it easy for cases like typedef where an attribute may be applied
as either a type attribute or a decl attribute.
2021-10-11 15:34:26 -07:00
Haowei Wu 1131b1eb35 [clang][Fuchsia] Support availability attr on Fuchsia
This patch adds support to __attribute__((availability)) annotation for
Fuchsia platform. This patch also adds '-ffuchsia-api-level' to allow
specify Fuchsia API level from the command line.

Differential Revision: https://reviews.llvm.org/D108592
2021-10-11 15:33:04 -07:00
Jinsong Ji 64d1d5f336 [AIX] Unsupported newly added AMDGPU clang test 2021-10-11 21:34:48 +00:00
James King 25fabc434a Add release note about `TypeLoc` matchers.
Reviewed By: ymandel, aaron.ballman

Differential Revision: https://reviews.llvm.org/D111518
2021-10-11 19:57:32 +00:00
Chris Bieneman 121b2252de AddGlobalAnnotations for function with or without function body.
When AnnotateAttr is on a function, AddGlobalAnnotations is only called
in CodeGenModule::EmitGlobalFunctionDefinition which means AnnotateAttr
on function declaration without function body will be ignored.
The patch will move AddGlobalAnnotations  to
CodeGenModule::SetFunctionAttributes, so with or without function body,
the AnnotateAttr will get code gen for a function.

It'll help case when AnnotateAttr is on external function, and the
AnnotateAttr will be consumed in IR level.

For example, a pass to collect num of uses for functions with
__attribute((annotate("count_use"))) after optimizations,
As long as there's __attribute((annotate("count_use"))), function with
or without function body should be counted.

Reviewed By: aaron.ballman

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

Patch by:  python3kgae (Xiang Li)
2021-10-11 14:50:34 -05:00
Nico Weber 5ab2a95edb [clang] Remove an else-after-return 2021-10-11 14:24:58 -04:00
Nico Weber 00ca004dda [clang] Convert a few loops to for-each 2021-10-11 14:24:32 -04:00
Nico Weber 144f851f6f [clang/CFG] Rewrap a line to 80 columns 2021-10-11 14:23:51 -04:00
Kazu Hirata d409048201 [Sema] Use llvm::is_contained (NFC) 2021-10-11 11:06:44 -07:00
Arthur Eubanks b41cfbfcbb [docs] Mention in release notes that we now support 2^32 alignment
Missed in D110451.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D111472
2021-10-11 10:23:15 -07:00
Craig Topper a5c3508ac7 [RISCV] Require tail policy argument to builtins to be an integer constant expression
The IR intrinsics use ImmArg for the policy operand so this needs to be enforced as a constant in the frontend.

Differential Revision: https://reviews.llvm.org/D110779
2021-10-11 09:55:04 -07:00
Victor Campos 3550e242fa [Clang][ARM][AArch64] Add support for Armv9-A, Armv9.1-A and Armv9.2-A
armv9-a, armv9.1-a and armv9.2-a can be targeted using the -march option
both in ARM and AArch64.

 - Armv9-A maps to Armv8.5-A.
 - Armv9.1-A maps to Armv8.6-A.
 - Armv9.2-A maps to Armv8.7-A.
 - The SVE2 extension is enabled by default on these architectures.
 - The cryptographic extensions are disabled by default on these
 architectures.

The Armv9-A architecture is described in the Arm® Architecture Reference
Manual Supplement Armv9, for Armv9-A architecture profile
(https://developer.arm.com/documentation/ddi0608/latest).

Reviewed By: SjoerdMeijer

Differential Revision: https://reviews.llvm.org/D109517
2021-10-11 17:44:09 +01:00
Hans Wennborg 774388241e [MS compat] Handle #pragma fenv_access like #pragma STDC FENV_ACCESS (PR50694)
This adds support for the MSVC spelling of the pragma in -fms-extensions
mode.

Differential revision: https://reviews.llvm.org/D111440
2021-10-11 17:07:26 +02:00
Qiu Chaofan d11ec6f67e [Clang] Enable IC/IF mode for __ibm128
As for 128-bit floating points on PowerPC, compiler should have three
machine modes:

- IFmode, always IBM extended double
- KFmode, always IEEE 754R 128-bit floating point
- TFmode, matches the semantics for long double

This commit adds support for IF mode with its complex variant, IC mode.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D109950
2021-10-11 17:38:04 +08:00
Qiu Chaofan 2fc0d439a4 [Clang] [PowerPC] Fix header include typo in smmintrin.h
The SSE4 header (smmintrin.h) should include SSSE3 (tmmintrin.h) instead
of SSE2 (emmintrin.h).

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D111482
2021-10-11 10:44:08 +08:00
Sylvestre Ledru b07ea8a967 clang release notes: improve the wording 2021-10-10 22:26:11 +02:00
Sylvestre Ledru 9c8f950a04 clang release notes: document the -Wbool-operation improvement
Reviewed By: xbolva00

Differential Revision: https://reviews.llvm.org/D111215
2021-10-10 21:28:40 +02:00
Nico Weber 62abc1842b clang: Add range-based CFG::try_blocks()
..and use it. No behavior change.
2021-10-10 15:15:37 -04:00
Nico Weber 23d5fe6235 clang: Convert two loops to for-each
And rewrap a line at 80 columns while here. No behavior change.
2021-10-10 14:55:46 -04:00
Kazu Hirata 0e9373a6a6 [Basic] Use llvm::is_contained (NFC) 2021-10-10 08:52:14 -07:00
william woodruff 451d0596d7 [clang] Fix JSON AST output when a filter is used
Without this, the combination of `-ast-dump=json` and `-ast-dump-filter FILTER` produces invalid JSON: the first line is a string that says `Dumping $SOME_DECL_NAME: `.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D108441
2021-10-10 07:46:17 +05:30
mydeveloperday 3019898e0d [clang-format][NFC] improve the visual of the "clang-formatted %"
NOTE: some files are being removed from those files that are clang-formatted
which means some lack of formatting is slipping through the net on reviews
2021-10-09 19:37:03 +01:00
Aaron Ballman af971365a2 Fix a diagnoses-valid in C++20 with variadic macros
C++20 and later allow you to pass no argument for the ... parameter in
a variadic macro, whereas earlier language modes and C disallow it.

We no longer diagnose in C++20 and later modes. This fixes PR51609.
2021-10-09 08:20:20 -04:00
mydeveloperday 3e553791ca [clang-format][NFC] Fix spelling mistakes 2021-10-09 12:27:08 +01:00
Frederic Cambus 6417260a57
[Driver][OpenBSD] Use ToolChain reference instead of getToolChain().
Differential Revision: https://reviews.llvm.org/D111462
2021-10-09 13:21:39 +02:00
mydeveloperday bbf4b3dbbe [clang-format][NFC] Fix spelling mistake 2021-10-09 12:18:25 +01:00
mydeveloperday a2a826d8b6 [clang-format][docs][NFC] correct the "first supported versions" of some of the clang-format options
Some of the first supported version field were incorrectly attributed to a later branch.

It wasn't possible to correctly determine the "introduced version" with my naive implementation
using git blame alone, (especially if the type had been changed from a bool -> enum)

I saw more things attributed to clang-format 13 than I remembered and reviewed
those options to determine their introduced version.

Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D110803
2021-10-09 11:02:49 +01:00
hsmahesha 0481682996 [CFE][Codegen][In-progress] Remove CodeGenFunction::InitTempAlloca()
CodeGenFunction::InitTempAlloca() inits the static alloca within the
entry block which may *not* necessarily be correct always.

For example, the current instruction insertion point (pointed by the
instruction builder) could be a program point which is hit multiple
times during the program execution, and it is expected that the static
alloca is initialized every time the program point is hit.

Hence remove CodeGenFunction::InitTempAlloca(), and initialize the
static alloca where the instruction insertion point is at the moment.

This patch, as a starting attempt, removes the calls to
CodeGenFunction::InitTempAlloca() which do not have any side effect on
the lit tests.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D111293
2021-10-09 09:23:14 +05:30
Richard Smith 7eae8c6e62 Don't update the vptr at the start of the destructor of a final class.
In this case, we know statically that we're destroying the most-derived
class, so the vptr must already point to the current class and never
needs to be updated.
2021-10-08 19:59:42 -07:00
Qiu Chaofan 85e565898f [Clang] Enable _Complex __ibm128 type
fae0dfa implemented the new __ibm128 type, this patch enables its
complex form.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D109948
2021-10-09 10:48:44 +08:00
Qiu Chaofan 8a714722e2 [NFC] [Clang] Use global enum for explicit float mode
Currently, there're multiple float types that can be represented by
__attribute__((mode(xx))). It's parsed, and then a corresponding type is
created if available.

This refactor moves the enum for mode into a global enum class visible
to ASTContext.

Reviewed By: aaron.ballman, erichkeane

Differential Revision: https://reviews.llvm.org/D111391
2021-10-09 10:39:10 +08:00
Joseph Huber bad44d5f39 [OpenMP] Add RTL function for getting number of threads in block.
This patch adds support for the
`__kmpc_get_hardware_num_threads_in_block` function that returns the
number of threads. This was missing in the new runtime and was used by
the AMDGPU plugin which prevented it from using the new runtime. This
patchs also unified the interface for getting the thread numbers in the
frontend.

Originally authored by jdoerfert.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D111475
2021-10-08 22:21:59 -04:00
Richard Smith 222305d6ff PR51079: Treat thread_local variables with an incomplete class type as
being not trivially destructible when determining if we can skip calling
their thread wrapper function.
2021-10-08 18:46:01 -07:00
Aditya Kumar 0f00aa502d Add no_instrument_function attribute to Objective C methods as well
There are functions where we do not want function instrumentation which is why we have `__attribute__((no_instrument_function))`. Extending this functionality to disable instrumentation for Objective-C methods as well. Objective C methods like `+load` run premain and having instrumentation on them causes runtime errors depending on the implementation of `__cyg_profile_func_enter` etc. functions

Reviewed By: rjmccall, aaron.ballman

Differential Revision: https://reviews.llvm.org/D111286
2021-10-08 17:54:44 -07:00
Leonard Chan 04aff39504 Revert "Reland "[clang-repl] Re-implement clang-interpreter as a test case.""
This reverts commit 1dba6b37bd.

Reverting because the ClangReplInterpreterExceptionTests test fails on
our builders with this patch.
2021-10-08 17:43:23 -07:00
Reid Kleckner 955dc3449a Fix TargetRegistry shlib build, clang edition 2021-10-08 15:43:56 -07:00
Reid Kleckner 89b57061f7 Move TargetRegistry.(h|cpp) from Support to MC
This moves the registry higher in the LLVM library dependency stack.
Every client of the target registry needs to link against MC anyway to
actually use the target, so we might as well move this out of Support.

This allows us to ensure that Support doesn't have includes from MC/*.

Differential Revision: https://reviews.llvm.org/D111454
2021-10-08 14:51:48 -07:00
Fangrui Song 3db1ade368 [Driver][test] Fix undefined-libs.cpp when CLANG_DEFAULT_UNWINDLIB is libunwind 2021-10-08 14:40:22 -07:00
Richard Smith 64e9044ea4 Fix unintended fall-through.
Unfortunately I've not found a way to exercise this code that doesn't
crash elsewhere yet, due to unrelated bugs in how Sema incorrectly
instantiates lambdas in function template signatures.
2021-10-08 14:25:17 -07:00
Richard Smith 7ac308fb8f PR52073: Fix equivalence computation for lambda-expressions.
Distinct lambda expressions are always considered non-equivalent, so two
token-for-token identical function declarations whose signatures involve
lambda-expressions declare distinct functions.
2021-10-08 13:54:01 -07:00
Vitaly Buka 05d46f627c [NFC][sanitizer] Remove sanitizer_persistent_allocator.cpp
We need to make it a template
2021-10-08 13:43:28 -07:00
Amy Kwan 03bfddae50 [NFC] Update vec_extract builtin signatures to take signed int.
This patch updates the vec_extract builtins to take a signed int as the second
parameter, as defined by the Power Vector Intrinsics Programming Reference.
This patch is NFC and all existing tests pass.

Differential Revision: https://reviews.llvm.org/D110935
2021-10-08 15:09:53 -05:00
Arthur Eubanks e1a9c04435 [test] Fixup builtin-assume-aligned.c
__builtin_assume_aligned's second parameter is size_t, which may be 32 bits.
We can't pass 2^32 when that happens. Update tests accordingly.

Example broken bot due to D111250:
https://lab.llvm.org/buildbot/#/builders/171/builds/4531
2021-10-08 13:07:28 -07:00
Arthur Eubanks a6891d2104 [clang] Set max allowed alignment to 2^32
Followup to D110451 which set LLVM's max allowed alignment to 2^32.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D111250
2021-10-08 11:44:15 -07:00
Masoud Ataei b0f68791f0 [clang] Option control afn flag
Clang option to set/unset afn fast-math flag.

 Differential: https://reviews.llvm.org/D106191
 Reviewd with: aaron.ballman, erichkeane, and others
2021-10-08 14:26:14 -04:00
James King 3ab238af4f [AST Matchers] Update dump_ast_matchers.py to query only class index page.
It may be possible to avoid relying on accessing many individual class pages,
by instead scanning the class index page at
https://clang.llvm.org/doxygen/classes.html. This updates the script to do so,
and includes updates to `LibASTMatchersReference.html` generated by the
modified script.

Reviewed By: aaron.ballman, sammccall

Differential Revision: https://reviews.llvm.org/D111332
2021-10-08 17:45:10 +00:00
James King ac74296562 Add `TypeLoc`-related matchers.
Contributes several matchers that involve `TypeLoc`s. These matchers are (in alphabetical order):

- elaboratedTypeLoc
- hasAnyTemplateArgumentLoc
- hasNamedTypeLoc
- hasPointeeLoc
- hasReferentLoc
- hasReturnTypeLoc
- hasTemplateArgumentLoc
- hasUnqualifiedLoc
- pointerTypeLoc
- qualifiedTypeLoc
- referenceTypeLoc
- templateSpecializationTypeLoc

Reviewed By: ymandel, aaron.ballman

Differential Revision: https://reviews.llvm.org/D111242
2021-10-08 17:42:18 +00:00
Keith Smiley 68e49aea9a Revert "[clang] Fix absolute file paths with -fdebug-prefix-map"
This reverts commit a23a596793.

This broke a windows test https://buildkite.com/llvm-project/premerge-checks/builds/59492#7dad207c-6cbe-40ad-95e4-c48b47fe2527

Differential Revision: https://reviews.llvm.org/D111444
2021-10-08 10:39:44 -07:00
Keith Smiley a23a596793 [clang] Fix absolute file paths with -fdebug-prefix-map
Previously if you passed an absolute path to clang, where only part of
the path to the file was remapped, it would result in the file's DIFile
being stored with a duplicate path, for example:

```
!DIFile(filename: "./ios/Sources/bar.c", directory: "./ios/Sources")
```

This change handles absolute paths, specifically in the case they are
remapped to something relative, and uses the dirname for the directory,
and basename for the filename.

This also adds a test verifying this behavior for more standard uses as
well.

Differential Revision: https://reviews.llvm.org/D111352
2021-10-08 10:35:17 -07:00
Zequan Wu f93169226a [clang-format-diff] Fix missing formatting for zero length git diff lines
If we only delete lines that are outer block statements (if, while, etc),
clang-format-diff.py can't format the statements inside the block statements.

An example to repro:
1. Delete the if statment at line 118 in llvm/lib/CodeGen/Analysis.cpp.
2. Run `git diff -U0 --no-color HEAD^ | clang/tools/clang-format/clang-format-diff.py -i -p1`

It fails to format the statement after if.

Differential Revision: https://reviews.llvm.org/D111273
2021-10-08 10:25:54 -07:00
Jake Egan 8037481cb2 [AIX] Disable tests failing due to missing DWARF sections
The following tests are failing due to missing DWARF sections. This patch sets these tests as XFAIL/DISABLED on AIX until a more permanent solution is implemented.

Reviewed By: shchenz

Differential Revision: https://reviews.llvm.org/D111336
2021-10-08 12:06:38 -04:00
Freddy Ye 6d276595d1 [NFC] Use CHECK-NEXT instead of CHECK-SAME in target-invalid-cpu-note.c
Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D110798
2021-10-08 22:07:40 +08:00
Qiongsi Wu 75127bce6d [AIX][ZOS] Excluding merge-objc-interface.m from Tests
Objective C is not supported on AIX or ZOS. This patch excludes the newly added `clang/test/Modules/merge-objc-interface.m` (added by https://reviews.llvm.org/D110280) from AIX and ZOS testing.

Many existing tests are already disabled by https://reviews.llvm.org/D109060.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D111406
2021-10-08 14:00:06 +00:00
Corentin Jabot ff013b6100 Extend init-statement to allow alias-declaration
Implement P2360R0 in C++23 mode and as an extension in older
languages mode.
2021-10-08 07:13:45 -04:00
John McCall 5ab6ee7599 Fix a variety of bugs with nil-receiver checks when targeting
non-Darwin ObjC runtimes:

- Use the same logic the Darwin runtime does for inferring that a
  receiver is non-null and therefore doesn't require null checks.
  Previously we weren't skipping these for non-super dispatch.

- Emit a null check when there's a consumed parameter so that we can
  destroy the argument if the call doesn't happen.  This mostly
  involves extracting some common logic from the Darwin-runtime code.

- Generate a zero aggregate by zeroing the same memory that was used
  in the method call instead of zeroing separate memory and then
  merging them with a phi.  This uses less memory and avoids unnecessary
  copies.

- Emit zero initialization, and generate zero values in phis, using
  the proper zero-value routines instead of assuming that the zero
  value of the result type has a bitwise-zero representation.
2021-10-08 05:44:06 -04:00
Saiyedul Islam 35ebe4cc24 [Clang][OpenMP] Add partial support for Static Device Libraries
An archive containing device code object files can be passed to
clang command line for linking. For each given offload target
it creates a device specific archives which is either passed to llvm-link
if the target is amdgpu, or to clang-nvlink-wrapper if the target is
nvptx. -L/-l flags are used to specify these fat archives on the command
line. E.g.
  clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp -L. -lmylib

It currently doesn't support linking an archive directly, like:
  clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp libmylib.a

Linking with x86 offload also does not work.

Reviewed By: ye-luo

Differential Revision: https://reviews.llvm.org/D105191
2021-10-08 09:37:51 +00:00
Frederic Cambus 1f90b365bd
[Driver][NetBSD] Use ToolChain reference instead of getToolChain().
Differential Revision: https://reviews.llvm.org/D111340
2021-10-08 11:13:22 +02:00
Wang, Pengfei c0f9c7c015 [X86] Check if struct is blank before getting the inner types
This fixes pr52011.

Reviewed By: LuoYuanke

Differential Revision: https://reviews.llvm.org/D111037
2021-10-08 17:09:34 +08:00
Qiu Chaofan 00c0ce0655 [NFC] [Clang] Remove pre-computed complex float types
As discussed in D109948, pre-computing all complex float types is not
necessary and brings extra overhead. This patch removes these defined
types, and construct them in-place when needed.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D111387
2021-10-08 15:52:16 +08:00
Vassil Vassilev 1dba6b37bd Reland "[clang-repl] Re-implement clang-interpreter as a test case."
Original commit message: "
    Original commit message: "
        Original commit message:"
          The current infrastructure in lib/Interpreter has a tool, clang-repl, very
          similar to clang-interpreter which also allows incremental compilation.

          This patch moves clang-interpreter as a test case and drops it as conditionally
          built example as we already have clang-repl in place.

          Differential revision: https://reviews.llvm.org/D107049
        "

        This patch also ignores ppc due to missing weak symbol for __gxx_personality_v0
        which may be a feature request for the jit infrastructure. Also, adds a missing
        build system dependency to the orc jit.
    "

    Additionally, this patch defines a custom exception type and thus avoids the
    requirement to include header <exception>, making it easier to deploy across
    systems without standard location of the c++ headers.
  "

  This patch also works around PR49692 and finds a way to use llvm::consumeError
  in rtti mode.

Differential revision: https://reviews.llvm.org/D107049
2021-10-08 06:04:39 +00:00
Craig Topper f2ad8c9dc6 [RISCV] Remove experimental-b extension that includes all Zb* extensions
At this point it looks like a B extension will never exist. Instead
Zba, Zbb, Zbc, and Zbs are individual extensions being ratified
together as a package. Unknown at this time when or if the other
Zb* extensions will be ratified.

This patch removes references to the B extension. I've updated and
split tests accordingly.

This has been split from D110669 to make review a little easier.

Differential Revision: https://reviews.llvm.org/D111338
2021-10-07 20:47:17 -07:00
Joseph Huber 9efdca87c7 [OpenMP] Introduce new flags to assert thread and team usage in the runtime
This patch adds two flags to be supported for the new runtime. The flags
are `-fopenmp-assume-threads-oversubscription` and
-fopenmp-assume-teams-oversubscription`. These add global values that
can be checked by the work sharing runtime functions to make better
judgements about how to distribute work between the threads.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D111348
2021-10-07 22:23:09 -04:00
Volodymyr Sapsai 9fad9de5c0 [modules] Fix IRGen assertion on accessing ObjC ivar inside a method.
When have ObjCInterfaceDecl with the same name in 2 different modules,
hitting the assertion

> Assertion failed: (Index < RL->getFieldCount() && "Ivar is not inside record layout!"),
> function lookupFieldBitOffset, file llvm-project/clang/lib/AST/RecordLayoutBuilder.cpp, line 3434.

on accessing an ivar inside a method. The assertion happens because
ivar belongs to one module while its containing interface belongs to
another module and then we fail to find the ivar inside the containing
interface. We already keep a single ObjCInterfaceDecl definition in
redecleration chain and in this case containing interface was correct.
The issue is with ObjCIvarDecl. IVar decl for IRGen is taken from
ObjCIvarRefExpr that is created in `Sema::BuildIvarRefExpr` using ivar
decl returned from `Sema::LookupIvarInObjCMethod`. And ivar lookup
returns a wrong decl because basically we take the first ObjCIvarDecl
found in `ASTReader::FindExternalVisibleDeclsByName` (called by
`DeclContext::lookup`). And in `ASTReader.Lookups` lookup table for a
wrong module comes first because `ASTReader::finishPendingActions`
processes `PendingUpdateRecords` in reverse order and the first
encountered ObjCIvarDecl will end up the last in `ASTReader.Lookups`.

Fix by merging ObjCIvarDecl from different modules correctly and by
using a canonical one in IRGen.

rdar://82854574

Differential Revision: https://reviews.llvm.org/D110280
2021-10-07 17:09:31 -07:00
Petr Hosek ebcfd3ae8c [CMake] Include llvm-libtool-darwin in Fuchsia toolchain
We want to use this tool in our build.

Differential Revision: https://reviews.llvm.org/D111366
2021-10-07 16:44:40 -07:00
Leonard Chan 976aa4d759 Reland "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build"
This reverts commit a625fd26ce.

Round 3: The scudo test was addressed in
6727832c32.
2021-10-07 14:19:29 -07:00
Keith Smiley 9f9ed7a81a [clang] Fix darwin REQUIRES test annotation (NFC)
Some subprojects like compiler-rt define the `darwin` feature in their
lit config, but clang does not do that, so we need to use the global
`system-darwin` here instead.

Differential Revision: https://reviews.llvm.org/D111267
2021-10-07 12:58:49 -07:00
Artem Belevich 29e00b29f7 [CUDA] Make sure <string.h> is included with original __THROW defined.
Otherwise we may end up with an inconsistent redeclarations of the standard
library functions if _FORTIFY_SOURCE is in effect.

https://bugs.llvm.org/show_bug.cgi?id=47869

Differential Revision: https://reviews.llvm.org/D110781
2021-10-07 11:43:56 -07:00
Luke Drummond 6283d468e2 Workaround build error for mingw-g++
mingw-g++ does not correctly support the full `std::errc` namespace as
worded in the standard[1]. As such, we cannot reliably use all names
therein. This patch changes the use of
`std::errc::state_not_recoverable`, to use portable error codes from the
`llvm::errc` equivalent.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71444

Reviewed by v.g.vassilev
Differential Revision: https://reviews.llvm.org/D111315
2021-10-07 18:34:16 +01:00
Corentin Jabot d456fed1a9 Add information about partially implemented features
Desccribe in cxx_status.html the missing parts of the partially
implemented proposals described in cxx_status.html.

Uses <details> blocks so the information appears collapsed
by default.
2021-10-07 13:07:44 -04:00
Amy Kwan 74b1ac7155 [NFC] Update return type of vec_popcnt to vector unsigned.
This patch updates the vec_popcnt builtins to return vector unsigned,
as defined by the Power Vector Intrinsics Programming Reference.
This patch is NFC and all existing tests pass.

Differential Revision: https://reviews.llvm.org/D110934
2021-10-07 11:33:19 -05:00
Saiyedul Islam 94e2b0258a Revert "[Clang][OpenMP] Add partial support for Static Device Libraries"
This reverts commit 4c41170895.
2021-10-07 14:13:24 +00:00
Saiyedul Islam 3eb44f4d28 Revert "[Clang][OpenMP] Fix windows buildbot failure for D105191"
This reverts commit 06404d5488.
2021-10-07 14:13:24 +00:00
Saiyedul Islam 1097f48e3d Revert "[Clang][OpenMP] Fix fat archive tests for Mac and Windows"
This reverts commit 2baf7ad6d2.
2021-10-07 14:13:24 +00:00
Saiyedul Islam 2baf7ad6d2 [Clang][OpenMP] Fix fat archive tests for Mac and Windows
Fixes missing libomptarget on Mac and Windows in check lines. Issue
was introduced by D105191.

Differential Revision: https://reviews.llvm.org/D111311
2021-10-07 13:38:46 +00:00
Balázs Kéri b7ac68d01e [clang][ASTImporter] Simplify code of attribute import [NFC].
The code of `ASTImporter::Import(const Attr *)` was repetitive,
it is now simplified. (There is still room for improvement but
probably only after big changes.)

Reviewed By: martong, steakhal

Differential Revision: https://reviews.llvm.org/D110810
2021-10-07 13:07:21 +02:00
Saiyedul Islam 06404d5488 [Clang][OpenMP] Fix windows buildbot failure for D105191
Fixes 4c41170895.
2021-10-07 05:54:56 +00:00
Saiyedul Islam 4c41170895 [Clang][OpenMP] Add partial support for Static Device Libraries
An archive containing device code object files can be passed to
clang command line for linking. For each given offload target
it creates a device specific archives which is either passed to llvm-link
if the target is amdgpu, or to clang-nvlink-wrapper if the target is
nvptx. -L/-l flags are used to specify these fat archives on the command
line. E.g.
  clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp -L. -lmylib

It currently doesn't support linking an archive directly, like:
  clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp libmylib.a

Linking with x86 offload also does not work.

Reviewed By: ye-luo

Differential Revision: https://reviews.llvm.org/D105191
2021-10-07 04:45:19 +00:00
hsmahesha 393581d8a5 [CFE][Codegen] Update auto-generated check lines for few GPU lit tests
which is essentially required as a pre-commit for https://reviews.llvm.org/D110257.

Reviewed By: yaxunl

Differential Revision: https://reviews.llvm.org/D110676
2021-10-07 09:05:39 +05:30
Itay Bookstein 40ec1c0f16 [IR][NFC] Rename getBaseObject to getAliaseeObject
To better reflect the meaning of the now-disambiguated {GlobalValue,
GlobalAlias}::getBaseObject after breaking off GlobalIFunc::getResolverFunction
(D109792), the function is renamed to getAliaseeObject.
2021-10-06 19:33:10 -07:00
Artem Belevich 6707a7d7e9 [CUDA] remove unneeded includes from CUDA-related headers.
This should fix bot failures on PPC and windows.
2021-10-06 17:20:21 -07:00
David Blaikie f6a561c4d6 DebugInfo: Use clang's preferred names for integer types
This reverts c7f16ab3e3 / r109694 - which
suggested this was done to improve consistency with the gdb test suite.
Possible that at the time GCC did not canonicalize integer types, and so
matching types was important for cross-compiler validity, or that it was
only a case of over-constrained test cases that printed out/tested the
exact names of integer types.

In any case neither issue seems to exist today based on my limited
testing - both gdb and lldb canonicalize integer types (in a way that
happens to match Clang's preferred naming, incidentally) and so never
print the original text name produced in the DWARF by GCC or Clang.

This canonicalization appears to be in `integer_types_same_name_p` for
GDB and in `TypeSystemClang::GetBasicTypeEnumeration` for lldb.

(I tested this with one translation unit defining 3 variables - `long`,
`long (*)()`, and `int (*)()`, and another translation unit that had
main, and a function that took `long (*)()` as a parameter - then
compiled them with mismatched compilers (either GCC+Clang, or
Clang+(Clang with this patch applied)) and no matter the combination,
despite the debug info for one CU naming the type "long int" and the
other naming it "long", both debuggers printed out the name as "long"
and were able to correctly perform overload resolution and pass the
`long int (*)()` variable to the `long (*)()` function parameter)

Did find one hiccup, identified by the lldb test suite - that CodeView
was relying on these names to map them to builtin types in that format.
So added some handling for that in LLVM. (these could be split out into
separate patches, but seems small enough to not warrant it - will do
that if there ends up needing any reverti/revisiting)

Differential Revision: https://reviews.llvm.org/D110455
2021-10-06 16:02:34 -07:00
Artem Belevich ccfb0555f7 [CUDA] Implement experimental support for texture lookups.
The patch implements header-only support for testure lookups.

The patch has been tested on a source file with all possible combinations of
argument types supported by CUDA headers, compiled and verified that the
generated instructions and their parameters match the code generated by NVCC.
Unfortunately, compiling texture code requires CUDA headers and can't be tested
in clang itself.  The test will need to be added to the test-suite later.

While generated code compiles and seems to match NVCC, I do not have any code
that uses textures that I could test correctness of the implementation. Hence
the experimental status.

Differential Revision: https://reviews.llvm.org/D110089
2021-10-06 15:15:53 -07:00
Richard Smith 141df74456 Add missing diagnostic for use of _reserved name in extern "C"
declaration.

Names starting with an underscore are reserved at the global scope, so
cannot be used as the name of an extern "C" symbol in any scope because
such usages conflict with a name at global scope.
2021-10-06 15:13:06 -07:00
Richard Smith 7063b76b02 PR50644: Do not warn on a declaration of `operator"" _foo`.
Also do not warn on `#define _foo` or `#undef _foo`.

Only global scope names starting with _[a-z] are reserved, not the use
of such an identifier in any other context.
2021-10-06 15:13:05 -07:00
Richard Smith 7ebcb7ce78 PR50641: Properly handle AttributedStmts when checking for a valid
constexpr function body.
2021-10-06 15:13:05 -07:00
Leonard Chan a625fd26ce Revert "Reland "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build""
This reverts commit c52d60ec3b.

The failing scudo test came up again.
2021-10-06 15:09:40 -07:00
Jennifer Yu a4743eba3c Fix assert of "Unable to find base lambda address" from
adjustMemberOfForLambdaCaptures.

The problem is happening when user passes lambda function with reference
type in the map clause.

The natural of the problem when processing generateInfoForCapture,
the BasePointer is generated with new load for a lambda variable with
reference type.  It is not expected in adjustMemberOfForLambdaCaptures.

One way to fix this is to skipping call to generateInfoForCapture for
map(to:lambda).  The map info will be generated later in the call to
generateDefaultMapInfo samiler as firsprivate clase.

This to fix https://bugs.llvm.org/show_bug.cgi?id=52071

Differential Revision:https://reviews.llvm.org/D111115
2021-10-06 14:14:28 -07:00
Leonard Chan c7e72784ae [clang][Fuchsia] Add -static-libgcc to TSAN tests
This will ensure that tsan tests are built with the built libunwind.a
rather than the host libunwind.so.
2021-10-06 14:01:39 -07:00
Leonard Chan c52d60ec3b Reland "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build"
This reverts commit 95f824ad7c.

We should've addressed the remaining issues on our CI builders.
2021-10-06 13:57:24 -07:00
Arthur Eubanks 6522b7cc32 [clang] Add option to clear AST memory before running LLVM passes
This is to save memory for Clang compiles.
Measuring building PassBuilder.cpp under /usr/bin/time, max rss goes from 0.93GB to 0.7GB.

This does not turn it by default yet.

I've turned on the option locally and run it over a good amount of files without any issues.

For more background, see
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068930.html.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D111105
2021-10-06 13:42:22 -07:00
Arthur Eubanks 05392466f0 Reland [IR] Increase max alignment to 4GB
Currently the max alignment representable is 1GB, see D108661.
Setting the align of an object to 4GB is desirable in some cases to make sure the lower 32 bits are clear which can be used for some optimizations, e.g. https://crbug.com/1016945.

This uses an extra bit in instructions that carry an alignment. We can store 15 bits of "free" information, and with this change some instructions (e.g. AtomicCmpXchgInst) use 14 bits.
We can increase the max alignment representable above 4GB (up to 2^62) since we're only using 33 of the 64 values, but I've just limited it to 4GB for now.

The one place we have to update the bitcode format is for the alloca instruction. It stores its alignment into 5 bits of a 32 bit bitfield. I've added another field which is 8 bits and should be future proof for a while. For backward compatibility, we check if the old field has a value and use that, otherwise use the new field.

Updating clang's max allowed alignment will come in a future patch.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D110451
2021-10-06 13:29:23 -07:00
Arthur Eubanks 569346f274 Revert "Reland [IR] Increase max alignment to 4GB"
This reverts commit 8d64314ffe.
2021-10-06 11:38:11 -07:00
Arthur Eubanks 8d64314ffe Reland [IR] Increase max alignment to 4GB
Currently the max alignment representable is 1GB, see D108661.
Setting the align of an object to 4GB is desirable in some cases to make sure the lower 32 bits are clear which can be used for some optimizations, e.g. https://crbug.com/1016945.

This uses an extra bit in instructions that carry an alignment. We can store 15 bits of "free" information, and with this change some instructions (e.g. AtomicCmpXchgInst) use 14 bits.
We can increase the max alignment representable above 4GB (up to 2^62) since we're only using 33 of the 64 values, but I've just limited it to 4GB for now.

The one place we have to update the bitcode format is for the alloca instruction. It stores its alignment into 5 bits of a 32 bit bitfield. I've added another field which is 8 bits and should be future proof for a while. For backward compatibility, we check if the old field has a value and use that, otherwise use the new field.

Updating clang's max allowed alignment will come in a future patch.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D110451
2021-10-06 11:03:51 -07:00
Fangrui Song a2796f1e86 [Driver][test] Add Debian multiarch lib/clang/14.0.0/x86_64-linux-gnu and include/x86_64-linux-gnu/c++/v1 tests 2021-10-06 10:49:25 -07:00
Arthur Eubanks 72cf8b6044 Revert "[IR] Increase max alignment to 4GB"
This reverts commit df84c1fe78.

Breaks some bots
2021-10-06 10:21:35 -07:00
Michael Kruse 2130117f92 [Clang][OpenMP] Allow loop-transformations with template parameters.
Clang would reject

    #pragma omp for
    #pragma omp tile sizes(P)
    for (int i = 0; i < 128; ++i) {}

where P is a template parameter, but the loop itself is not
template-dependent. Because P context-dependent, the TransformedStmt
cannot be generated and therefore is nullptr (until the template is
instantiated by TreeTransform). The OMPForDirective would still expect
the a loop is the dependent context and trigger an error.

Fix by introducing a NumGeneratedLoops field to OMPLoopTransformation.
This is used to distinguish the case where no TransformedStmt will be
generated at all (e.g. #pragma omp unroll full) and template
instantiation is needed. In the latter case, delay resolving the
iteration space like when the for-loop itself is template-dependent
until the template instatiation.

A more radical solution would always delay the iteration space analysis
until template instantiation, but would also break many test cases.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D111124
2021-10-06 12:21:04 -05:00
Frederic Cambus f0ffff43b7 [CMake] Fix typo in error message for LLD in bootstrap builds.
Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D110836
2021-10-06 22:38:12 +05:30
Arthur Eubanks df84c1fe78 [IR] Increase max alignment to 4GB
Currently the max alignment representable is 1GB, see D108661.
Setting the align of an object to 4GB is desirable in some cases to make sure the lower 32 bits are clear which can be used for some optimizations, e.g. https://crbug.com/1016945.

This uses an extra bit in instructions that carry an alignment. We can store 15 bits of "free" information, and with this change some instructions (e.g. AtomicCmpXchgInst) use 14 bits.
We can increase the max alignment representable above 4GB (up to 2^62) since we're only using 33 of the 64 values, but I've just limited it to 4GB for now.

The one place we have to update the bitcode format is for the alloca instruction. It stores its alignment into 5 bits of a 32 bit bitfield. I've added another field which is 8 bits and should be future proof for a while. For backward compatibility, we check if the old field has a value and use that, otherwise use the new field.

Updating clang's max allowed alignment will come in a future patch.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D110451
2021-10-06 09:54:14 -07:00
Arthur Eubanks afdac5fbcb [clang] Allow printing 64 bit ints in diagnostics
Currently we're limited to 32 bit ints in diagnostics.
With support for 4GB alignments coming soon, we need to report 4GB as the max alignment allowed.
I've tested that this does indeed properly print 2^32.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D111184
2021-10-06 09:53:47 -07:00
Gabor Marton b8f6c85a83 [analyzer][NFC] Add RangeSet::dump
This tiny change improves the debugging experience of the solver a lot!

Differential Revision: https://reviews.llvm.org/D110911
2021-10-06 18:45:07 +02:00
Gabor Marton 792be5df92 [analyzer][solver] Fix CmpOpTable handling bug
There is an error in the implementation of the logic of reaching the `Unknonw` tristate in CmpOpTable.

```
void cmp_op_table_unknownX2(int x, int y, int z) {
  if (x >= y) {
                    // x >= y    [1, 1]
    if (x + z < y)
      return;
                    // x + z < y [0, 0]
    if (z != 0)
      return;
                    // x < y     [0, 0]
    clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
  }
}
```
We miss the `FALSE` warning because the false branch is infeasible.

We have to exploit simplification to discover the bug. If we had `x < y`
as the second condition then the analyzer would return the parent state
on the false path and the new constraint would not be part of the State.
But adding `z` to the condition makes both paths feasible.

The root cause of the bug is that we reach the `Unknown` tristate
twice, but in both occasions we reach the same `Op` that is `>=` in the
test case. So, we reached `>=` twice, but we never reached `!=`, thus
querying the `Unknonw2x` column with `getCmpOpStateForUnknownX2` is
wrong.

The solution is to ensure that we reached both **different** `Op`s once.

Differential Revision: https://reviews.llvm.org/D110910
2021-10-06 18:28:03 +02:00
Michael Kruse f37e8b0b83 [Clang][OpenMP] Infix OMPLoopTransformationDirective abstract class. NFC.
Insert OMPLoopTransformationDirective between OMPLoopBasedDirective and the loop transformations OMPTileDirective and OMPUnrollDirective. This simplifies handling of loop transformations not requiring distinguishing between OMPTileDirective and OMPUnrollDirective anymore.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D111119
2021-10-06 10:49:07 -05:00
Nico Weber f9457f1f88 [clang] Don't mark _ReadBarrier, _ReadWriteBarrier, _WriteBarrier deprecated
It's true that docs.microsoft.com says:

"""The _ReadBarrier, _WriteBarrier, and _ReadWriteBarrier compiler
intrinsics and the MemoryBarrier macro are all deprecated and should not
be used. For inter-thread communication, use mechanisms such as
atomic_thread_fence and std::atomic<T>, which are defined in the C++
Standard Library. For hardware access, use the /volatile:iso compiler
option together with the volatile keyword."""

And these attributes have been here since these builtins were added in
r192860.

However:

- cl.exe does not warn on them even with /Wall
- none of the replacements are useful for C code
- we don't add __attribute__((__deprecated__())) to any other
  declarations in intrin.h
- intrin0.h in the MSVC headers declares _ReadWriteBarrier() (but
  without the deprecation attribute), so you get inconsistent
  deprecation warnings depending on if you include intrin.h or intrin0.h

The motivation is that compiling sqlite.h with clang-cl produces a
deprecation warning with clang-cl for _ReadWriteBarrier(), but not with
cl.exe.

Differential Revision: https://reviews.llvm.org/D111232
2021-10-06 10:50:02 -04:00
Amy Kwan 49dbde9c9e [AIX] Define WCHAR_T_TYPE as unsigned short on AIX for wchar.c test case.
The default wchar type is different on AIX vs. Linux. When this test is run on
AIX, WCHAR_T_TYPE ends up being set to int. This is incorrect as the default
wchar type on AIX is actually unsigned short, and setting the type incorrectly
causes the expected errors to not be found.

This patch sets the type correctly (to unsigned short) for AIX.

Differential Revision: https://reviews.llvm.org/D110428
2021-10-06 08:49:37 -05:00
Simon Pilgrim b9b90bb542 [clang] Replace report_fatal_error(std::string) uses with report_fatal_error(Twine)
As described on D111049, we're trying to remove the <string> dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared.
2021-10-06 11:43:19 +01:00
Vince Bridgers b29186c08a [analyzer] canonicalize special case of structure/pointer deref
This simple change addresses a special case of structure/pointer
aliasing that produced different symbolvals, leading to false positives
during analysis.

The reproducer is as simple as this.

```lang=C++
struct s {
  int v;
};

void foo(struct s *ps) {
  struct s ss = *ps;
  clang_analyzer_dump(ss.v); // reg_$1<int Element{SymRegion{reg_$0<struct s *ps>},0 S64b,struct s}.v>
  clang_analyzer_dump(ps->v); //reg_$3<int SymRegion{reg_$0<struct s *ps>}.v>
  clang_analyzer_eval(ss.v == ps->v); // UNKNOWN
}
```

Acks: Many thanks to @steakhal and @martong for the group debug session.

Reviewed By: steakhal, martong

Differential Revision: https://reviews.llvm.org/D110625
2021-10-06 05:18:27 -05:00
Albion Fung 13d3cd37e2 [PowerPC] Implement vector float and vector double version for vec_orc builtin
The builtin for vec_orc has support for the following two signatures,
but currently the compiler marks it ambiguous:
vector float vec_orc(vector float, vector float)
vector double vec_orc(vector double, vector double)

This patch implements these two builtins.

Differential revision: https://reviews.llvm.org/D110858
2021-10-06 02:47:42 -05:00
Arthur Eubanks cb89d3739d Revert "[clang] Allow printing 64 bit ints in diagnostics"
This reverts commit edfff2f8b0.

Breaks clang-tidy.
2021-10-05 22:24:16 -07:00
Arthur Eubanks edfff2f8b0 [clang] Allow printing 64 bit ints in diagnostics
Currently we're limited to 32 bit ints in diagnostics.
With support for 4GB alignments coming soon, we need to report 4GB as the max alignment allowed.
I've tested that this does indeed properly print 2^32.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D111184
2021-10-05 22:07:16 -07:00
Mircea Trofin 7d541eb4d4 [inliner] Mandatory inlining decisions produce remarks
This also removes the need to disable the mandatory inlining phase in
tests.

In a departure from the previous remark, we don't output a 'cost' in
this case, because there's no such thing. We just report that inlining
happened because of the attribute.

Differential Revision: https://reviews.llvm.org/D110891
2021-10-05 14:01:25 -07:00
Aaron Ballman 939712734a Fix some Sphinx warnings in the static analyzer docs
A heading wasn't underlined properly, and two links share the same text
and so they should use an anonymous hyperlink instead of a named one.
2021-10-05 16:43:55 -04:00
Aaron Ballman 1ddcb804f7 Update the release notes for consteval if support; NFC
This support was landed in 424733c12a.
2021-10-05 16:39:23 -04:00
Amy Huang c7104e5066 [Sema] Allow comparisons between different ms ptr size address space types.
We're currently using address spaces to implement __ptr32/__ptr64 attributes;
this patch fixes a bug where clang doesn't allow types with different pointer
size attributes to be compared.

Fixes https://bugs.llvm.org/show_bug.cgi?id=51889

Differential Revision: https://reviews.llvm.org/D110670
2021-10-05 10:56:29 -07:00
Simon Pilgrim 9503ad3b53 [clang] FatalErrorHandler.cpp - add explicit <stdio.h> include
Required for fprintf/stderr usage in the error handler, noticed while trying to remove the <string> dependency described in D111049
2021-10-05 17:03:17 +01:00
Hsiangkai Wang 80a6456306 [RISCV] Update to vlm.v and vsm.v according to v1.0-rc1.
vle1.v  -> vlm.v
vse1.v  -> vsm.v

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D106044
2021-10-05 21:49:54 +08:00
Vassil Vassilev f4f9ad0f5d Reland "[clang-repl] Allow loading of plugins in clang-repl."
Differential revision: https://reviews.llvm.org/D110484
2021-10-05 13:04:01 +00:00
Kamau Bridgeman 8737c74fab [PowerPC][MMA] Allow MMA builtin types in pre-P10 compilation units
This patch allows the use of __vector_quad and __vector_pair, PPC MMA builtin
types, on all PowerPC 64-bit compilation units. When these types are
made available the builtins that use them automatically become available
so semantic checking for mma and pair vector memop __builtins is also
expanded to ensure these builtin function call are only allowed on
Power10 and new architectures. All related test cases are updated to
ensure test coverage.

Reviewed By: #powerpc, nemanjai

Differential Revision: https://reviews.llvm.org/D109599
2021-10-05 07:59:32 -05:00
Aaron Ballman aa4f4d18e8 consteval if is now fully supported
This amends 424733c12a which accidentally
dropped the change to the status page.
2021-10-05 08:21:29 -04:00
Corentin Jabot 424733c12a Implement if consteval (P1938)
Modify the IfStmt node to suppoort constant evaluated expressions.

Add a new ExpressionEvaluationContext::ImmediateFunctionContext to
keep track of immediate function contexts.

This proved easier/better/probably more efficient than walking the AST
backward as it allows diagnosing nested if consteval statements.
2021-10-05 08:04:14 -04:00
Balázs Kéri bcefea80a4 [clang][ASTImporter] Add import of thread safety attributes.
Attributes of "C/C++ Thread safety attributes" section in Attr.td
are added to ASTImporter. The not added attributes from this section
do not need special import handling.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D110528
2021-10-05 13:08:31 +02:00
Simon Pilgrim e463b69736 [Support] Change fatal_error_handler_t to take a const char* instead of std::string
https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html

Excessive use of the <string> header has a massive impact on compile time; its most commonly included via the ErrorHandling.h header, which has to be included in many key headers, impacting many source files that have no need for std::string.

As an initial step toward removing the <string> include from ErrorHandling.h, this patch proposes to update the fatal_error_handler_t handler to just take a raw const char* instead.

The next step will be to remove the report_fatal_error std::string variant, which will involve a lot of cleanup and better use of Twine/StringRef.

Differential Revision: https://reviews.llvm.org/D111049
2021-10-05 10:55:40 +01:00
Vassil Vassilev 3e9d04f7e4 Revert "[clang-repl] Allow loading of plugins in clang-repl."
This reverts commit 81fb640f83 due to bot failures:
https://lab.llvm.org/buildbot#builders/57/builds/10807
2021-10-05 06:10:38 +00:00
Vassil Vassilev 81fb640f83 [clang-repl] Allow loading of plugins in clang-repl.
Differential revision: https://reviews.llvm.org/D110484
2021-10-05 05:20:30 +00:00
Leonard Chan 95f824ad7c Revert "[clang][Fuchsia] Re-enable compiler-rt tests in runtimes build"
This reverts commit 8480063f25.

We're seeing some test failures on our builders.
2021-10-04 16:11:43 -07:00
Arthur Eubanks 2568286892 [clang] Don't use the AST to display backend diagnostics
We keep a map from function name to source location so we don't have to
do it via looking up a source location from the AST. However, since
function names can be long, we actually use a hash of the function name
as the key.

Additionally, we can't rely on Clang's printing of function names via
the AST, so we just demangle the name instead.

This is necessary to implement
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068930.html.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D110665
2021-10-04 14:14:32 -07:00
Leonard Chan 8480063f25 [clang][Fuchsia] Re-enable compiler-rt tests in runtimes build
Differential Revision: https://reviews.llvm.org/D110778
2021-10-04 14:11:49 -07:00
serge-sans-paille 0f0e31cf51 Update inline builtin handling to honor gnu inline attribute
Per the GCC info page:

    If the function is declared 'extern', then this definition of the
    function is used only for inlining.  In no case is the function
    compiled as a standalone function, not even if you take its address
    explicitly.  Such an address becomes an external reference, as if
    you had only declared the function, and had not defined it.

Respect that behavior for inline builtins: keep the original definition, and
generate a copy of the declaration suffixed by '.inline' that's only referenced
in direct call.

This fixes holes in c3717b6858.

Differential Revision: https://reviews.llvm.org/D111009
2021-10-04 22:26:25 +02:00
Kamau Bridgeman 8328966520 [PowerPC] Fix to guard fetch and cas 64-bit builtin versions
The builtins: `__compare_and_swaplp`, `__fetch_and_addlp`,
` __fetch_and_andlp`, `__fetch_and_orlp`, `__fetch_and_swaplp` are
64 bit only. This patch ensures the compiler produces an error in 32 bit mode.

Reviewed By: #powerpc, nemanjai

Differential Revision: https://reviews.llvm.org/D110824
2021-10-04 14:45:36 -05:00
James King 56e72a40c1 Update `DynTypedNode` to support the conversion of `TypeLoc`s.
This provides better support for `TypeLoc`s to allow `TypeLoc`-related
matchers to feature stricter typing and to avoid relying on the dynamic
casting of `TypeLoc`s in matchers.

Reviewed By: ymandel, tdl-g, sbenza

Differential Revision: https://reviews.llvm.org/D110586
2021-10-04 19:25:24 +00:00
Lei Huang 8b3d944a97 [PowerPC] Disable vector types when not supported by subtarget features
Update clang to treat vector unsigned long long and friends as invalid
for AltiVec without VSX.

Reported in: https://bugs.llvm.org/show_bug.cgi?id=47782

Reviewed By: nemanjai, amyk

Differential Revision: https://reviews.llvm.org/D109178
2021-10-04 14:16:47 -05:00
Corentin Jabot 922863e75f Add core papers added in the October 2021 WG21 plenary 2021-10-04 14:42:13 -04:00
Zurab Tsinadze 811b1736d9 [analyzer] Add InvalidPtrChecker
This patch introduces a new checker: `alpha.security.cert.env.InvalidPtr`

Checker finds usage of invalidated pointers related to environment.

Based on the following SEI CERT Rules:
ENV34-C: https://wiki.sei.cmu.edu/confluence/x/8tYxBQ
ENV31-C: https://wiki.sei.cmu.edu/confluence/x/5NUxBQ

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D97699
2021-10-04 17:08:34 +02:00
Alexey Bataev bfc8f9e9b0 [clang] Fix computation of number of dependencies using OpenMP iterator,
by Raul Penacoba.

The size of kmp_depend_info and the number of dependencies are computed multiplying the iterator sizes, which not right.
Now size is computed as:

itersize1*numclausedeps1 + itersize2*numclausedeps2 + ... + itersizeN*numclausedepsN

where itersizeX is the size of the iterator and numclausedepsX the number of dependencies in that depend clause.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D111045
2021-10-04 07:06:51 -07:00
Stefan Pintilie 4fc2f4979c [PowerPC] Fix __builtin_ppc_load2r to return short instead of int.
This patch fixes the return value of the builtin __builtin_ppc_load2r to
correctly return short instead of int.

Reviewed By: nemanjai, #powerpc

Differential Revision: https://reviews.llvm.org/D110771
2021-10-04 06:17:02 -05:00
Jay Foad 566690b067 [APFloat] Remove BitWidth argument from getAllOnesValue
There's no need to pass this in explicitly because it is
trivially available from the semantics.
2021-10-04 11:32:16 +01:00
Jay Foad d933adeaca [APInt] Stop using soft-deprecated constructors and methods in clang. NFC.
Stop using APInt constructors and methods that were soft-deprecated in
D109483. This fixes all the uses I found in clang.

Differential Revision: https://reviews.llvm.org/D110808
2021-10-04 09:38:11 +01:00
Yuanfang Chen a944f801ca [Clang][NFC] Fix the comment for Sema::DiagIfReachable 2021-10-03 13:03:24 -07:00
Dávid Bolvanský fb84aa2a8f Fixed warnings in target/parser codes produced by -Wbitwise-instead-of-logicala 2021-10-03 15:04:01 +02:00
Dávid Bolvanský a76355d570 Unbreak hexagon-check-builtins.c due to rGb1fcca388441 2021-10-03 13:19:34 +02:00
mydeveloperday 5aca8bb963 [clang-format] allow clang-format to be passed a file of filenames so we can add a regression suite of "clean clang-formatted files" from LLVM
This change now generates that list, and the change to clang-format allows
us to run clang-format quickly over these files via the list of files.

clang-format.exe -verbose -n --files=./clang/docs/tools/clang-formatted-files.txt

```
Clang-formating 7926 files
Formatting [1/7925] clang/bindings/python/tests/cindex/INPUTS/header1.h
..
Formatting [7925/7925] utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
```

This is needed because putting all those files on the command line is too
long, and invoking 7900+ clang-formats is much slower (too slow to be honest)

Using this method it takes on 7.5 minutes (on my machine) to run
`clang-format -n` over all of the files (7925), this should result in us
testing any change quickly and easily.

We should be able to use rerunning this list to ensure that we don't regress
clang-format over a large code base, but also use it to ensure none of the
previous files which were 100% clang-formatted remain so.
(which the LLVM premerge checks should be enforcing)

Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D111000
2021-10-03 12:10:33 +01:00
Dávid Bolvanský f59cc9542b Reland "[Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects"
This reverts commit a4933f57f3. New warnings were fixed.
2021-10-03 13:05:09 +02:00
Dávid Bolvanský b1fcca3884 Fixed warnings in LLVM produced by -Wbitwise-instead-of-logical 2021-10-03 13:04:18 +02:00
Dávid Bolvanský a4933f57f3 Revert "[Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects"
This reverts commit f62d18ff14. Found some cases in LLVM itself.
2021-10-03 12:47:12 +02:00
Dávid Bolvanský f62d18ff14 [Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects
Motivation: https://arstechnica.com/gadgets/2021/07/google-pushed-a-one-character-typo-to-production-bricking-chrome-os-devices/

Warn for pattern boolA & boolB or boolA | boolB where boolA and boolB has possible side effects.

Casting one operand to int is enough to silence this warning: for example (int)boolA & boolB or boolA| (int)boolB

Fixes https://bugs.llvm.org/show_bug.cgi?id=51216

Differential Revision: https://reviews.llvm.org/D108003
2021-10-03 11:06:40 +02:00
Hsiangkai Wang c274384cff [NFC][RISCV] Update test cases through update_cc_test_checks.py. 2021-10-03 15:44:06 +08:00
mydeveloperday ac21e3922b [clang-format] NFC 1% improvement in the overall clang-formatted status 2021-10-02 18:05:45 +01:00
Josh Learn 3d209c76dd [clang-format] Constructor initializer lists format with pp directives
Currently constructor initializer lists sometimes format incorrectly
when there is a preprocessor directive in the middle of the list.
This patch fixes the issue when parsing the initilizer list by
ignoring the preprocessor directive when checking if a block is
part of an initializer list.

rdar://82554274

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D109951
2021-10-02 13:23:43 +01:00
mydeveloperday dd3caa99bd [clang-format] [docs] [NFC] improve clarity in the QualifierAlignment warning
Improve the clarity and guidance of the warning when using code modifying option in clang-format see {D69764}

Reviewed By: HazardyKnusperkeks, curdeius

Differential Revision: https://reviews.llvm.org/D110801
2021-10-02 13:18:42 +01:00
Jinsong Ji 9c31969e8d [AIX] Don't pass namedsects in LTO mode
LTO don't need binder option , don't pass it in LTO mode.

Reviewed By: Whitney

Differential Revision: https://reviews.llvm.org/D110955
2021-10-01 19:22:40 +00:00
Manas a3d0b5805e [analyzer] Fix deprecated plistlib functions
It replaces the usage of readPlist,writePlist functions with load,dump
in plistlib package.

This fixes deprecation issues when analyzer reports are being generated
outside of docker.

Patch by Manas!

Reviewed By: steakhal

Differential Revision: https://reviews.llvm.org/D107312
2021-10-01 17:07:24 +02:00
Nico Weber ec4a822866 [clang] Try to unbreak crash-report.cpp on PS4 bot after 8dfbe9b0a
Looks like exceptions are off-by-default with the PS4 triple.
Since adding -fexceptions defeats the purpose of the test change
in 8dfbe9b0a, pass an explicit triple instead.
2021-10-01 09:33:13 -04:00
Nemanja Ivanovic 369d785574 [PowerPC] Optimal sequence for doubleword vec_all_{eq|ne} on Power7
These builtins produce inefficient code for CPU's prior to Power8
due to vcmpequd being unavailable. The predicate forms can actually
leverage the available vcmpequw along with xxlxor to produce a better
sequence.
2021-10-01 08:27:15 -05:00
Balázs Kéri cad9ff531c [clang][ASTImporter] Import ConstructorUsingShadowDecl correctly.
Fix import of ConstructorUsingShadowDecl and add tests.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D110398
2021-10-01 11:41:08 +02:00
Gabor Marton a3a0b06626 [clang][ASTImporter] Import InheritedConstructor and ConstructorUsingShadowDecl.
Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D110395
2021-10-01 10:16:11 +02:00
Albion Fung 29bb877499 [PowerPC] Fix lharx and lbarx builtin signatures
The signatures for the PowerPC builtins lharx and
lbarx are incorrect, and causes issues when used in a function
that requires the return of the builtin to be promoted.
This patch fixes these signatures.

Differential revision: https://reviews.llvm.org/D110273
2021-09-30 22:36:13 -05:00
Craig Topper a21c557955 [RISCV] Remove Zbproposedc extension
This consists of 3 compressed instructions, c.not, c.neg, and c.zext.w.
I believe these have been picked up by the Zce effort using different
encodings. I don't think it makes sense to keep them in bitmanip. It
will eventually cause a conflict if/when Zce is implemented in llvm.

Differential Revision: https://reviews.llvm.org/D110871
2021-09-30 14:23:05 -07:00
Jinsong Ji 2443320d68 [AIX] Rename binder option for PGO support
Update the binder option.
2021-09-30 19:58:42 +00:00
Nico Weber e31899c708 Reland "[clang-cl] Accept `#pragma warning(disable : N)` for some N"
This reverts commit 0cd9d8a48b and
adds the changes described in https://reviews.llvm.org/D110668#3034461.
2021-09-30 15:03:23 -04:00
Arthur Eubanks 76902079e4 [clang] Don't modify OptRemark if the argument is not relevant
A followup to D110201.

 For example, we'd set OptimizationRemarkMissed's Regex to '.*' when
encountering -Rpass. Normally this doesn't actually affect remarks we
emit because in clang::ProcessWarningOptions() we'll separately look at
all -R arguments and turn on/off corresponding diagnostic groups.
However, this is reproducible with -round-trip-args.

Reviewed By: JamesNagurne

Differential Revision: https://reviews.llvm.org/D110673
2021-09-30 11:36:30 -07:00
Nico Weber 8dfbe9b0ae [clang] Make crash reproducer work with clang-cl
When clang crashes, it writes a standalone source file and shell script
to reproduce the crash.

The Driver used to set `Mode = CPPMode` in generateCompilationDiagnostics()
to force preprocessing mode. This has the side effect of making
IsCLMode() return false, which in turn meant Clang::AddClangCLArgs()
didn't get called when creating the standalone source file, which meant
the stand-alone file was preprocessed with the gcc driver's defaults
In particular, exceptions default to on with the gcc driver, but to
off with the cl driver. The .sh script did use the original command
line, so in the reproducer for a clang-cl crash, the standalone source
file could contain exception-using code after preprocessing that the
compiler invocation in the shell script would then complain about.

This patch removes the `Mode = CPPMode;` line and instead additionally
checks for `CCGenDiagnostics` in most places that check `CCCIsCPP().
This also matches the strategy Clang::ConstructJob() uses to add
-frewrite-includes for creating the standalone source file for a crash
report.

Fixes PR52007.

Differential Revision: https://reviews.llvm.org/D110783
2021-09-30 14:33:14 -04:00
Zequan Wu dbaa408336 [clang] do not emit note for bad conversion when destination type qualifiers are not compatibly include source type qualifiers
llvm.org/PR52014

Differential Revision: https://reviews.llvm.org/D110780
2021-09-30 11:24:18 -07:00
Nico Weber fa32fd3bf7 [clang] Remove duplication in types::getCompilationPhases()
Call Driver::getFinalPhase() instead of duplicating it.

https://reviews.llvm.org/D65993 added the duplication, then
02e35832c3 maded it more obviously a copy of getFinalPhase().

The only difference is that getCompilationPhases() used to use
LastPhase / IfsMerge where getFinalPhase() used Link. Adapt
getFinalPhase() to return IfsMerge when needed.

No intentional behavior change.

Differential Revision: https://reviews.llvm.org/D110770
2021-09-30 14:17:14 -04:00
Nemanja Ivanovic fad14a17a4 [PowerPC] Truncate element index for vec_insert in altivec.h
When a user specifies an out-of-range index for vec_insert, we
just produce IR that has undefined behaviour even though the
documentation states that modulo arithmetic is used. This patch
just truncates the value to a valid index.
2021-09-30 05:58:22 -05:00
Balazs Benics e5e0e00831 [NFC] Cleanup the overload of ASTImporter::import()
This patch aims to address the comment of a previous review:
https://reviews.llvm.org/D109237#inline-1040678

The original problem was the following:
  `T` is substituted by `clang::Type`

  Expected<T *> import(T *From) {
    auto ToOrErr = Importer.Import(From);
    //             ^^^^^^^^^^^^^^^^^^^^^
    if (!ToOrErr)
      return ToOrErr.takeError();
    return cast_or_null<T>(*ToOrErr);
    //     ^^^^^^^^^^^^^^^^^^^^^^^^^
  }

`Importer.Import()` operates on `const Type *`, thus returns `const Type *`.
Later, at the return statement, we will try to construct an `Expected<Type*>`
from a `const Type *`, which failed with a miserable error message.

In all other cases `importer.Import()` results in a non-const version,
so everything works out just fine, but for `clang::type`s, we should
really return a const version.

So, in case of `T` is a subclass of `clang::Type`, it will return a
`Exprected<const T*>` instead.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D109269
2021-09-30 11:53:08 +02:00
Marek Kurdej 2c60cfc05f [format] [docs] Fix typos and clarify QualifierAlignment/QualifierOrder documentation. 2021-09-30 09:42:34 +02:00