Commit Graph

69760 Commits

Author SHA1 Message Date
Ilya Biryukov
5ea158077e Revert "Reland [Modules] Remove unnecessary check when generating name lookup table in ASTWriter"
This reverts commit 67b298f6d8.

We got linker errors with undefined symbols during a compiler release
and tracked it down to this change. I am in the process of understanding
what is happening and getting a reproducer.

Sorry for reverting this again.

I will reopen #61065 until we fix this.
2023-04-21 14:08:18 +02:00
Manuel Klimek
9e9e096ae9 [clang-format] Fix dropped 'else'.
'else' was dropped accidentally in 398cddf6ac.

Patch by Jared Grubb.

Differential revision: https://reviews.llvm.org/D146310
2023-04-21 11:59:45 +00:00
Jorge Pinto Sousa
7c00219235 [clang] trigger -Wcast-qual on functional casts
-Wcast-qual does not trigger on the following code in Clang, but does
in GCC.

const auto i = 42;
using T = int*;
auto p = T(&i);

The expected behavior is that a functional cast should trigger
the warning the same as the equivalent C cast because
the meaning is the same, and nothing about the functional cast
makes it easier to recognize that a const_cast is occurring.

Fixes https://github.com/llvm/llvm-project/issues/62083
Differential Revision: https://reviews.llvm.org/D148276
2023-04-21 07:45:05 -04:00
Dominik Adamski
f900567678 [OpenMP][AMDGPU] Refactor setting uniform work group size attribute
Work group size attribute was set in Clang specific class. That's why
we cannot reuse this code in Flang.

If we move setting of this attribute to OpenMPIRBuilder, then we can reuse this
code in Flang and Clang. Function createOffloadEntry from OpenMPIRBuilder is
already used by Clang (via OpenMPIRBuilder::createOffloadEntriesAndInfoMetadata
function).

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

Reviewed By: jdoerfert
2023-04-21 01:35:39 -05:00
Sam McCall
0304aa25e0 [dataflow] allow specifying path to dot with $GRAPHVIZ_DOT
I'd like to use this in a CI system where it's easier to tell the
program about paths than manipulate $PATH.
2023-04-21 05:29:11 +02:00
Sam McCall
28114722ba [dataflow] Try to fix missing order dependency in HTMLLogger 2023-04-20 21:37:53 +02:00
Doru Bercea
01910787d3 Fix failure with team-wide allocated variable
Review: https://reviews.llvm.org/D147572
2023-04-20 14:40:35 -04:00
Ben Langmuir
e06a91c599 [clang][modules] Avoid re-exporting PCH imports on every later module import
We only want to make PCH imports visible once for the the TU, not
repeatedly after every subsequent import. This causes some incorrect
behaviour with submodule visibility, and causes us to get extra module
dependencies in the scanner. So far I have only seen obviously incorrect
behaviour when building with -fmodule-name to cause a submodule to be
textually included when using the PCH, though the old behaviour seems
wrong regardless.

rdar://107449644

Differential Revision: https://reviews.llvm.org/D148176
2023-04-20 11:29:23 -07:00
Fangrui Song
5cf37d8bd5 [Sema] -Wformat: recognize %lb for the printf/scanf family of functions
Fix https://github.com/llvm/llvm-project/issues/62247

D131057 added `bArg` and `BArg` in the `AsLongLong` label in
`FormatSpecifier::hasValidLengthModifier`, but missed the `AsLong` label,
therefore `%llb` is allowed while `%lb` (e.g. `printf("%lb", (long)10)`) has a
spurious warning. Add the missing case labels.

Reviewed By: aaron.ballman, enh

Differential Revision: https://reviews.llvm.org/D148779
2023-04-20 09:34:34 -07:00
Saleem Abdulrasool
3b0677964c Headers: use C++ inline semantics in C++ mode
When building with the 17.5.0 preview toolset for MSVC and building with
modules, the definition of _addcarry_u64 and _subborrow_u64 seem to
cause issues due to the use of GNU inline semantics. Change the headers
to prefer C++ inline semantics for C++ compilation, falling back to GNU
inlining semantics for C compilation.

This is motivated by https://github.com/microsoft/STL/issues/2520.

Differential Revision: https://reviews.llvm.org/D139749
Reviewed By: fsb4000
2023-04-20 09:02:52 -07:00
Zarko Todorovski
8a39465d00 [Clang][AIX] Remove error for -fprofile-instr-generate/use on AIX
Instrumented profiling now works on AIX and there is no dependency
on LTO for PGO. Remove the error.

