Commit Graph

94598 Commits

Author SHA1 Message Date
Balazs Benics 3a7a465def [analyzer][docs] Fix typo in checker name
Fixes #55720
2022-05-27 10:07:06 +02:00
Balazs Benics 3a666dd37a [analyzer][NFC] Use MemRegion::getRegion()'s return value unconditionally
Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126123
2022-05-27 10:07:06 +02:00
Balazs Benics 813acb1297 [analyzer][NFC] Remove unused SVal::hasConjuredSymbol
Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126130
2022-05-27 10:07:06 +02:00
Balazs Benics 81066603a8 [analyzer][NFC] Remove unused nonloc::ConcreteInt::evalBinOp
Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126129
2022-05-27 10:07:06 +02:00
Balazs Benics f6eab43764 [analyzer][NFC] Inline loc::ConcreteInt::evalBinOp
This patch also refactored some of the enclosing parts.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126128
2022-05-27 10:07:06 +02:00
Balazs Benics ee8987d585 [analyzer][NFC] Inline ExprEngine::evalMinus
Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126125
2022-05-27 10:07:06 +02:00
Balazs Benics 7a2d6dea73 [analyzer][NFC] Inline ExprEngine::evalComplement
Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126124
2022-05-27 10:07:06 +02:00
Enna1 52992f136b Add !nosanitize to FixedMetadataKinds
This patch adds !nosanitize metadata to FixedMetadataKinds.def, !nosanitize indicates that LLVM should not insert any sanitizer instrumentation.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D126294
2022-05-27 09:46:13 +08:00
Argyrios Kyrtzidis edcd06ba8b [test/ClangScanDeps] Add a target triple for `macro-expansions.cpp`
This should fix the `clang-ppc64-aix` builder.
2022-05-26 17:18:32 -07:00
Fangrui Song 056dec5dc8 [Driver][test] Change -target i386-unknown-linux-gnu to --target=i386 and remove unused -o %t.o
Use a generic ELF triple to demonstrate that these apply to all ELF OSes.
Also migrate away from the legacy `-target ` spelling.
2022-05-26 14:41:04 -07:00
owenca 5bf44aa434 [clang-format][NFC] Refactor UnwrappedLineParser::parseBlock()
Differential Revision: https://reviews.llvm.org/D126358
2022-05-26 13:56:47 -07:00
owenca 5221875a95 [clang-format] Fix an invalid code generation in RemoveBracesLLVM
Fixes #55706.

Differential Revision: https://reviews.llvm.org/D126438
2022-05-26 13:38:04 -07:00
Argyrios Kyrtzidis b4c83a13f6 [Tooling/DependencyScanning & Preprocessor] Refactor dependency scanning to produce pre-lexed preprocessor directive tokens, instead of minimized sources
This is a commit with the following changes:

* Remove `ExcludedPreprocessorDirectiveSkipMapping` and related functionality

Removes `ExcludedPreprocessorDirectiveSkipMapping`; its intended benefit for fast skipping of excluded directived blocks
will be superseded by a follow-up patch in the series that will use dependency scanning lexing for the same purpose.

* Refactor dependency scanning to produce pre-lexed preprocessor directive tokens, instead of minimized sources

Replaces the "source minimization" mechanism with a mechanism that produces lexed dependency directives tokens.

* Make the special lexing for dependency scanning a first-class feature of the `Preprocessor` and `Lexer`

This is bringing the following benefits:

    * Full access to the preprocessor state during dependency scanning. E.g. a component can see what includes were taken and where they were located in the actual sources.
    * Improved performance for dependency scanning. Measurements with a release+thin-LTO build shows ~ -11% reduction in wall time.
    * Opportunity to use dependency scanning lexing to speed-up skipping of excluded conditional blocks during normal preprocessing (as follow-up, not part of this patch).

For normal preprocessing measurements show differences are below the noise level.

