Commit Graph

89663 Commits

Author SHA1 Message Date
Valeriy Savchenko 8474bb13c3 [analyzer][solver][NFC] Simplify function signatures
Since RangeSet::Factory actually contains BasicValueFactory, we can
remove value factory from many function signatures inside the solver.

Differential Revision: https://reviews.llvm.org/D105005
2021-06-28 14:20:06 +03:00
Gabor Marton 6f3b775c3e [Analyzer][solver] Add dump methods for (dis)equality classes.
This proved to be very useful during debugging.

Differential Revision: https://reviews.llvm.org/D103967
2021-06-28 12:57:14 +02:00
David Spickett a498553162 [clang][ARM] Mark sanitize-coverage-old-pm.c unsupported on armv7l
Our v7 Linux bots report the arch as "armv7l", not "armv7".
2021-06-28 08:32:36 +00:00
Jinsong Ji eb237ffca8 [PowerPC] Add XL Compat fetch builtins
Prototype
```
unsigned int __fetch_and_add (volatile unsigned int* addr, unsigned int
val);
unsigned long __fetch_and_addlp (volatile unsigned long* addr, unsigned
long val);
```
Ref:
https://www.ibm.com/docs/en/xl-c-and-cpp-linux/16.1.1?topic=functions-fetch

Reviewed By: #powerpc, w2yehia, lkail

Differential Revision: https://reviews.llvm.org/D104991
2021-06-28 02:52:32 +00:00
Muhammad Omair Javaid 2ddca686ee Tag sanitize-coverage-old-pm.c unsupported on arm 32 bit
This test is again failing across multiple bots and passing on others
there is no reliable way to enable it for some of the bots while
disabling for the unsupported ones. Tagging it as unsupported across all
types of Arm 32 bit cores.
2021-06-28 07:19:11 +05:00
Muhammad Omair Javaid 3a6599b7bd Remove XFAIL flag from sanitize-coverage-old-pm.c
This test has started passing consistently on 32bit arm where underlying
core is reported as Armv7 or Thumbv7.
However it still fails intermittently on 32bit AArch32 reported as Armv8l.

https://lab.llvm.org/buildbot/#/builders/190/builds/20
https://lab.llvm.org/buildbot/#/builders/170/builds/41
2021-06-28 03:38:08 +05:00
Darwin Xu e5a8f230c7 [clang-format] Fix the issue that empty lines being removed at the beginning of namespace
This is a bug fix of https://bugs.llvm.org/show_bug.cgi?id=50116

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D104044
2021-06-27 15:59:21 +01:00
Craig Topper 7a112356e4 [X86] Correct the conversion of VALIGND/Q intrinsics to shufflevector.
We need to mask the immediate to the width of a single vector
rather than 2 vectors. If we use the width of 2 vectors then
any shift larger than the length of 1 vector is going to overflow
the shuffle indices.

Fixes PR50895.
2021-06-26 19:06:00 -07:00
Ed Maste 699d47472c [Driver] do not link _p libs for -pg on FreeBSD 14 and later
In FreeBSD 14 the project will deprecate the _p special profiling
libraries.

Support for -pg (i.e., mcount) still exists but libraries compiled
with -pg will not be built by default, so stop linking against them.

Reviewed by:	Dimitry Andric
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.llvm.org/D104753
2021-06-26 17:47:54 -04:00
Matheus Izvekov d6144c30fb [clang] add C++ feature test macro for P2266 simpler implicit move
The feature was implemented in D99005, but we forgot to add the test
macro.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D104984
2021-06-26 23:05:23 +02:00
mydeveloperday 8b7881a084 [clang-format] Add basic support for formatting JSON
I find as I develop I'm moving between many different languages C++,C#,JavaScript all the time. As I move between the file types I like to keep `clang-format` as my formatting tool of choice. (hence why I initially added C# support  in {D58404}) I know those other languages have their own tools but I have to learn them all, and I have to work out how to configure them, and they may or may not have integration into my IDE or my source code integration.

