Commit Graph

87338 Commits

Author SHA1 Message Date
Jan Svoboda ff4b76d74f [clang][cli] Port TargetOpts simple string based options to new option parsing system
Depends on D84190

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84668
2020-12-18 09:40:56 +01:00
Jan Svoboda f4511aec2b [clang][cli] Port HeaderSearch simple string options to new option parsing system
Depends on D84669

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84670
2020-12-18 09:30:32 +01:00
Jan Svoboda caeb56503e [clang][cli] Convert Analyzer option string based options to new option parsing system
Depends on D84185

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84186
2020-12-18 08:56:06 +01:00
Richard Smith 8c1f2d15b8 Following up on PR48517, fix handling of template arguments that refer
to dependent declarations.

Treat an id-expression that names a local variable in a templated
function as being instantiation-dependent.

This addresses a language defect whereby a reference to a dependent
declaration can be formed without any construct being value-dependent.
Fixing that through value-dependence turns out to be problematic, so
instead this patch takes the approach (proposed on the core reflector)
of allowing the use of pointers or references to (but not values of)
dependent declarations inside value-dependent expressions, and instead
treating template arguments as dependent if they evaluate to a constant
involving such dependent declarations.

This ends up affecting a bunch of OpenMP tests, due to OpenMP
imprecisely handling instantiation-dependent constructs, bailing out
early instead of processing dependent constructs to the extent possible
when handling the template.
2020-12-17 23:54:37 -08:00
Richard Smith 4b388859f5 Ensure that we transform types into the current instantiation even if
they're only instantiation-dependent.
2020-12-17 23:23:05 -08:00
Richard Smith 71886c56f3 Where possible, don't try to ask whether a template argument is
dependent until it's been converted to match its parameter.

The type of a non-type template parameter can in general affect whether
the template argument is dependent.

Note that this is not always possible. For template arguments that name
static local variables in templates, the type of the template parameter
affects whether the argument is dependent, so the query is imprecise
until we know the parameter type. For example, in:

template<typename T> void f() {
  static const int n = 5;
  typename T::template X<n> x;
}

... we don't know whether 'n' is dependent until we know whether the
corresponding template parameter is of type 'int' or 'const int&'.
2020-12-17 23:23:05 -08:00
Richard Smith 638867afd4 DR2064: decltype(E) is only a dependent type if E is type-dependent, not
if E is merely instantiation-dependent.
2020-12-17 23:23:05 -08:00
Richard Smith d3bf0bb189 PR24076, PR33655, C++ CWG 1558: Consider the instantiation-dependence of
the nested-name-specifier when determining whether a qualified type is
instantiation-dependent.
2020-12-17 21:31:23 -08:00
Rong Xu 3733463dbb [IR][PGO] Add hot func attribute and use hot/cold attribute in func section
Clang FE currently has hot/cold function attribute. But we only have
cold function attribute in LLVM IR.

This patch adds support of hot function attribute to LLVM IR.  This
attribute will be used in setting function section prefix/suffix.
Currently .hot and .unlikely suffix only are added in PGO (Sample PGO)
compilation (through isFunctionHotInCallGraph and
isFunctionColdInCallGraph).

This patch changes the behavior. The new behavior is:
(1) If the user annotates a function as hot or isFunctionHotInCallGraph
    is true, this function will be marked as hot. Otherwise,
(2) If the user annotates a function as cold or
    isFunctionColdInCallGraph is true, this function will be marked as
    cold.

The changes are:
(1) user annotated function attribute will used in setting function
    section prefix/suffix.
(2) hot attribute overwrites profile count based hotness.
(3) profile count based hotness overwrite user annotated cold attribute.

The intention for these changes is to provide the user a way to mark
certain function as hot in cases where training input is hard to cover
all the hot functions.

Differential Revision: https://reviews.llvm.org/D92493
2020-12-17 18:41:12 -08:00
Tom Stellard 3203143f13 CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)
Add a special case for handling __builtin_mul_overflow with unsigned
inputs and a signed output to avoid emitting the __muloti4 library
call on x86_64.  __muloti4 is not implemented in libgcc, so avoiding
this call fixes compilation of some programs that call
__builtin_mul_overflow with these arguments.

For example, this fixes the build of cpio with clang, which includes code from
gnulib that calls __builtin_mul_overflow with these argument types.

Reviewed By: vsk

Differential Revision: https://reviews.llvm.org/D84405
2020-12-17 14:30:31 -08:00
Joachim Meyer c755e41c33 Fix -Wno-error= parsing in clang-format.
As noted in https://reviews.llvm.org/D86137#2460135 parsing of
the clang-format parameter -Wno-error=unknown fails.
This currently is done by having `-Wno-error=unknown` as an option.
In this patch this is changed to make `-Wno-error=` parse an enum into a bit set.
This way the parsing is fixed and also we can possibly add new options easily.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D93459
2020-12-17 22:23:42 +01:00
Nico Weber 49c248bd62 clang-cl: Remove /Zd flag
cl.exe doesn't understand Zd (in either MSVC 2017 or 2019), so neiter
should we. It used to do the same as `-gline-tables-only` which is
exposed as clang-cl flag as well, so if you want this behavior, use
`gline-tables-only`. That makes it clear that it's a clang-cl-only flag
that won't work with cl.exe.

Motivated by the discussion in D92958.

Differential Revision: https://reviews.llvm.org/D93458
2020-12-17 15:39:40 -05:00
Johannes Doerfert 994bb6eb7d [OpenMP][NFC] Provide a new remark and documentation
If a GPU function is externally reachable we give up trying to find the
(unique) kernel it is called from. This can hinder optimizations. Emit a
remark and explain mitigation strategies.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D93439
2020-12-17 14:38:26 -06:00
Nick Desaulniers e75fec2b23 [AttrDocs] document always_inline
GNU documentaion for always_inline:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html

GNU documentation for function attributes:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Microsoft documentation for __force_inline:
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp

Reviewed By: ojeda

Differential Revision: https://reviews.llvm.org/D68410
2020-12-17 12:34:23 -08:00
Valentin Clement f4c8b80318 [openmp] Remove clause from OMPKinds.def and use OMP.td info
Remove the OpenMP clause information from the OMPKinds.def file and use the
information from the new OMP.td file. There is now a single source of truth for the
directives and clauses.

To avoid generate lots of specific small code from tablegen, the macros previously
used in OMPKinds.def are generated almost as identical. This can be polished and
possibly removed in a further patch.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D92955
2020-12-17 14:08:12 -05:00
Baptiste Saleil c2892978e9 [PowerPC] Rename the vector pair intrinsics and builtins to replace the _mma_ prefix by _vsx_
On PPC, the vector pair instructions are independent from MMA.
This patch renames the vector pair LLVM intrinsics and Clang builtins to replace the _mma_ prefix by _vsx_ in their names.
We also move the vector pair type/intrinsic/builtin tests to their own files.

Differential Revision: https://reviews.llvm.org/D91974
2020-12-17 13:19:27 -05:00
Tomas Matheson f500662924 Detect section type conflicts between functions and variables
If two variables are declared with __attribute__((section(name))) and
the implicit section types (e.g. read only vs writeable) conflict, an
error is raised. Extend this mechanism so that an error is raised if the
section type implied by a function's __attribute__((section)) conflicts
with that of another variable.
2020-12-17 11:43:47 -05:00
Jon Chesterfield daf39e3f2d [amdgpu] Default to code object v3
[amdgpu] Default to code object v3
v4 is not yet readily available, and doesn't appear
to be implemented in the back end

Reviewed By: t-tye, yaxunl

Differential Revision: https://reviews.llvm.org/D93258
2020-12-17 16:09:33 +00:00
Zequan Wu fb0f728805 [Clang] Make nomerge attribute a function attribute as well as a statement attribute.
Differential Revision: https://reviews.llvm.org/D92800
2020-12-17 07:45:38 -08:00
Florian Hahn 01089c876b
[InstCombine] Preserve !annotation on newly created instructions.
If the source instruction has !annotation metadata, all instructions
created during combining should also have it. Tell the builder to
add it.

The !annotation system was discussed on llvm-dev as part of
'RFC: Combining Annotation Metadata and Remarks'
(http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html)

This patch is based on an earlier patch by Francis Visoiu Mistrih.

Reviewed By: thegameg, lebedev.ri

Differential Revision: https://reviews.llvm.org/D91444
2020-12-17 15:20:23 +00:00
serge-sans-paille 5e31e226b5 Remove Python2 fallback and only advertise Python3 in the doc
Differential Revision: https://www.youtube.com/watch?v=RsL0cipURA0
2020-12-17 15:40:16 +01:00
Lucas Prates c5046ebdf6 [ARM] Adding v8.7-A command-line support for the ARM target
This extends the command-line support for the 'armv8.7-a' architecture
name to the ARM target.

Based on a patch written by Momchil Velikov.

Reviewed By: ostannard

Differential Revision: https://reviews.llvm.org/D93231
2020-12-17 13:48:54 +00:00
Lucas Prates c4d851b079 [ARM][AAarch64] Initial command-line support for v8.7-A
This introduces command-line support for the 'armv8.7-a' architecture name
(and an alias without the '-', as usual), and for the 'ls64' extension name.

Based on patches written by Simon Tatham.

Reviewed By: ostannard

Differential Revision: https://reviews.llvm.org/D91776
2020-12-17 13:47:28 +00:00
dfukalov 9ed8e0caab [NFC] Reduce include files dependency and AA header cleanup (part 2).
Continuing work started in https://reviews.llvm.org/D92489:

Removed a bunch of includes from "AliasAnalysis.h" and "LoopPassManager.h".

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D92852
2020-12-17 14:04:48 +03:00
Barry Revzin 92310454bf Make LLVM build in C++20 mode
Part of the <=> changes in C++20 make certain patterns of writing equality
operators ambiguous with themselves (sorry!).
This patch goes through and adjusts all the comparison operators such that
they should work in both C++17 and C++20 modes. It also makes two other small
C++20-specific changes (adding a constructor to a type that cases to be an
aggregate, and adding casts from u8 literals which no longer have type
const char*).

There were four categories of errors that this review fixes.
Here are canonical examples of them, ordered from most to least common:

// 1) Missing const
namespace missing_const {
    struct A {
    #ifndef FIXED
        bool operator==(A const&);
    #else
        bool operator==(A const&) const;
    #endif
    };

    bool a = A{} == A{}; // error
}

// 2) Type mismatch on CRTP
namespace crtp_mismatch {
    template <typename Derived>
    struct Base {
    #ifndef FIXED
        bool operator==(Derived const&) const;
    #else
        // in one case changed to taking Base const&
        friend bool operator==(Derived const&, Derived const&);
    #endif
    };

    struct D : Base<D> { };

    bool b = D{} == D{}; // error
}

// 3) iterator/const_iterator with only mixed comparison
namespace iter_const_iter {
    template <bool Const>
    struct iterator {
        using const_iterator = iterator<true>;

        iterator();

        template <bool B, std::enable_if_t<(Const && !B), int> = 0>
        iterator(iterator<B> const&);

    #ifndef FIXED
        bool operator==(const_iterator const&) const;
    #else
        friend bool operator==(iterator const&, iterator const&);
    #endif
    };

    bool c = iterator<false>{} == iterator<false>{} // error
          || iterator<false>{} == iterator<true>{}
          || iterator<true>{} == iterator<false>{}
          || iterator<true>{} == iterator<true>{};
}

// 4) Same-type comparison but only have mixed-type operator
namespace ambiguous_choice {
    enum Color { Red };

    struct C {
        C();
        C(Color);
        operator Color() const;
        bool operator==(Color) const;
        friend bool operator==(C, C);
    };

    bool c = C{} == C{}; // error
    bool d = C{} == Red;
}

Differential revision: https://reviews.llvm.org/D78938
2020-12-17 10:44:10 +00:00
mydeveloperday db41c0b357 [clang-format] PR35514 brace-init member initializers in function-try-blocks are not formatted correctly
https://bugs.llvm.org/show_bug.cgi?id=35514

Initializer lists with a try-block are incorrectly formatted.

e.g.

```
Foo(int abc, int def) try : _abc(abc), _def{def}, _ghi{1} {
  callA();
  callB();
} catch (std::exception&) {
}
```

is formatted as:

```
Foo(int abc, int def) try : _abc(abc), _def { def }
, _ghi{1} {
  callA();
  callB();
}
catch (std::exception&) {
}
```

This revision adds support in the parseTryCatch for braced initializers in the initializer list

Reviewed By: curdeius, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D93296
2020-12-17 09:39:37 +00:00
Andrzej Warzynski 7f19712a6a [clang][nfc] Update comment to match the opening `{` 2020-12-17 09:04:41 +00:00
Fangrui Song c70f36865e Use basic_string::find(char) instead of basic_string::find(const char *s, size_type pos=0)
Many (StringRef) cannot be detected by clang-tidy performance-faster-string-find.
2020-12-16 23:28:32 -08:00
Johannes Doerfert 2e6e4e6aee [OpenMP] Add initial support for `omp [begin/end] assumes`
The `assumes` directive is an OpenMP 5.1 feature that allows the user to
provide assumptions to the optimizer. Assumptions can refer to
directives (`absent` and `contains` clauses), expressions (`holds`
clause), or generic properties (`no_openmp_routines`, `ext_ABCD`, ...).