Since, after this change, we don't minimize sources and pass them in place of the real sources, `DependencyScanningFilesystem` is not technically necessary, but it has valuable performance benefits for caching file `stat`s along with the results of scanning the sources. So the setup of using the `DependencyScanningFilesystem` during a dependency scan remains.

Differential Revision: https://reviews.llvm.org/D125486
Differential Revision: https://reviews.llvm.org/D125487
Differential Revision: https://reviews.llvm.org/D125488
2022-05-26 12:50:06 -07:00
Argyrios Kyrtzidis b58a420ff4 [Tooling/DependencyScanning] Rename refactorings towards transitioning dependency scanning to use pre-lexed preprocessor directive tokens
This is first of a series of patches for making the special lexing for dependency scanning a first-class feature of the `Preprocessor` and `Lexer`.
This patch only includes NFC renaming changes to make reviewing of the functionality changing parts easier.

Differential Revision: https://reviews.llvm.org/D125484
2022-05-26 12:49:51 -07:00
Joel E. Denny 48ca3a5ebb [OpenMP] Extend omp teams to permit nested omp atomic
OpenMP 5.2, sec. 10.2 "teams Construct", p. 232, L9-12 restricts what
regions can be strictly nested within a `teams` construct.  This patch
relaxes Clang's enforcement of this restriction in the case of nested
`atomic` constructs unless `-fno-openmp-extensions` is specified.
Cases like the following then seem to work fine with no additional
implementation changes:

```
 #pragma omp target teams map(tofrom:x)
 #pragma omp atomic update
 x++;
```

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D126323
2022-05-26 14:59:16 -04:00
Aaron Ballman 6273b5cbcd Roll back use of #warning for header deprecations
e5ccd66801 and
5029dce492 added deprecation warnings to
the <stdbool.h> and <stdnoreturn.h> headers, respectively, because the
headers are deprecated in C2x.

However, there are system headers that include these headers
unconditionally, and #warning diagnostics within system headers are
shown to users instead of suppressed, which means these deprecation
warnings are being triggered in circumstances that users have no
control over except to disable all the warnings through the
_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS macro or other means.

This removes the problematic #warning uses until we find a more
palatable solution.
2022-05-26 14:51:39 -04:00
Bruno Cardoso Lopes ce54b22657 [Clang][CoverageMapping] Fix switch counter codegen compile time explosion
C++ generated code with huge amount of switch cases chokes badly while emitting
coverage mapping, in our specific testcase (~72k cases), it won't stop after hours.
After this change, the frontend job now finishes in 4.5s and shrinks down `@__covrec_`
by 288k when compared to disabling simplification altogether.

There's probably no good way to create a testcase for this, but it's easy to
reproduce, just add thousands of cases in the below switch, and build with
`-fprofile-instr-generate -fcoverage-mapping`.

```
enum type : int {
 FEATURE_INVALID = 0,
 FEATURE_A = 1,
 ...
};

const char *to_string(type e) {
  switch (e) {
  case type::FEATURE_INVALID: return "FEATURE_INVALID";
  case type::FEATURE_A: return "FEATURE_A";}
  ...
  }

```

Differential Revision: https://reviews.llvm.org/D126345
2022-05-26 11:05:15 -07:00
Mike Rice 0a5cfbf7b2 [OpenMP] Use the align clause value from 'omp allocate' for globals
Refactor the code that handles the align clause of 'omp allocate' so
it can be used with globals as well as local variables.

Differential Revision: https://reviews.llvm.org/D126426
2022-05-26 09:51:48 -07:00
Anastasia Stulova 3087afb421 [OpenCL][Doc] Misc improvements related to SPIR-V support. 2022-05-26 15:54:33 +01:00
Paul Robinson 634c8ef69a [PS5] Allow dllimport/dllexport same as PS4 2022-05-26 07:01:30 -07:00
Tyler Chatow 8f70d16c9a [clang-format] Handle attributes in enum declaration.
Fixes https://github.com/llvm/llvm-project/issues/55457

