Commit Graph

91245 Commits

Author SHA1 Message Date
Michael Benfield 15e3d39110 [clang] Fortify warning for scanf calls with field width too big.
Differential Revision: https://reviews.llvm.org/D111833
2021-10-28 02:52:03 +00:00
Kai Luo 6ea2431d3f [clang][compiler-rt][atomics] Add `__c11_atomic_fetch_nand` builtin and support `__atomic_fetch_nand` libcall
Add `__c11_atomic_fetch_nand` builtin to language extensions and support `__atomic_fetch_nand` libcall in compiler-rt.

Reviewed By: theraven

Differential Revision: https://reviews.llvm.org/D112400
2021-10-28 02:18:43 +00:00
Johannes Doerfert 6cf6fa6ef1 [OpenMP] Declare variants for templates need to match # template args
A declare variant template is only compatible with a base when the
number of template arguments is equal, otherwise our instantiations will
produce nonsensical results.

Exposes as part of D109344.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D109770
2021-10-27 21:04:32 -05:00
Jon Chesterfield 6c7b203d1d Revert "[libomptarget] Build DeviceRTL for amdgpu"
- more tests failing on CI than failed locally when writing this patch

This reverts commit 33427fdb7b.
2021-10-28 01:01:53 +01:00
Jon Chesterfield 33427fdb7b [libomptarget] Build DeviceRTL for amdgpu
Passes same tests as the current deviceRTL. Includes cmake change from D111987.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D112227
2021-10-28 00:41:45 +01:00
Roman Lebedev b291597112
Revert rest of `IRBuilderBase`'s short-circuiting folds
Upon further investigation and discussion,
this is actually the opposite direction from what we should be taking,
and this direction wouldn't solve the motivational problem anyway.

Additionally, some more (polly) tests have escaped being updated.
So, let's just take a step back here.

This reverts commit f3190dedee.
This reverts commit 749581d21f.
This reverts commit f3df87d57e.
This reverts commit ab1dbcecd6.
2021-10-28 02:15:14 +03:00
Félix Cloutier d378a0febc [Sema] Recognize format argument indicated by format attribute inside blocks
- `[[format(archetype, fmt-idx, ellipsis)]]` specifies that a function accepts a
  format string and arguments according to `archetype`. This is how Clang
  type-checks `printf` arguments based on the format string.
- Clang has a `-Wformat-nonliteral` warning that is triggered when a function
  with the `format` attribute is called with a format string that is not
  inspectable because it isn't constant. This warning is suppressed if the
  caller has the `format` attribute itself and the format argument to the callee
  is the caller's own format parameter.
- When using the `format` attribute on a block, Clang wouldn't recognize its
  format parameter when calling another function with the format attribute. This
  would cause unsuppressed -Wformat-nonliteral warnings for no supported reason.

Reviewed By: ahatanak

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

Radar-Id: rdar://84603673
2021-10-27 15:48:35 -07:00
Matheus Izvekov 32d45862fc
[clang] NFC: remove carriage return from AST tests
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D112372
2021-10-28 00:25:02 +02:00
Matheus Izvekov 086e111216
[clang] NFC: include non friendly types and missing sugar in test expectations
The dump of all diagnostics of all tests under `clang/test/{CXX,SemaCXX,SemaTemplate}` was analyzed , and all the cases where there were obviously bad canonical types being printed, like `type-parameter-*-*` and `<overloaded function type>` were identified. Also a small amount of cases of missing sugar were analyzed.

This patch then spells those explicitly in the test expectations, as preparatory work for future fixes for these problems.

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

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D110210
2021-10-27 23:03:29 +02:00
Matheus Izvekov 2d7fba5f95
[clang] deprecate frelaxed-template-template-args, make it on by default
A resolution to the ambiguity issues created by P0522, which is a DR solving
CWG 150, did not come as expected, so we are just going to accept the change,
and watch how users digest it.

For now we deprecate the flag with a warning, and make it on by default.
We don't remove the flag completely in order to give users a chance to
work around any problems by disabling it.

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

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D109496
2021-10-27 22:48:27 +02:00
Sam McCall de7494a33a [AST] fail rather than crash when const evaluating invalid c++ foreach
Differential Revision: https://reviews.llvm.org/D112633
2021-10-27 22:45:32 +02:00
Florian Hahn 01870d51b8
[Clang] Add elementwise abs builtin.
This patch implements __builtin_elementwise_abs as specified in
D111529.