I am increasingly finding that I'm editing additional JSON files as part of my daily work and my editor and git commit hooks are just not setup to go and run [[ https://stedolan.github.io/jq/ | jq ]], So I tend to go to  [[ https://jsonformatter.curiousconcept.com/ | JSON Formatter ]] and copy and paste back and forth. To get nicely formatted JSON. This is a painful process and I'd like a new one that causes me much less friction.

This has come up from time to time:

{D10543}
https://stackoverflow.com/questions/35856565/clang-format-a-json-file
https://bugs.llvm.org/show_bug.cgi?id=18699

I would like to stop having to do that and have formatting JSON as a first class clang-format support `Language` (even if it has minimal style settings at present).

This revision adds support for formatting JSON using the inbuilt JSON serialization library of LLVM, With limited control at present only over the indentation level

This adds an additional Language into the .clang-format file to separate the settings from your other supported languages.

Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D93528
2021-06-26 15:20:17 +01:00
mydeveloperday 37c2233097 [clang-format] [PR50702] Lamdba processing does not respect AfterClass and AfterNamespace
https://bugs.llvm.org/show_bug.cgi?id=50702

I believe {D44609} may be too aggressive with brace wrapping rules which doesn't always apply to Lamdbas

The introduction of BeforeLambdaBody and AllowShortLambdasOnASingleLine has impact on brace handling on other block types, which I suspect we didn't see before as people may not be using the BeforeLambdaBody  style

From what I can tell this can be seen by the unit test I change as its not honouring the orginal LLVM brace wrapping style for the `Fct()` function

I added a unit test from PR50702 and have removed some of the code (which has zero impact on the unit test, which kind of suggests its unnecessary), some additional attempt has been made to try and ensure we'll only break on what is actually a LamdbaLBrace

Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D104222
2021-06-26 13:34:07 +01:00
mydeveloperday ee3b2c47ce [clang-format] PR50525 doesn't handle AlignConsecutiveAssignments correctly in some situations
https://bugs.llvm.org/show_bug.cgi?id=50525

AlignConsecutiveAssignments/Declarations cause incorrect alignment in the presence of a DesignatedInitializerPeriod (https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html)

```
static NTSTATUS stg(PLW_STREAM Stream, int identity)
{
     NTSTATUS             status;
     BYTE                 payload[256] = {'l', 'h', 'o', 't', 's', 'e'};
     struct dm_rpc_header header       = {.drh_magic        = DRH_MAGIC,
                                    .drh_op_code      = RPC_OP_ECHO,
                                    .drh_payload_size = sizeof(payload),
                                    .drh_body_size    = sizeof(payload),
                                    .drh_request_id   = 1};
     header.drh_version                = identity;
```

This fix addresses that by ensuring the period isn't ignored

Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D104900
2021-06-26 13:29:16 +01:00
Timm Bäder 3255db4919 [clang][tests] Specify unwindlib in aix-ld tests
Clang can be configured with a different default unwindlib, for example
gcc. In that case, -lunwind will not be present in the output.

Fix this by explicitly specifying libunwind as the unwindlib.

Differential Revision: https://reviews.llvm.org/D104899
2021-06-26 13:09:29 +02:00
Saurabh Jha c8f3f46c69 [Docs] Minor fixes with language extension docs
There were some issues in the patch https://reviews.llvm.org/D104198. I also forgot to address one comment. This patch addresses these.

Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D104971
2021-06-26 10:07:33 +01:00
Andrew Browne 45f6d5522f [DFSan] Change shadow and origin memory layouts to match MSan.
Previously on x86_64:

  +--------------------+ 0x800000000000 (top of memory)
  | application memory |
  +--------------------+ 0x700000008000 (kAppAddr)
  |                    |
  |       unused       |
  |                    |
  +--------------------+ 0x300000000000 (kUnusedAddr)
  |       origin       |
  +--------------------+ 0x200000008000 (kOriginAddr)
  |       unused       |
  +--------------------+ 0x200000000000
  |   shadow memory    |
  +--------------------+ 0x100000008000 (kShadowAddr)
  |       unused       |
  +--------------------+ 0x000000010000
  | reserved by kernel |
  +--------------------+ 0x000000000000

  MEM_TO_SHADOW(mem) = mem & ~0x600000000000
  SHADOW_TO_ORIGIN(shadow) = kOriginAddr - kShadowAddr + shadow