Reviewed By: qiongsiwu1

Differential Revision: https://reviews.llvm.org/D148177
2023-04-20 11:08:12 -04:00
Aaron Ballman
63a82dd4eb [C11] Allow casting to an _Atomic-qualified type
We were failing to strip off atomic qualification when forming the cast
destination type, but properly stripping off cvr qualification. Now we
accept atomic, qualified, or unqualified destination types.

Note: the semantics of the cast still drop the qualifier, so such a
cast does not result in an atomic rvalue.

Fixes https://github.com/llvm/llvm-project/issues/39596
2023-04-20 10:24:22 -04:00
Aaron Ballman
2e275e2435 [C11] Allow initialization of an atomic-qualified pointer from a null pointer constant
The relevant language rule from C11 is 6.5.16.1p1: "the left operand is
an atomic, qualified, or unqualified pointer, and the right is a null
pointer constant; or". We correctly handled qualified or unqualified
pointer types, but failed to handle atomic-qualified pointer types. Now
we look through the atomic qualification before testing the constraint
requirements.

Fixes https://github.com/llvm/llvm-project/issues/49563
Differential Revision: https://reviews.llvm.org/D148730
2023-04-20 08:02:40 -04:00
Owen Pan
51f6a16646 [clang-format] Hanlde leading whitespaces for JSON files
Fixes #62228.
Fixes #62229.

Differential Revision: https://reviews.llvm.org/D148777
2023-04-20 04:31:55 -07:00
Timm Bäder
80fda7a346 [clang][Sema][NFC] Make a bunch of things const if possible
And some general code style cleanup.

Differential Revision: https://reviews.llvm.org/D148696
2023-04-20 12:23:51 +02:00
Timm Bäder
9bbe25eca5 [clang][Lex][NFC] Use a range for loop in StringLiteralParser 2023-04-20 11:51:05 +02:00
Timm Bäder
30aea03202 [clang][Sema][NFC] Use existing TargetInfo local variable 2023-04-20 11:25:46 +02:00
Petr Hosek
038536acaf [Driver] Support response file on baremetal driver
All officially supported linkers should support response files and
this avoids issues when compiling on platforms such as Windows.

Differential Revision: https://reviews.llvm.org/D148760
2023-04-20 02:45:26 +00:00
Petr Hosek
9ba3a22803 [Driver] Support response file in Fuchsia driver
All officially supported linkers should support response files and
this avoids issues when compiling on platforms such as Windows.

Differential Revision: https://reviews.llvm.org/D148763
2023-04-20 02:44:40 +00:00
MalavikaSamak
9516419c50 Revert "Revert "[-Wunsafe-buffer-usage] Handle unevaluated contexts that contain unsafe buffer usages""
This reverts commit 7bf5f4692a and adding -frtti flag to support PS4/PS5 builds.
2023-04-19 16:53:34 -07:00
NAKAMURA Takumi
a2d1611b7b [CMake] Reduce deps 2023-04-20 08:45:38 +09:00
MalavikaSamak
7bf5f4692a Revert "[-Wunsafe-buffer-usage] Handle unevaluated contexts that contain unsafe buffer usages"
This reverts commit 777eb4bcfc.
2023-04-19 16:09:21 -07:00
MalavikaSamak
777eb4bcfc [-Wunsafe-buffer-usage] Handle unevaluated contexts that contain unsafe buffer usages
This patch handles unevaluated contexts to ensure no warnings are produced by the machinery
for buffer access made within an unevaluated contexts. However, such accesses must be
considered by a FixableGadget and produce the necessary fixits.

Reviewed by: NoQ, ziqingluo-90, jkorous

Differential revision: https://reviews.llvm.org/D144905
2023-04-19 15:53:21 -07:00
Fangrui Song
adbdef6a9f [Driver] Make -fsanitize=kcfi,function incompatible
A -fsanitize=kcfi instrumented function has a special instruction/data
before the function entry at a fixed offset.
A -fsanitize=function instrumented function has special instruction/data
after the function entry at a fixed offset (may change to *before* in D148665).

The two instrumentations are not intended to be used together and will become
incompatible after D148665.

Reviewed By: samitolvanen