Ensures that attributes in the enum declaration are interpreted
correctly, for instance:

```
enum class [[nodiscard]] E {
  a,
  b
};
```

Reviewed By: MyDeveloperDay, curdeius

Differential Revision: https://reviews.llvm.org/D125848
2022-05-26 15:43:57 +02:00
Nathan Sidwell 6b8c6f15fd [clang][PR55406] CFG for coroutine
CoreturnStmt needs to keep the operand value distinct from its use in
any return_value call, so that instantiation may rebuild the latter.
But it also needs to keep the operand value separate in the case of
calling return_void.  Code generation checks the operand value form to
determine whether it is a distincte entity to the promise call.  This
adds the same logic to CFG generation.

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D126399
2022-05-26 06:40:43 -07:00
Joseph Huber 1bae02b773 [Cuda] Use fallback method to mangle externalized decls if no CUID given
CUDA requires that static variables be visible to the host when
offloading. However, The standard semantics of a stiatc variable dictate
that it should not be visible outside of the current file. In order to
access it from the host we need to perform "externalization" on the
static variable on the device. This requires generating a semi-unique
name that can be affixed to the variable as to not cause linker errors.

This is currently done using the CUID functionality, an MD5 hash value
set up by the clang driver. This allows us to achieve is mostly unique
ID that is unique even between multiple compilations of the same file.
However, this is not always availible. Instead, this patch uses the
unique ID from the file to generate a unique symbol name. This will
create a unique name that is consistent between the host and device side
compilations without requiring the CUID to be entered by the driver. The
one downside to this is that we are no longer stable under multiple
compilations of the same file. However, this is a very niche use-case
and is not supported by Nvidia's CUDA compiler so it likely to be good
enough.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D125904
2022-05-26 09:18:22 -04:00
Marek Kurdej d4d28f2ace [clang-format] Fix QualifierAlignment with global namespace qualified types.
Fixes https://github.com/llvm/llvm-project/issues/55610.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D126096
2022-05-26 15:02:33 +02:00
Aaron Ballman 605651135b Fix failing test case with strict prototype changes
Amends 681c50c62e and hopefully fixes:

https://lab.llvm.org/buildbot/#/builders/109/builds/39347
https://lab.llvm.org/buildbot/#/builders/188/builds/14634
and others
2022-05-26 08:46:11 -04:00
Aaron Ballman 681c50c62e Improve the strict prototype diagnostic behavior
Post-commit feedback on https://reviews.llvm.org/D122895 pointed out
that the diagnostic wording for some code was using "declaration" in a
confusing way, such as:

int foo(); // warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x

int foo(int arg) { // warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x
  return 5;
}

And that we had other minor issues with the diagnostics being somewhat
confusing.

This patch addresses the confusion by reworking the implementation to
be a bit more simple and a bit less chatty. Specifically, it changes
the warning and note diagnostics to be able to specify "declaration" or
"definition" as appropriate, and it changes the function merging logic
so that the function without a prototype is always what gets warned on,
and the function with a prototype is sometimes what gets noted.
Additionally, when diagnosing a K&R C definition that is preceded by a
function without a prototype, we don't note the prior declaration, we
warn on it because it will also be changing behavior in C2x.

Differential Revision: https://reviews.llvm.org/D125814
2022-05-26 08:35:56 -04:00
Gabor Marton cd5783d3e8 [analyzer][solver] Handle UnarySymExpr in SMTConv
Dependent patch adds UnarySymExpr, now I'd like to handle that for SMT
conversions like refutation.

Differential Revision: https://reviews.llvm.org/D125547
2022-05-26 14:14:10 +02:00
Gabor Marton 88abc50398 [analyzer][solver] Handle UnarySymExpr in RangeConstraintSolver
Fixes https://github.com/llvm/llvm-project/issues/55241