Now for x86_64:

  +--------------------+ 0x800000000000 (top of memory)
  |    application 3   |
  +--------------------+ 0x700000000000
  |      invalid       |
  +--------------------+ 0x610000000000
  |      origin 1      |
  +--------------------+ 0x600000000000
  |    application 2   |
  +--------------------+ 0x510000000000
  |      shadow 1      |
  +--------------------+ 0x500000000000
  |      invalid       |
  +--------------------+ 0x400000000000
  |      origin 3      |
  +--------------------+ 0x300000000000
  |      shadow 3      |
  +--------------------+ 0x200000000000
  |      origin 2      |
  +--------------------+ 0x110000000000
  |      invalid       |
  +--------------------+ 0x100000000000
  |      shadow 2      |
  +--------------------+ 0x010000000000
  |    application 1   |
  +--------------------+ 0x000000000000

  MEM_TO_SHADOW(mem) = mem ^ 0x500000000000
  SHADOW_TO_ORIGIN(shadow) = shadow + 0x100000000000

Reviewed By: stephan.yichao.zhao, gbalats

Differential Revision: https://reviews.llvm.org/D104896
2021-06-25 17:00:38 -07:00
Matheus Izvekov ad14b5b008 [clang] Stop providing builtin overload candidate for relational function pointer comparisons
Word on the grapevine was that the committee had some discussion that
ended with unanimous agreement on eliminating relational function pointer comparisons.

We wanted to be bold and just ban all of them cold turkey.
But then we chickened out at the last second and are going for
eliminating just the spaceship overload candidate instead, for now.

See D104680 for reference.

This should be fine and "safe", because the only possible semantic change this
would cause is that overload resolution could possibly be ambiguous if
there was another viable candidate equally as good.

But to save face a little we are going to:
* Issue an "error" for three-way comparisons on function pointers.
  But all this is doing really is changing one vague error message,
  from an "invalid operands to binary expression" into an
  "ordered comparison of function pointers", which sounds more like we mean business.
* Otherwise "warn" that comparing function pointers like that is totally
  not cool (unless we are told to keep quiet about this).

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D104892
2021-06-26 00:08:02 +02:00
Joseph Huber 9ce02ea8c9 [OpenMP] Add Module metadata for OpenMP compilation
This patch adds a module level metadata flag indicating that the module
was compiled with the `-fopenmp` flag. This will make it easier for
passes like OpenMPOpt to determine if it should be run.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D102361
2021-06-25 16:34:19 -04:00
Valeriy Savchenko d646157146 [analyzer] Fix assertion failure on code with transparent unions
rdar://76948312

Differential Revision: https://reviews.llvm.org/D104716
2021-06-25 23:09:16 +03:00
Joel E. Denny cc60fa2685 [UpdateCCTestChecks] Fix new test from 9eaf0d120d
`clang/test/utils/update_cc_test_checks/check-globals.test` from
9eaf0d120d broke at:

* <https://lab.llvm.org/buildbot/#/builders/110/builds/4415>
* <https://lab.llvm.org/buildbot/#/builders/5/builds/9076>

The problem is non-deterministic test order because the
`.lit_test_times.txt` from one run of a sample test suite affects the
other.
2021-06-25 14:29:58 -04:00
Nico Weber fda790fbfa [clang] Make fewer assumptions about path to lit.site.cfg after 9eaf0d120d 2021-06-25 14:01:29 -04:00
Joel E. Denny 9eaf0d120d [UpdateCCTestChecks] Support --check-globals
This option is already supported by update_test_checks.py, but it can
also be useful in update_cc_test_checks.py.  For example, I'd like to
use it in OpenMP offload codegen tests to check global variables like
`.offload_maptypes*`.