Differential Revision: https://reviews.llvm.org/D148671
2023-04-19 13:15:33 -07:00
Fangrui Song
e67493f572 [Driver] -fsanitize=kcfi doesn't need RequiresPIE
As mentioned on D148671: this is unneeded. This commit is a no-op for most Linux
builds since CLANG_DEFAULT_PIE_ON_LINUX defaults to 1.
2023-04-19 13:10:46 -07:00
Itay Bookstein
782c59a4ee [OpenMP] Prefix outlined and reduction func names with original func's name
This patch prefixes omp outlined helpers and reduction funcs
with the original function's name.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D140722
2023-04-19 23:00:26 +03:00
Christopher Di Bella
33e21610f9 [clang] makes __is_trivially_equality_comparable available as a struct
Since this was originally a name in library, it needs an escape hatch
for versions of Clang that are slightly out-of-sync with libc++.

Differential Revision: https://reviews.llvm.org/D148677
2023-04-19 17:16:40 +00:00
Paul Robinson
12426441ea [Header][doc] Tweak wording for MWAIT[X] intrinsics 2023-04-19 09:57:33 -07:00
Itay Bookstein
6fdd13e0ec Revert "[OpenMP] Prefix outlined and reduction func names with original func's name"
This reverts commit 029bfc311d.
2023-04-19 19:08:49 +03:00
Paul Robinson
5ddcef2ad3 [Headers][doc] Add/revise MONITOR/MWAIT descriptions
Differential Revision: https://reviews.llvm.org/D148653
2023-04-19 09:50:15 -07:00
Itay Bookstein
029bfc311d [OpenMP] Prefix outlined and reduction func names with original func's name
This patch attempts to prefix omp outlined helpers and reduction funcs
with the original function's name.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D140722
2023-04-19 19:05:21 +03:00
Sam McCall
bbffa8bd75 [dataflow] add missing clangLex dep after a443b3d18e 2023-04-19 16:12:42 +02:00
Sam McCall
a443b3d18e [dataflow] add HTML logger: browse code/cfg/analysis timeline/state
With -dataflow-log=/dir we will write /dir/0.html etc for each
function analyzed.

These files show the function's code and CFG, and the path through
the CFG taken by the analysis. At each analysis point we can see the
lattice state.

Currently the lattice state dump is not terribly useful but we can
improve this: showing values associated with the current Expr,
simplifying flow condition, highlighting changes etc.

(Trying not to let this patch scope-creep too much, so I ripped out the
half-finished features)

Demo: 9718fdd484/analysis.html

Differential Revision: https://reviews.llvm.org/D146591
2023-04-19 15:37:06 +02:00
Marco Elver
5f605e254a [SanitizerBinaryMetadata] Respect no_sanitize("thread") function attribute
To avoid false positives, respect no_sanitize("thread") when atomics
metadata is enabled.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D148694
2023-04-19 14:49:56 +02:00
Sam McCall
bf47c1ed85 [dataflow] Extract arena for Value/StorageLocation out of DataflowAnalysisContext
DataflowAnalysisContext has a few too many responsibilities, this narrows them.

It also allows the Arena to be shared with analysis steps, which need to create
Values, without exposing the whole DACtx API (flow conditions etc).
This means Environment no longer needs to proxy all these methods.
(For now it still does, because there are many callsites to update, and maybe
if we separate bool formulas from values we can avoid churning them twice)

In future, if we untangle the concepts of Values from boolean formulas/atoms,
Arena would also be responsible for creating formulas and managing atom IDs.

Differential Revision: https://reviews.llvm.org/D148554
2023-04-19 14:32:13 +02:00
Timm Bäder
70ba243c6a [clang][Interp][NFC] Small State.cpp refactoring 2023-04-19 08:13:16 +02:00
Bill Wendling
b51a03e1bb [Clang][NFC] Rename methods/vars to reflect their real usage
The "getField" method is a bit confusing considering we also have a
"getFieldName" method. Instead, use "getFieldDecl" rather than
"getField".

Differential Revision: https://reviews.llvm.org/D147743
2023-04-18 13:48:08 -07:00
Vassil Vassilev
310ee08d5d Reland "[clang-repl] Enable debugging of JIT-ed code."
Original commit message: "
[clang-repl] Enable debugging of JIT-ed code.

    This change follows llvm/llvm-project@21b5ebd and makes use of the jitlink
    infrastructure. In order to use this feature inside lldb one needs to run the
    lldb command: settings set plugin.jit-loader.gdb.enable on

    This works currently only on Darwin since jitlink is not a default ELF/x86-64
    backend yet.

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

