Commit Graph

93521 Commits

Author SHA1 Message Date
Evgenii Stepanov c5ea8e9138 Use-after-dtor detection for trivial base classes.
-fsanitize-memory-use-after-dtor detects memory access after a
subobject is destroyed but its memory is not yet deallocated.
This is done by poisoning each object memory near the end of its destructor.

Subobjects (members and base classes) do this in their respective
destructors, and the parent class does the same for its members with
trivial destructors.

Inexplicably, base classes with trivial destructors are not handled at
all. This change fixes this oversight by adding the base class poisoning logic
to the parent class destructor.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D119300
2022-03-16 18:20:27 -07:00
Evgeny Shulgin 3587b15abe [Clang] [P2025] More exhaustive tests for NRVO
This is a preliminary patch ahead of D119792 (I'll rebase that one on top of this).
This shows what Clang's _current_ behaviour is for calculating NRVO in various
common cases. Then, in D119792 (and future patches), I'll be able to demostrate
exactly how LLVM IR for each of these cases changes.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D119927
2022-03-17 03:58:40 +03:00
Zixu Wang 3840082ab5 [FIX][NFC] Fix a test case in clang/SymbolGraph
The clang/SymbolGraph/global_record.c test case explicitly diffs the
clang version in use, which causes failures. Fix the issue by normalize
the `generator` field before checking the output.
2022-03-16 17:19:35 -07:00
Eli Friedman 04ba344176 [CodeGen] Inline _byteswap_* builtins.
As discussed in D57915.

Fixes https://github.com/llvm/llvm-project/issues/39999 .

Differential Revision: https://reviews.llvm.org/D121865
2022-03-16 16:18:51 -07:00
Zixu Wang fa331da8fb [FIX][clang-extract-api] Fix scope naming violation 2022-03-16 16:04:44 -07:00
Johannes Doerfert a597d6a780 Revert "[OpenMP][FIX] Allow device constructors for AMD GPU"
This reverts commit 07b1766461 as it broke
the buildbots:
    https://lab.llvm.org/buildbot#builders/193/builds/8594
2022-03-16 17:35:54 -05:00
Zixu Wang 5aab45f430 [clang][extract-api] Add global record support
Add facilities for extract-api:
- Structs/classes to hold collected API information: `APIRecord`, `API`
- Structs/classes for API information:
  - `AvailabilityInfo`: aggregated availbility information
  - `DeclarationFragments`: declaration fragments
    - `DeclarationFragmentsBuilder`: helper class to build declaration
      fragments for various types/declarations
  - `FunctionSignature`: function signature
- Serialization: `Serializer`
- Add output file for `ExtractAPIAction`
- Refactor `clang::RawComment::getFormattedText` to provide an
  additional `getFormattedLines` for a more detailed view of comment lines
  used for the SymbolGraph format

Add support for global records (global variables and functions)
- Add `GlobalRecord` based on `APIRecord` to store global records'
  information
- Implement `VisitVarDecl` and `VisitFunctionDecl` in `ExtractAPIVisitor` to
  collect information
- Implement serialization for global records
- Add test case for global records

Differential Revision: https://reviews.llvm.org/D119479
2022-03-16 15:13:55 -07:00
Johannes Doerfert 07b1766461 [OpenMP][FIX] Allow device constructors for AMD GPU
In AMD GPU device code the globals are in AS(1). Before, we crashed if
the global was a structure. Now we simply cast away the AS before we
generate the code to initialize the global.

Differential Revision: https://reviews.llvm.org/D121837
2022-03-16 17:04:28 -05:00
Mike Rice 79f661edc1 [OpenMP] Initial parsing/sema for the 'omp teams loop' construct
Adds basic parsing/sema/serialization support for the #pragma omp teams loop
directive.

Differential Revision: https://reviews.llvm.org/D121713
2022-03-16 14:39:18 -07:00
Arthur Eubanks 2371c5a0e0 [OpaquePtr][ARM] Use elementtype on ldrex/ldaex/stlex/strex
Includes verifier changes checking the elementtype, clang codegen
changes to emit the elementtype, and ISel changes using the elementtype.

Basically the same as D120527.

Reviewed By: #opaque-pointers, nikic

Differential Revision: https://reviews.llvm.org/D121847
2022-03-16 14:11:53 -07:00
Marek Kurdej dbefb7e86f [clang-format] Reformat. NFC. 2022-03-16 21:54:11 +01:00
Thomas Lively 7e8913d775 [WebAssembly] Fix names of SIMD instructions containing '_zero'
Fix the instruction names to match the WebAssembly spec:

 - `i32x4.trunc_sat_zero_f64x2_{s,u}` => `i32x4.trunc_sat_f64x2_{s,u}_zero`
 - `f32x4.demote_zero_f64x2` => `f32x4.demote_f64x2_zero`

Also rename related things like intrinsics, builtins, and test functions to
match.

Reviewed By: aheejin

Differential Revision: https://reviews.llvm.org/D121661
2022-03-16 13:34:57 -07:00
Yitzhak Mandelbaum e0aefb4f92 [clang][dataflow] Add an API for dataflow "models" -- reusable analysis components.
This patch introduces `DataflowModel`, an abstract base class for dataflow
"models": reusable analysis components that model a particular aspect of program
semantics.

Differential Revision: https://reviews.llvm.org/D121796
2022-03-16 19:47:57 +00:00
Petr Hosek 67f53708b2 Revert "[CMake][Fuchsia] Use correct architecture for iossim"
This reverts commit 1b6ff3f4f8 since
it broke Fuchsia's macOS builders.
2022-03-16 10:10:15 -07:00
David Truby d38c9d3834 [NFC][clang][SVE] Auto-generate SVE operator tests. 2022-03-16 16:39:27 +00:00
Yonghong Song 3251ba2d0f [Attr] Fix a btf_type_tag AST generation
Current ASTContext.getAttributedType() takes attribute kind,
ModifiedType and EquivType as the hash to decide whether an AST node
has been generated or note. But this is not enough for btf_type_tag
as the attribute might have the same ModifiedType and EquivType, but
still have different string associated with attribute.

For example, for a data structure like below,
  struct map_value {
        int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *a;
        int __attribute__((btf_type_tag("tag2"))) __attribute__((btf_type_tag("tag4"))) *b;
  };
The current ASTContext.getAttributedType() will produce
an AST similar to below:
  struct map_value {
        int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *a;
        int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *b;
  };
and this is incorrect.

It is very difficult to use the current AttributedType as it is hard to
get the tag information. To fix the problem, this patch introduced
BTFTagAttributedType which is similar to AttributedType
in many ways but with an additional BTFTypeTagAttr. The tag itself can
be retrieved with BTFTypeTagAttr.
With the new BTFTagAttributed type, the debuginfo code can be greatly
simplified compared to previous TypeLoc based approach.

Differential Revision: https://reviews.llvm.org/D120296
2022-03-16 08:46:52 -07:00
Kazushi (Jam) Marukawa c2f62ab84b [Clang][VE] Add the rest of intrinsics to clang
Add the rest of intrinsics to clang except intrinsics using vector mask
registers.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D121586
2022-03-17 00:17:21 +09:00
Zhouyi Zhou 30adb9fd27 let EST_Uninstantiated in FunctionProtoType::canThrow return
CT_Dependent

When compile following code without -std=c++17, clang will abort by
llvm_unreachable:

class A {
  public:

  static const char X;

};
const char A::X = 0;

template<typename U> void func() noexcept(U::X);

template<class... B, char x>
void foo(void(B...) noexcept(x)) {}

void bar()
{

  foo(func<A>);

}

So, my solution is to let EST_Uninstantiated in
FunctionProtoType::canThrow return CT_Dependent

Differential Revision: https://reviews.llvm.org/D121498
2022-03-16 07:09:42 -07:00
Jan Svoboda f9096b89dd [clang][deps] NFC: Align path separator conversion in tests
This is the only test in the ClangScanDeps suite that doesn't convert (double) backslashes to forward slashes.
2022-03-16 13:40:09 +01:00
Jan Svoboda 85db3a27cf [clang][deps] Attempt to fix test on Windows
This test fails on Windows due to path separators
2022-03-16 13:36:32 +01:00
Jan Svoboda 1e25ff84d8 [clang][deps] Fix traversal of precompiled dependencies
The code for traversing precompiled dependencies is somewhat complicated and contains a dangling iterator bug.

This patch simplifies the code and fixes the bug.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D121533
2022-03-16 12:17:53 +01:00
Jan Svoboda d73daa9135 [clang][deps] Don't prune search paths used by dependencies
When pruning header search paths (to reduce the number of modules we need to build explicitly), we can't prune the search paths used in (transitive) dependencies of a module. Otherwise, we could end up with either of the following dependency graphs:

```
X:<hash1> -> Y:<hash2>
X:<hash1> -> Y:<hash3>
```

depending on the search paths of the translation unit we discovered `X` and `Y` from.

This patch fixes that.

Depends on D121295.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D121303
2022-03-16 12:17:53 +01:00
Jan Svoboda 6007b0b67b [clang][deps] NFC: Use range-based for loop instead of iterators
The iterator is not needed after the loop body anymore, meaning we can use more terse range-based for loop.

Depends on D121295.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D121685
2022-03-16 12:17:53 +01:00
Jan Svoboda 77924d60ef [clang][deps] Modules don't contribute to search path usage
To reduce the number of modules we build in explicit builds (which use strict context hash), we prune unused header search paths. This essentially merges parts of the dependency graph.

Determining whether a search path was used to discover a module (through implicit module maps) proved to be somewhat complicated. Initial support landed in D102923, while D113676 attempts to fix some bugs.

However, now that we don't use implicit module maps in explicit builds (since D120465), we don't need to consider such search paths as used anymore. Modules are no longer discovered through the header search mechanism, so we can drop such search paths (provided they are not needed for other reasons).

This patch removes whatever support for detecting such usage we had, since it's buggy and not required anymore.

Depends on D120465.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D121295
2022-03-16 12:17:52 +01:00
Andrzej Warzynski a7c08bcf77 [flang][driver] Add support for `-mllvm`
This option is added in both `flang-new` (the compiler driver) and
`flang-new -fc1` (the frontend driver). The semantics are consistent
with `clang` and `clang -cc1`.

As Flang does not run any LLVM passes when invoked with `-emit-llvm`
(i.e. `flang-new -S -emit-llvm <file>`), the tests use
`-S`/`-c`/`-emit-obj` instead. These options require an LLVM backend to
be run by the driver to generate the output (this makese `-mllvm`
relevant here).

Differential Revision: https://reviews.llvm.org/D121374
2022-03-16 10:41:04 +00:00
Simon Moll 0aab344104 [Clang] Allow "ext_vector_type" applied to Booleans
This is the `ext_vector_type` alternative to D81083.

This patch extends Clang to allow 'bool' as a valid vector element type
(attribute ext_vector_type) in C/C++.

This is intended as the canonical type for SIMD masks and facilitates
clean vector intrinsic declarations.  Vectors of i1 are supported on IR
level and below down to many SIMD ISAs, such as AVX512, ARM SVE (fixed
vector length) and the VE target (NEC SX-Aurora TSUBASA).

The RFC on cfe-dev: https://lists.llvm.org/pipermail/cfe-dev/2020-May/065434.html

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D88905
2022-03-16 11:10:32 +01:00
Sam McCall 75acad41bc Use lit_config.substitute instead of foo % lit_config.params everywhere
This mechanically applies the same changes from D121427 everywhere.

Differential Revision: https://reviews.llvm.org/D121746
2022-03-16 09:57:41 +01:00
Owen Pan 7fb2d9f9b5 [clang-format] Fix crashes due to missing l_paren
Fixes #54384.

Differential Revision: https://reviews.llvm.org/D121682
2022-03-16 01:45:20 -07:00
Vlad Serebrennikov a603f566db [clang] CWG 2354: prohibit alignas for enums
Reviewed By: aaron.ballman, erichkeane

Differential Revision: https://reviews.llvm.org/D121723
2022-03-16 15:48:18 +08:00
Sam McCall 89cd86bbc5 Reapply [pseudo] Move pseudoparser from clang to clang-tools-extra"
This reverts commit 049f4e4eab.

The problem was a stray dependency in CLANG_TEST_DEPS which caused cmake
to fail if clang-pseudo wasn't built. This is now removed.
2022-03-16 01:10:55 +01:00
Sam McCall 049f4e4eab Revert "[pseudo] Move pseudoparser from clang to clang-tools-extra"
This reverts commit b97856c4cf.

Breaks a bunch of bots:
https://lab.llvm.org/buildbot/#/builders/193/builds/8513
2022-03-16 01:06:24 +01:00
Sam McCall b97856c4cf [pseudo] Move pseudoparser from clang to clang-tools-extra
This should make clearer that:
 - it's not part of clang proper
 - there's no expectation to update it along with clang (beyond green tests)
 - clang should not depend on it

This is intended to be expose a library, so unlike other tools has a split
between include/ and lib/.

The main renames are:
  clang/lib/Tooling/Syntax/Pseudo/*           => clang-tools-extra/pseudo/lib/*
  clang/include/clang/Tooling/Syntax/Pseudo/* => clang-tools-extra/pseudo/include/clang-pseudo/*
  clang/tools/clang/pseudo/*                  => clang-tools-extra/pseudo/tool/*
  clang/test/Syntax/*                         => clang-tools-extra/pseudo/test/*
  clang/unittests/Tooling/Syntax/Pseudo/*     => clang-tools-extra/pseudo/unittests/*
  #include "clang/Tooling/Syntax/Pseudo/*"    => #include "clang-pseudo/*"
  namespace clang::syntax::pseudo             => namespace clang::pseudo
  check-clang                                 => check-clang-pseudo
  clangToolingSyntaxPseudo                    => clangPseudo
The clang-pseudo and ClangPseudoTests binaries are not renamed.

See discussion around:
https://discourse.llvm.org/t/rfc-a-c-pseudo-parser-for-tooling/59217/50

Differential Revision: https://reviews.llvm.org/D121233
2022-03-16 00:14:11 +01:00
Aleksandr Platonov 1bb13b3f49 Fix sphinx build because of indentation 2022-03-16 00:11:56 +03:00
Keith Smiley a2db7d5e9c reland: [clang] Don't append the working directory to absolute paths
This fixes a bug that happens when using -fdebug-prefix-map to remap an
absolute path to a relative path. Since the path was absolute before
remapping, it is safe to assume that concatenating the remapped working
directory would be wrong.

This was originally submitted as https://reviews.llvm.org/D113718, but
reverted because when testing with dwarf 5 enabled, the tests were too
strict.

Differential Revision: https://reviews.llvm.org/D121663
2022-03-15 13:42:35 -07:00
Björn Schäpers 1db8112311 [clang-format] Fix crash with ObjC Blocks
Fixes https://github.com/llvm/llvm-project/issues/54367
Fixes https://github.com/llvm/llvm-project/issues/54368

Differential Revision: https://reviews.llvm.org/D121596
2022-03-15 21:41:57 +01:00
Roy Jacobson bc7034c1ec [Concepts] Fix an assertion failure while diagnosing constrained
function candidates

See: https://github.com/llvm/llvm-project/issues/54379

I tried to see if I can reuse ResolveAddressOfOverloadedFunction for
explicit function instantiation and so I managed to hit this ICE.

Bug was the diagnostic required an argument (%0) and specific code path
didn't pass an argument.

Differential Revision: https://reviews.llvm.org/D121646
2022-03-15 13:11:32 -07:00
Aleksandr Platonov 8bd00557e3 [clang][parser] Allow GNU attributes before namespace identifier
GCC supports:
- `namespace <gnu attributes> identifier`
- `namespace identifier <gnu attributes>`

But clang supports only `namespace identifier <gnu attributes>` and diagnostics for `namespace <gnu attributes> identifier` case looks unclear:
Code:
```
namespace __attribute__((visibility("hidden"))) A
{
}
```
Diags:
```
test.cpp:1:49: error: expected identifier or '{'
namespace __attribute__((visibility("hidden"))) A
                                                ^
test.cpp:1:49: error: C++ requires a type specifier for all declarations
test.cpp:3:2: error: expected ';' after top level declarator
}
```

This patch adds support for `namespace <gnu attributes> identifier` and also forbids gnu attributes for nested namespaces (this already done for C++ attributes).

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121245
2022-03-15 22:30:22 +03:00
Jake Egan d1873d395d [NFC][AIX] Disable precompiled module file test on AIX
This patch follows the same reasoning as D114481. The PCH reader looks for `__clangast` section in the precompiled module file, which is not present in the file on AIX and not supported in XCOFF yet.

Reviewed By: daltenty

Differential Revision: https://reviews.llvm.org/D121709
2022-03-15 15:16:15 -04:00
Eli Friedman 5791e28f30 Complete the list of single-underscore keywords for MSVC compat.
List derived from https://docs.microsoft.com/en-us/cpp/cpp/keywords-cpp
. Not that this is something we really want to encourage, but some of
these show up in practice, so I figured I should just complete the list.

Differential Revision: https://reviews.llvm.org/D121412
2022-03-15 11:58:40 -07:00
Yi Kong ba59476515 Revert "[clang][driver] Emit a warning if -xc/-xc++ is after the last input file"
This reverts commit 1c1a4b9556.

Some builders failed.
2022-03-16 01:17:17 +08:00
Yi Kong 1c1a4b9556 [clang][driver] Emit a warning if -xc/-xc++ is after the last input file
This follows the same warning GCC produces.

Differential Revision: https://reviews.llvm.org/D121683
2022-03-16 01:08:00 +08:00
Yitzhak Mandelbaum 4633c02eb0 [clang][dataflow] Allow disabling built-in transfer functions for CFG terminators
Terminators are handled specially in the transfer functions so we need an
additional check on whether the analysis has disabled built-in transfer
functions.

Differential Revision: https://reviews.llvm.org/D121694
2022-03-15 15:10:32 +00:00
Ties Stuij 352453569b [AARCH64] ssbs should be enabled by default for cortex-x1, cortex-x1c, cortex-a77
Reviewed By: amilendra

Differential Revision: https://reviews.llvm.org/D121206
2022-03-15 13:44:20 +00:00
Simon Pilgrim 7262eacd41 Revert rG9c542a5a4e1ba36c24e48185712779df52b7f7a6 "Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO"
Mane of the build bots are complaining: Unknown command line argument '-lower-global-dtors'
2022-03-15 13:01:35 +00:00
Marek Kurdej 3227aa3aa8 [clang-format] Correctly format variable templates.
Fixes https://github.com/llvm/llvm-project/issues/54257.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121456
2022-03-15 13:16:56 +01:00
Marek Kurdej e60defb931 [clang-format] Add regression tests for function ref qualifiers on operator definition. NFC.
Fixes https://github.com/llvm/llvm-project/issues/54374.
2022-03-15 12:58:08 +01:00
Marek Kurdej 126b37a713 [clang-format] Correctly recognize arrays in template parameter list.
Fixes https://github.com/llvm/llvm-project/issues/54245.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121584
2022-03-15 11:33:13 +01:00
Stanislav Gatev 092a530ca1 [clang][dataflow] Model the behavior of non-standard optional constructors
Model nullopt, inplace, value, and conversion constructors.

Reviewed-by: ymandel, xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D121602
2022-03-15 08:13:13 +00:00
Keith Smiley cb22d71806 [clang] Fix DIFile directory root on Windows
On unix systems this logic would not separate the file and directory of
the DIFile unless they shared more components at the start than just the
root path character. The logic to do this was unix specific so it didn't
work on Windows. Now we check if the entire root_path is the same as
what you were going to set as the Dir and use the full filepath in that
case.

Differential Revision: https://reviews.llvm.org/D111579
2022-03-14 20:07:01 -07:00
Petr Hosek 1b6ff3f4f8 [CMake][Fuchsia] Use correct architecture for iossim
We should be building iossim for x86_64, not arm64.

Differential Revision: https://reviews.llvm.org/D121659
2022-03-14 19:21:09 -07:00
Owen Pan 0a0cc3c58a [clang-format] Don't unwrap lines preceded by line comments
Fixes #53495

Differential Revision: https://reviews.llvm.org/D121576
2022-03-14 19:16:29 -07:00
Joseph Huber f1388b616a [OpenMP][Fix] Fix test failing after patch 2022-03-14 21:51:38 -04:00
Joseph Huber 670438e55d [OpenMP][Fix] Add offloading kind to AMDGPU libraries
Summary:
A previous patch added the offloading kind to the triple format we used.
I forgot to update the line where we add the AMDGPU libraries.
2022-03-14 21:18:19 -04:00
Julian Lettner 9c542a5a4e Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO
For MachO, lower `@llvm.global_dtors` into `@llvm_global_ctors` with
`__cxa_atexit` calls to avoid emitting the deprecated `__mod_term_func`.

Reuse the existing `WebAssemblyLowerGlobalDtors.cpp` to accomplish this.

Enable fallback to the old behavior via Clang driver flag
(`-fregister-global-dtors-with-atexit`) or llc / code generation flag
(`-lower-global-dtors-via-cxa-atexit`).  This escape hatch will be
removed in the future.

Differential Revision: https://reviews.llvm.org/D121327
2022-03-14 17:51:18 -07:00
Joseph Huber 23d885b3a2 [OpenMP][NFC] Refactor new driver to be more general
This path refactors the new driver to be less dependent on OpenMP. This
is done in preparation for the new driver to be able to handle other
offloading kinds and compile them together.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D120934
2022-03-14 20:08:29 -04:00
Joseph Huber 9f89769cd7 [Clang] Add offload kind to embedded offload object
This patch adds the offload kind to the embedded section name in
preparation for offloading to different kinda like CUDA or HIP.

Depends on D120288

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D120271
2022-03-14 20:08:27 -04:00
Joseph Huber 06b336c4cd [OpenMP] Implement dense map info for device file
This patch implements a DenseMap info struct for the device file type.
This is used to help grouping device files that have the same triple and
architecture. Because of this the filename, which will always be unique
for each file, is not used.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D120288
2022-03-14 20:08:26 -04:00
Joseph Huber 806bbc49dc [OpenMP] Try to embed offloading objects after codegen
Currently we use the `-fembed-offload-object` option to embed a binary
file into the host as a named section. This is currently only used as a
codegen action, meaning we only handle this option correctly when the
input is a bitcode file. This patch adds the same handling to embed an
offloading object after we complete code generation. This allows us to
embed the object correctly if the input file is source or bitcode.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D120270
2022-03-14 20:08:24 -04:00
Dávid Bolvanský 56e7d6bd44 [Clang] noinline stmt attribute - emit warnings rather than errors
Compatible behaviour with always_inline stmt attribute
2022-03-14 23:40:17 +01:00
Dávid Bolvanský a717e9d47e [AttrDocs] try to fix build 2022-03-14 22:19:55 +01:00
Dávid Bolvanský 003c0b9307 [Clang] always_inline statement attribute
Motivation:

```
int test(int x, int y) {
    int r = 0;
    [[clang::always_inline]] r += foo(x, y); // force compiler to inline this function here
    return r;
}
```

In 2018, @kuhar proposed "Introduce per-callsite inline intrinsics" in https://reviews.llvm.org/D51200 to solve this motivation case (and many others).

This patch solves this problem with call site attribute. "noinline" statement attribute already landed in D119061. Also, some LLVM Inliner fixes landed so call site attribute is stronger than function attribute.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D120717
2022-03-14 21:45:31 +01:00
Fangrui Song 407c721ceb [Support] Change zlib::compress to return void
With a sufficiently large output buffer, the only failure is Z_MEM_ERROR.
Check it and call the noreturn report_bad_alloc_error if applicable.
resize_for_overwrite may call report_bad_alloc_error as well.

Now that there is no other error type, we can replace the return type with void
and simplify call sites.

Reviewed By: ikudrin

Differential Revision: https://reviews.llvm.org/D121512
2022-03-14 11:38:04 -07:00
Stanislav Gatev cf63e9d4ca [clang][dataflow] Add support for nested composite bool expressions
This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Differential Revision: https://reviews.llvm.org/D121455
2022-03-14 17:18:30 +00:00
Arthur Eubanks 250620f76e [OpaquePtr][AArch64] Use elementtype on ldxr/stxr
Includes verifier changes checking the elementtype, clang codegen
changes to emit the elementtype, and ISel changes using the elementtype.

Reviewed By: #opaque-pointers, nikic

Differential Revision: https://reviews.llvm.org/D120527
2022-03-14 10:09:59 -07:00
Jonas Devlieghere df6fcef2b8
Fix the implicit module build (2/2)
This fixes the implicit module build after b1b4b6f366 broke the LLDB
build: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/42084/

My previous commit didn't have the modulemap change staged.
2022-03-14 09:43:13 -07:00
Arthur Eubanks 4fc7c55fff [NewPM] Actually recompute GlobalsAA before module optimization pipeline
RequireAnalysis<GlobalsAA> doesn't actually recompute GlobalsAA.
GlobalsAA isn't invalidated (unless specifically invalidated) because
it's self-updating via ValueHandles, but can be imprecise during the
self-updates.

Rather than invalidating GlobalsAA, which would invalidate AAManager and
any analyses that use AAManager, create a new pass that recomputes
GlobalsAA.

Fixes #53131.

Differential Revision: https://reviews.llvm.org/D121167
2022-03-14 09:42:34 -07:00
Jonas Devlieghere f51d7e4bae
Fix the implicit module build
This fixes the implicit module build after b1b4b6f366 broke the LLDB
build: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/42084/
2022-03-14 09:24:17 -07:00
Marek Kurdej a6b2f50fb4 Revert "[clang-format] Correctly format variable templates."
This reverts commit a140b7104f.

It provoked the bug https://github.com/llvm/llvm-project/issues/54374.
2022-03-14 16:04:09 +01:00
Aaron Ballman 9e3e85ac6e Silence -Wlogical-op-parentheses and fix a logic bug while doing so 2022-03-14 10:13:39 -04:00
Aaron Ballman 8cba72177d Implement literal suffixes for _BitInt
WG14 adopted N2775 (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2775.pdf)
at our Feb 2022 meeting. This paper adds a literal suffix for
bit-precise types that automatically sizes the bit-precise type to be
the smallest possible legal _BitInt type that can represent the literal
value. The suffix chosen is wb (for a signed bit-precise type) which
can be combined with the u suffix (for an unsigned bit-precise type).

The preprocessor continues to operate as-if all integer types were
intmax_t/uintmax_t, including bit-precise integer types. It is a
constraint violation if the bit-precise literal is too large to fit
within that type in the context of the preprocessor (when still using
a pp-number preprocessing token), but it is not a constraint violation
in other circumstances. This allows you to make bit-precise integer
literals that are wider than what the preprocessor currently supports
in order to initialize variables, etc.
2022-03-14 09:24:19 -04:00
Erich Keane dc152659b4 Have cpu-specific variants set 'tune-cpu' as an optimization hint
Due to various implementation constraints, despite the programmer
choosing a 'processor' cpu_dispatch/cpu_specific needs to use the
'feature' list of a processor to identify it. This results in the
identified processor in source-code not being propogated to the
optimizer, and thus, not able to be tuned for.

This patch changes to use the actual cpu as written for tune-cpu so that
opt can make decisions based on the cpu-as-spelled, which should better
match the behavior expected by the programmer.

Note that the 'valid' list of processors for x86 is in
llvm/include/llvm/Support/X86TargetParser.def. At the moment, this list
contains only Intel processors, but other vendors may wish to add their
own entries as 'alias'es (or with different feature lists!).

If this is not done, there is two potential performance issues with the
patch, but I believe them to be worth it in light of the improvements to
behavior and performance.

1- In the event that the user spelled "ProcessorB", but we only have the
features available to test for "ProcessorA" (where A is B minus
features),
AND there is an optimization opportunity for "B" that negatively affects
"A", the optimizer will likely choose to do so.

2- In the event that the user spelled VendorI's processor, and the
feature
list allows it to run on VendorA's processor of similar features, AND
there
is an optimization opportunity for VendorIs that negatively affects
"A"s,
the optimizer will likely choose to do so. This can be fixed by adding
an
alias to X86TargetParser.def.

Differential Revision: https://reviews.llvm.org/D121410
2022-03-14 06:14:30 -07:00
Egor Zhdan 6ca2f1938f [Clang][Sema] Avoid crashing for `__builtin_memcpy_inline` with an array argument
This change teaches the Sema logic for `__builtin_memcpy_inline` to implicitly convert arrays passed as arguments to pointers, similarly to regular `memcpy`.

This code will no longer cause a compiler crash:
```
void f(char *p) {
    char s[1] = {0};
    __builtin_memcpy_inline(p, s, 1);
}
```

rdar://88147527

Differential Revision: https://reviews.llvm.org/D121475
2022-03-14 12:47:30 +00:00
Björn Schäpers 35abbf166d [clang-format] Fix crash on asm block with label
Fixes https://github.com/llvm/llvm-project/issues/54349

Differential Revision: https://reviews.llvm.org/D121559
2022-03-14 12:44:48 +01:00
Björn Schäpers b7494a1d72 [clang-format][NFC] Left renamed to OpeningBrace...
in TokenAnnotator::parseBrace. Left is misleading, because we have a
loop and Left does not move.

Also return early.

Differential Revision: https://reviews.llvm.org/D121558
2022-03-14 12:44:47 +01:00
Björn Schäpers acd17a2be8 [clang-format] Fix crash on invalid requires expression
Fixes https://github.com/llvm/llvm-project/issues/54350

Differential Revision: https://reviews.llvm.org/D121550
2022-03-14 12:44:46 +01:00
Björn Schäpers 2d8e907016 [clang-format][NFC] Rename Left to OpeningParen...
in TokenAnnotator::parseParens(). Left is misleading since we have a
loop and Left is not adjusted.

Differential Revision: https://reviews.llvm.org/D121557
2022-03-14 12:44:45 +01:00
Marek Kurdej 2507e0a257 [clang-format] Clean up UnwrappedLineParser::parseRecord. NFC. 2022-03-14 11:59:52 +01:00
Stanislav Gatev 9e0fc67683 [clang][dataflow] Model the behavior of various optional members
Model `make_optional`, optional's default constructor, `emplace`,
`reset`, and `operator bool` members.

Reviewed-by: xazax.hun

Differential Revision: https://reviews.llvm.org/D121378
2022-03-14 06:50:14 +00:00
sstwcw c24b3db45c [clang-format] Add option to align compound assignments like `+=`
Reviewed By: curdeius, HazardyKnusperkeks, MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D119599
2022-03-14 04:41:40 +00:00
sstwcw 93b5505b45 [clang-format] Extract doc for entire configuration structs
Previously the comments for configuration structs as a whole like
`BraceWrappingFlags` did not go into the doc.

Reviewed By: curdeius

Differential Revision: https://reviews.llvm.org/D120361
2022-03-14 04:41:40 +00:00
Marek Kurdej 0570af1758 [clang-format] Fix incorrect assertion on macro definitions with keyword class.
Fixes https://github.com/llvm/llvm-project/issues/54348.
2022-03-13 22:17:48 +01:00
Marek Kurdej a140b7104f [clang-format] Correctly format variable templates.
Fixes https://github.com/llvm/llvm-project/issues/54257.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121456
2022-03-13 22:00:17 +01:00
Marek Kurdej 36d13d3f8a [clang-format] Add space to comments starting with '#'.
Fixes https://github.com/llvm/llvm-project/issues/35116.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121451
2022-03-13 21:56:22 +01:00
Marek Kurdej 596fa2d900 [clang-format] Handle attributes before case label.
Fixes https://github.com/llvm/llvm-project/issues/53110.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121450
2022-03-13 21:53:40 +01:00
Austin Kerbow 62bcfcb5a5 [AMDGPU] Add llvm.amdgcn.s.setprio intrinsic
Reviewed By: rampitec, arsenm

Differential Revision: https://reviews.llvm.org/D120976
2022-03-12 22:15:42 -08:00
Krystian Kuzniarek 9106a07f1f [clang-format][docs] Fix incorrect 'clang-format 12' option markers
Introduced by 23a5090c6, some style option markers indicated
'clang-format 12', though their respective options were available in
earlier releases.

Differential Revision: https://reviews.llvm.org/D120631
2022-03-12 22:49:57 +01:00
Björn Schäpers 8b4d68bf65 [clang-format] Handle builtins in constraint expression
Fixes https://github.com/llvm/llvm-project/issues/54106

Differential Revision: https://reviews.llvm.org/D120774
2022-03-12 22:44:24 +01:00
mydeveloperday adfe58b09d [clang-format] Minimize the damage caused by AlignArrayOfStructures when working on non square arrays
I have lost count of the number of times this has been reported, but it fundamentally comes down to the fact that the "AlignArrayLeft/Right" function is fundamentally broken for non-square arrays.

As a result, a pointer can end up running off the end of the array structure, I've spent the last 2 weekends trying to rewrite this algorithm but I've struggled to get it aligned correctly.

This is an interim fix, that ignores all array that are non-square and leaves them alone. I think this can allow us to close out most of the crashes (if not all).

I think this can help reduce the number of bugs coming in that are duplicates.

https://github.com/llvm/llvm-project/issues/53748
https://github.com/llvm/llvm-project/issues/51767
https://github.com/llvm/llvm-project/issues/51277

Reviewed By: curdeius, HazardyKnusperkeks, feg208

Differential Revision: https://reviews.llvm.org/D121069
2022-03-12 17:22:31 +00:00
serge-sans-paille ed98c1b376 Cleanup includes: DebugInfo & CodeGen
Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup
Differential Revision: https://reviews.llvm.org/D121332
2022-03-12 17:26:40 +01:00
Jan Svoboda 913107fa1f [clang][deps] Update helper script documentation
Since D118986, clang-scan-deps returns the whole command line even for the original translation units.
2022-03-12 16:55:38 +01:00
Jan Svoboda c4b13f7a2f [clang][deps] Simplify PREFIX definitions in tests
Instead of outputting the test directory into the JSON result file, parsing it with `FileCheck` and then potentially stripping it, simply use `FileCheck`'s `-D` option.

Note that we use `%/t` instead of `%t` in order to normalize to forward slashes on Windows, which matches what we do with `sed 's:\\\\\?:/:g'`.

Differential Revision: https://reviews.llvm.org/D121516
2022-03-12 16:45:09 +01:00
Jan Svoboda 4d6835f96d [clang][deps] Attempt to fix Windows test failure 2022-03-12 12:09:22 +01:00
Jan Svoboda cf4a31fc0f [clang][deps] Remove '-fmodules-cache-path=' arguments
With explicit modules build, the '-fmodules-cache-path=' argument is unused.

This patch removes the argument to avoid warnings or errors (with '-Werror') stemming from that.

Depends on D118915.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D120474
2022-03-12 11:42:07 +01:00
Jan Svoboda 7f6af60746 [clang][deps] Generate '-fmodule-file=' only for direct dependencies
The `clang-scan-deps` tool currently generates `-fmodule-file=` command-line arguments for the whole transitive closure of modular dependencies. This is not necessary, we only need to provide the direct dependencies on the command line. Information about transitive dependencies is stored within the `.pcm` files of direct dependencies. This makes the command lines shorter, but should be a NFC otherwise (unless there are bugs in the loading mechanism for explicit modules).

Depends on D120465.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D118915
2022-03-12 11:32:51 +01:00
Jan Svoboda a6ef363546 [clang][deps] Disable implicit module maps
Since D113473, we don't report any module map files via `-fmodule-map-file=` in explicit builds. The ultimate goal here is to make sure Clang doesn't open/read/parse/evaluate unnecessary module maps.

However, implicit module maps still end up reading all reachable module maps. This patch disables implicit module maps in explicit builds.

Unfortunately, we still need to report some module map files that aren't encoded in PCM files of dependencies: module maps that are necessary to correctly evaluate includes in modules marked as `[no_undeclared_includes]`.

Depends on D120464.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D120465
2022-03-12 11:07:21 +01:00
Kazushi (Jam) Marukawa b1b4b6f366 [Clang][VE] Add vector load intrinsics
Add vector load intrinsic instructions for VE.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D121049
2022-03-12 09:09:57 +09:00
Petr Hosek 0c0f6cfb7b [CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE
This clarifies that this is an LLVM specific variable and avoids
potential conflicts with other projects.

Differential Revision: https://reviews.llvm.org/D119918
2022-03-11 15:43:01 -08:00
Julian Lettner 46626bc873 [NFC] Improve comment and rename test file 2022-03-11 14:47:54 -08:00
owenca 9f616a467f [clang-format][NFC] Group QualifierAlignment with other C++ passes
Also increases the initial size of Passes to 8 and move the
definition of BracesInserter up.

Differential Revision: https://reviews.llvm.org/D121434
2022-03-11 14:18:00 -08:00
Akira Hatanaka aa4ea0ee54 [NFC][Clang][OpaquePtr] Remove calls to Address::deprecated in a couple
more files

Differential Revision: https://reviews.llvm.org/D121135
2022-03-11 09:30:31 -08:00
David Truby 058c92f2a4 [clang][SVE] Add aarch64-registered-target to sve vector op tests
This fixes failing tests where aarch64 isn't available.
2022-03-11 16:01:00 +00:00
David Truby 3aca0ffd50 [clang][SVE] Add support for arithmetic operators on SVE types
This patch implements support for the +, -, *, / and % operators on sizeless SVE
types. Support for these operators on svbool_t is excluded.

Differential Revision: https://reviews.llvm.org/D120323
2022-03-11 15:39:44 +00:00
Marek Kurdej b44eb207e9 [clang-format] Refactor condition in AnnotatingParser::modifyContext(). NFC. 2022-03-11 13:12:43 +01:00
Matt Devereau 6c5da880e0 [AArch64][SVE][Clang] Fix crash for incorrect svptrue and svcnt parameters
Giving an int parameter to SVE intrinsics svptrue and svcnt caused Clang
to crash on compilation. Changing their parameter types to void instead of
omitting args results in a diagnostic error message instead.

Differential Revision: https://reviews.llvm.org/D121294
2022-03-11 11:19:53 +00:00
Vassil Vassilev 788e0f7f3e [clang-repl] Add an accessor to our underlying execution engine
This patch will allow better incremental adoption of these changes in downstream
cling and other users which want to experiment by customizing the execution
engine.
2022-03-11 09:24:47 +00:00
4vtomat 25df633c24 Split up large test files(over 10k lines) under clang/test/CodeGen/RISCV including:
The llvm pre-merge test got timeout due to large test files, this commit
split up the files that have over 10k lines under clang/test/CodeGen/RISCV
into even smaller ones.

Differential Revision: https://reviews.llvm.org/D121431
2022-03-10 19:13:39 -08:00
Zequan Wu d54c4df314 [clang-format] Fix namespace format when the name is followed by a macro
Example:
```
$ cat a.cpp
namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
void test() {}
}

$ clang-format a.cpp
namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
void test() {}
}// namespace my_namespace::yeahAPI_AVAILABLE(macos(10.15))
```
After:
```
$ clang-format a.cpp
namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
void test() {}
}// namespace my_namespace::yeah
```

Reviewed By: MyDeveloperDay, owenpan, curdeius

Differential Revision: https://reviews.llvm.org/D121269
2022-03-10 15:00:32 -08:00
Eli Friedman 27a5749625 [Sema][Windows] Don't special-case void* in __unaligned conversions.
As far as I can tell, MSVC allows the relevant conversions for all
pointer types. Found compiling a Windows SDK header.

I've verified that the updated errors in MicrosoftExtensions.cpp match
the ones that MSVC actually emits, except for the one with a FIXME. (Not
sure why this wasn't done for the patch that added the tests.)

To make up for the missing error, add a warning that triggers on
conversions that drop the __unaligned qualfier.

Differential Revision: https://reviews.llvm.org/D120936
2022-03-10 14:49:16 -08:00
owenca 0be56c8701 [clang-format][NFC] Group all C++ passes under isCpp()
Also removes a not very helpful comment.
2022-03-10 14:30:30 -08:00
owenca e2b219bded [clang-format] Handle "// clang-format off" for RemoveBracesLLVM
Differential Revision: https://reviews.llvm.org/D121352
2022-03-10 13:30:53 -08:00
Zahira Ammarguellat 15ef06f453 Diagnose when `#pragma clang fp eval_method` doesn't have a supported value.
Currently the compiler is crashing.

Differential Revision: https://reviews.llvm.org/D121380
2022-03-10 13:19:53 -08:00
Kirill Stoimenov 035441ff30 [ASan] Moved optimized callbacks out of asan_static to avoid DSO size increase.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D121405
2022-03-10 21:11:32 +00:00
Stanislav Gatev af98b0af67 [clang][dataflow] Add analysis that detects unsafe accesses to optionals
This commit reverts e0cc28dfdc and moves
UncheckedOptionalAccessModelTest.cpp into clang/unittests/Analysis/FlowSensitive,
to avoid build failures. The test will be moved back into a Models subdir
in a follow up patch that will address the build configuration issues.

Original description:

Adds a dataflow analysis that detects unsafe accesses to values of type
`std::optional`, `absl::optional`, or `base::Optional`.

Reviewed-by: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D121197
2022-03-10 11:05:31 +00:00
Ahmed Bougacha 89c94c242c [clang][Driver] Get darwin -Xarch_ working for subtypes, again.
35ca7d9ddf broke 471c4f8299 for -arch flags that don't map 1:1
to the triple arch.  This has been broken for the many years since.
It hasn't mattered much since then, mostly because few people use it,
but also because it works for x86_64/i386, armv7/armv7s
don't differ much, arm64 is its own arch, and arm64/arm64_32 have
different arches (and it's a rare combination anyway).

But arm64/arm64e exposes this issue again.

Patch by: Justin Bogner <mail@justinbogner.com>
with some added tests.
2022-03-09 18:21:45 -08:00
Yaxun (Sam) Liu da9a70313d [HIP] Fix -fno-gpu-sanitize
Fix a typo about -fno-gpu-sanitize handling and disable warnings when
-fno-gpu-sanitize is specified.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D121302
2022-03-09 20:58:50 -05:00
Yaxun (Sam) Liu 6730b44480 [HIP] Fix HIP include path
The clang compiler prepends the HIP header include paths to the search
list using -internal-isystem when building for the HIP language. This
prevents warnings related to things like reserved identifiers when
including the HIP headers even when ROCm is installed in a non-system
directory, such as /opt/rocm.

However, when HIP is installed in /usr, then the prepended include
path would be /usr/include. That is a problem, because the C standard
library headers are stored in /usr/include and the C++ standard
library headers must come before the C library headers in the search
path list (because the C++ standard library headers use #include_next
to include the C standard library headers).

While the HIP wrapper headers _do_ need to be earlier in the search
than the C++ headers, those headers get their own subdirectory and
their own explicit -internal-isystem argument. This include path is for
<hip/hip_runtime_api.h> and <hip/hip_runtime.h>, which do not require a
particular search ordering with respect to the C or C++ headers. Thus,
HIP include path is added after other system include paths.

With contribution from Cordell Bloor.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D120132
2022-03-09 20:57:27 -05:00
Brad Smith 9abeb80e80 [Driver][OpenBSD] Disable unwind tables on Arm
Arm is not quite ready for unwinding yet.
2022-03-09 20:33:16 -05:00
David Blaikie 85ee1d3ca1 Revert "Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static""
Regresses:
typedef struct {
  static void  f() {
  }
} a_t;

Causing this to error instead of warn, because the linkage is computed
earlier/too early perhaps. I'll send out a review to see if there's some
other path forward or if this is an acceptable regression, etc.

This reverts commit 275c56226d.
2022-03-09 21:12:56 +00:00
Andrzej Warzynski 38101b4e95 [flang][driver] Add support for -S and implement -c/-emit-obj
This patch adds support for:
  * `-S` in Flang's compiler and frontend drivers,
and implements:
  * `-emit-obj` in Flang's frontend driver and `-c` in Flang's compiler
    driver (this is consistent with Clang).
(these options were already available before, but only as placeholders).
The semantics of these options in Clang and Flang are identical.

The `EmitObjAction` frontend action is renamed as `BackendAction`. This
new name more accurately reflects the fact that this action will
primarily run the code-gen/backend pipeline in LLVM. It also makes more
sense as an action implementing both `-emit-obj` and `-S` (originally,
it was just `-emit-obj`).

`tripleName` from FirContext.cpp is deleted and, when a target triple is
required, `mlir::LLVM::LLVMDialect::getTargetTripleAttrName()` is used
instead. In practice, this means that `fir.triple` is replaced with
`llvm.target_triple`. The former was effectively ignored. The latter is
used when lowering from the LLVM dialect in MLIR to LLVM IR (i.e. it's
embedded in the generated LLVM IR module). The driver can then re-use
it when configuring the backend. With this change, the LLVM IR files
generated by e.g. `tco` will from now on contain the correct target
triple.

The code-gen.f90 test is replaced with code-gen-x86.f90 and
code-gen-aarch64.f90. With 2 seperate files we can verify that
`--target` is correctly taken into account. LIT configuration is updated
to enable e.g.:
```
! REQUIRES: aarch64-registered-target
```

Differential Revision: https://reviews.llvm.org/D120568
2022-03-09 15:48:09 +00:00
Stanislav Gatev 3dd7877b27 Revert "[clang][dataflow] Move dataflow testing support out of unittests"
This reverts commit 26bbde2612.
2022-03-09 15:38:51 +00:00
Stanislav Gatev 26bbde2612 [clang][dataflow] Move dataflow testing support out of unittests
This enables tests out of clang/unittests/Analysis/FlowSensitive to
use the testing support utilities.

Reviewed-by: ymandel, gribozavr2

Differential Revision: https://reviews.llvm.org/D121285
2022-03-09 15:31:02 +00:00
Timm Bäder e5ccd66801 [clang][sema] Enable first-class bool support for C2x
Implement N2395 for C2x.

This also covers adding "bool", which is part of N2394.

Differential Revision: https://reviews.llvm.org/D120244
2022-03-09 15:04:24 +01:00
Simon Pilgrim d258196f5f [clang] ScalarExprEmitter::VisitCastExpr - use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointers are always dereferenced, so assert the cast is correct instead of returning nullptr
2022-03-09 11:40:37 +00:00
Simon Pilgrim a157d839c5 [clang] Environment::createValueUnlessSelfReferential - use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointer is always dereferenced, so assert the cast is correct instead of returning nullptr
2022-03-09 11:40:37 +00:00
Simon Pilgrim 8d0931114f [clang] Sema::ActOnModuleImport - remove superfluous nullptr test
Mod has already been dereferenced
2022-03-09 11:40:36 +00:00
Chuanqi Xu ae4eb938c0 [NFC] [C++20] [Modules] Add test to show private module fragment is not allowed in partition unit 2022-03-09 19:05:54 +08:00
Stanislav Gatev e0cc28dfdc Revert "[clang][dataflow] Add analysis that detects unsafe accesses to optionals"
This reverts commit ce205cffdf.
2022-03-09 09:51:03 +00:00
Stanislav Gatev ce205cffdf [clang][dataflow] Add analysis that detects unsafe accesses to optionals
Adds a dataflow analysis that detects unsafe accesses to values of type
`std::optional`, `absl::optional`, or `base::Optional`.

Reviewed-by: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D121197
2022-03-09 09:42:51 +00:00
Chuanqi Xu 845f0bb5fa Revert "[clang][ABI] New C++20 module mangling scheme"
This reverts commit 21e16ab6b8.

It looks like it would break builds in mac. See
https://reviews.llvm.org/D118352.
2022-03-09 10:15:15 +08:00
Ryan Senanayake b3dae59b9d [clang] Fix CodeGenAction for LLVM IR MemBuffers
Replaces use of getCurrentFile with getCurrentFileOrBufferName
in CodeGenAction. This avoids an assertion error or an incorrect
name chosen for the output file when assertions are disabled.
This error previously occurred when the FrontendInputFile was a
MemoryBuffer instead of a file.

Reviewed By: jlebar

Differential Revision: https://reviews.llvm.org/D121259
2022-03-09 00:39:48 +00:00
Andrzej Warzynski 8321579b28 [flang][driver] Add support for `-debug-dump-pft`
This patch adds support for dumping the pre-FIR tree in `flang-new
-fc1`, i.e. Flang's frontend driver. This flag is functionally identical
to `-pft-test` in `bbc` and semantically similar to
`-fdebug-dump-parse-tree` from `flang-new -fc1`.

Differential Revision: https://reviews.llvm.org/D121198
2022-03-08 19:21:58 +00:00
eopXD 550b2eaaa6 [RISCV] Add combination crypto extensions in ISAInfo
The crypto extension have several shorthand extensions that don't consist of any extra instructions.
Take `zk` for example, while the extension would imply `zkn, zkr, zkt`. The 3 extensions should also
combine back into `zk` to maintain the canonical order in isa strings.

This patch addresses the above.

Reviewed By: VincentWu

Differential Revision: https://reviews.llvm.org/D119530
2022-03-08 09:52:38 -08:00
Akira Hatanaka 9bb8c80bea [NFC][Clang][OpaquePtr] Remove calls to Address::deprecated in
CGBuiltin.cpp

Differential Revision: https://reviews.llvm.org/D121153
2022-03-08 09:45:15 -08:00
Aaron Ballman 1c55f05c6a Properly diagnose constant evaluation issues at TU scope
We were not creating an evaluation context for the TU scope, so we
never popped an evaluation context for it. Popping the evaluation
context triggers a number of diagnostics, including warnings about
immediate invocations that we were previously missing.

Note: I think we have an additional issue that we should solve, but not
as part of this patch. I don't think Clang is properly modeling static
initialization as happening before constant expression evaluation. I
think structure members members are zero initialized per
http://eel.is/c++draft/basic.start.static#1,
https://eel.is/c++draft/basic.start.static#2.sentence-2, and
http://eel.is/c++draft/dcl.init#general-6.2 and the new test case
actually should be accepted. However, it's also worth noting that other
compilers behave the way this patch makes Clang behave:
https://godbolt.org/z/T7noqhdPr
2022-03-08 10:19:15 -05:00
Timm Bäder 5b7941ad7c [clang][driver] Fix float128 diagnostics with glibc >= 2.32
Fix checking for an unsupported stdlib++.

Differential Revision: https://reviews.llvm.org/D121209
2022-03-08 15:49:01 +01:00
Nathan Sidwell 21e16ab6b8 [clang][ABI] New C++20 module mangling scheme
The existing module symbol mangling scheme turns out to be
undemangleable.  It is also desirable to switch to the
strong-ownership model as the hoped-for C++17 compatibility turns out
to be fragile, and we also now have a better way of controlling that.

The issue is captured on the ABI list at:
  https://github.com/itanium-cxx-abi/cxx-abi/issues/134

A document describing the issues and new mangling is at:
  https://drive.google.com/file/d/1qQjqptzOFT_lfXH8L6-iD9nCRi34wjft/view

This patch is the code-generation part.  I have a demangler too, but
that patch is based on some to-be-landed refactoring of the demangler.

The old mangling is unceremoniously dropped.  No backwards
compatibility, no deprectated old-mangling flag.  It was always
labelled experimental.  (Old and new manglings cannot be confused.)

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D118352
2022-03-08 06:21:50 -08:00
Marek Kurdej f537a40916 [clang-format] Correctly detect `!` as TT_NonNullAssertion after `default`.
Fixes https://github.com/llvm/llvm-project/issues/53153.

Depends on D121132.

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121136
2022-03-08 13:35:26 +01:00
Marek Kurdej 7a54fceb25 [clang-format] Handle C# 9 `init` accessor specifier.
Before, the code:
```
int Value { get; } = 0;
int Value { init; } = 0;
```
was formatted incoherently:
```
int Value { get; } = 0;
int Value { init; }
= 0;
```
because `init` was not recognised as an accessor specifier.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D121132
2022-03-08 13:33:36 +01:00
Adrian Kuegel 75aca24d2f [clang] Fix reference to file that was moved. 2022-03-08 12:26:02 +01:00
Krystian Kuzniarek 481f681867 [AST] Fix typo in assert messages
Differential Revision: https://reviews.llvm.org/D120221
2022-03-08 11:06:50 +00:00
Argyrios Kyrtzidis f2b24905bf [Sema] Mark the referenced destructor during transformation of a `CXXBindTemporaryExpr`
Otherwise we will fail to generate the definition of a defaulted destructor,
if the only reference was in a templated temporary.

rdar://89366678

Differential Revision: https://reviews.llvm.org/D120426
2022-03-08 01:00:07 -08:00
Stanislav Mekhanoshin 9eabea3968 [AMDGPU] Set noclobber metadata on loads instead of cast to constant
A load via pointer cast to constant will return true from
pointsToConstantMemory which is not necessarily so.

Fixes: SWDEV-326463

Differential Revision: https://reviews.llvm.org/D121172
2022-03-07 23:13:02 -08:00
Yuanfang Chen eddd94c27d Reland "[clang][debug] port clang-cl /JMC flag to ELF"
This relands commit 7313474319.

It failed on Windows/Mac because `-fjmc` is only checked for ELF targets.
Check the flag unconditionally instead and issue a warning for non-ELF targets.
2022-03-07 21:55:41 -08:00
Phoebe Wang 4de9a752d6 [X86] Add helper enum for ternary intrinsics
Reviewed By: RKSimon, LuoYuanke

Differential Revision: https://reviews.llvm.org/D120307
2022-03-08 11:19:05 +08:00
Yitzhak Mandelbaum 18c84e2d32 [clang][dataflow] Fix nullptr dereferencing error.
When pre-initializing fields in the environment, the code assumed that all
fields of a struct would be initialized. However, given limits on value
construction, that assumption is incorrect. This patch changes the code to drop
that assumption and thereby avoid dereferencing a nullptr.

Differential Revision: https://reviews.llvm.org/D121158
2022-03-08 03:01:31 +00:00
Peixin-Qiao 4e159e4c7b [clang] Fix OpenMP critical hint parameter check
The paramemter of hint clause in OpenMP critical hint should be
non-negative. The omp_lock_hint_none is 0 in omp.h.

Reviewed By: Alexey Bataev

Differential Revision: https://reviews.llvm.org/D121101
2022-03-08 09:04:31 +08:00
Sam Clegg c832edfd3f [WebAssembly] Add new target feature in support of 'extended-const' proposal
We don't yet do anything when this feature is enabled, this change
just lays the ground work by accepting that there is such a feature.

See https://github.com/WebAssembly/extended-const

Differential Revision: https://reviews.llvm.org/D121151
2022-03-07 16:45:42 -08:00
Yuanfang Chen f46fa4de4a Revert "[clang][debug] port clang-cl /JMC flag to ELF"
This reverts commit 7313474319.

Break bots:
http://45.33.8.238/win/54551/step_7.txt
http://45.33.8.238/macm1/29590/step_7.txt
2022-03-07 12:40:43 -08:00
Stanislav Mekhanoshin 932f628121 [AMDGPU] new gfx940 fp atomics
Differential Revision: https://reviews.llvm.org/D121028
2022-03-07 12:32:02 -08:00
Haojian Wu 2d01ac18df [pseudo] Strip comments for TokenStream.
Add a utility function to strip comments from a "raw" tokenstream. The
derived stream will be fed to the GLR parser (for early testing).

Differential Revision: https://reviews.llvm.org/D121092
2022-03-07 20:24:37 +01:00
Haojian Wu d5b8ecbd33 [pseudo] empty parameter-declaration should be allowed in lambda declarator.
This was an oversight, as we did a avoild-nullable modication to
parameter-declaration-clause.

Differential Revision: https://reviews.llvm.org/D121089
2022-03-07 20:05:35 +01:00
Nico Weber e6a8b92b89 [clang-format] Fix namespace end comments in ObjC++ files too
See also d96ae86735.

Differential Revision: https://reviews.llvm.org/D121112
2022-03-07 13:30:25 -05:00
David Blaikie c0a6433f2b Simplify OpenMP Lambda use
* Use default ref capture for non-escaping lambdas (this makes
  maintenance easier by allowing new uses, removing uses, having
  conditional uses (such as in assertions) not require updates to an
  explicit capture list)
* Simplify addPrivate API not to take a lambda, since it calls it
  unconditionally/immediately anyway - most callers are simply passing
  in a named value or short expression anyway and the lambda syntax just
  adds noise/overhead

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D121077
2022-03-07 18:23:20 +00:00
Yuanfang Chen 7313474319 [clang][debug] port clang-cl /JMC flag to ELF
The motivation is to enable the MSVC-style JMC instrumentation usable by a ELF-based
debugger. Since there is no prior experience implementing JMC feature for ELF-based
debugger, it might be better to just reuse existing MSVC-style JMC instrumentation.
For debuggers that support both ELF&COFF (like lldb), the JMC implementation might
be shared between ELF&COFF. If this is found to inadequate, it is pretty low-cost
switching to alternatives.

Implementation:
- The '-fjmc' is already a driver and cc1 flag. Wire it up for ELF in the driver.
- Refactor the JMC instrumentation pass a little bit.
- The ELF handling is different from MSVC in two places:
  * the flag section name is ".just.my.code" instead of ".msvcjmc"
  * the way default function is provided: MSVC uses /alternatename; ELF uses weak function.

Based on D118428.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D119910
2022-03-07 10:16:24 -08:00
Yi Kong bc1f8b6b9b Fix the comment for EnableNoundefAttrs, NFC 2022-03-08 01:59:44 +08:00
Stanislav Gatev 1e5715857a [clang][dataflow] Extend flow conditions from block terminators
This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D120984
2022-03-07 17:50:44 +00:00
Sam McCall 54d6b5b67f [pseudo] Rename {Preprocess,PPStructure} -> DirectiveMap. NFC
More precisely describes what this file does.
Per comments on https://reviews.llvm.org/D121092
2022-03-07 17:41:35 +01:00
phyBrackets 90a6e35478 [analyzer][NFC] Merge similar conditional paths
Reviewed By: aaron.ballman, steakhal

Differential Revision: https://reviews.llvm.org/D121045
2022-03-07 22:05:27 +05:30
Marek Kurdej d03e342803 [clang-format] Fix assertion failure/crash with `AllowShortFunctionsOnASingleLine: Inline/InlineOnly`.
Fixes https://github.com/llvm/llvm-project/issues/54147.

When handling `AllowShortFunctionsOnASingleLine`, we were searching for the last line with a smaller level than the current line. The search was incorrect when the first line had the same level as the current one. This led to an unsatisfied assumption about the existence of a brace (non-comment token).

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D120902
2022-03-07 16:54:08 +01:00
Kadir Cetinkaya d65952b9bd
[clang] Adjust LookupTest for UsingTypeLocs
We no longer traverse the underlying RecordTypeLoc directly, but rather
visit the UsingTypeLoc.

Differential Revision: https://reviews.llvm.org/D121103
2022-03-07 16:22:03 +01:00
Sam McCall 68b4e2d703 [pseudo] Add readme
Differential Revision: https://reviews.llvm.org/D121108
2022-03-07 15:54:00 +01:00
Endre Fülöp bfc40b1a1a [analyzer] Fix buildbot failure for D120369
Fix test case for GenericTaintChecker.
Redefinition of types is a C11 feature, and it broke a buildbot.
Commit amended: 4fd6c6e65a.
2022-03-07 14:56:04 +01:00
Endre Fülöp 4fd6c6e65a [analyzer] Add more propagations to Taint analysis
Add more functions as taint propators to GenericTaintChecker.

Reviewed By: steakhal

Differential Revision: https://reviews.llvm.org/D120369
2022-03-07 13:18:54 +01:00
Jan Svoboda 2d26f163f6 [clang][modules] Fix failing test
This test started failing on Windows after b45888e959 due to path separators not matching up.
2022-03-07 11:21:21 +01:00
Jan Svoboda b45888e959 [clang][modules] Report module maps affecting `no_undeclared_includes` modules
Since D106876, PCM files don't report module maps as input files unless they contributed to the compilation.

Reporting only module maps of (transitively) imported modules is not enough, though. For modules marked with `[no_undeclared_includes]`, other module maps affect the compilation by introducing anti-dependencies.

This patch makes sure such module maps are being reported as input files.

Depends on D120463.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D120464
2022-03-07 10:47:46 +01:00
Jan Svoboda 242b24c184 [clang][modules] NFC: Simplify and clarify test
This patch simplifies a test that checks only used module map files are reported as input files in PCM files.

Instead of using opaque `diff`, this patch uses `clang -module-file-info` and `FileCheck` to verify this.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D120463
2022-03-07 10:47:46 +01:00
Timm Bäder 7b969b0bb5 [clang][parser] Stop dragging an EndLoc around when parsing attributes
It's almost always entirely unused and if it is used, the end of the
attribute range can be used instead.

Differential Revision: https://reviews.llvm.org/D120888
2022-03-07 08:16:39 +01:00
Qiu Chaofan b2497e5435 [PowerPC] Add generic fnmsub intrinsic
Currently in Clang, we have two types of builtins for fnmsub operation:
one for float/double vector, they'll be transformed into IR operations;
one for float/double scalar, they'll generate corresponding intrinsics.

But for the vector version of builtin, the 3 op chain may be recognized
as expensive by some passes (like early cse). We need some way to keep
the fnmsub form until code generation.

This patch introduces ppc.fnmsub.* intrinsic to unify four fnmsub
intrinsics.

Reviewed By: shchenz

Differential Revision: https://reviews.llvm.org/D116015
2022-03-07 13:00:06 +08:00
William S. Moses 87ec6f41bb [OpenMPIRBuilder] Allocate temporary at the correct block in a nested parallel
The OpenMPIRBuilder has a bug. Specifically, suppose you have two nested openmp parallel regions (writing with MLIR for ease)

```
omp.parallel {
  %a = ...
  omp.parallel {
    use(%a)
  }
}
```

As OpenMP only permits pointer-like inputs, the builder will wrap all of the inputs into a stack allocation, and then pass this
allocation to the inner parallel. For example, we would want to get something like the following:

```
omp.parallel {
  %a = ...
  %tmp = alloc
  store %tmp[] = %a
  kmpc_fork(outlined, %tmp)
}
```

However, in practice, this is not what currently occurs in the context of nested parallel regions. Specifically to the OpenMPIRBuilder,
the entirety of the function (at the LLVM level) is currently inlined with blocks marking the corresponding start and end of each
region.

```
entry:
  ...

parallel1:
  %a = ...
  ...

parallel2:
  use(%a)
  ...

endparallel2:
  ...

endparallel1:
  ...
```

When the allocation is inserted, it presently inserted into the parent of the entire function (e.g. entry) rather than the parent
allocation scope to the function being outlined. If we were outlining parallel2, the corresponding alloca location would be parallel1.

This causes a variety of bugs, including https://github.com/llvm/llvm-project/issues/54165 as one example.

This PR allows the stack allocation to be created at the correct allocation block, and thus remedies such issues.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D121061
2022-03-06 18:34:25 -05:00
mydeveloperday 4ab5d7608b [clang-format] NFC update LLVM overall clang-formatted status
A 1% increase in the number of clang-formatted files.

An additional 530 files have been added to LLVM, and an additional
450 files are now clang-format clean. Raising the overall % to 53%

There are now 8857 files clean out of 16432 (ignoring lit tests)
2022-03-06 20:03:27 +00:00
Jun Zhang 17a68065c3
[Clang] Use = default(NFC) 2022-03-06 14:25:22 +08:00
owenca 28b76b1e23 [clang-format] Handle goto labels for RemoveBracesLLVM
Differential Revision: https://reviews.llvm.org/D121042
2022-03-05 12:46:57 -08:00
Benjamin Kramer e44bbedb32 Make ParsedAttrInfo and subclasses use constexpr construction
This removes a 30 kB global initializer. NFCI.
2022-03-05 20:37:21 +01:00
Benjamin Kramer 14af99d375 [OpenCL] Turn global vector into static array. NFCI. 2022-03-05 19:16:28 +01:00
mydeveloperday 28bb040ded [clang-format] QualifierOrder does not reorder template arguments
https://github.com/llvm/llvm-project/issues/53981

Reorder the qualifiers inside the template argument. This should handle the simple cases of

```
<const T>
<T const>
```

But only by relaxing that single letter capital variables are not possible macros

Fixes: #53981

Reviewed By: HazardyKnusperkeks, curdeius

Differential Revision: https://reviews.llvm.org/D120710
2022-03-05 18:08:25 +00:00
Benjamin Kramer a887b95edf [clang-format] Turn global COperatorsFollowingVar vector into a switch
LLVM optimizes this into a bit test. NFCI.
2022-03-05 18:00:16 +01:00
Corentin Jabot fda7d029e5 [NFC][Clang] Fix a couple of typos 2022-03-05 09:45:04 +01:00
Shao-Ce SUN fa9c8bab0c [RISCV] Support k-ext clang intrinsics
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D112774
2022-03-05 13:57:18 +08:00
Thomas Lively c01ec30830 [WebAssembly] Update Preprocessor/init.c test after 3be9e0ba97 2022-03-04 18:40:10 -08:00
Vladimir Vereschaka d860ac5da6 [CMake] Replace `TARGET_TRIPLE` with `TOOLCHAIN_TARGET_TRIPLE` for Win-to-Arm cross toolchain cache file. NFC.
Avoid using TARGET_TRIPLE argument for the cross toolchain cmake cache file and replace it
with TOOLCHAIN_TARGET_TRIPLE.

Reference: https://reviews.llvm.org/D119918

Differential Revision: https://reviews.llvm.org/D121029
2022-03-04 16:39:28 -08:00
Thomas Lively 3be9e0ba97 [WebAssembly] Check bulk-memory when adjusting lang opts
We previously had logic to disable pthreads, set the ThreadModel to Single, and
disable thread-safe statics when the atomics target features is disabled, since
that means that the resulting program will not be used in a threaded context.
Similarly check for the presence of the bulk-memory feature, since that is also
necessary to produce multithreaded programs.

Differential Revision: https://reviews.llvm.org/D121014
2022-03-04 16:07:16 -08:00
Zequan Wu be5705767a [clang-format] fix namepsace format when the name is macro expansion
Originally filed at crbug.com/1184570.
When the name of a namespace is a macro that takes arguments,
- It fixed the indentation.
- It fixed the namepsace end comments.

Differential Revision: https://reviews.llvm.org/D120931
2022-03-04 16:01:17 -08:00
Andrew Browne 9129743dde [Docs] List __has_feature(dataflow_sanitizer) in LanguageExtensions docs. 2022-03-04 15:48:07 -08:00
Yaxun (Sam) Liu 22b6e8173c Fix test failure in openmp-offload.c
Update active offload kind of actions for OpenMP programs.

The change is expected as of e5eb365069.
2022-03-04 16:32:30 -05:00
Yaxun (Sam) Liu e5eb365069 [CUDA][HIP] Fix offloading kind for linking C++ programs
When both CUDA or HIP programs and C++ programs are passed
to clang driver without -c, C++ programs are treated as CUDA
or HIP program, which is incorrect.

This is because action builder sets the offloading kind of input
job actions to the linking action to be the union of offloading
kind of the input job actions, i.e. if there is one HIP or CUDA
input to the linker, then all the input to the linker is marked
as HIP or CUDA.

To fix this issue, the offload action builder tracks the originating
input argument of each host action, which allows it to determine
the active offload kind of each host action. Then the offload
kind of each input action to the linker can be determined
individually.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D120911
2022-03-04 15:56:54 -05:00
Yaxun (Sam) Liu bde13a8102 [HIP] Fix job action offloading kind for mixed HIP/C++ compilation
When both HIP and C++ programs are input files to clang
with -c, clang treats C++ programs as HIP programs,
which is incorrect.

This is due to action builder does not set correct
offloading kind for job actions for C++ programs.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D120910
2022-03-04 15:34:02 -05:00
Paul Robinson e22e2774d9 [RGT] DistroTest: Separate environment-specific test functions
This allows using GTEST_SKIP() to identify un-executed tests.

Found by the Rotten Green Tests project.
2022-03-04 12:28:38 -08:00
Richard d5d03135a7 [tooling] Explain how to create a compilation database on Windows [NFC]
Differential Revision: https://reviews.llvm.org/D120947
2022-03-04 13:06:08 -07:00
Arthur O'Dwyer f0891cd61b [clang] [concepts] Check constrained-auto return types for void-returning functions
Fixes #49188.

Differential Revision: https://reviews.llvm.org/D119184
2022-03-04 12:43:06 -05:00
Arthur O'Dwyer adf6703f75 [clang] [NFC] Add `const` to a parameter that's not modified.
Reviewed as part of D119184.
2022-03-04 12:43:05 -05:00
Yitzhak Mandelbaum c88deef0a7 [clang][dataflow] Add `MatchSwitch` utility library.
Adds `MatchSwitch`, a library for simplifying implementation of transfer
functions. `MatchSwitch` supports constructing a "switch" statement, where each
case of the switch is defined by an AST matcher. The cases are considered in
order, like pattern matching in functional languages.

Differential Revision: https://reviews.llvm.org/D120900
2022-03-04 17:19:51 +00:00
Yitzhak Mandelbaum 7ee97c24ef [clang][dataflow] Add a lattice to track source locations.
This patch adds a simpe lattice used to collect source loctions. An intended application is to track errors found in code during an analysis.

Differential Revision: https://reviews.llvm.org/D120890
2022-03-04 17:13:24 +00:00
Aaron Ballman 6afe035404 Revert "[analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions"
This reverts commit 9c300c18a4.

This broke the sphinx bot and seems like an unintentional commit.
2022-03-04 07:21:52 -05:00
4vtomat 5a148869d3 [NFC] Divide tests into smaller files
This commit divides the large test files(over 30k lines) under clang/test/CodeGen/RISCV including:
rvv-intrinsics/vloxseg.c
rvv-intrinsics/vluxseg.c
rvv-intrinsics-overloaded/vloxseg.c
rvv-intrinsics-overloaded/vluxseg.c
into "non-masked" version and "masked" version which can reduce the test cases by 50% in a single file.

Differential Revision: https://reviews.llvm.org/D120967
2022-03-04 04:16:52 -08:00
Florian Hahn fb42e557d8
[Driver] Split up huge arm-cortex-cpus.c test.
This test file has grown to the point where it takes a huge amount of
time to run. At the moment, this test seems to consistently time out
when running in the pre-commit checks in Phabricator with a 10 minute
timeout. For example see
https://reviews.llvm.org/harbormaster/unit/view/2832724/

While splitting up the test file is not ideal, it is even more
undesirable to have huge test files that time out in common settings.

This patch splits up the test file roughly in the middle.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D120876
2022-03-04 11:37:00 +00:00
Florian Hahn 8f5bdaf481
[Driver] Split up huge aarch64-cpus.c test.
This test file has grown to the point where it takes a huge amount of
time to run. At the moment, this test seems to consistently time out
when running in the pre-commit checks in Phabricator with a 10 minute
timeout. For example see
https://reviews.llvm.org/harbormaster/unit/view/2832723/

While splitting up the test file is not ideal, it is even more
undesirable to have huge test files that time out in common settings.

This patch splits up the test file roughly in the middle.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D120875
2022-03-04 11:24:12 +00:00
Tim Northover 4f637c30e1 [tests][Driver] Pass an empty sysroot for `DEFAULT_SYSROOT` builds
The baremetal-sysroot test fails when the toolchain is configured with
DEFAULT_SYSROOT. So, to emulate not having passed one at all, let's
pass an empty sysroot instead.

https://reviews.llvm.org/D119144

Patch by Carlo Cabrera <carlo.antonio.cabrera@gmail.com>
2022-03-04 09:01:50 +00:00
phyBrackets 9c300c18a4 [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions
Few weeks back I was experimenting with reading the uninitialized values from src , which is actually a bug but the CSA seems to give up at that point . I was curious about that and I pinged @steakhal on the discord and according to him this seems to be a genuine issue and needs to be fix. So I goes with fixing this bug and thanks to @steakhal who help me creating this patch. This feature seems to break some tests but this was the genuine problem and the broken tests also needs to fix in certain manner. I add a test but yeah we need more tests,I'll try to add more tests.Thanks

Reviewed By: steakhal, NoQ

Differential Revision: https://reviews.llvm.org/D120489
2022-03-04 12:17:58 +05:30
Shoaib Meenai b4c1cbff79 [hmaptool] Fix string decoding for Python 3
Our "strings" were actually bytes, which made verbose dumping fail.
Decode them so they actually become strings.

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D118005
2022-03-03 15:18:21 -08:00
Shoaib Meenai 0c1d330431 [hmaptool] Fix dumping
It was complaining about too many values to unpack, since our struct
unpack format string specified six members, but we only had five
variables to unpack to. The sixth value is the max value length, but
it's not used in dumping, so we can ignore it.

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D118004
2022-03-03 15:18:09 -08:00
Vladimir Vereschaka 19c1b084a7 [CMake] Update cache file for Win to ARM cross tooolchain. NFC.
Removed passing CMAKE_AR from the library configurations.
2022-03-03 14:32:16 -08:00
Aaron Ballman d74a3a514c Fixed sphinx build due to indentation 2022-03-03 16:03:05 -05:00
Erich Keane 94623fb1c9 [NFC] move CheckInstantiatedFunctionTemplateConstraints to SemaConcepts.cpp
This is a Sema function that now no longer depends on any of the
functionality in SemaTemplateInstantiateDecl.cpp (as the static function
was moved to Sema in a previous NFC).  Moving it to SemaConcept means
that it and CheckFunctionConstraints can be changed to share more.
2022-03-03 11:47:20 -08:00
Shivam 56eaf869be [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions
Few weeks back I was experimenting with reading the uninitialized values from src , which is actually a bug but the CSA seems to give up at that point . I was curious about that and I pinged @steakhal on the discord and according to him this seems to be a genuine issue and needs to be fix. So I goes with fixing this bug and thanks to @steakhal who help me creating this patch. This feature seems to break some tests but this was the genuine problem and the broken tests also needs to fix in certain manner. I add a test but yeah we need more tests,I'll try to add more tests.Thanks

Reviewed By: steakhal, NoQ

Differential Revision: https://reviews.llvm.org/D120489
2022-03-04 00:21:06 +05:30
Shivam bd1917c88a [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions
Few weeks back I was experimenting with reading the uninitialized values from src , which is actually a bug but the CSA seems to give up at that point . I was curious about that and I pinged @steakhal on the discord and according to him this seems to be a genuine issue and needs to be fix. So I goes with fixing this bug and thanks to @steakhal who help me creating this patch. This feature seems to break some tests but this was the genuine problem and the broken tests also needs to fix in certain manner. I add a test but yeah we need more tests,I'll try to add more tests.Thanks

Reviewed By: steakhal, NoQ

Differential Revision: https://reviews.llvm.org/D120489
2022-03-03 23:21:26 +05:30
Erich Keane de5785ad9d [NFC] Change TemplateInstantiator to refer to the base using a typedef
A few places were inconsistent here, which makes a refactor to support
delayed concepts significantly more difficult.
2022-03-03 09:12:05 -08:00
Akira Hatanaka 3717b9661f [NFC][Clang][OpaquePtr] Remove calls to Address::deprecated in
CGBlocks.cpp

Differential Revision: https://reviews.llvm.org/D120856
2022-03-03 08:54:46 -08:00
Paul Robinson 7b85f0f32f [PS4] isPS4 and isPS4CPU are not meaningfully different 2022-03-03 11:36:59 -05:00
Corentin Jabot 942c03910a [Clang] Diagnose invalid member variable with template parameters
Fixes https://github.com/llvm/llvm-project/issues/54151

Reviewed By: erichkeane, aaron.ballman

Differential Revision: https://reviews.llvm.org/D120881
2022-03-03 15:51:46 +01:00
Roy Jacobson 5aeaabf35e [Concepts] Check constraints for explicit template instantiations
The standard requires[0] member function constraints to be checked when
explicitly instantiating classes. This patch adds this constraints
check.

This issue is tracked as #46029 [1].

Note that there's an related open CWG issue (2421[2]) about what to do when
multiple candidates have satisfied constraints. This is particularly an
issue because mangling doesn't contain function constraints, and so the
following code still ICEs with definition with same mangled name
'_ZN1BIiE1fEv' as another definition:

template<class T>
struct B {
  int f() requires std::same_as<T, int> {
    return 0;
  }
  int f() requires (std::same_as<T, int> &&
                    !std::same_as<T, char>) {
    return 1;
  }
};

template struct B<int>;

Also note that the constraints checking while instantiating *functions*
is still not implemented. I started looking at it but It's a bit more
complicated. I believe in such a case we have to consider the partial
constraints order and potentially choose the best candidate out of the
set of multiple valid ones.

[0]: https://eel.is/c++draft/temp.explicit#10
[1]: https://github.com/llvm/llvm-project/issues/46029
[2]: https://cplusplus.github.io/CWG/issues/2421.html

Differential Revision: https://reviews.llvm.org/D120255
2022-03-03 06:33:49 -08:00
Haojian Wu 28ccf32672 [pseudo] Fix an out-of-bound access for LRTable::Actions.
Without this patch, when End == Start, we access Actions[Actions.end()]
though we return an empty result.
This fixes an assertion failure in MSVC STL debug build.
2022-03-03 14:27:44 +01:00
owenca 1aa608a020 [clang-format] Handle wrapped else for RemoveBracesLLVM
Removes the newline before the right brace that's followed by an
else on the next line.

Differential Revision: https://reviews.llvm.org/D120873
2022-03-03 04:53:15 -08:00
Kristóf Umann d832078904 [analyzer] Improve NoOwnershipChangeVisitor's understanding of deallocators
The problem with leak bug reports is that the most interesting event in the code
is likely the one that did not happen -- lack of ownership change and lack of
deallocation, which is often present within the same function that the analyzer
inlined anyway, but not on the path of execution on which the bug occured. We
struggle to understand that a function was responsible for freeing the memory,
but failed.

D105819 added a new visitor to improve memory leak bug reports. In addition to
inspecting the ExplodedNodes of the bug pat, the visitor tries to guess whether
the function was supposed to free memory, but failed to. Initially (in D108753),
this was done by checking whether a CXXDeleteExpr is present in the function. If
so, we assume that the function was at least party responsible, and prevent the
analyzer from pruning bug report notes in it. This patch improves this heuristic
by recognizing all deallocator functions that MallocChecker itself recognizes,
by reusing MallocChecker::isFreeingCall.

Differential Revision: https://reviews.llvm.org/D118880
2022-03-03 11:27:56 +01:00
Haojian Wu ba6c71b137 [AST] Use RecoveryExpr to model a DeclRefExpr which refers to an invalid Decl.
Previously, we didin't build a DeclRefExpr which refers to an invalid declaration.

In this patch, we handle this case by building an empty RecoveryExpr,
which will preserve more broken code (AST parent nodes that contain the
RecoveryExpr is preserved in the AST).

Differential Revision: https://reviews.llvm.org/D120812
2022-03-03 10:33:40 +01:00
Aakanksha 840695814a [AMDGPU] Add gfx1036 target
Differential Revision: https://reviews.llvm.org/D120846
2022-03-02 23:26:38 +00:00
Stanislav Mekhanoshin 2e2e64df4a [AMDGPU] Add gfx940 target
This is target definition only.

Differential Revision: https://reviews.llvm.org/D120688
2022-03-02 13:54:48 -08:00
Tong Zhang f76d3b800f [clang][CGStmt] fix crash on invalid asm statement
Clang is crashing on the following statement

  char var[9];
  __asm__ ("" : "=r" (var) : "0" (var));

This is similar to existing test: crbug_999160_regtest

The issue happens when EmitAsmStmt is trying to convert input to match
output type length. However, that is not guaranteed to be successful all the
time and if the statement itself is invalid like having an array type in
the example, we should give a regular error message here instead of
using assert().

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D120596
2022-03-02 11:18:55 -08:00
Joseph Huber 3f7c3ff90e [OpenMP] Handle sysroot option in offloading linker wrapper
Summary:
This patch correctly handles the `--sysroot=` option when passed to the
linker wrapper. This allows users to correctly find libraries that may
contain offloading code if using this option.
2022-03-02 13:02:41 -05:00
Akira Hatanaka d112cc2756 [NFC][Clang][OpaquePtr] Remove the call to Address::deprecated in
CreatePointerBitCastOrAddrSpaceCast

Differential Revision: https://reviews.llvm.org/D120757
2022-03-02 08:58:00 -08:00
Marek Kurdej 13351fdf8c [clang-format] Recognize "if consteval".
Fixes https://github.com/llvm/llvm-project/issues/54140.

Reviewed By: MyDeveloperDay, JohelEGP

Differential Revision: https://reviews.llvm.org/D120806
2022-03-02 17:46:45 +01:00
Simon Pilgrim ca94f28d15 [clang] ExprEngine::VisitCXXNewExpr - remove superfluous nullptr tests
FD has already been dereferenced
2022-03-02 15:59:10 +00:00
Chuanqi Xu 3eb2da76d7 [NFC] [C++20] [Modules] Simplify ActOnModuleImport by merging Path and Parition
Reviewed By: iains

Differential Revision: https://reviews.llvm.org/D120793
2022-03-02 23:06:36 +08:00
Saiyedul Islam 1e78d07dc9
[clang-offload-bundler] Fix typo in a test case
Intermediate file of one of the test was getting overwritten due
to name clash.
2022-03-02 13:33:56 +00:00
Manas 3ca1098557 [clang][scan-build] Change mode of installation for scan-build.1
Currently, manpage for scan-build is installed as a program, with
permission of 755. This patch makes installation of scan-build.1 as
file, with 644 permission.

Patch by Manas.

Reviewed By: steakhal

Differential Revision: https://reviews.llvm.org/D120646
2022-03-02 13:12:08 +01:00
Dawid Jurczak d813116c9d [NFC][Lexer] Remove getLangOpts function from Lexer
Given that there is only one external user of Lexer::getLangOpts
we can remove getter entirely without much pain.

Differential Revision: https://reviews.llvm.org/D120404
2022-03-02 11:17:05 +01:00
Haojian Wu 05d7e9f68e [pseudo] fix some comment nits, NFC. 2022-03-02 10:19:17 +01:00
Haojian Wu 7f99e1870f [pseudo] Add a print-grammar option in the tool
This is helpful for debugging purposes.

Differential Revision: https://reviews.llvm.org/D120724
2022-03-02 10:05:49 +01:00
Stanislav Gatev ae60884dfe [clang][dataflow] Add flow condition constraints to Environment
This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D120711
2022-03-02 08:57:27 +00:00
Haojian Wu 28efb1ccf5 [pseudo] Fix an out-of-bound error in LRTable::find.
The linear scan should not escape the TargetedStates range.

Differential Revision: https://reviews.llvm.org/D120723
2022-03-02 09:53:52 +01:00
Iain Sandoe 17ce5497aa [C++20][Modules] Improve efficiency of isModulePartition method.
The original implementation of this used the presence of a ":" in the module
name as the key, but since we now generate modules with the correct kind, we
can just test that.

Differential Revision: https://reviews.llvm.org/D120764
2022-03-02 08:31:46 +00:00
Saiyedul Islam 7a02abf06f
[clang-offload-bundler] HIP and OpenMP comaptibility for linking heterogeneous archive library
`hip-openmp-compatible` flag treats hip and hipv4 offload kinds
as compatible with openmp offload kind while extracting code objects
from a heterogenous archive library. Vice versa is also considered
compatible if hip code was compiled with -fgpu-rdc.

This flag only relaxes compatibility criteria on `OffloadKind`,
rest of the components like `Triple` and `GPUArhc` still needs to
be compatible.

Reviewed By: yaxunl

Differential Revision: https://reviews.llvm.org/D120697
2022-03-02 07:55:06 +00:00
Mircea Trofin cb2160760e [nfc][codegen] Move RegisterBank[Info].h under CodeGen
This wraps up from D119053. The 2 headers are moved as described,
fixed file headers and include guards, updated all files where the old
paths were detected (simple grep through the repo), and `clang-format`-ed it all.

Differential Revision: https://reviews.llvm.org/D119876
2022-03-01 21:53:25 -08:00
Zhihao Yuan 44eee659f1
[AST] Print NTTP args as string-literals when possible
C++20 non-type template parameter prints `MyType<{{116, 104, 105, 115}}>` when the code is as simple as `MyType<"this">`. This patch prints `MyType<{"this"}>`, with one layer of braces preserved for the intermediate structural type to trigger CTAD.

`StringLiteral` handles this case, but `StringLiteral` inside `APValue` code looks like a circular dependency. The proposed patch implements a cheap strategy to emit string literals in diagnostic messages only when they are readable and fall back to integer sequences.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D115031
2022-03-01 19:34:27 -06:00
Florian Mayer 1d730d80ce [HWASAN] erase lifetime intrinsics if tag is outside.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D120437
2022-03-01 14:47:33 -08:00
Krystian Kuzniarek 5e51ace4e8 [clang-format][docs] Fix a bad comment
Follow up to 8f310d1967.

Differential Revision: https://reviews.llvm.org/D120618
2022-03-01 21:55:32 +01:00
Björn Schäpers d6daca2173 [clang-format] Fix BreakBeforeBinaryOperators with TemplateCloser on the lhs
In the presence of pp branches we parse the token stream multiple times.
Thus the token already has the type set. It's best just not to assert on
any type in the parser.

Fixes https://github.com/llvm/llvm-project/issues/54019

Differential Revision: https://reviews.llvm.org/D120621
2022-03-01 21:55:32 +01:00
Björn Schäpers 78ac867018 [clang-format] Fix requires related crash
In the presence of pp branches we parse the token stream multiple times.
Thus the token already has the type set. It's best just not to assert on
any type in the parser.

Fixes https://github.com/llvm/llvm-project/issues/54019

Differential Revision: https://reviews.llvm.org/D120512
2022-03-01 21:55:31 +01:00
Björn Schäpers 1e7cc72ac9 [clang-format] Allow to set token types final
We have a little problem. TokenAnnotator::resetTokenMetadata() resets
the type, except for a (growing) whitelist. This is because the
TokenAnnotator visits some tokens multiple times. E.g. trying to
identify if a < is an operator less or a template opener. And in some
runs, which are bascially "reverted" the types are reset.

On the other hand, if the parser does already know the type, it should
be able to set it, without it being reset. So we introduce the ability
to set a type and make that final.

Differential Revision: https://reviews.llvm.org/D120511
2022-03-01 21:55:31 +01:00
Nicolas Miller 510fd283fd [NVPTX] Add ex2.approx.f16/f16x2 support
NOTE: this is a follow-up commit with the missing clang-side changes.

This patch adds builtins and intrinsics for the f16 and f16x2 variants of the ex2
instruction.

These two variants were added in PTX7.0, and are supported by sm_75 and above.

Note that this isn't wired with the exp2 llvm intrinsic because the ex2
instruction is only available in its approx variant.

Running ptxas on the assembly generated by the test f16-ex2.ll works as
expected.

Differential Revision: https://reviews.llvm.org/D119157
2022-03-01 11:07:11 -08:00
Jakub Chlanda a895182302 [NVPTX] Add more FMA intriniscs/builtins
This patch adds builtins/intrinsics for the following variants of FMA:

NOTE: follow-up commit with the missing clang-side changes.

- f16, f16x2
  - rn
  - rn_ftz
  - rn_sat
  - rn_ftz_sat
  - rn_relu
  - rn_ftz_relu
- bf16, bf16x2
  - rn
  - rn_relu

ptxas (Cuda compilation tools, release 11.0, V11.0.194) is happy with the generated assembly.

Differential Revision: https://reviews.llvm.org/D118977
2022-03-01 11:07:11 -08:00
Jakub Chlanda 7a6d692b3b [NVPTX] Expose float tys min, max, abs, neg as builtins
Adds support for the following builtins:

abs, neg:
- .bf16,
- .bf16x2
min, max
- {.ftz}{.NaN}{.xorsign.abs}.f16
- {.ftz}{.NaN}{.xorsign.abs}.f16x2
- {.NaN}{.xorsign.abs}.bf16
- {.NaN}{.xorsign.abs}.bf16x2
- {.ftz}{.NaN}{.xorsign.abs}.f32

Differential Revision: https://reviews.llvm.org/D117887
2022-03-01 11:07:11 -08:00
Tong Zhang 17ce89fa80 [SanitizerBounds] Add support for NoSanitizeBounds function
Currently adding attribute no_sanitize("bounds") isn't disabling
-fsanitize=local-bounds (also enabled in -fsanitize=bounds). The Clang
frontend handles fsanitize=array-bounds which can already be disabled by
no_sanitize("bounds"). However, instrumentation added by the
BoundsChecking pass in the middle-end cannot be disabled by the
attribute.

The fix is very similar to D102772 that added the ability to selectively
disable sanitizer pass on certain functions.

In this patch, if no_sanitize("bounds") is provided, an additional
function attribute (NoSanitizeBounds) is attached to IR to let the
BoundsChecking pass know we want to disable local-bounds checking. In
order to support this feature, the IR is extended (similar to D102772)
to make Clang able to preserve the information and let BoundsChecking
pass know bounds checking is disabled for certain function.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D119816
2022-03-01 18:47:02 +01:00
Erich Keane c601377b23 [NFC]Promote addInstantiatedParametersToScope to a private Sema function
This is used a few places in SemaTeplateInstantiateDecl, but is going
to be useful in SemaConcept.cpp as well. This patch switches it to be
a private function in Sema.

Differential Revision: https://reviews.llvm.org/D120729
2022-03-01 08:31:51 -08:00
Kristóf Umann 32ac21d049 [NFC][analyzer] Allow CallDescriptions to be matched with CallExprs
Since CallDescriptions can only be matched against CallEvents that are created
during symbolic execution, it was not possible to use it in syntactic-only
contexts. For example, even though InnerPointerChecker can check with its set of
CallDescriptions whether a function call is interested during analysis, its
unable to check without hassle whether a non-analyzer piece of code also calls
such a function.

The patch adds the ability to use CallDescriptions in syntactic contexts as
well. While we already have that in Signature, we still want to leverage the
ability to use dynamic information when we have it (function pointers, for
example). This could be done with Signature as well (StdLibraryFunctionsChecker
does it), but it makes it even less of a drop-in replacement.

Differential Revision: https://reviews.llvm.org/D119004
2022-03-01 17:13:04 +01:00
Adam Czachorowski 8f4ea36bfe [clang] Improve laziness of resolving module map headers.
clang has support for lazy headers in module maps - if size and/or
modtime and provided in the cppmap file, headers are only resolved when
an include directive for a file with that size/modtime is encoutered.

Before this change, the lazy resolution was all-or-nothing per module.
That means as soon as even one file in that module potentially matched
an include, all lazy files in that module were resolved. With this
change, only files with matching size/modtime will be resolved.

The goal is to avoid unnecessary stat() calls on non-included files,
which is especially valuable on networked file systems, with higher
latency.

Differential Revision: https://reviews.llvm.org/D120569
2022-03-01 15:56:23 +01:00
Egor Zhdan 3cdc1c155b [Clang] Add `-funstable` flag to enable unstable and experimental features
This new flag enables `__has_feature(cxx_unstable)` that would replace libc++ macros for individual unstable/experimental features, e.g. `_LIBCPP_HAS_NO_INCOMPLETE_RANGES` or `_LIBCPP_HAS_NO_INCOMPLETE_FORMAT`.

This would make it easier and more convenient to opt-in into all libc++ unstable features at once.

Differential Revision: https://reviews.llvm.org/D120160
2022-03-01 12:35:20 +00:00
Kristina Bessonova 57aaab3b17 [NVPTX] Fix nvvm.match.sync*.i64 intrinsics return type (i64 -> i32)
NVVM IR specification defines them with i32 return type:

  declare i32 @llvm.nvvm.match.any.sync.i64(i32 %membermask, i64 %value)
  declare {i32, i1} @llvm.nvvm.match.all.sync.i64(i32 %membermask, i64 %value)
  ...
  The i32 return value is a 32-bit mask where bit position in mask corresponds
  to thread’s laneid.

as well as PTX ISA:

  9.7.12.8. Parallel Synchronization and Communication Instructions: match.sync

  match.any.sync.type  d, a, membermask;
  match.all.sync.type  d[|p], a, membermask;
  ...
  Destination d is a 32-bit mask where bit position in mask corresponds
  to thread’s laneid.

Additionally, ptxas doesn't accept intructions, produced by NVPTX backend.
After this patch, it compiles with no issues.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D120499
2022-03-01 12:26:16 +02:00
Iain Sandoe a29f8dbb7f [C++20][Modules][8/8] Amend module visibility rules for partitions.
Implementation partitions bring two extra cases where we have
visibility of module-private data.

1) When we import a module implementation partition.
2) When a partition implementation imports the primary module intertace.

We maintain a record of direct imports into the current module since
partition decls from direct imports (but not trasitive ones) are visible.

The rules on decl-reachability are much more relaxed (with the standard
giving permission for an implementation to load dependent modules and for
the decls there to be reachable, but not visible).

Differential Revision: https://reviews.llvm.org/D118599
2022-03-01 08:29:05 +00:00
Balázs Kéri d8a2afb244 [clang][analyzer] Add modeling of 'errno'.
Add a checker to maintain the system-defined value 'errno'.
The value is supposed to be set in the future by existing or
new checkers that evaluate errno-modifying function calls.

Reviewed By: NoQ, steakhal

Differential Revision: https://reviews.llvm.org/D120310
2022-03-01 08:20:33 +01:00
Zhihao Yuan d1a59eefd3
[Clang] Remove redundant init-parens in AST print
Given a dependent `T` (maybe an undeduced `auto`),

Before:

    new T(z)  -->  new T((z))  # changes meaning with more args
    new T{z}  -->  new T{z}
        T(z)  -->      T(z)
        T{z}  -->      T({z})  # forbidden if T is auto

After:

    new T(z)  -->  new T(z)
    new T{z}  -->  new T{z}
        T(z)   -->     T(z)
        T{z}   -->     T{z}

Depends on D113393

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D120608
2022-02-28 19:31:16 -06:00