Reviewed By: jdoerfert, arichardson, ggeorgakoudis

Differential Revision: https://reviews.llvm.org/D104714
2021-06-25 13:17:56 -04:00
Yaxun (Sam) Liu 4921ecfc81 [clang] Fix build failure due to _S
_S is a reserved identifier in <ctype.h> on Solaris.
2021-06-25 10:10:27 -04:00
Yaxun (Sam) Liu 3193133add [OpenCL] Do not include default header for preprocessor output as input
When clang driver is used with -save-temps to compile OpenCL program,
clang driver first launches clang -cc1 -E to generate preprocessor expansion output,
then launches clang -cc1 with the generated preprocessor expansion output as input
to generate LLVM IR.

Currently clang by default passes "-finclude-default-header" "-fdeclare-opencl-builtins"
in both steps, which causes default header included again in the second step, which
causes error.

This patch let clang not to include default header when input type is preprocessor expansion
output, which fixes the issue.

Reviewed by: Anastasia Stulova

Differential Revision: https://reviews.llvm.org/D104800
2021-06-25 10:01:51 -04:00
Andrzej Warzynski 2a7bb8494e [flang][driver] Add `-fno-analyzed-objects-for-unparse`
This patch adds a new option for the new Flang driver:
`-fno-analyzed-objects-for-unparse`. The semantics are similar to
`-funparse-typed-exprs-to-f18-fc` from `f18`. For consistency, the
latter is replaced with `-fno-analyzed-objects-for-unparse`.

The new option controls the behaviour of the unparser (i.e. the action
corresponding to `-fdebug-unparse`). The default behaviour is to use the
analyzed objects when unparsing. The new flag can be used to turn this
off, so that the original parse-tree objects are used. The analyzed
objects are generated during the semantic checks [1].

This patch also updates the semantics of
`-fno-analyzed-objects-for-unparse`/`-funparse-typed-exprs-to-f18-fc`
in `f18`, so that this flag is always taken into account when `Unparse`
is used (this way the semantics in `f18` and `flang-new` are identical).

The added test file is based on example from Peter Steinfeld.

[1]
https://github.com/llvm/llvm-project/blob/main/flang/docs/Semantics.md

Differential Revision: https://reviews.llvm.org/D103612
2021-06-25 13:28:12 +01:00
Stuart Brady e47027d091 [OpenCL] Use DW_LANG_OpenCL language tag for OpenCL C
Note regarding C++ for OpenCL:

   When compiling C++ for OpenCL, DW_LANG_C_plus_plus* is emitted.

   There is no DWARF language code defined for C++ for OpenCL as of yet,
   but DWARF issue 210514.1 has been raised to request one.

   In the mean time, continuing to emit DW_LANG_C_plus_plus* for C++ for
   OpenCL allows the potential to distinguish between C++ for OpenCL and
   OpenCL C in !DICompileUnit nodes, whereas using DW_LANG_OpenCL for
   C++ for OpenCL would prevent this.

   This change therefore leaves C++ for OpenCL as-is.

Reviewed By: shchenz, Anastasia

Differential Revision: https://reviews.llvm.org/D104118
2021-06-25 11:48:42 +01:00
Gabor Marton 0646e36254 [Analyzer][solver] Fix crashes during symbol simplification
Consider the code
```
  void f(int a0, int b0, int c)
  {
      int a1 = a0 - b0;
      int b1 = (unsigned)a1 + c;
      if (c == 0) {
          int d = 7L / b1;
      }
  }
```
At the point of divisiion by `b1` that is considered to be non-zero,
which results in a new constraint for `$a0 - $b0 + $c`. The type
of this sym is unsigned, however, the simplified sym is `$a0 -
$b0` and its type is signed. This is probably the result of the
inherent improper handling of casts. Anyway, Range assignment
for constraints use this type information. Therefore, we must
make sure that first we simplify the symbol and only then we
assign the range.