This patch reverts commit e64fbf2cca and adds
the missing library dependencies which caused the initial failure.
2023-04-18 18:33:52 +00:00
Jonas Paulsson
790c9ac529 [ClangFE] Handle statement expressions properly with CheckAtomicAlignment().
Make CheckAtomicAlignment() return the computed pointer for reuse to avoid
emitting it twice.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D148422
2023-04-18 19:33:32 +02:00
David Tenty
8d2e9fc855 [PowerPC] Add function pointer alignment to DataLayout
The alignment of function pointers was added to the Datalayout by
D57335 but currently is unset for the Power target. This will cause us
to compute a conservative minimum alignment of one if places like
Value::getPointerAlignment.

This patch implements the function pointer alignment in the Datalayout
for the Power backend and Power targets in clang, so we can query the
value for a particular Power target.

We come up with the correct value one of two ways:

- If the target uses function descriptor objects (i.e. ELFv1 & AIX ABIs),
  then a function pointer points to the descriptor, so use the alignment
  we would emit the descriptor with.
- If the target doesn't use function descriptor objects (i.e. ELFv2), a
  function pointer points to the global entry point, so use the minimum
  alignment for code on Power (i.e. 4-bytes).

Reviewed By: nemanjai

Differential Revision: https://reviews.llvm.org/D147016
2023-04-18 13:00:27 -04:00
Paul Robinson
0905c567f0 [Headers][doc] Add FMA intrinsic descriptions
Differential Revision: https://reviews.llvm.org/D148021
2023-04-18 09:31:09 -07:00
Vassil Vassilev
e64fbf2cca Revert "[clang-repl] Enable debugging of JIT-ed code."
This reverts commit 1e4891e681.

Some bots complain about undefined llvm_orc_registerJITLoaderGDBAllocAction.
2023-04-18 13:41:38 +00:00
Vassil Vassilev
1e4891e681 [clang-repl] Enable debugging of JIT-ed code.
This change follows llvm/llvm-project@21b5ebd and makes use of the jitlink
infrastructure. In order to use this feature inside lldb one needs to run the
lldb command: settings set plugin.jit-loader.gdb.enable on

This works currently only on Darwin since jitlink is not a default ELF/x86-64
backend yet.

Differential revision: https://reviews.llvm.org/D148481
2023-04-18 13:19:42 +00:00
Ilya Biryukov
67b298f6d8 Reland [Modules] Remove unnecessary check when generating name lookup table in ASTWriter
Fixes #61065.

This reverts commit 363c98b2d6 and relands
db987b9589 with fixes from
bc95f27337.

The module-related issues surfaced there are fixed in the
previous commit.
2023-04-18 12:40:39 +02:00
Ilya Biryukov
ccf7191719 [Modules] Do not rewrite existing decls when deserializing class fields
Classes can have implicit members that were added before fields were
deserialized. These members were previously silently removed from
`decls()` when fields were deserialized after them.

This was the root cause of a compilation error exposed in
bc95f27337, added a test for it.

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D148515
2023-04-18 12:40:39 +02:00
Stoorx
830b359d3a [clang] Return std::unique_ptr<TargetInfo> from AllocateTarget
In file 'clang/lib/Basic/Targets.cpp' the function 'AllocateTarget' had a raw pointer as a return type, which have been wrapped in the 'std::unique_ptr' in all usages.
This commit changes the signature of the function to return an instance of 'std::unique_ptr' directly.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D148574
2023-04-18 10:07:26 +00:00
mydeveloperday
799b794d76 [clang-format] C# short ternary operator misinterpreted as a CSharpNullable
Refactor the CSharpNullable assignment code to be a little easier to read (Honestly I don't like it when an if expression get really long and complicated).
Handle the case where '?' is actually a ternary operator.

Fixes: #58067

Reviewed By: owenpan, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D148473
2023-04-18 10:17:28 +01:00
Mats Petersson
efae695d52 Add -f[no-]loop-versioning option
Add flags for loop-versioning pass enable/disable

Reviewed By: awarzynski, tblah

Differential Revision: https://reviews.llvm.org/D141307
2023-04-18 09:47:54 +01:00
Martin Braenne
d9e717338f [clang][dataflow] Associate FunctionToPointerDecay nodes with a value.
To ensure that we have a pointee for the `PointerValue`, we also create
storage locations for `FunctionDecl`s referenced in the function under analysis.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D148006
2023-04-18 07:15:29 +00:00
Martin Braenne
6ab900f874 [clang][dataflow] Add support for new expressions.
Reviewed By: xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D147698
2023-04-18 04:11:43 +00:00