Differential Revision: https://reviews.llvm.org/D125395
2022-05-26 14:09:46 +02:00
Gabor Marton b5b2aec1ff [analyzer] Add UnarySymExpr
This patch adds a new descendant to the SymExpr hierarchy. This way, now
we can assign constraints to symbolic unary expressions. Only the unary
minus and bitwise negation are handled.

Differential Revision: https://reviews.llvm.org/D125318
2022-05-26 14:00:27 +02:00
Gabor Marton ca3d962548 [analyzer] Return from reAssume if State is posteriorly overconstrained
Depends on D124758. That patch introduced serious regression in the run-time in
some special cases. This fixes that.

Differential Revision: https://reviews.llvm.org/D126406
2022-05-26 13:50:40 +02:00
Aaron Ballman 85750de685 Use the canonical type when matching a generic selection association
This ensures that a deduced type like __auto_type matches the correct
association instead of matching all associations.

This addresses a regression from e4a42c5b64

Fixes #55702
2022-05-26 07:42:13 -04:00
Ivan Kosarev ad1d60c3be [FileCheck] Catch missspelled directives.
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D125604
2022-05-26 11:37:19 +01:00
Eric Li 5520c58390 [clang][dataflow] Fix incorrect CXXThisExpr pointee for lambdas
When constructing the `Environment`, the `this` pointee is established
for a `CXXMethodDecl` by looking at its parent. However, inside of
lambdas, a `CXXThisExpr` refers to the captured `this` coming from the
enclosing member function.

When establishing the `this` pointee for a function, we check whether
the function is a lambda, and check for an enclosing member function
to establish the `this` pointee storage location.

Differential Revision: https://reviews.llvm.org/D126413
2022-05-25 20:58:02 +00:00
Eric Li 33b598a808 [clang][dataflow] Relax assert on existence of `this` pointee storage
Support for unions is incomplete (per 99f7d55e) and the `this` pointee
storage location is not set for unions. The assert in
`VisitCXXThisExpr` is then guaranteed to trigger when analyzing member
functions of a union.

This commit changes the assert to an early-return. Any expression may
be undefined, and so having a value for the `CXXThisExpr` is not a
postcondition of the transfer function.

Differential Revision: https://reviews.llvm.org/D126405
2022-05-25 20:58:02 +00:00
Joseph Huber b7c8c4d8cf [Clang] Introduce `--offload-link` option to perform offload device linking
The new driver uses an augmented linker wrapper to perform the device
linking phase, but to the user looks like a regular linker invocation.
Contrary to the old driver, the new driver contains all the information
necessary to produce a linked device image in the host object itself.
Currently, we infer the usage of the device linker by the user
specifying an offloading toolchain, e.g. (--offload-arch=...) or
(-fopenmp-targets=...), but this shouldn't be strictly necessary.
This patch introduces a new option `--offload-link` to tell
 the driver to use the offloading linker instead. So a compilation flow
 can now look like this,

```
clang foo.cu --offload-new-driver -fgpu-rdc --offload-arch=sm_70 -c
clang foo.o --offload-link -lcudart
```

I was considering if this could be merged into the `-fuse-ld` option,
but because the device linker wraps over the users linker it would
conflict with that. In the future it's possible to merge this into `lld`
completely or `gold` via a plugin and we would use this option to
enable the device linking feature. Let me know what you think for this.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D126398
2022-05-25 16:30:53 -04:00
Alex Lorenz 79e09af1d6 [clang] Fix the begin location of concepts specialization expression
The concept specialization expression should start at the location of
the  nested qualifiers when it has nested qualifiers.
This ensures that libclang reports correct source ranges that include
all subexpressions when visiting the expression.