Reviewed By: aaron.ballman, scanon

Differential Revision: https://reviews.llvm.org/D111986
2021-10-27 21:01:44 +01:00
Roman Lebedev 101aaf62ef
Revert "[NFC] `IRBuilderBase::CreateAdd()`: place constant onto RHS"
Clang OpenMP codegen tests are failing,
will recommit afterwards.

This reverts commit 4723c9b3c6.
2021-10-27 22:21:37 +03:00
Roman Lebedev 42712698fd
Revert "[IR] `IRBuilderBase::CreateAdd()`: short-circuit `x + 0` --> `x`"
Clang OpenMP codegen tests are failing.

This reverts commit 288f1f8abe.
This reverts commit cb90e5356a.
2021-10-27 22:21:37 +03:00
Roman Lebedev cb90e5356a
[IR] `IRBuilderBase::CreateAdd()`: short-circuit `x + 0` --> `x`
There's precedent for that in `CreateOr()`/`CreateAnd()`.

The motivation here is to avoid bloating the run-time check's IR
in `SCEVExpander::generateOverflowCheck()`.

Refs. https://reviews.llvm.org/D109368#3089809
2021-10-27 21:34:38 +03:00
Roman Lebedev 4723c9b3c6
[NFC] `IRBuilderBase::CreateAdd()`: place constant onto RHS 2021-10-27 21:34:38 +03:00
Aaron Ballman 9fcca8b470 Fix consteval crash when transforming 'this' expressions
When reaching the end of a function body, we need to ensure that the
ExitFunctionBodyRAII object is destroyed before we pop the declaration context
for the function. Exiting the function body causes us to handle immediate
invocations, which involves template transformations that need to know the
correct type for this.

This addresses PR48235.
2021-10-27 11:25:07 -04:00
Gabor Marton a8297ed994 [Analyzer][solver] Handle adjustments in constraint assignor remainder
We can reuse the "adjustment" handling logic in the higher level
of the solver by calling `State->assume`.

Differential Revision: https://reviews.llvm.org/D112296
2021-10-27 17:14:34 +02:00
Roman Lebedev f3190dedee
[IR] `IRBuilderBase::CreateAnd()`: short-circuit `x & 0` --> `0`
https://alive2.llvm.org/ce/z/YzPhSb

Refs. https://reviews.llvm.org/D109368#3089809
2021-10-27 18:01:06 +03:00
Roman Lebedev 749581d21f
[IR] `IRBuilderBase::CreateAnd()`: fix short-circuiting for constant on LHS
Refs. https://reviews.llvm.org/D109368#3089809
2021-10-27 18:01:06 +03:00
Roman Lebedev f3df87d57e
[IR] `IRBuilderBase::CreateOr()`: fix short-circuiting for constant on LHS
There is no guarantee that the constant is on RHS here,
we have to handle both cases.

Refs. https://reviews.llvm.org/D109368#3089809
2021-10-27 18:01:06 +03:00
Roman Lebedev ab1dbcecd6
[IR] `IRBuilderBase::CreateSelect()`: if cond is a constant i1, short-circuit
While we could emit such a tautological `select`,
it will stick around until the next instsimplify invocation,
which may happen after we count the cost of this redundant `select`.
Which is precisely what happens with loop vectorization legality checks,
and that artificially increases the cost of said checks,
which is bad.

There is prior art for this in `IRBuilderBase::CreateAnd()`/`IRBuilderBase::CreateOr()`.

Refs. https://reviews.llvm.org/D109368#3089809
2021-10-27 18:01:05 +03:00
Gabor Marton 888af47095 [Analyzer][solver] Simplification: reorganize equalities with adjustment
Initiate the reorganization of the equality information during symbol
simplification. E.g., if we bump into `c + 1 == 0` during simplification
then we'd like to express that `c == -1`. It makes sense to do this only
with `SymIntExpr`s.

Reviewed By: steakhal