Differential Revision: https://reviews.llvm.org/D104844
2021-06-25 11:49:26 +02:00
Jinsong Ji f3ef4f5bff [PowerPC] Add XL compat __compare_and_swap builtins
Prototype
int __compare_and_swap (volatile int* addr, int* old_val_addr, int
new_val);

int __compare_and_swaplp (volatile long* addr, long* old_val_addr, long
new_val);

Refer to
https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=functions-compare-swap-compare-swaplp

Reviewed By: w2yehia

Differential Revision: https://reviews.llvm.org/D104837
2021-06-25 01:08:48 +00:00
Craig Topper f225367305 [RISCV] Add vget/vset intrinsics for inserting and extracting between different lmuls.
These allow getting a whole register from a larger lmul. Or
inserting a whole register into a larger lmul register. Fractional
lmuls are not supported as they would require a vslide.

Based on this update to the intrinsic doc
https://github.com/riscv/rvv-intrinsic-doc/pull/99

Reviewed By: HsiangKai

Differential Revision: https://reviews.llvm.org/D104822
2021-06-24 18:06:36 -07:00
Muhammad Omair Javaid e8cded57fb Unsupported sanitize-coverage-old-pm.c on 32 bit Arm
sanitize-coverage-old-pm.c is passing intermittently on different
arm v7 machines. This patch moves it to unsupported on all arm 32
targets reporting armv8l core.
2021-06-25 00:57:24 +00:00
Muhammad Omair Javaid d6a91f6c56 Revert "[Clang] XFAIL sanitize-coverage-old-pm.c on 32bit Armv8l"
This reverts commit c5028f3473.
2021-06-25 05:00:14 +05:00
Nemanja Ivanovic ef906573a1 [PowerPC] Fix vec_add for 64-bit on pre-Power7 subtargets
The shift of the carry was actually incorrect.
2021-06-24 18:42:44 -05:00
Fangrui Song f1e2d5851b [OptTable] Rename PrintHelp to printHelp
To be consistent with other member functions and match the coding standard.
2021-06-24 14:47:03 -07:00
Martin Storsjö e5c7c171e5 [clang] Rename StringRef _lower() method calls to _insensitive()
This is mostly a mechanical change, but a testcase that contains
parts of the StringRef class (clang/test/Analysis/llvm-conventions.cpp)
isn't touched.
2021-06-25 00:22:01 +03:00
Seraphime Kirkovski a08fa8a508 [Clang-Format] Add ReferenceAlignment directive
This introduces ReferenceAlignment style option modeled around
PointerAlignment.
Style implementors can specify Left, Right, Middle or Pointer to
follow whatever the PointerAlignment option specifies.

Differential Revision: https://reviews.llvm.org/D104096
2021-06-24 22:27:45 +02:00
Björn Schäpers b3ccf4fc02 [clang-format][NFC] Fix documentation
This amends 64cf5eba06.
2021-06-24 21:19:14 +02:00
Akira Hatanaka 8db0dbbe2c [CodeGen] Don't create fake FunctionDecls when generating block/byref
copy/dispose helper functions

We found out that these fake functions would cause clang to crash if the
changes proposed in https://reviews.llvm.org/D98799 were made.

The original patch was reverted in f681fd927e
because debug locations were missing in the body of the block byref
helper functions. This patch fixes the bug by calling CreateArtificial
after the calls to StartFunction.

Differential Revision: https://reviews.llvm.org/D104082
2021-06-24 11:45:52 -07:00
Aakanksha Patil 3453f3dd46 [AMDGPU] Add gfx1035 target
Differential Revision: https://reviews.llvm.org/D104804
2021-06-24 14:32:41 -04:00
Saurabh Jha cd256c8bcc Add documentation for compound assignment and type conversion of matrix types 2021-06-24 15:50:58 +01:00
Muhammad Omair Javaid c5028f3473 [Clang] XFAIL sanitize-coverage-old-pm.c on 32bit Armv8l
sanitize-coverage-old-pm.c started failing on arm 32 bit where
underlying architecture reported is armv8l fore 32bit arm.
This patch XFAILS sanitize-coverage-old-pm.c on armv8l similar
to armv7 and thumbv7.
2021-06-24 15:48:13 +05:00
Denys Petrov e76c008c90 [analyzer] Added a test case for PR46264
Summary: It's not able to reproduce the issue (https://bugs.llvm.org/show_bug.cgi?id=46264) for the latest sources. Add a reported test case to try to catch the problem if occur es.

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