The `assumes` spelling is used for assumptions in the global scope while
`assume` is used for executable contexts with an associated structured
block.

This patch only implements the global spellings. While clauses with
arguments are "accepted" by the parser, they will simply be ignored for
now. The implementation lowers the assumptions directly to the
`AssumptionAttr`.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D91980
2020-12-16 20:02:49 -06:00
Tom Roeder 1844ab770c [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.
This allows ASTs to be merged when they contain GenericSelectionExpr
nodes (this is _Generic from C11). This is needed, for example, for
CTU analysis of C code that makes use of _Generic, like the Linux
kernel.

The node is already supported in the AST, but it didn't have a matcher
in ASTMatchers. So, this change adds the matcher and adds support to
ASTImporter. Additionally, this change adds support for structural
equivalence of _Generic in the AST.

Reviewed By: martong, aaron.ballman

Differential Revision: https://reviews.llvm.org/D92600
2020-12-16 15:39:50 -08:00
Tom Roeder f31e9bcd73 Test commit: add valid punctuation to a comment. NFC. 2020-12-16 15:33:19 -08:00
Thomas Preud'homme 150fe05db4 [Test] Fix undef var in catch-undef-behavior.c
Commit 9e52c43090 removed the directive
defining LINE_1600 but left a string substitution to that variable in a
CHECK-NOT directive. This will make that CHECK-NOT directive always fail
to match, no matter the string.

This commit follows the pattern done in
9e52c43090 of simplifying the CHECK-NOT to
only look for the function name and the opening parenthesis, thereby not
requiring the LINE_1600 variable.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D93350
2020-12-16 22:39:41 +00:00
Reid Kleckner b7905e81fc Fix split-debug.c test on Windows 2020-12-16 13:48:57 -08:00
Shivanshu Goyal e53b9f733a Print source location in the error message when parens are missing around sizeof typename and the expression is inside macro expansion
Given the following code:

```
void Foo(int);

void Baz()
{
	Bar(sizeof int);
}
```

The error message which is printed today is this:
```
error: expected parentheses around type name in sizeof expression
```

There is no source location printed whatsoever, so fixing a compile break like this becomes extremely hard in a large codebase.

My change improves the error message. But it doesn't output a FixItHint because I wasn't able to figure out how to get the locations for left and right parens. So any tips would be appreciated.

```
<source>:7:6: error: expected parentheses around type name in sizeof expression
        Bar(sizeof int);
            ^
```

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D91129
2020-12-16 12:03:31 -08:00
Richard Smith 735ab86b81 PR47474: Add test for Clang's current behavior.
Our current behavior rejects the example, following the current language
rules, but it's likely the rules will be revised to allow this example.
2020-12-16 12:01:00 -08:00
Yaxun (Sam) Liu b9fb063e63 [clang-offload-bundler] Add option -allow-missing-bundles
There are out-of-tree tools using clang-offload-bundler to extract
bundles from bundled files. When a bundle is not in the bundled
file, clang-offload-bundler is expected to emit an error message
and return non-zero value. However currently clang-offload-bundler
silently generates empty file for the missing bundles.

Since OpenMP/HIP toolchains expect the current behavior, an option
-allow-missing-bundles is added to let clang-offload-bundler
create empty file when a bundle is missing when unbundling.
The unbundling job action is updated to use this option by
default.

clang-offload-bundler itself will emit error when a bundle
is missing when unbundling by default.

Changes are also made to check duplicate targets in -targets
option and emit error.

Differential Revision: https://reviews.llvm.org/D93068
2020-12-16 14:52:39 -05:00
Emma Blink 7685d818ef Mark implicit coroutine variables as being implicit
This prevents the clang-tidy readability-identifier-naming check from
triggering on implicit __coro_gro and __promise variables in coroutines.
2020-12-16 14:42:07 -05:00
Bardia Mahjour 6eff12788e [DDG] Data Dependence Graph - DOT printer - recommit
This is being recommitted to try and address the MSVC complaint.

This patch implements a DDG printer pass that generates a graph in
the DOT description language, providing a more visually appealing
representation of the DDG. Similar to the CFG DOT printer, this
functionality is provided under an option called -dot-ddg and can
be generated in a less verbose mode under -dot-ddg-only option.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D90159
2020-12-16 12:37:36 -05:00
Jon Chesterfield c0619d3b21 [NFC] Use regex for code object version in hip tests
[NFC] Use regex for code object version in hip tests

Extracted from D93258. Makes tests robust to changes in default
code object version.

Reviewed By: t-tye

Differential Revision: https://reviews.llvm.org/D93398
2020-12-16 17:00:19 +00:00
Erik Pilkington 92d6e8001e NFC: balance a quote in AttrDocs.td
This was confusing my editor.
2020-12-16 10:01:24 -05:00
Erik Pilkington 95b2dab199 [Sema] Fix a miscompile by retaining array qualifiers when folding VLAs to constant arrays
rdar://72243125

Differential revision: https://reviews.llvm.org/D93247
2020-12-16 10:01:24 -05:00
Joe Ellis dad07baf12 [clang][AArch64][SVE] Avoid going through memory for VLAT <-> VLST casts
This change makes use of the llvm.vector.extract intrinsic to avoid
going through memory when performing bitcasts between vector-length
agnostic types and vector-length specific types.

Depends on D91362

Reviewed By: c-rhodes

Differential Revision: https://reviews.llvm.org/D92761
2020-12-16 12:24:32 +00:00
Jan Svoboda 0da240c2d0 [clang][cli] Port DependencyOutput string based options to new option parsing system
Depends on D84186

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D84187
2020-12-16 10:28:37 +01:00
Qiu Chaofan f141d1afc5 [NFC] Pre-commit test for long-double builtins
This test reflects clang behavior on long-double type math library
builtins under default or explicit 128-bit long-double options.
2020-12-16 17:19:54 +08:00
Jan Svoboda 383778e217 [clang][cli] Port LangOpts option flags to new option parsing system
Depends on D83892 & D83694 & D93104.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D83979
2020-12-16 10:16:27 +01:00
Jan Svoboda 741978d727 [clang][cli] Port CodeGen option flags to new option parsing system
Depends on D83697.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D83892
2020-12-16 10:00:33 +01:00
Jan Svoboda f2661bed18 [clang][cli] Prevent double denormalization
If both flags created through BoolOption are CC1Option and the keypath has a non-default or non-implied value, the denormalizer gets called twice. If the denormalizer has the ability to generate both flags, we can end up generating the same flag twice.

Reviewed By: dexonsmith, Bigcheese

Differential Revision: https://reviews.llvm.org/D93094
2020-12-16 09:44:54 +01:00
Jan Svoboda 95114f21f5 [clang][cli] Do not marshall only CC1Option flags in BoolOption
We cannot be sure whether a flag is CC1Option inside the definition of `BoolOption`. Take the example below:

```
let Flags = [CC1Option] in {
  defm xxx : BoolOption<...>;
}
```

where TableGen applies `Flags = [CC1Option]` to the `xxx` and `no_xxx` records **after** they have been is fully declared by `BoolOption`.

For the refactored `-f[no-]debug-pass-manager` flags (see the diff), this means `BoolOption` never adds any marshalling info, as it doesn't see either of the flags as `CC1Option`.

For that reason, we should defensively append the marshalling information to both flags inside `BoolOption`. Now the check for `CC1Option` needs to happen later, in the parsing macro, when all TableGen logic has been resolved.

However, for some flags defined through `BoolOption`, we can run into issues:

```
// Options.td
def fenable_xxx : /* ... */;

// Both flags are CC1Option, the first is implied.
defm xxx : BoolOption<"xxx,
  "Opts.Xxx", DefaultsToFalse,
  ChangedBy<PosFlag, [CC1Option], "", [fenable_xxx]>,
  ResetBy<NegFlag, [CC1Option]>>;
```

When parsing `clang -cc1 -fenable-xxx`:
* we run parsing for `PosFlag`:
  * set `Opts.Xxx` to default `false`,
  * discover `PosFlag` is implied by `-fenable-xxx`: set `Opts.Xxx` to `true`,
  * don't see `-fxxx` on command line: do nothing,
* we run parsing for `NegFlag`:
  * set `Opts.Xxx` to default `false`,
  * discover `NegFlag` cannot be implied: do nothing,
  * don't see `-fno-xxx` on command line: do nothing.

Now we ended up with `Opts.Xxx` set to `false` instead of `true`. For this reason, we need to ensure to append the same `ImpliedByAnyOf` instance to both flags.

This means both parsing runs now behave identically (they set the same default value, run the same "implied by" check, and call `makeBooleanOptionNormalizer` that already has information on both flags, so it returns the same value in both calls).

The solution works well, but what might be confusing is this: you have defined a flag **A** that is not `CC1Option`, but can be implied by another flag **B** that is `CC1Option`:
* if **A** is defined manually, it will never get implied, as the code never runs
```
def no_signed_zeros : Flag<["-"], "fno-signed-zeros">, Group<f_Group>, Flags<[]>,
  MarshallingInfoFlag<"LangOpts->NoSignedZero">, ImpliedByAnyOf<[menable_unsafe_fp_math]>;
```
* if **A** is defined by `BoolOption`, it could get implied, as the code is run by its `CC1Option` counterpart:
```
defm signed_zeros : BoolOption<"signed-zeros",
  "LangOpts->NoSignedZero", DefaultsToFalse,
  ChangedBy<NegFlag, [], "Allow optimizations that ignore the sign of floating point zeros",
            [cl_no_signed_zeros, menable_unsafe_fp_math]>,
  ResetBy<PosFlag, [CC1Option]>, "f">, Group<f_Group>;
```

This is a surprising inconsistency.

One solution might be to somehow propagate the final `Flags` of the implied flag in `ImpliedByAnyOf` and check whether it has `CC1Option` in the parsing macro. However, I think it doesn't make sense to spend time thinking about a corner case that won't come up in real code.

An observation: it is unfortunate that the marshalling information is a part of the flag definition. If we represented it in a separate structure, we could avoid the "double parsing" problem by having a single source of truth. This would require a lot of additional work though.

Note: the original patch missed the `CC1Option` check in the parsing macro, making my reasoning here incomplete. Moreover, it contained a change to denormalization that wasn't necessarily related to these changes, so I've extracted that to a follow-up patch: D93094.

Reviewed By: dexonsmith, Bigcheese

Differential Revision: https://reviews.llvm.org/D93008
2020-12-16 09:29:40 +01:00
Yaxun (Sam) Liu 4f14b80803 [HIP] unbundle bundled preprocessor output
There is a use case that users want to emit preprocessor
output as file and compile the preprocessor output later
with -x hip-cpp-output.

Clang emits bundled preprocessor output when users
compile with -E for combined host/device compilations.
Clang should be able to compile the bundled preprocessor
output with -x hip-cpp-output. Basically clang should
unbundle the bundled preprocessor output and launch
device and host compilation actions.

Currently there is a bug in clang driver causing bundled
preprocessor output not unbundled.

This patch fixes that.

Differential Revision: https://reviews.llvm.org/D92720
2020-12-15 22:14:18 -05:00
Nathan James c415e709e9
[ASTMatchers][NFC] Strip prefixes eagerly in dynamic matcher arg traits. 2020-12-16 01:56:30 +00:00
Johannes Doerfert 1efd7a73ac Revert "[OpenMP] Add initial support for `omp [begin/end] assumes`"
There is a build error with gcc-5 [0], investigating now.

[0] https://reviews.llvm.org/D91980#2456526

This reverts commit a5a14cbe7f.
2020-12-15 18:03:10 -06:00
Stephen Kelly 702f822ca5 [ASTMatcher] Avoid isImplicit call on object which could be nullptr
A callExpr whose argument is dependent has a null getCalleeDecl().

Differential Revision: https://reviews.llvm.org/D93324
2020-12-15 23:27:38 +00:00
Johannes Doerfert bc7126b2bc [FIX] Add the comma missing in D91979 2020-12-15 17:24:53 -06:00
Richard Smith 7e7f38f853 DR1413 and part of P1815R2: Minor improvements to Clang's determination
of type- and value-dependency.

A static data member initialized to a constant inside a class template
is no longer considered value-dependent, per DR1413. A const but not
constexpr variable of literal type (other than integer or enumeration)
is no longer considered value-dependent, per P1815R2.
2020-12-15 14:53:26 -08:00
Richard Smith 6b760a50f5 DR2100: &expr is value-dependent if expr constant-evaluates to a
dependent declaration.
2020-12-15 14:53:26 -08:00
Johannes Doerfert a5a14cbe7f [OpenMP] Add initial support for `omp [begin/end] assumes`
The `assumes` directive is an OpenMP 5.1 feature that allows the user to
provide assumptions to the optimizer. Assumptions can refer to
directives (`absent` and `contains` clauses), expressions (`holds`
clause), or generic properties (`no_openmp_routines`, `ext_ABCD`, ...).

The `assumes` spelling is used for assumptions in the global scope while
`assume` is used for executable contexts with an associated structured
block.

This patch only implements the global spellings. While clauses with
arguments are "accepted" by the parser, they will simply be ignored for
now. The implementation lowers the assumptions directly to the
`AssumptionAttr`.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D91980
2020-12-15 16:51:34 -06:00
Johannes Doerfert b9c77542e2 [Clang][Attr] Introduce the `assume` function attribute
The `assume` attribute is a way to provide additional, arbitrary
information to the optimizer. For now, assumptions are restricted to
strings which will be accumulated for a function and emitted as comma
separated string function attribute. The key of the LLVM-IR function
attribute is `llvm.assume`. Similar to `llvm.assume` and
`__builtin_assume`, the `assume` attribute provides a user defined
assumption to the compiler.

A follow up patch will introduce an LLVM-core API to query the
assumptions attached to a function. We also expect to add more options,
e.g., expression arguments, to the `assume` attribute later on.

The `omp [begin] asssumes` pragma will leverage this attribute and
expose the functionality in the absence of OpenMP.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D91979
2020-12-15 16:51:34 -06:00
Richard Smith c4736b91f8 Don't memcpy from an empty ArrayRef; the base pointer could be null, and
the C rules say memcpy can't accept a null pointer.

This should fix a test failure with the ubsan buildbots.
2020-12-15 14:37:52 -08:00
Duncan P. N. Exon Smith 0eb4378290 Frontend: Fix confusing comment at call to clearOutputFiles, NFC
Fix the comment in front of `compileModuleImpl`'s call to
`CompilerInstance::clearOutputFiles`. The purpose of this call is to
delete any stray temporary files after the module generation thread
crashes.

The comment is from f545f67de3, and
was associated with manually deleting a generated module map. Then
13afbf42d8 added this `clearOutputFiles`
call between the comment and the code it referenced. Finally,
1f76c4e810 started sending the generated
module map directly to the SourceManager instead of putting it on disk,
deleting the call that the comment referenced.

No functionality change.
2020-12-15 14:21:37 -08:00
Fangrui Song 59decf8e9c [clang] Migrate deprecated DebugInfo::get to DILocation::get 2020-12-15 13:59:31 -08:00
Baptiste Saleil 57d83c3a90 [PowerPC] Enable paired vector type and intrinsics when MMA is disabled
This patch enables the Clang type __vector_pair and its associated LLVM
intrinsics even when MMA is disabled. With this patch, the type is now controlled
by the PPC paired-vector-memops option. The builtins and intrinsics will be
renamed to drop the mma prefix in another patch.

Differential Revision: https://reviews.llvm.org/D91819
2020-12-15 15:14:11 -06:00
Craig Topper c103f9ef5a [RISCV] Use default member initializers for the feature flags in RISCVTargetInfo. NFC
This avoids having to repeat all the flags in the constructor's
initializer list in the same order. This style is already used by
several other targets.
2020-12-15 12:37:47 -08:00
Richard Smith 76edf98b27 Set decl on DeclRefExpr directly during deserialization rather than
relying on a setter that might have additional side-effects. NFC.
2020-12-15 12:00:57 -08:00
Richard Smith 6c365cd31e Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types.
For the Itanium ABI, this implements the mangling rule suggested in
https://github.com/itanium-cxx-abi/cxx-abi/issues/47, namely mangling
such template arguments as being cast to the parameter type in the case
where the template name is overloadable. This can cause a mangling
change for rare cases, where

 * the template argument declaration is converted from its declared type
   to the type of the template parameter, and
 * the template parameter either has a deduced type or is a parameter of
   a function template.

However, such changes are necessary to avoid mangling collisions. The
ABI changes can be reversed with -fclang-abi-compat=11 or earlier.

Re-commit with a fix for a couple of regressions.

Differential Revision: https://reviews.llvm.org/D91488
2020-12-15 12:00:57 -08:00
Aaron Ballman ef40d5233b Adding a test case that I accidentally dropped from 27ea7d0a6e 2020-12-15 14:56:44 -05:00
cchen 82f2c61ca0 [OPENMP51] Add present modifier in defaultmap clause
Support present modifier in defaultmap by adding an extra dimension
for `ImplicitMap`. Therefore, we now create OMPMapClause in `ActOnOpenMPExecutableDirective`
based on both `maptype` and `maptype-modifier`.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D92427
2020-12-15 13:50:12 -06:00
Kevin P. Neal 2ec5973fdd Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute."
The test is busted on some hosts that aren't the one I'm using.

This reverts commit 67a1ffd88a.
2020-12-15 12:58:47 -05:00
Kevin P. Neal 67a1ffd88a [FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute.
Similar to D69312, and documented in D69839, the IRBuilder needs to add
the strictfp attribute to invoke instructions when constrained floating
point is enabled.

Differential Revision: https://reviews.llvm.org/D93134
2020-12-15 12:38:10 -05:00
Joe Ellis 5a2a8369e8 [AArch64][NEON] Remove undocumented vceqz{,q}_p16, vml{a,s}q_n_f64 intrinsics
Prior to this patch, Clang supported the following C/C++ intrinsics:

    vceqz_p16
    vceqzq_p16
    vmlaq_n_f64
    vmlsq_n_f64

... exposed through arm_neon.h. However, these intrinsics are not part
of the ACLE, allowing developers to write code that is not compatible
with other toolchains.

This patch removes these intrinsics.

There is a bug report capturing this issue here:

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

Reviewed By: bsmith

Differential Revision: https://reviews.llvm.org/D93206
2020-12-15 17:19:16 +00:00
Nathan James 8acb5f2723
[clang][driver][NFC] Use StringRef instead of std::string 2020-12-15 16:19:12 +00:00
Mircea Trofin e2dc306b1a [utils] Fix UpdateTestChecks case where 2 runs differ for last label
Two RUN lines produce outputs that, each, have some common parts and
some different parts. The common parts are checked under label A. The
differing parts are associated to a function and checked under labels B
and C, respectivelly.
When build_function_body_dictionary is called for the first RUN line, it
will attribute the function body to labels A and C. When the second RUN
is passed to build_function_body_dictionary, it sees that the function
body under A is different from what it has. If in this second RUN line,
A were at the end of the prefixes list, A's body is still kept
associated with the first run's function.

When we output the function body (i.e. add_checks), we stop after
emitting for the first prefix matching that function. So we end up with
the wrong function body (first RUN's A-association).

There is no reason to special-case the last label in the prefixes list,
and the fix is to always clear a label association if we find a RUN line
where the body is different.

Differential Revision: https://reviews.llvm.org/D93078
2020-12-15 07:16:54 -08:00
Chuanqi Xu 8b48d24373 [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment
Summary: The clang-format may go wrong when handle c++ coroutine keywords and pointer.
The default value for PointerAlignment is PAS_Right. So the following format is good:
```
co_return *a;
```
But within some code style, the value for PointerAlignment is PAS_Left, the behavior goes wrong:
```
co_return* a;
```

test-plan: check-clang

reviewers: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D91245
2020-12-15 20:50:46 +08:00
Jan Svoboda 56c5548d7f [clang][cli] Squash multiple cc1 -fxxx-exceptions flags into single -exception-model=xxx option
This patch enables marshalling of the exception model options while enforcing their mutual exclusivity. The clang driver interface remains the same, this only affects the cc1 command line.

Depends on D93215.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93216
2020-12-15 10:15:58 +01:00
Jan Svoboda 573255b47e [clang][cli] Squash exception model in LangOptions into one member
This squashes multiple members in LangOptions into one. This is leveraged in a follow-up patch that implements marshalling of related command-line options.

Depends on D93214.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93215
2020-12-15 10:15:58 +01:00
Jan Svoboda f24e58df7d [clang][cli] Create accessors for exception models in LangOptions
This abstracts away the members that are being replaced in a follow-up patch.

Depends on D83979.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93214
2020-12-15 10:15:58 +01:00
Nico Weber 7799ef7121 Revert "Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef"
This reverts commit a40db5502b.
and follow-up d636b881bb

Somewhat speculative, likely broke check-clang on Windows:
https://reviews.llvm.org/D92975#2453482
2020-12-14 22:05:08 -05:00
Nico Weber c9ede6f336 Revert "[amdgpu] Default to code object v3"
This reverts commit 4b2e7d0215.
Breaks check-clang, see https://reviews.llvm.org/D93258#2453600
2020-12-14 22:01:26 -05:00
Rong Xu c36f31c4db [PGO] remove unintentional code in early commit
Remove unintentional code in
commit 54e03d [PGO] Verify BFI counts after loading profile data.
2020-12-14 18:41:49 -08:00
Alexander Kornienko 9c49b0bba0 Remove the ast_type_traits namespace.
This is the final cleanup after https://reviews.llvm.org/D74499

Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D93244
2020-12-15 02:16:12 +01:00
Jon Chesterfield 4b2e7d0215 [amdgpu] Default to code object v3
[amdgpu] Default to code object v3
v4 is not yet readily available, and doesn't appear
to be implemented in the back end

Reviewed By: t-tye

Differential Revision: https://reviews.llvm.org/D93258
2020-12-15 01:11:09 +00:00
Reid Kleckner d2ed9d6b7e Revert "ADT: Migrate users of AlignedCharArrayUnion to std::aligned_union_t, NFC"
We determined that the MSVC implementation of std::aligned* isn't suited
to our needs. It doesn't support 16 byte alignment or higher, and it
doesn't really guarantee 8 byte alignment. See
https://github.com/microsoft/STL/issues/1533

Also reverts "ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC"

Also reverts "ADT: Remove AlignedCharArrayUnion, NFC" to bring back
AlignedCharArrayUnion.

This reverts commit 4d8bf870a8.

This reverts commit d10f9863a5.

This reverts commit 4b5dc150b9.
2020-12-14 17:04:06 -08:00
Rong Xu 54e03d03a7 [PGO] Verify BFI counts after loading profile data
This patch adds the functionality to compare BFI counts with real
profile
counts right after reading the profile. It will print remarks under
-Rpass-analysis=pgo, or the internal option -pass-remarks-analysis=pgo.

Differential Revision: https://reviews.llvm.org/D91813
2020-12-14 15:56:10 -08:00
Gulfem Savrun Yeniceri 7c0e3a77bc [clang][IR] Add support for leaf attribute
This patch adds support for leaf attribute as an optimization hint
in Clang/LLVM.

Differential Revision: https://reviews.llvm.org/D90275
2020-12-14 14:48:17 -08:00
Duncan P. N. Exon Smith b61f288a58 Add comment to closing brace of anonymous namespace, NFC 2020-12-14 14:38:12 -08:00
Duncan P. N. Exon Smith 90d056ceb9 AST: Silence an instance of -Wsign-compare, NFC
Looks this this was added by 68f53960e1.
2020-12-14 14:36:59 -08:00
Duncan P. N. Exon Smith a40db5502b Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef
Migrate `HeaderSearch::LoadedModuleMaps` and a number of APIs over to
`FileEntryRef`. This should have no functionality change. Note that two
`FileEntryRef`s hash the same if they point at the same `FileEntry`.

Differential Revision: https://reviews.llvm.org/D92975
2020-12-14 14:35:11 -08:00
Bardia Mahjour a29ecca781 Revert "[DDG] Data Dependence Graph - DOT printer"
This reverts commit fd4a10732c, to
investigate the failure on windows: http://lab.llvm.org:8011/#/builders/127/builds/3274
2020-12-14 16:54:20 -05:00
Philip Reames 3b3eb7f07f Speculative fix for build bot failures
(The clang build fails for me locally, so this is based on built bot output and a guess as to root cause.)

f5fe849 made the execution of LAA conditional, so I'm guessing that's the root cause.
2020-12-14 13:44:40 -08:00
Bardia Mahjour fd4a10732c [DDG] Data Dependence Graph - DOT printer
This patch implements a DDG printer pass that generates a graph in
the DOT description language, providing a more visually appealing
representation of the DDG. Similar to the CFG DOT printer, this
functionality is provided under an option called -dot-ddg and can
be generated in a less verbose mode under -dot-ddg-only option.

Differential Revision: https://reviews.llvm.org/D90159
2020-12-14 16:41:14 -05:00
Matt Arsenault ef4da3c2ba clang: Add byval on x86_intrcc parameter 0
This will allow removing the special case treatment of the parameter
and avoid depending on the pointer's element type.
2020-12-14 16:34:37 -05:00
Hafiz Abid Qadeer 670686ad8e Add initial support for multilibs in Baremetal toolchain.
This patch add support of riscv multilibs in the Baremetal toolchain. It is
a bit different to what is done in GNU.cpp as we are not iterating a
GNU sysroot to find the multilibs. This is intended for an llvm only
toolchain. We are not checking for the presence of any runtime bits to
enable a specific multilib.

I have structured the patch so that other targets for which
there is no multilibs support yet in Baremetal.cpp (e.g. arm-none-eabi)
will not be affected. Patch also allows some multilibs reuse.

Long term, I would like to go in the direction of data-driven specification of
multilib directories and flags.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D93138
2020-12-14 20:49:45 +00:00
Artem Belevich 0936655bac [CUDA] Do not diagnose host/device variable access in dependent types.
`isCUDADeviceBuiltinSurfaceType()`/`isCUDADeviceBuiltinTextureType()` do not
work on dependent types as they rely on specific type attributes.

Differential Revision: https://reviews.llvm.org/D92893
2020-12-14 11:53:18 -08:00
Sylvain Audi 5f53d28fa6 Revert "[clang-scan-deps] Support clang-cl"
Reverting, as it breaks build on mac.

This reverts commit 640ad76911.
2020-12-14 13:32:38 -05:00
Gabor Marton 68f53960e1 [ASTImporter] Fix import of a typedef that has an attribute
The import of a typedefs with an attribute uses clang::Decl::setAttrs().
But that needs the ASTContext which we can get only from the
TranslationUnitDecl. But we can get the TUDecl only thourgh the
DeclContext, which is not set by the time of the setAttrs call.

Fix: import the attributes only after the DC is surely imported.
Btw, having the attribute import initiated from GetImportedOrCreateDecl was
fundamentally flawed. Now that is implicitly fixed.

Differential Revision: https://reviews.llvm.org/D92962
2020-12-14 18:27:05 +01:00
Sylvain Audi 640ad76911 [clang-scan-deps] Support clang-cl
clang-scan-deps contains some command line parsing and modifications.
This patch adds support for clang-cl command options.

Differential Revision: https://reviews.llvm.org/D92191
2020-12-14 12:06:05 -05:00
Raphael Isemann 22ccdb7870 Revert "Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types."
This reverts commit 05cdf4acf4. It breaks stage-2
compilation of LLVM, see https://reviews.llvm.org/D91488#2451534
2020-12-14 14:03:38 +01:00
Jan Svoboda 16aa00b622 [clang][cli] Port FileSystem options to new option parsing system
Depends on D84187

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84188
2020-12-14 10:17:23 +01:00
Jan Svoboda e2fc85c69b [clang][cli] Better defaults for MarshallingInfoString
Depends on D84018

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84185
2020-12-14 09:59:56 +01:00
Jan Svoboda 4b6f29413c [clang][cli] Port Preprocessor and PreprocessorOutput option flags to new option parsing system
Depends on D83979

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D84018
2020-12-14 09:19:57 +01:00
Haojian Wu 6326b09885 [AST][RecoveryExpr] Preserve type for broken overrload member call expr.
Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D80109
2020-12-14 08:50:41 +01:00
Richard Smith 05cdf4acf4 Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types.
For the Itanium ABI, this implements the mangling rule suggested in
https://github.com/itanium-cxx-abi/cxx-abi/issues/47, namely mangling
such template arguments as being cast to the parameter type in the case
where the template name is overloadable. This can cause a mangling
change for rare cases, where

 * the template argument declaration is converted from its declared type
   to the type of the template parameter, and
 * the template parameter either has a deduced type or is a parameter of
   a function template.

However, such changes are necessary to avoid mangling collisions. The
ABI changes can be reversed with -fclang-abi-compat=11 or earlier.

Re-commit with a fix for the regression introduced last time: don't
expect parameters and arguments to line up inside an <unresolved-name>
mangling.

Differential Revision: https://reviews.llvm.org/D91488
2020-12-13 22:43:24 -08:00
Richard Smith abbd57e558 Factor out and centralize repeated 'getExpandedPackSize'. 2020-12-13 22:43:23 -08:00
Tony 5ad202ce89 [NFC][AMDGPU] Reformat AMD GPU targets in cuda.cpp
Differential Revision: https://reviews.llvm.org/D93181
2020-12-13 23:02:59 +00:00
Simon Pilgrim 4855a1004d [X86] Convert fadd/fmul _mm_reduce_* intrinsics to emit llvm.reduction intrinsics (PR47506)
Followup to D87604, having confirmed on PR47506 that we can use the llvm codegen expansion for fadd/fmul as well.

Differential Revision: https://reviews.llvm.org/D92940
2020-12-13 15:37:35 +00:00
Björn Schäpers 36306403d4 [clang-format] Remove double trim
Lines[i] is already trimmed 3 lines before

Differential Revision: https://reviews.llvm.org/D91996
2020-12-13 14:16:54 +01:00
Kazushi (Jam) Marukawa 05d1729232 [VE] Optimize toolchain regression test
Optimize toolchain regression test for VE by removing not a useful test
(-fuse-init-array test) and merge several tests to one test which checks
default behavior of driver.  Also add sysroot to reduce conflicts.

These are suggested in https://reviews.llvm.org/D92996.
Thank you so much.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D93084
2020-12-13 20:26:05 +09:00
Alexey Bader a500a43587 [CodeGen][AMDGPU] Fix ICE for static initializer IR generation
Differential Revision: https://reviews.llvm.org/D92782
2020-12-12 23:26:54 +03:00
Nico Weber 956034c6c8 [mac/arm] XFAIL two more tests on arm64-apple
Part of PR46644
2020-12-12 15:20:50 -05:00
Nico Weber a5c65de295 mac/arm: XFAIL the last 3 failing tests
We should fix them, but let's XFAIL them for now so that we can start
running check-clang on bots and lock in the passing tests.

Part of 46644.
2020-12-12 15:09:17 -05:00
Tony 7beee561e2 [AMDGPU] Add missing targets to target-invalid-cpu-note.c
Differential Revision: https://reviews.llvm.org/D93018
2020-12-12 18:19:03 +00:00
Tony 92ab6ed667 [AMDGPU] Add missing targets to amdgpu-features.cl
Differential Revision: https://reviews.llvm.org/D93017
2020-12-12 18:19:02 +00:00
Melanie Blower 320af6b138 Create SPIRABIInfo to enable SPIR_FUNC calling convention.
Background: Call to library arithmetic functions for div is emitted by the
compiler and it set wrong “C” calling convention for calls to these functions,
whereas library functions are declared with `spir_function` calling convention.
InstCombine optimization replaces such calls with “unreachable” instruction.
It looks like clang lacks SPIRABIInfo class which should specify default
calling conventions for “system” function calls. SPIR supports only
SPIR_FUNC and SPIR_KERNEL calling convention.

Reviewers: Erich Keane, Anastasia

Differential Revision: https://reviews.llvm.org/D92721
2020-12-12 05:48:20 -08:00
Jan Svoboda adf3c27742 [clang][cli] Revert accidental access-control flag rename
This commit <https://reviews.llvm.org/rGe5158b52730d323bb8cd2cba6dc6c89b90cba452> introduced an accidental change, which renames `-faccess-control` and `-fno-access-control` to `-fno-access-control` and `-fno-no-access-control`.

Reviewed By: dexonsmith, MaskRay

Differential Revision: https://reviews.llvm.org/D93104
2020-12-12 11:26:53 +01:00
Jan Svoboda 6baa9769ed [clang][cli] Add flexible TableGen multiclass for boolean options
This introduces more flexible multiclass for declaring two flags controlling the same boolean keypath.

Compared to existing Opt{In,Out}FFlag multiclasses, the new syntax makes it easier to read option declarations and reason about the keypath.

This also makes specifying common properties of both flags possible.

I'm open to suggestions on the class names. Not 100% sure the benefits are worth the added complexity.

Depends on D92774.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92775
2020-12-12 10:53:28 +01:00
Jan Svoboda 10f40576f7 [clang][cli] Don't always emit -f[no-]legacy-pass-manager
We don't need to always generate `-f[no-]experimental-new-pass-manager`.

This patch does not change the behavior of any other command line flag. (For example `-triple` is still being always generated.)

Reviewed By: dexonsmith, Bigcheese

Differential Revision: https://reviews.llvm.org/D92857
2020-12-12 10:11:23 +01:00
Jan Svoboda 6f26a6de48 Reland "[clang][cli] CompilerInvocationTest: add tests for boolean options"
Add more tests of the command line marshalling infrastructure.

The new tests now make a "round-trip": from arguments, to CompilerInvocation instance to arguments again in a single test case.

The TODOs are resolved in a follow-up patch.

Depends on D92830.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92774
2020-12-12 09:46:20 +01:00
Duncan P. N. Exon Smith e095959e0c Fixup for 8c86197de3 to avoid making it platform-dependent 2020-12-11 17:34:00 -08:00
Duncan P. N. Exon Smith 8c86197de3 clang-import-test: Clean up error output for files that cannot be found
Pass on the filesystem error string `FileManager::getFileRef` in
`clang-import-test`'s `ParseSource` function. Also include "error:" and
a newline in the output. As a side effect, migrate to the `FileEntryRef`
overload of `SourceManager::createFileID`.

No real functionality change here, just slightly better output on error.

Differential Revision: https://reviews.llvm.org/D92971
2020-12-11 17:07:58 -08:00
Duncan P. N. Exon Smith a600432199 Frontend: Migrate to FileEntryRef in TextDiagnosticTest, NFC
Migrate over to the `FileEntryRef` overloads of
`SourceManager::createFileID` and `overrideFileContents` (using
`getVirtualFileRef`) in `TextDiagnostic`'s `ShowLine` test.

No functionality change.

Differential Revision: https://reviews.llvm.org/D92968
2020-12-11 17:06:28 -08:00
Nikita Popov 8d4b139e9d Revert "Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types."
This reverts commit 7b3470baf8.

Causes a crash while building tramp3d-v4 from test-suite.
2020-12-12 00:04:10 +01:00
Richard Smith 7b3470baf8 Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types.
For the Itanium ABI, this implements the mangling rule suggested in
https://github.com/itanium-cxx-abi/cxx-abi/issues/47, namely mangling
such template arguments as being cast to the parameter type in the case
where the template name is overloadable. This can cause a mangling
change for rare cases, where

 * the template argument declaration is converted from its declared type
   to the type of the template parameter, and
 * the template parameter either has a deduced type or is a parameter of
   a function template.

However, such changes are necessary to avoid mangling collisions. The
ABI changes can be reversed with -fclang-abi-compat=11 or earlier.

Differential Revision: https://reviews.llvm.org/D91488
2020-12-11 13:26:33 -08:00
Marco Elver c28b18af19 [KernelAddressSanitizer] Fix globals exclusion for indirect aliases
GlobalAlias::getAliasee() may not always point directly to a
GlobalVariable. In such cases, try to find the canonical GlobalVariable
that the alias refers to.

Link: https://github.com/ClangBuiltLinux/linux/issues/1208

Reviewed By: dvyukov, nickdesaulniers

Differential Revision: https://reviews.llvm.org/D92846
2020-12-11 12:20:40 +01:00
Haojian Wu 556e4eba44 [AST][RecoveryAST] Preserve type for member call expr if argments are not matched.
Differential Revision: https://reviews.llvm.org/D92298
2020-12-11 10:38:03 +01:00
Haojian Wu 5663bf201f Revert "[analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis."
The patch introduced a cycle dependency:

clangAnalysis -> clangFrontend -> clangSema -> clangAnalysis

This reverts commit 00ffea77ad.
This reverts commit ea6641085d.
2020-12-11 10:16:13 +01:00
Artem Dergachev 8c5ca7c6e6 [analyzer] OSObjectCStyleCast: Improve warning message.
Suggest OSRequiredCast as a closer alternative to C-style cast.
Explain how to decide.
2020-12-10 19:46:33 -08:00
Duncan P. N. Exon Smith 494aacd72c Tooling: Migrate some tests to FileEntryRef, NFC
Migrate to the `FileEntryRef` overload of `SourceManager::createFileID`
(using `FileManager::getOptionalFileRef`) in RefactoringTest.cpp and
RewriterTestContext.h.

No functionality change.

Differential Revision: https://reviews.llvm.org/D92967
2020-12-10 18:05:03 -08:00
Richard Smith a3fe12dc58 Ensure that we don't leave behind "InstantiatingSpecialization" entries
after destroying an InstantiatingTemplate object.

This previously caused us to (silently!) bail out of class template
instantiation, thinking we'd produced an error, in some corner cases.
2020-12-10 17:01:44 -08:00
Alexander Kornienko 027899dab6 Remove references to the ast_type_traits namespace
Follow up to cd62511496 /
https://reviews.llvm.org/D74499

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D92994
2020-12-11 00:58:46 +01:00
Kazushi (Jam) Marukawa cd5855ac3b [VE] Remove -faddrsig and -fnoaddrsig tests
Remove explicitly declared -faddrsig and -fnoaddrsig option tests
since those are already tested in addrsig.c.  We test only the implicit
behavior of VE driver.

This is suggested in https://reviews.llvm.org/D92386.  Thanks.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D92996
2020-12-11 08:25:38 +09:00
Duncan P. N. Exon Smith 0978c83e6f Basic: Initialize FileEntry's fields inline, almost NFC
Initialize most of FileEntry's fields inline (all the ones that can be).
The only functionality change is to avoid leaving some fields
uninitialized.
2020-12-10 13:57:21 -08:00
Arthur Eubanks ff7e1da68f [NPM] Support -fmerge-functions
I tried to put it in the same place in the pipeline as the legacy PM.

Fixes PR48399.

Reviewed By: asbirlea, nikic

Differential Revision: https://reviews.llvm.org/D93002
2020-12-10 11:45:08 -08:00
Artem Dergachev 00ffea77ad [analyzer][CTU] Add an abstraction layer between libCrossTU and libAnalysis.
Fixes shared libs build after D67422.

Differential Revision: https://reviews.llvm.org/D92432
2020-12-10 11:02:54 -08:00
Artem Dergachev ea6641085d Revert "Revert "Revert "Revert "[analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.""""
This reverts commit 6a89cb8136.
2020-12-10 11:02:54 -08:00
Andrzej Warzynski 764690b8a8 [clang] Remove `-triple` from the invocations of `flang-new -fc1`
This is just a small change in the Flang tool within libclangDriver.
Currently it passes `-triple` when calling `flang-new -fc1` for various
driver Jobs. As there is no support for code-generation, `-triple` is
not required and should remain unsupported. It is safe to remove it.

This hasn't been a problem as the affected driver Jobs are not yet
implemented or used. However, we will be adding support for them in the
near future and the fact `-triple` is added will become a problem.

Differential Revision: https://reviews.llvm.org/D93027
2020-12-10 17:54:12 +00:00
Florian Hahn 9c4cddb53a
[Clang] Add vcmla and rotated variants for Arm ACLE.
This patch adds vcmla and the rotated variants as defined in
"Arm Neon Intrinsics Reference for ACLE Q3 2020" [1]

The *_lane_* are still missing, but they can be added separately.

This patch only adds the builtin mapping for AArch64.

[1] https://developer.arm.com/documentation/ihi0073/latest

Reviewed By: t.p.northover

Differential Revision: https://reviews.llvm.org/D92930
2020-12-10 16:54:08 +00:00
Anastasia Stulova a84599f177 [OpenCL] Implement extended subgroups fully in headers.
Extended subgroups are library style extensions and therefore
they require no changes in the frontend. This commit:
1. Moves extension macro definitions to the internal headers.
2. Removes extension pragmas because they are not needed.

Tags: #clang

Differential Revision: https://reviews.llvm.org/D92231
2020-12-10 16:40:15 +00:00
clementval 456c885df3 Revert "[openmp] Remove clause from OMPKinds.def and use OMP.td info"
This reverts commit a7b2847216.

failing buildbot on warnings
2020-12-10 10:34:59 -05:00
Valentin Clement a7b2847216 [openmp] Remove clause from OMPKinds.def and use OMP.td info
Remove the OpenMP clause information from the OMPKinds.def file and use the
information from the new OMP.td file. There is now a single source of truth for the
directives and clauses.

To avoid generate lots of specific small code from tablegen, the macros previously
used in OMPKinds.def are generated almost as identical. This can be polished and
possibly removed in a further patch.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D92955
2020-12-10 10:19:09 -05:00
Sjoerd Meijer 99ad078b91 [AArch64] Cortex-R82: remove crypto
Remove target features crypto for Cortex-R82, because it doesn't have any, and
add LSE which was missing while we are at it.
This also removes crypto from the v8-R architecture description because that
aligns better with GCC and so far none of the R-cores have implemented crypto,
so is probably a more sensible default.

Differential Revision: https://reviews.llvm.org/D91994
2020-12-10 12:54:51 +00:00
Peter Waller 2315e9874c [AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend
... and give more guidance to users.

If specifying -msve-vector-bits on a non-SVE target, clang would say:

    error: '-msve-vector-bits' is not supported without SVE enabled

1. The driver lacks logic for "implied features".
   This would result in this error being raised for -march=...+sve2,
   even though +sve2 implies +sve.

2. Feature implication is well modelled in LLVM, so push the error down
   the stack.

3. Hint to the user what flag they need to consider setting.

Now clang fails later, when the feature is used, saying:

  aarch64-sve-vector-bits.c:42:41: error: 'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=
  typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));

Move clang/test/Sema/{neon => arm}-vector-types-support.c and put tests for
this warning together in one place.

Reviewed By: sdesmalen

Differential Revision: https://reviews.llvm.org/D92487
2020-12-10 12:43:14 +00:00
mydeveloperday 95616a033c [clang-format] NFC Add release note for IndentPragmas
Add additional release note to announce new clang-format option added during {D92753}
2020-12-10 11:24:12 +00:00
mydeveloperday e9e6e3b34a [clang-format] Add IndentPragma style to eliminate common clang-format off scenario
A quick search of github.com, shows one common scenario for excessive use of //clang-format off/on is the indentation of #pragma's, especially around the areas of loop optimization or OpenMP

This revision aims to help that by introducing an `IndentPragmas` style, the aim of which is to keep the pragma at the current level of scope

```
    for (int i = 0; i < 5; i++) {
// clang-format off
        #pragma HLS UNROLL
        // clang-format on
        for (int j = 0; j < 5; j++) {
// clang-format off
            #pragma HLS UNROLL
            // clang-format on
     ....
```

can become

```
    for (int i = 0; i < 5; i++) {
        #pragma HLS UNROLL
        for (int j = 0; j < 5; j++) {
            #pragma HLS UNROLL
        ....
```

This revision also support working alongside the `IndentPPDirective` of `BeforeHash` and `AfterHash` (see unit tests for examples)

Reviewed By: curdeius

Differential Revision: https://reviews.llvm.org/D92753
2020-12-10 11:17:33 +00:00
mydeveloperday 7b2d62fd7f [clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess
clang-format see the `disable:` in   __pragma(warning(disable:)) as ObjectiveC method call

Remove any line starting with `#` or __pragma line from being part of the ObjectiveC guess

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

Reviewed By: curdeius, krasimir

Differential Revision: https://reviews.llvm.org/D92922
2020-12-10 11:13:22 +00:00
mydeveloperday 254677e9ed [clang-format] [NFC] Fix spelling and grammatical errors in IncludeBlocks text
Fix spelling mistake
Leave space after `.` and before beginning of next sentence
Reword it slightly to try and make it more readable.
Ensure RST is updated correctly (it generated a change)

Reviewed By: HazardyKnusperkeks, curdeius

Differential Revision: https://reviews.llvm.org/D92822
2020-12-10 11:06:48 +00:00
Haojian Wu a053929854 [AST] Fix a constexpr-evaluator crash on error-dependent returnstmt.
When the evaluator encounters an error-dependent returnstmt, before this patch
it returned a ESR_Returned without setting the result, the callsides think this
is a successful execution, and try to access the Result which causes the crash.

The fix is to always return failed as we don't know the result of the
error-dependent return stmt.

Differential Revision: https://reviews.llvm.org/D92969
2020-12-10 10:12:15 +01:00
Luo, Yuanke f80b29878b [X86] AMX programming model.
This patch implements amx programming model that discussed in llvm-dev
 (http://lists.llvm.org/pipermail/llvm-dev/2020-August/144302.html).
 Thank Hal for the good suggestion in the RA. The fast RA is not in the patch yet.
 This patch implemeted 7 components.

1. The c interface to end user.
2. The AMX intrinsics in LLVM IR.
3. Transform load/store <256 x i32> to AMX intrinsics or split the
   type into two <128 x i32>.
4. The Lowering from AMX intrinsics to AMX pseudo instruction.
5. Insert psuedo ldtilecfg and build the def-use between ldtilecfg to amx
   intruction.
6. The register allocation for tile register.
7. Morph AMX pseudo instruction to AMX real instruction.

Change-Id: I935e1080916ffcb72af54c2c83faa8b2e97d5cb0

Differential Revision: https://reviews.llvm.org/D87981
2020-12-10 17:01:54 +08:00
Yuanfang Chen fc3942526f [NFCI] Add a missing triple in clang/test/CodeGen/ppc64le-varargs-f128.c 2020-12-09 18:17:34 -08:00
Richard Smith 7127fd1786 MSABI: Basic mangling for access to member subobjects in a class
non-type template parameter.

The mangling information used here comes from private communication with
Jon Caves at Microsoft.
2020-12-09 18:08:49 -08:00
Fangrui Song 880aa6ac66 [test] Fix test/Driver/ve-toolchain.cpp
It should specify --sysroot to test the paths of crt1.o/crti.o/crtbegin.o.
For a user who enable VE but do not actually have VE sysroot,
the "nld" command line will have bare "crt1.o" "crti.o" ... "crtbegin.o"
2020-12-09 17:26:22 -08:00
Fangrui Song 754d1d3d52 [test] Fix Misc/time-passes.c 2020-12-09 17:17:28 -08:00
Fangrui Song 872bf68001 Default CodeGenOptions::LegacyPassManager to !LLVM_ENABLE_NEW_PASS_MANAGER
Fixes test/CodeGen/flatten.c
2020-12-09 17:10:17 -08:00
Fangrui Song f9c0d1b056 [Driver] Add -f[no-]legacy-pass-manager to supersede -f[no-]experimental-new-pass-manager
The new PM is considered stable and many downstream groups have adopted it (some
have adopted it for more than two years). Add -f[no-]legacy-pass-manager to reflect the
fact that it is no longer experimental and the legacy pass manager is something we strive to retire.

In the future, when the legacy PM eventually goes away,
-fno-experimental-new-pass-manager and -flegacy-pass-manager will be removed.

This patch also changes -f[no-]legacy-pass-manager to pass `-plugin-opt={new,legacy}-pass-manager` to the linker (supported by both ld.lld and LLVMgold.so) when -flto/-flto=thin is specified

Reviewed By: aeubanks, rsmith

Differential Revision: https://reviews.llvm.org/D92915
2020-12-09 16:57:36 -08:00
Artem Belevich 016e4ebfde [DWARF] Allow toolchain to adjust specified DWARF version.
This is needed for CUDA compilation where NVPTX back-end only supports DWARF2,
but host compilation should be allowed to use newer DWARF versions.

Differential Revision: https://reviews.llvm.org/D92617
2020-12-09 16:34:34 -08:00
Duncan P. N. Exon Smith 2ea8c69eff Tooling: Migrate to FileEntryRef in clang::tooling::applyAllReplacements, NFC
Migrate to the `FileEntryRef` overload of `SourceManager::createFileID`.
2020-12-09 16:31:38 -08:00
Duncan P. N. Exon Smith 347e1f6213 Frontend: Use a getVirtualFileRef for a named pipe main file, NFC 2020-12-09 16:17:14 -08:00
Duncan P. N. Exon Smith 75a95bc80e clang-format: Migrate createInMemoryFile to FileEntryRef, NFC 2020-12-09 15:00:53 -08:00
Duncan P. N. Exon Smith c3ff9939bf Remove RemappedFiles param from ASTUnit::LoadFromASTFile, NFC
This parameter is always set to `None`. Remove it.

Differential Revision: https://reviews.llvm.org/D90889
2020-12-09 14:44:31 -08:00
Duncan P. N. Exon Smith 898d61b3cf ARCMigrate: Migrate ObjCMT.cpp over to FileEntryRef
Migrate ObjCMT.cpp from using `const FileEntry*` to `FileEntryRef`. This
is one of the blockers for changing `SourceManager` to use
`FileEntryRef`.

This adds an initial version of `SourceManager::getFileEntryRefForID`,
which uses to `FileEntry::getLastRef`; after `SourceManager` switches,
`SourceManager::getFileEntryForID` will need to call this function.

This also adds uses of `FileEntryRef` as a key in a `DenseMap`, and a
call to `hash_value(Optional)` in `DenseMapInfo<EditEntry>`; support for
these were added in prep commits.

Differential Revision: https://reviews.llvm.org/D92678
2020-12-09 14:16:05 -08:00
Duncan P. N. Exon Smith a5c89bb021 Frontend: Migrate to FileEntryRef in CompilerInstance::InitializeSourceManager, NFC
Use `FileManager::getVirtualFileRef` to get the virtual file for stdin,
and add an overload of `SourceManager::overrideFileContents` that takes
a `FileEntryRef`, migrating `CompilerInstance::InitializeSourceManager`.

Differential Revision: https://reviews.llvm.org/D92680
2020-12-09 13:28:29 -08:00
Yuanfang Chen 8b23b3ab3a [NFCI] Add missing triple to several LTO tests
Also remove the module triple of clang/test/CodeGenObjC/arc.ll, the
commandline tripe is all it needs.
2020-12-09 13:13:58 -08:00
Gabor Marton a5e6590b15 [ASTImporter] Support CXXDeductionGuideDecl with local typedef
CXXDeductionGuideDecl with a local typedef has its own copy of the
TypedefDecl with the CXXDeductionGuideDecl as the DeclContext of that
TypedefDecl.
```
      template <typename T> struct A {
        typedef T U;
        A(U, T);
      };
      A a{(int)0, (int)0};
```
Related discussion on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2020-November/067252.html

Without this fix, when we import the CXXDeductionGuideDecl (via
VisitFunctionDecl) then before creating the Decl we must import the
FunctionType. However, the first parameter's type is the afore mentioned
local typedef. So, we then start importing the TypedefDecl whose
DeclContext is the CXXDeductionGuideDecl itself. The infinite loop is
formed.
```
 #0 clang::ASTNodeImporter::VisitCXXDeductionGuideDecl(clang::CXXDeductionGuideDecl*) clang/lib/AST/ASTImporter.cpp:3543:0
 #1 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*> >::Visit(clang::Decl*) /home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/DeclNodes.inc:405:0
 #2 clang::ASTImporter::ImportImpl(clang::Decl*) clang/lib/AST/ASTImporter.cpp:8038:0
 #3 clang::ASTImporter::Import(clang::Decl*) clang/lib/AST/ASTImporter.cpp:8200:0
 #4 clang::ASTImporter::ImportContext(clang::DeclContext*) clang/lib/AST/ASTImporter.cpp:8297:0
 #5 clang::ASTNodeImporter::ImportDeclContext(clang::Decl*, clang::DeclContext*&, clang::DeclContext*&) clang/lib/AST/ASTImporter.cpp:1852:0
 #6 clang::ASTNodeImporter::ImportDeclParts(clang::NamedDecl*, clang::DeclContext*&, clang::DeclContext*&, clang::DeclarationName&, clang::NamedDecl*&, clang::SourceLocation&) clang/lib/AST/ASTImporter.cpp:1628:0
 #7 clang::ASTNodeImporter::VisitTypedefNameDecl(clang::TypedefNameDecl*, bool) clang/lib/AST/ASTImporter.cpp:2419:0
 #8 clang::ASTNodeImporter::VisitTypedefDecl(clang::TypedefDecl*) clang/lib/AST/ASTImporter.cpp:2500:0
 #9 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*> >::Visit(clang::Decl*) /home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/DeclNodes.inc:315:0
 #10 clang::ASTImporter::ImportImpl(clang::Decl*) clang/lib/AST/ASTImporter.cpp:8038:0
 #11 clang::ASTImporter::Import(clang::Decl*) clang/lib/AST/ASTImporter.cpp:8200:0
 #12 llvm::Expected<clang::TypedefNameDecl*> clang::ASTNodeImporter::import<clang::TypedefNameDecl>(clang::TypedefNameDecl*) clang/lib/AST/ASTImporter.cpp:165:0
 #13 clang::ASTNodeImporter::VisitTypedefType(clang::TypedefType const*) clang/lib/AST/ASTImporter.cpp:1304:0
 #14 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType> >::Visit(clang::Type const*) /home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/TypeNodes.inc:74:0
 #15 clang::ASTImporter::Import(clang::QualType) clang/lib/AST/ASTImporter.cpp:8071:0
 #16 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) clang/lib/AST/ASTImporter.cpp:179:0
 #17 clang::ASTNodeImporter::VisitFunctionProtoType(clang::FunctionProtoType const*) clang/lib/AST/ASTImporter.cpp:1244:0
 #18 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType> >::Visit(clang::Type const*) /home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/TypeNodes.inc:47:0
 #19 clang::ASTImporter::Import(clang::QualType) clang/lib/AST/ASTImporter.cpp:8071:0
 #20 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) clang/lib/AST/ASTImporter.cpp:179:0
 #21 clang::QualType clang::ASTNodeImporter::importChecked<clang::QualType>(llvm::Error&, clang::QualType const&) clang/lib/AST/ASTImporter.cpp:198:0
 #22 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) clang/lib/AST/ASTImporter.cpp:3313:0
 #23 clang::ASTNodeImporter::VisitCXXDeductionGuideDecl(clang::CXXDeductionGuideDecl*) clang/lib/AST/ASTImporter.cpp:3543:0
```

The fix is to first create the TypedefDecl and only then start to import
the DeclContext.
Basically, we could do this during the import of all other Decls (not
just for typedefs). But it seems, there is only one another AST
construct that has a similar cycle: a struct defined as a function
parameter:
```
int struct_in_proto(struct data_t{int a;int b;} *d);

```
In that case, however, we had decided to return simply with an error
back then because that seemed to be a very rare construct.

Differential Revision: https://reviews.llvm.org/D92209
2020-12-09 21:25:04 +01:00
Richard Smith 4ae8651c59 Add another test for PR48434. 2020-12-09 12:22:35 -08:00
Richard Smith 2a2c228c7a Add new 'preferred_name' attribute.
This attribute permits a typedef to be associated with a class template
specialization as a preferred way of naming that class template
specialization. This permits us to specify that (for example) the
preferred way to express 'std::basic_string<char>' is as 'std::string'.

The attribute is applied to the various class templates in libc++ that have
corresponding well-known typedef names.

This is a re-commit. The previous commit was reverted because it exposed
a pre-existing bug that has since been fixed / worked around; see
PR48434.

Differential Revision: https://reviews.llvm.org/D91311
2020-12-09 12:22:35 -08:00
Richard Smith 997a719d5a PR48434: Work around crashes due to deserialization cycles via typedefs.
Ensure that we can deserialize a TypedefType even while in the middle of
deserializing its TypedefDecl, by removing the need to look at the
TypedefDecl while constructing the TypedefType.

This fixes all the currently-known failures for PR48434, but it's not a
complete fix, because we can still trigger deserialization cycles, which
are not supposed to happen.
2020-12-09 12:22:35 -08:00
Duncan P. N. Exon Smith 82789228c6 Frontend: Migrate to FileEntryRef in VerifyDiagnosticConsumer.cpp, NFC
Add a `FileEntryRef` overload of `SourceManager::translateFile`, and
migrate `ParseDirective` in VerifyDiagnosticConsumer.cpp to use it and
the corresponding overload of `createFileID`.

No functionality change here.

Differential Revision: https://reviews.llvm.org/D92699
2020-12-09 11:51:43 -08:00
Reid Kleckner df282215d4 Don't setup inalloca for swiftcc on i686-windows-msvc
Swiftcall does it's own target-independent argument type classification,
since it is not designed to be ABI compatible with anything local on the
target that isn't LLVM-based. This means it never uses inalloca.
However, we have duplicate logic for checking for inalloca parameters
that runs before call argument setup. This logic needs to know ahead of
time if inalloca will be used later, and we can't move the
CGFunctionInfo calculation earlier.

This change gets the calling convention from either the
FunctionProtoType or ObjCMethodDecl, checks if it is swift, and if so
skips the stackbase setup.

Depends on D92883.

Differential Revision: https://reviews.llvm.org/D92944
2020-12-09 11:08:48 -08:00
Reid Kleckner d7098ff29c De-templatify EmitCallArgs argument type checking, NFCI
This template exists to abstract over FunctionPrototype and
ObjCMethodDecl, which have similar APIs for storing parameter types. In
place of a template, use a PointerUnion with two cases to handle this.
Hopefully this improves readability, since the type of the prototype is
easier to discover. This allows me to sink this code, which is mostly
assertions, out of the header file and into the cpp file. I can also
simplify the overloaded methods for computing isGenericMethod, and get
rid of the second EmitCallArgs overload.

Differential Revision: https://reviews.llvm.org/D92883
2020-12-09 11:08:00 -08:00
Jan Svoboda 13e4e5ed59 Revert "[clang][cli] CompilerInvocationTest: add tests for boolean options"
Differential Revision of original patch: https://reviews.llvm.org/D92774
2020-12-09 10:35:07 +01:00
Jan Svoboda 35621cc2e3 [clang][cli] CompilerInvocationTest: add tests for boolean options
Add more tests of the command line marshalling infrastructure.

The new tests now make a "round-trip": from arguments, to CompilerInvocation instance to arguments again in a single test case.

The TODOs are resolved in a follow-up patch.

Depends on D92830.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92774
2020-12-09 08:58:46 +01:00
Jan Svoboda 216d43053b [clang][cli] CompilerInvocationTest: join and add test cases
Depends on D92829.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92830
2020-12-09 08:58:45 +01:00
Jan Svoboda 03692bae1f [clang][cli] CompilerInvocationTest: check arg parsing does not produce diagnostics
Depends on D92828.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92829
2020-12-09 08:58:45 +01:00
Jan Svoboda 4894e423e7 [clang][cli] CompilerInvocationTest: remove unnecessary command line arguments
Depends on D92827.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92828
2020-12-09 08:58:45 +01:00
Jan Svoboda 5afff86d26 [clang][cli] CompilerInvocationTest: split enum test into two
Depends on D92826.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92827
2020-12-09 08:58:45 +01:00
Jan Svoboda f825ec86e1 [clang][cli] CompilerInvocationTest: rename member variable in fixture
Depends on D92825.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92826
2020-12-09 08:58:45 +01:00
Jan Svoboda cf2bb22392 [clang][cli] CompilerInvocationTest: join two test fixtures into one
Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92825
2020-12-09 08:58:45 +01:00
Duncan P. N. Exon Smith 2878e965af Basic: Add hashing support for FileEntryRef and DirectoryEntryRef
Allow hashing FileEntryRef and DirectoryEntryRef via `hash_value`, and
use that to implement `DenseMapInfo`. This hash should be equal whenever
the entry is the same (the name used to reference it is not relevant).

Also add `DirectoryEntryRef::isSameRef` to simplify the implementation
and facilitate testing.

Differential Revision: https://reviews.llvm.org/D92627
2020-12-08 18:10:53 -08:00
Duncan P. N. Exon Smith 5207f19d10 ADT: Allow IntrusiveRefCntPtr construction from std::unique_ptr, NFC
Allow a `std::unique_ptr` to be moved into the an `IntrusiveRefCntPtr`,
and remove a couple of now-unnecessary `release()` calls.

Differential Revision: https://reviews.llvm.org/D92888
2020-12-08 17:33:19 -08:00
Duncan P. N. Exon Smith b85c6e5bcd ARCMigrate: Use hash_combine in the DenseMapInfo for EditEntry
Simplify the DenseMapInfo for `EditEntry` by migrating from
`FoldingSetNodeID` to `llvm::hash_combine`. Besides the cleanup, this
reduces the diff for a future patch which changes the type of one of the
fields.

There should be no real functionality change here, although I imagine
the hash value will churn since its a different hashing infrastructure.

Differential Revision: https://reviews.llvm.org/D92630
2020-12-08 13:46:21 -08:00
Fangrui Song 85c18d3521 [Driver] Add -gno-split-dwarf which can disable debug fission
Currently when -gsplit-dwarf is specified (could be buried in a build system),
there is no convenient way to cancel debug fission without affecting the debug
information amount (all of -g0, -g1 -fsplit-dwarf-inlining and -gline-directives-only
can, but they affect the debug information amount).

Reviewed By: #debug-info, dblaikie

Differential Revision: https://reviews.llvm.org/D92809
2020-12-08 13:24:59 -08:00
Saleem Abdulrasool b13f741511 APINotes: add bitcode format schema definitions
This adds the bitcode format schema required for serialization of the
YAML data to a binary format.  APINotes are pre-compiled and re-used in
the binary format from the frontend.  These definitions provide the data
layout representation enabling writing (and eventually) reading of the
data in bitcode format.

This is extracted from the code contributed by Apple at
https://github.com/llvm/llvm-project-staging/tree/staging/swift/apinotes.

Differential Revision: https://reviews.llvm.org/D91997
Reviewed By: Gabor Marton
2020-12-08 21:15:41 +00:00
Fangrui Song 843f2dbf00 [Driver] Don't make -gsplit-dwarf imply -g2
RFC: http://lists.llvm.org/pipermail/cfe-dev/2020-May/065430.html
Agreement from GCC: https://sourceware.org/pipermail/gcc-patches/2020-May/545688.html

g_flags_Group options generally don't affect the amount of debugging
information. -gsplit-dwarf is an exception. Its order dependency with
other gN_Group options make it inconvenient in a build system:

* -g0 -gsplit-dwarf -> level 2
   -gsplit-dwarf "upgrades" the amount of debugging information despite
   the previous intention (-g0) to drop debugging information
* -g1 -gsplit-dwarf -> level 2
  -gsplit-dwarf "upgrades" the amount of debugging information.
* If we have a higher-level -gN, -gN -gsplit-dwarf will supposedly decrease the
  amount of debugging information. This happens with GCC -g3.

The non-orthogonality has confused many users. GCC 11 will change the semantics
(-gsplit-dwarf no longer implies -g2) despite the backwards compatibility break.
This patch matches its behavior.

New semantics:

* If there is a g_Group, allow split DWARF if useful
  (none of: -g0, -gline-directives-only, -g1 -fno-split-dwarf-inlining)
* Otherwise, no-op.

To restore the original behavior, replace -gsplit-dwarf with -gsplit-dwarf -g.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D80391
2020-12-08 13:14:34 -08:00
Duncan P. N. Exon Smith 51f3432f4b Frontend: Clarify logic for using the preamble in ASTUnit::CodeComplete, almost NFC
Clarify the logic for using the preamble (and overriding the main file
buffer) in `ASTUnit::CodeComplete` by factoring out a couple of lambdas
(`getUniqueID` and `hasSameUniqueID`).  While refactoring the logic,
hoist the check for `Line > 1` and locally check if the filenames are
equal (both to avoid unnecessary `stat` calls) and skip copying out the
filenames to `std::string`.

Besides fewer calls to `stat`, there's no functionality change here.

Differential Revision: https://reviews.llvm.org/D91296
2020-12-08 12:52:17 -08:00
Masoud Ataei fc750f609d [PPC] Fixing a typo in altivec.h. Commenting out an unnecessary macro 2020-12-08 19:21:02 +00:00
Yuanfang Chen 1821265db6 [Time-report] Add a flag -ftime-report={per-pass,per-pass-run} to control the pass timing aggregation
Currently, -ftime-report + new pass manager emits one line of report for each
pass run. This potentially causes huge output text especially with regular LTO
or large single file (Obeserved in private tests and was reported in D51276).
The behaviour of -ftime-report + legacy pass manager is
emitting one line of report for each pass object which has relatively reasonable
text output size. This patch adds a flag `-ftime-report=` to control time report
aggregation for new pass manager.

The flag is for new pass manager only. Using it with legacy pass manager gives
an error. It is a driver and cc1 flag. `per-pass` is the new default so
`-ftime-report` is aliased to `-ftime-report=per-pass`. Before this patch,
functionality-wise `-ftime-report` is aliased to `-ftime-report=per-pass-run`.

* Adds an boolean variable TimePassesHandler::PerRun to control per-pass vs per-pass-run.
* Adds a new clang CodeGen flag CodeGenOptions::TimePassesPerRun to work with the existing CodeGenOptions::TimePasses.
* Remove FrontendOptions::ShowTimers, its uses are replaced by the existing CodeGenOptions::TimePasses.
* Remove FrontendTimesIsEnabled (It was introduced in D45619 which was largely reverted.)

Differential Revision: https://reviews.llvm.org/D92436
2020-12-08 10:13:19 -08:00
Nigel Perks 27ea7d0a6e Fix inconsistent availability attribute message string literal check.
Function Parser::ParseAvailabilityAttribute checks that the message string of
an availability attribute is not a wide string literal. Test case
clang/test/Parser/attr-availability.c specifies that a string literal is
expected.

The code checked that the first token in a string concatenation is a string
literal, and then that the concatenated string consists of 1-byte characters.
On a target where wide character is 1 byte, a string concatenation "a" L"b"
passes both those checks, but L"b" alone is rejected. More generally, "a" u8"b"
passes the checks, but u8"b" alone is rejected.

So check isAscii() instead of character size.
2020-12-08 12:33:59 -05:00
Simon Pilgrim 25f5df7e0b SemaType.cpp - use castAs<> instead of getAs<> for dereferenced pointers
Fix static analyzer warnings - castAs<> will assert the type is correct, but getAs<> just returns null, which would just result in a dereferenced null pointer.
2020-12-08 16:37:20 +00:00
Gabor Marton febe75032f [analyzer][StdLibraryFunctionsChecker] Add more return value contraints
This time, we add contraints to functions that either return with [0, -1] or
with a file descriptor.

Differential Revision: https://reviews.llvm.org/D92771
2020-12-08 17:04:29 +01:00
Gabor Marton d14c631673 [analyzer][StdLibraryFunctionsChecker] Make close and mmap to accept -1 as fd
close:
It is quite often that users chose to call close even if the fd is
negative. Theoretically, it would be nicer to close only valid fds, but
in practice the implementations of close just returns with EBADF in case
of a non-valid fd param. So, we can eliminate many false positives if we
let close to take -1 as an fd. Other negative values are very unlikely,
because open and other fd factories return with -1 in case of failure.

mmap:
In the case of MAP_ANONYMOUS flag (which is supported e.g. in Linux) the
mapping is not backed by any file; its contents are initialized to zero.
The fd argument is ignored; however, some implementations require fd to
be -1 if MAP_ANONYMOUS (or MAP_ANON) is specified, and portable
applications should ensure this.
Consequently, we must allow -1 as the 4th arg.

Differential Revision: https://reviews.llvm.org/D92764
2020-12-08 16:58:30 +01:00
Kevin P. Neal acd4950d4f [FPEnv] Correct constrained metadata in fp16-ops-strict.c
This test shows we're in some cases not getting strictfp information from
the AST. Correct that.

Differential Revision: https://reviews.llvm.org/D92596
2020-12-08 10:18:32 -05:00
Jan Svoboda 083e035c47 [clang][cli] Unify boolean marshalling
Use lambdas with captures to replace the redundant infrastructure for marshalling of two boolean flags that control the same keypath.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92773
2020-12-08 13:47:30 +01:00
Tim Northover c5978f42ec UBSAN: emit distinctive traps
Sometimes people get minimal crash reports after a UBSAN incident. This change
tags each trap with an integer representing the kind of failure encountered,
which can aid in tracking down the root cause of the problem.
2020-12-08 10:28:26 +00:00
Luís Marques 3af354e863 [Clang][CodeGen][RISCV] Fix hard float ABI for struct with empty struct and complex
Fixes bug 44904.

Differential Revision: https://reviews.llvm.org/D91278
2020-12-08 09:19:05 +00:00
Luís Marques fa8f5bfa4e [Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct
The code seemed not to account for the field 1 offset.

Differential Revision: https://reviews.llvm.org/D91270
2020-12-08 09:19:05 +00:00
Luís Marques ca93f9abdc [Clang][CodeGen][RISCV] Add hard float ABI tests with empty struct
This patch adds tests that showcase a behavior that is currently buggy.
Fix in a follow-up patch.

Differential Revision: https://reviews.llvm.org/D91269
2020-12-08 09:19:05 +00:00
Richard Smith a1344779ab Revert "Add new 'preferred_name' attribute."
This change exposed a pre-existing issue with deserialization cycles
caused by a combination of attributes and template instantiations
violating the deserialization ordering restrictions; see PR48434 for
details.

A previous commit attempted to work around PR48434, but appears to have
only been a partial fix, and fixing this properly seems non-trivial.
Backing out for now to unblock things.

This reverts commit 98f76adf4e and
commit a64c26a47a.
2020-12-08 00:42:48 -08:00
Qiu Chaofan 5e85a2ba16 [PowerPC] Implement intrinsic for DARN instruction
Instruction darn was introduced in ISA 3.0. It means 'Deliver A Random
Number'. The immediate number L means:

- L=0, the number is 32-bit (higher 32-bits are all-zero)
- L=1, the number is 'conditioned' (processed by hardware to reduce bias)
- L=2, the number is not conditioned, directly from noise source

GCC implements them in three separate intrinsics: __builtin_darn,
__builtin_darn_32 and __builtin_darn_raw. This patch implements the
same intrinsics. And this change also addresses Bugzilla PR39800.

Reviewed By: steven.zhang

Differential Revision: https://reviews.llvm.org/D92465
2020-12-08 14:08:52 +08:00
Vitaly Buka 6e614b0c7e [NFC][MSan] Round up OffsetPtr in PoisonMembers
getFieldOffset(layoutStartOffset)  is expected to point to the first trivial
field or the one which follows non-trivial. So it must be byte aligned already.
However this is not obvious without assumptions about callers.
This patch will avoid the need in such assumptions.

Depends on D92727.

Differential Revision: https://reviews.llvm.org/D92728
2020-12-07 19:57:49 -08:00
Richard Smith 590e146532 Fix assertion failure due to incorrect dependence bits on a DeclRefExpr
that can only be set correctly after instantiating the initializer for a
variable.
2020-12-07 18:48:38 -08:00
Fangrui Song 29295e2165 [test] Rewrite split-debug.c
Use generic ELF target triples.
Add missing coverage: -gsplit-dwarf=split -g -fsplit-dwarf-inlining
Reorganize and add comments.
Test -gno-pubnames
2020-12-07 18:40:31 -08:00
Yaxun (Sam) Liu efc063b621 Fix lit test failure due to 0b81d9
These lit tests now requires amdgpu-registered-target since they
use clang driver and clang driver passes an LLVM option which
is available only if amdgpu target is registered.

Change-Id: I2df31967409f1627fc6d342d1ab5cc8aa17c9c0c
2020-12-07 19:50:21 -05:00
Richard Smith a64c26a47a Fix deserialization cycle in preferred_name attribute.
This is really just a workaround for a more fundamental issue in the way
we deserialize attributes. See PR48434 for details.

Also fix tablegen code generator to produce more correct indentation to
resolve buildbot issues with -Werror=misleading-indentation firing
inside the generated code.
2020-12-07 16:02:05 -08:00
Yaxun (Sam) Liu 0b81d9a992 [AMDGPU] add -mcode-object-version=n
Add option -mcode-object-version=n to control code object version for
AMDGPU.

Differential Revision: https://reviews.llvm.org/D91310
2020-12-07 18:08:37 -05:00
Yaxun (Sam) Liu 5cae708002 [clang][AMDGPU] remove mxnack and msramecc options
Remove mxnack and msramecc options since they
are deprecated by --offload-arch.

This is part of https://reviews.llvm.org/D60620
2020-12-07 18:08:37 -05:00
Yaxun (Sam) Liu 4bed1d9b32 [HIP] fix bundle entry ID for --
Canonicalize triple used in fat binary. Change from
amdgcn-amd-amdhsa to amdgcn-amd-amdhsa-.

This is part of https://reviews.llvm.org/D60620
2020-12-07 18:08:37 -05:00
Yaxun (Sam) Liu 40ad476a32 [clang][AMDGPU] rename sram-ecc as sramecc
As backend renamed sram-ecc to sramecc, this patch makes
corresponding change in clang.

Differential Revision: https://reviews.llvm.org/D86217
2020-12-07 18:05:47 -05:00
Jann Horn 6dad7ec539 [clang] Fix noderef for AddrOf on MemberExpr
Committing on behalf of thejh (Jann Horn).

As part of this change, one existing test case has to be adjusted
because it accidentally stripped the NoDeref attribute without
getting caught.

Depends on D92140

Differential Review: https://reviews.llvm.org/D92141
2020-12-07 14:48:41 -08:00
Leonard Chan 155fca3cae [clang] Fix noderef for array member of deref expr
Committing on behalf of thejh (Jann Horn).

    Given an attribute((noderef)) pointer "p" to the struct

    struct s { int a[2]; };
    ensure that the following expressions are treated the same way by the
    noderef logic:

    p->a
    (*p).a
    Until now, the first expression would be treated correctly (nothing is
    added to PossibleDerefs because CheckMemberAccessOfNoDeref() bails out
    on array members), but the second expression would incorrectly warn
    because "*p" creates a PossibleDerefs entry.

    Handle this case the same way as for the AddrOf operator.

    Differential Revision: https://reviews.llvm.org/D92140
2020-12-07 14:39:42 -08:00
Erik Pilkington 5a28e1d9e5 [clang] Add support for attribute 'swift_async'
This attributes specifies how (or if) a given function or method will be
imported into a swift async method. rdar://70111252

Differential revision: https://reviews.llvm.org/D92742
2020-12-07 17:19:26 -05:00
Erik Pilkington 9cd2413f1c [clang] Add a new nullability annotation for swift async: _Nullable_result
_Nullable_result generally like _Nullable, except when being imported into a
swift async method. rdar://70106409

Differential revision: https://reviews.llvm.org/D92495
2020-12-07 17:19:20 -05:00
Vitaly Buka 3e1cb0db8a [CodeGen][MSan] Don't use offsets of zero-sized fields
Such fields will likely have offset zero making
__sanitizer_dtor_callback poisoning wrong regions.
E.g. it can poison base class member from derived class constructor.

Differential Revision: https://reviews.llvm.org/D92727
2020-12-07 13:37:40 -08:00
Richard Smith 98f76adf4e Add new 'preferred_name' attribute.
This attribute permits a typedef to be associated with a class template
specialization as a preferred way of naming that class template
specialization. This permits us to specify that (for example) the
preferred way to express 'std::basic_string<char>' is as 'std::string'.

The attribute is applied to the various class templates in libc++ that have
corresponding well-known typedef names.

Differential Revision: https://reviews.llvm.org/D91311
2020-12-07 12:53:07 -08:00
Nathan James dc361d5c2a
[llvm] Add asserts in (ThreadSafe)?RefCountedBase destructors
Added a trivial destructor in release mode and in debug mode a destructor that asserts RefCount is indeed zero.
This ensure people aren't manually (maybe accidentally) destroying these objects like in this contrived example.
```lang=c++
{
  std::unique_ptr<SomethingRefCounted> Object;
  holdIntrusiveOwnership(Object.get());
  // Object Destructor called here will assert.
}
```

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D92480
2020-12-07 20:20:08 +00:00
Erich Keane 1c98f98410 Stop ExtractTypeForDeductionGuide from recursing on TypeSourceInfo
As reported in PR48177, the type-deduction extraction ends up going into
an infinite loop when the type referred to has a recursive definition.
This stops recursing and just substitutes the type-source-info the
TypeLocBuilder identified when transforming the base.
2020-12-07 11:29:57 -08:00
Yu Shan 3ce78f54ed [analyzer] Ignore annotations if func is inlined.
When we annotating a function header so that it could be used by other
TU, we also need to make sure the function is parsed correctly within
the same TU. So if we can find the function's implementation,
ignore the annotations, otherwise, false positive would occur.
Move the escape by value case to post call and do not escape the handle
if the function is inlined and we have analyzed the handle.

Differential Revision: https://reviews.llvm.org/D91902
2020-12-07 11:28:11 -08:00
Jennifer Yu f8d5b49c78 Fix missing error for use of 128-bit integer inside SPIR64 device code.
Emit error for use of 128-bit integer inside device code had been
already implemented in https://reviews.llvm.org/D74387.  However,
the error is not emitted for SPIR64, because for SPIR64, hasInt128Type
return true.

hasInt128Type: is also used to control generation of certain 128-bit
predefined macros, initializer predefined 128-bit integer types and
build 128-bit ArithmeticTypes.  Except predefined macros, only the
device target is considered, since error only emit when 128-bit
integer is used inside device code, the host target (auxtarget) also
needs to be considered.

The change address:
1. (SPIR.h) Correct hasInt128Type() for SPIR targets.
2. Sema.cpp and SemaOverload.cpp: Add additional check to consider host
   target(auxtarget) when call to hasInt128Type.  So that __int128_t
   and __int128() are allowed to avoid error when they used outside
   device code.
3. SemaType.cpp: add check for SYCLIsDevice to delay the error message.
   The error will be emitted if the use of 128-bit integer in the device
   code.

   Reviewed By: Johannes Doerfert and Aaron Ballman

   Differential Revision: https://reviews.llvm.org/D92439
2020-12-07 10:42:32 -08:00
Richard Sandiford fd14a27533 [Sema] Make more overload candidate types use iterator_ranges (NFC)
I have a patch that adds another group of candidate types to
BuiltinCandidateTypeSet.  Currently two styles are in use: the older
begin/end pairs and the newer iterator_range approach.  I think the
group of candidates that I want to add should use iterator ranges,
but I'd also like to consolidate the handling of the new candidates
with some existing code that uses begin/end pairs.  This patch therefore
converts the begin/end pairs to iterator ranges as a first step.

No functional change intended.

Differential Revision: https://reviews.llvm.org/D92222
2020-12-07 18:34:53 +00:00
Fangrui Song 1b734c662b [Parse] Delete unused declarations 2020-12-07 08:46:17 -08:00
Yitzhak Mandelbaum e6bc4a71e3 [libTooling] Add `describe` combinator for formatting AST nodes for diagnostics.
This new stencil combinator is intended for use in diagnostics and the like.

Differential Revision: https://reviews.llvm.org/D92658
2020-12-07 16:08:05 +00:00
Jinsong Ji b49b8f096c [PowerPC][Clang] Remove QPX support
Clean up QPX code in clang missed in https://reviews.llvm.org/D83915

Reviewed By: #powerpc, steven.zhang

Differential Revision: https://reviews.llvm.org/D92329
2020-12-07 10:15:39 -05:00
Sam McCall a1cb9cbf5c Add ability to load a FixedCompilationDatabase from a buffer.
Previously, loading one from a file meant allowing the library to do the IO.
Clangd would prefer to do such IO itself (e.g. to allow caching).

Differential Revision: https://reviews.llvm.org/D92640
2020-12-07 13:07:10 +01:00
Qiu Chaofan 6bf29dbb15 [PowerPC] [Clang] Enable float128 feature on P9 by default
As Power9 introduced hardware support for IEEE quad-precision FP type,
the feature should be enabled by default on Power9 or newer targets.

Reviewed By: steven.zhang

Differential Revision: https://reviews.llvm.org/D90213
2020-12-07 18:31:00 +08:00
Hafiz Abid Qadeer 275592e714 Provide default location of sysroot for Baremetal toolchain.
Currently, Baremetal toolchain requires user to pass a sysroot location
using a --sysroot flag. This is not very convenient for the user. It also
creates problem for toolchain vendors who don't have a fixed location to
put the sysroot bits.

Clang does provide 'DEFAULT_SYSROOT' which can be used by the toolchain
builder to provide the default location. But it does not work if toolchain
is targeting multiple targets e.g. arm-none-eabi/riscv64-unknown-elf which
clang is capable of doing.

This patch tries to solve this problem by providing a default location of
the toolchain if user does not explicitly provides --sysroot. The exact
location and name can be different but it should fulfill these conditions:

1. The sysroot path should have a target triple element so that multi-target
toolchain problem (as I described above) could be addressed.

2. The location should not be $TOP/$Triple as this is used by gcc generally
and will be a problem for installing both gcc and clang based toolchain at
the same location.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D92677
2020-12-07 09:19:52 +00:00
Fangrui Song 5755522b5a Sema.h: delete unused variables/functions/type aliases 2020-12-06 20:39:01 -08:00
Fangrui Song 192fb1bd8a [Sema] Delete unused declarations
Notes about some declarations:

* clang::Sema::endsWithnarrowing: deleted by rC148381
* clang::Sema::ConvertIntegerToTypeWarnOnOverflow: deleted by rC214678
* clang::Sema::FreePackedContext: deleted by rC268085
* clang::Sema::ComputeDefaulted*: deleted by rC296067
2020-12-06 20:16:00 -08:00
Fangrui Song a2f922140f [TableGen] Delete 11 unused declarations 2020-12-06 13:21:07 -08:00
Vitaly Buka 1f21f6d6a4 [NFC][CodeGen] Simplify SanitizeDtorMembers::Emit 2020-12-05 21:11:27 -08:00
Vitaly Buka 452eddf30b [NFC][CodeGen] Add sanitize-dtor-zero-size-field test
The test demonstrates invalid behaviour which will be fixed soon.
2020-12-05 16:39:48 -08:00
Benjamin Kramer 2a136a7a9c [X86] Autodetect znver3 2020-12-05 19:08:20 +01:00
mydeveloperday 8668eae2ad [clang-format] Add option for case sensitive regexes for sorted includes
I think the title says everything.

Reviewed By: MyDeveloperDay

Patch By:  HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D91507
2020-12-05 16:33:21 +00:00
mydeveloperday 0e226d00d2 [clang-format] [NFC] keep clang-format tests clang-format clean
I use several of the clang-format clean directories as a test suite, this one had got slightly out of wack in a prior commit

Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D92666
2020-12-05 10:15:52 +00:00
Fangrui Song 1ab9327d1c [TargetMachine][CodeGenModule] Delete unneeded ppc32 special case from shouldAssumeDSOLocal
PPCMCInstLower does not actually call shouldAssumeDSOLocal for ppc32 so this is dead.
Actually Clang ppc32 does produce a pair of absolute relocations which match GCC.

This also fixes a comment (R_PPC_COPY and R_PPC64_COPY do exist).
2020-12-05 00:42:07 -08:00
Hsiangkai Wang 5e953a274b [RISCV] Define preprocessor definitions for 'V' extension.
Differential Revision: https://reviews.llvm.org/D92650
2020-12-05 08:34:32 +08:00
Alex Lorenz db226cdf4c [objc] diagnose protocol conformance in categories with direct members
in their corresponding class interfaces

Categories that add protocol conformances to classes with direct members should prohibit protocol
conformances when the methods/properties that the protocol expects are actually declared as 'direct' in the class.

Differential Revision: https://reviews.llvm.org/D92602
2020-12-04 15:55:34 -08:00
Alex Lorenz eddd1d192b [clang] add a `swift_async_name` attribute
The swift_async_name attribute provides a name for a function/method that can be used
to call the async overload of this method from Swift. This name specified in this attribute
assumes that the last parameter in the function/method its applied to is removed when
Swift invokes it, as the the Swift's await/async transformation implicitly constructs the callback.

Differential Revision: https://reviews.llvm.org/D92355
2020-12-04 15:55:29 -08:00
Alex Lorenz 03dcd57ecf [clang] add a new `swift_attr` attribute
The swift_attr attribute is a generic annotation attribute that's not used by clang,
but is used by the Swift compiler. The Swift compiler can use these annotations to provide
various syntactic and semantic sugars for the imported Objective-C API declarations.

Differential Revision: https://reviews.llvm.org/D92354
2020-12-04 15:53:24 -08:00
Duncan P. N. Exon Smith d126943251 Index: Remove unused internal header SimpleFormatContext.h, NFC
Looks like nothing has included this header since
d21485d2f5 / r286279 in 2016. Delete the
dead code.
2020-12-04 15:10:27 -08:00
shafik 6333871f85 Add diagnostic for for-range-declaration being specificed with thread_local
Currently we have a diagnostic that catches the other storage class specifies for the range based for loop declaration but we miss the thread_local case. This changes adds a diagnostic for that case as well.

Differential Revision: https://reviews.llvm.org/D92671
2020-12-04 15:06:35 -08:00
Duncan P. N. Exon Smith b4f4fc6872 ASTImporter: Migrate to the FileEntryRef overload of SourceManager::createFileID, NFC
Migrate `ASTImporter::Import` over to using the `FileEntryRef` overload
of `SourceManager::createFileID`. No functionality change here.

Differential Revision: https://reviews.llvm.org/D92529
2020-12-04 14:45:59 -08:00
Duncan P. N. Exon Smith 9ae0a46f2b ARCMigrate: Initialize fields in EditEntry inline, NFC
Initialize the fields inline instead of having to manually write out a
default constructor.

Differential Revision: https://reviews.llvm.org/D92597
2020-12-04 14:43:22 -08:00
Duncan P. N. Exon Smith 1b023f54b6 Frontend: Use translateLineCol instead of translateFileLineCol, NFC
`ParseDirective` in VerifyDiagnosticConsumer.cpp is already calling
`translateFile`, so use the `FileID` returned by that to call
`translateLineCol` instead of using the more heavyweight
`translateFileLineCol`.

No functionality change here.
2020-12-04 14:37:48 -08:00
Alexey Bataev d764ad72e5 [OPENMP]Fix PR48394: need to capture variables used in atomic constructs.
The variables used in atomic construct should be captured in outer
task-based regions implicitly. Otherwise, the compiler will crash trying
to find the address of the local variable.

Differential Revision: https://reviews.llvm.org/D92682
2020-12-04 13:08:54 -08:00
Sam McCall 650e04e179 [Tooling] JSONCompilationDatabase::loadFromBuffer retains the buffer, copy it.
This function doesn't seem to be used in-tree outside tests.
However clangd wants to use it soon, and having the CDB be self-contained seems
reasonable.

Differential Revision: https://reviews.llvm.org/D92646
2020-12-04 21:54:55 +01:00
Duncan P. N. Exon Smith d10f9863a5 ADT: Migrate users of AlignedCharArrayUnion to std::aligned_union_t, NFC
Prepare to delete `AlignedCharArrayUnion` by migrating its users over to
`std::aligned_union_t`.

I will delete `AlignedCharArrayUnion` and its tests in a follow-up
commit so that it's easier to revert in isolation in case some
downstream wants to keep using it.

Differential Revision: https://reviews.llvm.org/D92516
2020-12-04 12:34:49 -08:00
mydeveloperday 88c21f8488 [clang-format] NFC update in the overall clang-formatted status
The current state of the clang-formatted-ness of the LLVM project hasn't been updated since June bring it upto date
2020-12-04 20:10:10 +00:00
Artem Belevich 4326792942 [CUDA] Another attempt to fix early inclusion of <new> from libstdc++
Previous patch (9a465057a6) did not fix the problem.
https://bugs.llvm.org/show_bug.cgi?id=48228

If the <new> is included too early, before CUDA-specific defines are available,
just include-next the standard <new> and undo the include guard.  CUDA-specific
variants of operator new/delete will be declared if/when <new> is used from the
CUDA source itself, when all CUDA-related macros are available.

Differential Revision: https://reviews.llvm.org/D91807
2020-12-04 12:03:35 -08:00
Duncan P. N. Exon Smith 5b267fb796 ADT: Stop peeking inside AlignedCharArrayUnion, NFC
Update all the users of `AlignedCharArrayUnion` to stop peeking inside
(to look at `buffer`) so that a follow-up patch can replace it with an
alias to `std::aligned_union_t`.

This was reviewed as part of https://reviews.llvm.org/D92512, but I'm
splitting this bit out to commit first to reduce churn in case the
change to `AlignedCharArrayUnion` needs to be reverted for some
unexpected reason.
2020-12-04 11:07:42 -08:00
Hafiz Abid Qadeer ca2888310b Don't use sysroot/include when sysroot is empty.
Baremetal toolchain add Driver.SysRoot/include to the system include
paths without checking if Driver.SysRoot is empty. This resulted in
"-internal-isystem" "include" in the command. This patch adds check for
empty sysroot.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D92176
2020-12-04 18:33:24 +00:00
mydeveloperday 840e651dc6 [clang-format] Improve clang-formats handling of concepts
This is a starting point to improve the handling of concepts in clang-format. There is currently no real formatting of concepts and this can lead to some odd formatting, e.g.

Reviewed By: mitchell-stellar, miscco, curdeius

Differential Revision: https://reviews.llvm.org/D79773
2020-12-04 17:45:50 +00:00
Erik Pilkington 4fa0dbd688 Fix a test failing on windows 2020-12-04 11:20:17 -05:00
Alexey Bataev 2502f89954 [OPENMP]Fix PR48387: disable warning messages caused by internal conversions.
Compiler needs to convert some of the loop iteration
variables/conditions to different types for better codegen and it may
lead to spurious warning messages about implicit signed/unsigned
conversions.

Differential Revision: https://reviews.llvm.org/D92655
2020-12-04 07:44:36 -08:00