Differential Revision: https://reviews.llvm.org/D111642
2021-10-27 16:48:55 +02:00
Nico Weber c7aaa2efef [clang] Add range accessor for ObjCAtTryStmt catch_stmts and use it
No behavior change.

Differential Revision: https://reviews.llvm.org/D112543
2021-10-27 08:57:05 -04:00
Nico Weber 7c10c9d8e8 [clang] Convert ObjCAtTryStmt to llvm::TrailingObjects
And make it final while here.

No behavior change.

Differential Revision: https://reviews.llvm.org/D112542
2021-10-27 08:57:05 -04:00
Jan Svoboda e76a9f1636 [clang][deps] Fix fragile test
This test was failing on GreenDragon.
2021-10-27 14:00:13 +02:00
Alexandros Lamprineas 8689f5e6e7 [AArch64] Add support for the 'R' architecture profile.
This change introduces subtarget features to predicate certain
instructions and system registers that are available only on
'A' profile targets. Those features are not present when
targeting a generic CPU, which is the default processor.

In other words the generic CPU now means the intersection of
'A' and 'R' profiles. To maintain backwards compatibility we
enable the features that correspond to -march=armv8-a when the
architecture is not explicitly specified on the command line.

References: https://developer.arm.com/documentation/ddi0600/latest

Differential Revision: https://reviews.llvm.org/D110065
2021-10-27 12:32:30 +01:00
Vassil Vassilev f0d527b28d [clang-repl] Remove redundant link libraries and drop unused file.
Many thanks to @thakis for pointing this out.

That commit should have been a part of https://reviews.llvm.org/D107049
2021-10-27 10:13:30 +00:00
Shraiysh Vaishay 9fb52cb3f1 [MLIR][OpenMP] Added omp.atomic.read and omp.atomic.write
This patch supports the atomic construct (read and write) following
section 2.17.7 of OpenMP 5.0 standard. Also added tests and
verifier for the same.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D111992
2021-10-27 14:05:44 +05:30
Uday Bondhugula 9fb9c6b91e [Clang][NFC] Clang CUDA codegen clean-up
Update an instance of dyn_cast -> cast and other NFC clang-tidy fixes
for Clang CUDA codegen.

Differential Revision: https://reviews.llvm.org/D112284
2021-10-27 11:07:20 +05:30
Ben Shi 9c7ace60aa [CUDA][NFC] Fix inexact warning message about lambdas
Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D112521
2021-10-27 01:28:35 +00:00
Vassil Vassilev c24a58081b Reinstate "[clang-repl] Re-implement clang-interpreter as a test case."
Original commit message: "
  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.
       "

       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.
"

This patch also checks if stl is built with rtti.

Differential revision: https://reviews.llvm.org/D107049
2021-10-26 19:29:56 +00:00
Florian Hahn d7fbad0dcf
[Matrix] Replace some err kinds with err_builtin_invalid_arg_type. (NFC)
Replace some custom matrix diagnostic kinds with the more generic
err_builtin_invalid_arg_type introduced in D111985.

Reviewed By: aaron.ballman, erichkeane

Differential Revision: https://reviews.llvm.org/D112532
2021-10-26 20:28:16 +01:00
Luke Petre a9db0a804a [AST] Fix the EndLoc calculation for ObjCObjectPointer
There is an issue where the AST code does not compute the correct SourceRange
for a ObjCObjectPointer.

From Richard Smith (ie @zygoloid) in discord:

I think the problem is that we set an invalid location for the * (because there
isn't one): https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaType.cpp#L1121
And then we use the default getLocalSourceRangeImpl for a PointerLikeTypeLoc
that just assumes the * location is the type's end location:
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/TypeLoc.h#L1293
Possibly we should be special-casing that here:
https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/TypeLoc.cpp#L228

My change:

introduces a AST dump test to show the issue in the first commit
special cases ObjCObjectPointerType in the second commit to correctly compute
the end location
2021-10-26 14:03:29 -04:00
Zahira Ammarguellat e84c5419e2 Fix indentation and pragma name. 2021-10-26 13:58:43 -04:00
Balazs Benics c18407217e [analyzer] Fix StringChecker for Unknown params
It seems like protobuf crashed the `std::string` checker.
Somehow it acquired `UnknownVal` as the sole `std::string` constructor
parameter, causing a crash in the `castAs<Loc>()`.

This patch addresses this.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D112551
2021-10-26 18:15:00 +02:00
Florian Hahn 1ef25d28c1
[Clang] Add elementwise min/max builtins.
This patch implements __builtin_elementwise_max and
__builtin_elementwise_min, as specified in D111529.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D111985
2021-10-26 16:53:40 +01:00
Kirill Bobyrev 03506722e0 [clang] Do not traverse EnumDecl's type in RecursiveASTVisitor
This is inconsistent with the code and comments in
RecursiveASTVisitor.h and is not a correct behavior:

https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/RecursiveASTVisitor.h#L1879-L1880

> We shouldn't traverse D->getTypeForDecl(); it's a result of
> declaring the type, not something that was written in the source.

Fixes the failures in 1c2e249f93
2021-10-26 17:17:10 +02:00
Florian Hahn 025988ded6
Specify Clang vector builtins.
This patch specifies a set of vector builtins for Clang, as discussed on
cfe-dev:
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068999.html
https://lists.llvm.org/pipermail/cfe-dev/2021-October/069070.html

Reviewed By: scanon

Differential Revision: https://reviews.llvm.org/D111529
2021-10-26 15:34:31 +01:00
Nico Weber 04f30795f1 [clang] Implement CFG construction for @try and @catch
@finally is still not implemented.

With this, clang can emit -Wreturn-type warnings for functions containing
@try/@catch (but not yet @finally), and -Wunreachable-code also works for those
functions.

The implementation is similar to D36914.

Part of PR46693.

Differential Revision: https://reviews.llvm.org/D112287
2021-10-26 09:45:22 -04:00
Nico Weber 0b7c9addce [clang] Make loop in CFGBuilder::VisitCXXTryStmt() more canonical
No behavior change.
2021-10-26 09:45:22 -04:00
Nico Weber aa42785d01 [clang] Simplify CFG block printing code a bit
No behavior change.
2021-10-26 09:45:22 -04:00
Nico Weber d054b31d59 [clang] Use consistent punctuation at end of Block NULL comment
No behavior change.
2021-10-26 09:45:22 -04:00
Jake Egan 1ff1bcab97 [AIX][ZOS] Disable tests due to lack of Objective-C support
AIX and z/OS lack Objective-C support, so mark these tests as unsupported for AIX and z/OS.

This patch follows the same reasoning as D109060.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D112390
2021-10-25 23:32:13 -04:00
Haowei Wu 07bed3ae52 [clang][Fuchsia] Add additional unit test for availability attr
This change adds additional unit tests for availability attribute
support for Fuchsia platform.

Differential Revision: https://reviews.llvm.org/D112271
2021-10-25 15:40:30 -07:00
Duncan P. N. Exon Smith da47ec3ca0 Basic: Stop using expectedToOptional() in FileManagerTest, NFC
Remove a couple of uses of expectedToOptional() in FileManagerTest,
using Expected<T>::moveInto() to extract the value instead instead.
2021-10-25 13:44:45 -07:00
Wei Wang b283d55c90 [openmp] Emit deferred diag only when device compilation presents
There is no need to check for deferred diag when device compilation or target is
not given. This results in considerable build time improvement in some cases.

Differential Revision: https://reviews.llvm.org/D109175
2021-10-25 11:19:18 -07:00
Mike Rice d8699391a4 [OPENMP51]Initial parsing/sema for append_args clause for 'declare variant'
Adds initial parsing and sema for the 'append_args' clause.

Note that an AST clause is not created as it instead adds its values
to the OMPDeclareVariantAttr.

Differential Revision: https://reviews.llvm.org/D111854
2021-10-25 09:38:50 -07:00
Craig Topper 2e94c2bd75 [RISCV] Remove always_inline and nodebug attributes from RISCV vector intrinsic header.
I don't think these are needed with the way builtin_alias is
implemented.
2021-10-25 09:29:37 -07:00
Kazu Hirata 16ceb44e62 [clang] Use llvm::{count,count_if,find_if,all_of,none_of} (NFC) 2021-10-25 09:14:45 -07:00