Prevent: https://bugs.llvm.org/show_bug.cgi?id=46264
2021-06-24 12:24:26 +03:00
Yaxun (Sam) Liu 82e03e494f [HIP] Defer operator overloading errors
Although clang is able to defer overloading resolution
diagnostics for common functions. It does not defer
overloading resolution caused diagnostics for overloaded
operators.

This patch extends the existing deferred
diagnostic mechanism and defers a diagnostic caused
by overloaded operator.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D104505
2021-06-23 23:39:59 -04:00
Peter Collingbourne e655e74a31 AST: Create __va_list in the std namespace even in C.
This ensures that the mangled type names match between C and C++,
which is significant when using -fsanitize=cfi-icall. Ideally we
wouldn't have created this namespace at all, but it's now part of
the ABI (e.g. in mangled names), so we can't change it.

Differential Revision: https://reviews.llvm.org/D104830
2021-06-23 18:59:10 -07:00
Whitney Tsang ab244db1fa [AIX] Emitting diagnostics error for profile options
Only LLVM-based instrumentation profile is supported on AIX.
And it currently must be used with full LTO.

Reviewed By: hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D104803
2021-06-24 00:23:28 +00:00
modimo 42b99e094c [Clang] Check for returns_nonnull when deciding to add allocation null checks
Non-throwing allocators currently will always get null-check code. However, if the non-throwing allocator is explicitly annotated with returns_nonnull the null check should be elided.

Testing:
ninja check-all
added test case correctly elides

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D102820
2021-06-23 17:15:12 -07:00
Jian Cai 0eac975b51 Reland "[AArch64] handle -Wa,-march="
This reverts commit fd11a26d36, which was
reverted by 9145a3d4ab due to a test
failure on aarch64 backend, e.g.
https://lab.llvm.org/buildbot/#/builders/43/builds/7031. This patch
fixed the test failure.

Reviewed By: DavidSpickett, nickdesaulniers

Differential Revision: https://reviews.llvm.org/D103184
2021-06-23 12:01:57 -07:00
Vitali Lovich be9a87fe9b [clang-format] Add IfMacros option
https://bugs.llvm.org/show_bug.cgi?id=49354

Differential Revision: https://reviews.llvm.org/D102730
2021-06-23 08:51:53 -07:00
Ethan Stewart 5dfdc1812d [OpenMP][AMDGCN] Apply fix for isnan, isinf and isfinite for amdgcn.
This fixes issues with various return types(bool/int) and was already
in place for nvptx headers, adjusted to work for amdgcn. This does
not affect hip as the change is guarded with OPENMP_AMDGCN.
Similar to D85879.

Reviewed By: jdoerfert, JonChesterfield, yaxunl

Differential Revision: https://reviews.llvm.org/D104677
2021-06-23 15:26:09 +01:00
serge-sans-paille a0d05ed848 Handle interactions between reserved identifier and user-defined suffixes
According to https://eel.is/c++draft/over.literal

> double operator""_Bq(long double);  // OK: does not use the reserved identifier _­Bq ([lex.name])
> double operator"" _Bq(long double); // ill-formed, no diagnostic required: uses the reserved identifier _­Bq ([lex.name])

Obey that rule by keeping track of the operator literal name status wrt. leading whitespace.

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

Differential Revision: https://reviews.llvm.org/D104299
2021-06-23 15:38:42 +02:00
owenca ca7f471585 [clang-format] Fix a bug that indents else-comment-if incorrectly
PR50809

Differential Revision: https://reviews.llvm.org/D104774
2021-06-23 04:57:45 -07:00