Differential Revision: https://reviews.llvm.org/D126332
2022-05-25 12:39:21 -07:00
Christian Sigg c4bc416418 [LLVM] Add rcp.approx.ftz.f32 intrinsic
Split out from https://reviews.llvm.org/D126158.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D126369
2022-05-25 21:05:20 +02:00
James Y Knight 997b072e10 C++ DR2394: Const-default-constructible for members.
Const class members may be initialized with a defaulted default
constructor under the same conditions it would be allowed for a const
object elsewhere.

Differential Revision: https://reviews.llvm.org/D126170
2022-05-25 14:20:11 -04:00
Daniel Grumberg 504736cedf [clang][extract-api] Don't emit symbols prefixed with an underscore
These symbols are understood to not be used for client API consumption
by convention so they should not appear in the generated symbol graph.

Differential Revision: https://reviews.llvm.org/D125678
2022-05-25 19:02:18 +01:00
Aaron Ballman 9368bf9023 Removing this as part of the revert done in 69da3b6aea
This appears to have been added in a follow-up commit that I missed.
2022-05-25 13:45:17 -04:00
Aaron Ballman 69da3b6aea Revert "[OpenMP] atomic compare fail : Parser & AST support"
This reverts commit 232bf8189e.

It broke the sanitize buildbot: https://lab.llvm.org/buildbot/#/builders/5/builds/24074

It also reproduces on Windows debug builds as a crash.
2022-05-25 13:34:34 -04:00
Mike Rice ba3f85390b [OpenMP] Add diagnostic for unterminated 'omp [begin] declare target'
Warns when end-of-file is reached without seeing all matching
'omp end declare target' directives. The diagnostic shows the
location of the related begin directive.

Differential Revision: https://reviews.llvm.org/D126331
2022-05-25 10:34:07 -07:00
Joseph Huber 8a1984c25e [Clang][Docs] Document `-Xoffload-linker` flag
Summary:
I added the `-Xoffload-linker` flag and did not provide additional
documentation. This patch adds it.
2022-05-25 13:33:10 -04:00
Martin Boehme 6f4644d194 [clang] Don't parse MS attributes in `ParseExportDeclaration()`.
As @rsmith commented on https://reviews.llvm.org/D111548: "That looks like it's
simply a bug as far as I can tell, and that call can be removed. MS attributes
will be parsed as part of the decl specifier sequence as needed and don't need
to be parsed as declaration attributes."

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D126062
2022-05-25 17:15:41 +02:00
Paul Robinson d8dda57ae7 [PS5] Default to -fno-rtti 2022-05-25 06:48:21 -07:00
Haojian Wu a17fc7fd86 Fix unused-variable warning, NFC. 2022-05-25 15:25:03 +02:00
Haojian Wu c673d67bc7 [AST] Dont invalidate a ref-type var decl if it has no initializer.
This would allow more AST nodes being preserved for broken code, and
have a more consistent valid bit for ref-type var decl (currently, a
ref-type var decl with a broken initializer is valid).

Per https://reviews.llvm.org/D76831#1973053, the initializer of a variable
should play no part in its "invalid" bit.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D122935
2022-05-25 15:14:35 +02:00
Aaron Ballman f96aa834d7 Test C DR conformance (part three of many)
This adds more of the tests for the first 100 DRs in C and updates
their status on the status page.
2022-05-25 08:18:16 -04:00
Anastasia Stulova 730dc4e9bc [Clang] Added options for integrated backend.
Following the new flow for external object code emission,
provide flags to switch between integrated and external
backend similar to the integrated assembler options.

SPIR-V target is the only user of this functionality at
this point.

This patch also updated SPIR-V documentation to clarify
that integrated object code emission for SPIR-V is an
experimental feature.

Differential Revision: https://reviews.llvm.org/D125679
2022-05-25 12:07:33 +01:00
Sven van Haastregt 0d7f8d42fd [OpenCL] Remove argument names from async copy builtins
This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" the argument name identifiers.

Continues the direction set out in D119560.
2022-05-25 10:05:25 +01:00