Commit Graph

57156 Commits

Author SHA1 Message Date
Momchil Velikov 173b711e83 [ARM][MVE] MVE-I should not be disabled by -mfpu=none
Architecturally, it's allowed to have MVE-I without an FPU, thus
-mfpu=none should not disable MVE-I, or moves to/from FP-registers.

This patch removes `+/-fpregs` from features unconditionally added to
target feature list, depending on FPU and moves the logic to Clang
driver, where the negative form (`-fpregs`) is conditionally added to
the target features list for the cases of `-mfloat-abi=soft`, or
`-mfpu=none` without either `+mve` or `+mve.fp`. Only the negative
form is added by the driver, the positive one is derived from other
features in the backend.

Differential Revision: https://reviews.llvm.org/D71843
2020-01-09 14:03:25 +00:00
Saar Raz b65b1f322b [Concepts] Function trailing requires clauses
Function trailing requires clauses now parsed, supported in overload resolution and when calling, referencing and taking the address of functions or function templates.

Differential Revision: https://reviews.llvm.org/D43357
2020-01-09 15:07:51 +02:00
Simon Pilgrim d462185e8d Fix "pointer is null" static analyzer warning. NFCI.
Use cast<> instead of dyn_cast<> since we know that the pointer should be valid (and is dereferenced immediately below).
2020-01-09 12:37:38 +00:00
Simon Pilgrim e315ce2bd3 Fix "pointer is null" static analyzer warnings. NFCI.
Use castAs<> instead of getAs<> since the pointer is dereferenced immediately below and castAs will perform the null assertion for us.
2020-01-09 12:05:48 +00:00
Simon Pilgrim e3e72a2619 Fix "pointer is null" static analyzer warnings. NFCI.
Assert that the pointers are non-null before dereferencing them.
2020-01-09 12:05:47 +00:00
Simon Pilgrim 0d5407987a Fix MSVC unhandled enum warning. NFCI. 2020-01-09 11:11:01 +00:00
Ehud Katz 24b326cc61 [APFloat] Fix checked error assert failures
`APFLoat::convertFromString` returns `Expected` result, which must be
"checked" if the LLVM_ENABLE_ABI_BREAKING_CHECKS preprocessor flag is
set.
To mark an `Expected` result as "checked" we must consume the `Error`
within.
In many cases, we are only interested in knowing if an error occured,
without the need to examine the error info. This is achieved, easily,
with the `errorToBool()` API.
2020-01-09 09:42:32 +02:00
Justin Hibbits ff0311c4b3 [PowerPC]: Add powerpcspe target triple subarch component
Summary:
This allows the use of '-target powerpcspe-unknown-linux-gnu' or
'powerpcspe-unknown-freebsd' to be used, instead of
'-target powerpc-unknown-linux-gnu -mspe'.

Reviewed By: dim
Differential Revision: https://reviews.llvm.org/D72014
2020-01-08 19:10:53 -06:00
Rihan Yang 2823e91d55 Add a new AST matcher 'optionally'.
This matcher matches any node and at the same time executes all its
inner matchers to produce any possbile result bindings.

This is useful when a user wants certain supplementary information
that's not always present along with the main match result.
2020-01-08 14:10:11 -05:00
Simon Pilgrim 5936717fa6 Fix "pointer is null" static analyzer warning. NFCI.
Use castAs<> instead of getAs<> since we know that the pointer will be valid (and is dereferenced immediately below).
2020-01-08 17:19:08 +00:00
Alexey Bataev c74a8adda3 [OPENMP]Allow comma in combiner expression.
Use ParseExpression() instead of ParseAssignmentExpression() to allow
commas in combiner expressions.
2020-01-08 10:00:11 -05:00
Aaron Ballman 7a77ad1446 Fixing a formatting nit; NFC 2020-01-08 08:53:04 -05:00
Aaron Ballman 55a51e1c79 Disallow an empty string literal in an asm label
An empty string literal in an asm label does not make a whole lot of sense. GCC
does not diagnose such a construct, but it also generates code that cannot be
assembled by gas should two symbols have an empty asm label within the same TU.
This does not affect an asm statement with an empty string literal, which is
still a useful construct.
2020-01-08 08:38:02 -05:00
Tim Northover 903e5c3028 AArch64: add missing Apple CPU names and use them by default.
Apple's CPUs are called A7-A13 in official communication, occasionally with
weird suffixes which we probably don't need to care about. This adds each one
and describes its features. It also switches the default CPU to the canonical
name for Cyclone, but leaves legacy support in so that existing bitcode still
compiles.
2020-01-08 09:24:06 +00:00
Fangrui Song 907a0cadb2 [PowerPC] Default ppc64 linux-gnu/freebsd to -fno-PIC
According to D53384, the default was switched from -fno-PIC to -fPIC to
work around a -fsanitize=leak bug on big-endian.

This gratuitous difference between little-endian and big-endian is
undesired, and not acceptable on powerpc64-unknown-freebsd.  If
-fsanitize=leak still has the problem, we should consider defaulting to
-fPIC/-fPIE only when -fsanitize=leak is specified (see SanitizerArgs::requiresPIE())

powerpc64-ibm-aix is unaffected: it still defaults to -fPIC.
powerpc64-linux-musl is unaffected (-fPIE since D39588): it still defaults to -fPIE.

Reviewed By: #powerpc, jhibbits

Differential Revision: https://reviews.llvm.org/D72363
2020-01-07 15:09:22 -08:00
Fangrui Song 8edf759ca7 [PowerPC][Triple] Use elfv2 on freebsd>=13 and linux-musl
Summary:
Every powerpc64le platform uses elfv2.

For powerpc64, the environments "elfv1" and "elfv2" were added for
FreeBSD ELFv1->ELFv2 migration in D61950.  FreeBSD developers have
decided to use OS versions to select ABI, and no one is relying on the
environments.

Also use elfv2 on powerpc64-linux-musl.

Users can always use -mabi=elfv1 and -mabi=elfv2 to override the default
ABI.

Reviewed By: adalava

Differential Revision: https://reviews.llvm.org/D72352
2020-01-07 11:40:56 -08:00
Alexey Bataev 4558842891 [OPENMP]Reduce calls for the mangled names.
Use canonical decls instead of mangled names in the set of already
emitted decls. This allows to reduce the number of function calls for
getting declarations mangled names and speedup the compilation.
2020-01-07 14:28:17 -05:00
Alexey Bataev c972f6fd79 [OPENMP]Allow using of members in standalone declaration pragmas.
If standalone OpenMP declaration pragma, like declare mapper or declare
reduction, is declared in the class context, it may reference a member
(data or function) in its internal expressions/statements. So, the
parsing of such pragmas must be dalayed just like the parsing of the
member initializers/definitions before the completion of the class
declaration.
2020-01-07 13:44:10 -05:00
Gabor Horvath 247a603254 [LifetimeAnalysis] Do not forbid void deref type in gsl::Pointer/gsl::Owner annotations
It turns out it is useful to be able to define the deref type as void.
In case we have a type erased owner, we want to express that the pointee
can be basically any type. It should not be unnatural to have a void
deref type as we already familiar with "pointers to void".

Differential Revision: https://reviews.llvm.org/D72097
2020-01-07 08:32:40 -08:00
Yaxun (Sam) Liu 9f2d8b5c0c [HIP] Add option --gpu-max-threads-per-block=n
Add this option to change the default launch bounds.

Differential Revision: https://reviews.llvm.org/D71221
2020-01-07 11:18:00 -05:00
Alexey Bataev 3f2e3dc44b [OPENMP]Do not diagnose references to non-integral types for ref in
declare simd.

According to the standard, a list-item that appears in a linear clause without the ref modifier must be of integral or pointer type, or must be a reference to an integral or pointer type. Added check that this restriction is applied only to non-ref items.
2020-01-07 09:28:50 -05:00
Simon Pilgrim 3b417b7cf7 Fix "pointer is null" static analyzer warning. NFCI. 2020-01-07 13:41:52 +00:00
Jim Lin ab1bcda851 [NFC] Use isX86() instead of getArch()
Summary: This is a clean up for https://reviews.llvm.org/D72247.

Reviewers: MaskRay, craig.topper, jhenderson

Reviewed By: MaskRay

Subscribers: hiraditya, rupprecht, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D72320
2020-01-07 17:35:44 +08:00
Richard Smith 907cefe721 Always deduce the lengths of contained parameter packs when deducing a
pack expansion.

Previously, if all parameter / argument pairs for a pack expansion
deduction were non-deduced contexts, we would not deduce the arity of
the pack, and could end up deducing a different arity (leading to
failures during substitution) or defaulting to an arity of 0 (leading to
bad diagnostics about passing the wrong number of arguments to a
variadic function). Instead, we now always deduce the arity for all
involved packs any time we deduce a pack expansion.

This will result in less substitution happening in some cases, which
could avoid non-SFINAEable errors, and should generally improve the
quality of diagnostics when passing initializer lists to variadic
functions.
2020-01-06 17:24:29 -08:00
Akira Hatanaka 20f005d25f [CodeGen][ObjC] Push the properties of a protocol before pushing the
properties of the protocol it inherits

This fixes a bug where the type string for a @dynamic property of an
@implementation didn't have 'D' in it when the protocol it conforms to
redeclares the property declared in the base protocol.

rdar://problem/45503561
2020-01-06 16:16:02 -08:00
Fangrui Song 6904cd9486 Add Triple::isX86()
Reviewed By: craig.topper, skan

Differential Revision: https://reviews.llvm.org/D72247
2020-01-06 15:51:02 -08:00
Tyker f5329bfc76 [Diagnostic] make Wmisleading-indendation not warn about labels
Reviewers: aaron.ballman, xbolva00

Reviewed By: aaron.ballman

Subscribers: nickdesaulniers, nathanchance

Differential Revision: https://reviews.llvm.org/D72202
2020-01-06 23:22:27 +01:00
Alexey Bataev 7b518dcb29 [OPENMP50]Support lastprivate conditional updates in inc/dec unary ops.
Added support for checking of updates of variables used in unary
pre(pos) inc/dec expressions.
2020-01-06 16:37:01 -05:00
stevewan 02f694b69a [NFC] Test commit, revert whitespace change
As per the Developer Policy, upon obtaining commit access.
2020-01-06 16:28:13 -05:00
stevewan b73fea6a7c [NFC] Test commit, whitespace change
As per the Developer Policy, upon obtaining commit access.
2020-01-06 16:24:27 -05:00
Mitchell Balan d45aafa2fb [clang-format] fix conflict between FormatStyle::BWACS_MultiLine and BeforeCatch/BeforeElse
Summary:
Found a bug introduced with BraceWrappingFlags AfterControlStatement MultiLine. This feature conflicts with the existing BeforeCatch and BeforeElse flags.

For example, our team uses BeforeElse.

if (foo ||
    bar) {
  doSomething();
}
else {
  doSomethingElse();
}

If we enable MultiLine (which we'd really love to do) we expect it to work like this:

if (foo ||
    bar)
{
  doSomething();
}
else {
  doSomethingElse();
}

What we actually get is:

if (foo ||
    bar)
{
  doSomething();
}
else
{
  doSomethingElse();
}

Reviewers: MyDeveloperDay, Bouska, mitchell-stellar

Patch by: pastey

Subscribers: Bouska, cfe-commits

Tags: clang

Differential Revision: https://reviews.llvm.org/D71939
2020-01-06 09:21:41 -05:00
Ehud Katz f3f7dc3d29 [APFloat] Fix compilation warnings 2020-01-06 11:30:40 +02:00
Ehud Katz c5fb73c5d1 [APFloat] Add recoverable string parsing errors to APFloat
Implementing the APFloat part in PR4745.

Differential Revision: https://reviews.llvm.org/D69770
2020-01-06 10:09:01 +02:00
Kristina Brooks b18cb9c471 [Gnu toolchain] Look at standard GCC paths for libstdcxx by default
Linux' current addLibCxxIncludePaths and addLibStdCxxIncludePaths
are actually almost non-Linux-specific at all, and can be reused
almost as such for all gcc toolchains. Only keep
Android/Freescale/Cray hacks in Linux's version.

Patch by sthibaul (Samuel Thibault)

Differential Revision: https://reviews.llvm.org/D69758
2020-01-05 21:43:18 +00:00
Stephen Kelly ad0a45833b Allow using traverse() with bindings 2020-01-05 20:48:56 +00:00
Stephen Kelly 4711512384 Fix oversight in AST traversal helper 2020-01-05 20:27:37 +00:00
Jonas Paulsson c0f1eac008 [SystemZ] Don't allow CL option -mpacked-stack with -mbackchain.
-mpacked-stack is currently not supported with -mbackchain, so this should
result in a compilation error message instead of being silently ignored.

Review: Ulrich Weigand
2020-01-03 12:26:54 -08:00
Alexey Bataev add743b434 [OPENMP]Fix crash on error message for declare reduction.
If the qualified reduction name is specified and not found, the compiler
may crash because of not specified parameter.
2020-01-03 12:13:03 -05:00
Nico Weber ba3484c051 [clang-format/java] format multiple qualified annotations on one declaration better
Before:
    class Foo {
      @CommandLineFlags
          .Add
          @Features.foo
          public void test() {}
    }

Now:
    class Foo {
        @Features.foo
        @CommandLineFlags.Add
        public void test() { }
    }

See also https://crbug.com/1034115
2020-01-03 12:11:44 -05:00
Kelvin Li 427ffa2cdb [OpenMP] diagnose zero-length array section in the depend clause
The OpenMP specification disallows having zero-length array
sections in the depend clause (OpenMP 5.0 2.17.11).

Differential Revision: https://reviews.llvm.org/D71969
2020-01-03 11:55:37 -05:00
Tyker b4b904e19b [Diagnostic] Fixed add ftabstop to -Wmisleading-indentation
Summary:
this allow much better support of codebases like the linux kernel that mix tabs and spaces.

-ftabstop=//Width// allow specifying how large tabs are considered to be.

Reviewers: xbolva00, aaron.ballman, rsmith

Reviewed By: aaron.ballman

Subscribers: mstorsjo, cfe-commits, jyknight, riccibruno, rsmith, nathanchance

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71037
2020-01-03 17:22:24 +01:00
Ilya Biryukov 04f627f6b9 [Syntax] Build spanning SimpleDecalration for classes, structs, etc
When they are free-standing, e.g. `struct X;` or `struct X {};`.
Although this complicates the common case (of free-standing class
declarations), this ensures the less common case (e.g. `struct X {} a;`)
are handled uniformly and produce similar syntax trees.
2020-01-03 12:33:11 +01:00
Alexey Bataev a58da1a2ff [OPENMP50]Codegen for lastprivate conditional list items.
Added codegen support for lastprivate conditional. According to the
standard, if  when the conditional modifier appears on the clause, if an
assignment to a list item is encountered in the construct then the
original list item is assigned the value that is assigned to the new
list item in the sequentially last iteration or lexically last section
in which such an assignment is encountered.
We look for the assignment operations and check if the left side
references lastprivate conditional variable. Then the next code is
emitted:
if (last_iv_a <= iv) {
  last_iv_a = iv;
  last_a = lp_a;
}

At the end the implicit barrier is generated to wait for the end of all
threads and then in the check for the last iteration the private copy is
assigned the last value.

if (last_iter) {
  lp_a = last_a; // <--- new code
  a = lp_a;      // <--- store of private value to the original  variable.
}
2020-01-02 16:43:00 -05:00
Alexey Bataev 1fcc9b6ff8 [OPENMP] Restore allowing of braced initializers in the declare reduction
init.

Braced initializers were not accepted after the last fix in the initialier.Restored previous functionality.
2020-01-02 16:10:17 -05:00
Nathan James ec3d8e61b5 Handle init statements in readability-else-after-return
Adds a new ASTMatcher condition called 'hasInitStatement()' that matches if,
switch and range-for statements with an initializer. Reworked clang-tidy
readability-else-after-return to handle variables in the if condition or init
statements in c++17 ifs. Also checks if removing the else would affect object
lifetimes in the else branch.

Fixes PR44364.
2020-01-02 13:39:27 -05:00
Kevin P. Neal 89d6c288ba [SystemZ] Use FNeg in s390x clang builtins
The s390x builtins are still using FSub instead of FNeg. Correct that.
2020-01-02 12:14:43 -05:00
serge_sans_paille 24ab9b537e Generalize the pass registration mechanism used by Polly to any third-party tool
There's quite a lot of references to Polly in the LLVM CMake codebase. However
the registration pattern used by Polly could be useful to other external
projects: thanks to that mechanism it would be possible to develop LLVM
extension without touching the LLVM code base.

This patch has two effects:

1. Remove all code specific to Polly in the llvm/clang codebase, replaicing it
   with a generic mechanism

2. Provide a generic mechanism to register compiler extensions.

A compiler extension is similar to a pass plugin, with the notable difference
that the compiler extension can be configured to be built dynamically (like
plugins) or statically (like regular passes).

As a result, people willing to add extra passes to clang/opt can do it using a
separate code repo, but still have their pass be linked in clang/opt as built-in
passes.

Differential Revision: https://reviews.llvm.org/D61446
2020-01-02 16:45:31 +01:00
Alexey Bataev 87a004d0f8 [OpenMP] Fix formatting of OpenMP error message, by Wang Tianqing.
Summary: `getListOfPossibleValues()` formatted incorrectly when there is only one value, emitting something like `expected 'conditional' or  in OpenMP clause 'lastprivate'`.

Reviewers: jdoerfert, ABataev

Reviewed By: jdoerfert

Subscribers: guansong, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71884
2020-01-02 10:07:04 -05:00
Mark de Wever e5ab1e49f9 Improve Wrange-loop-analyses for rvalue reference
The Wrange-loop-analyses warns if a copy is made. Suppress this warning when
a temporary is bound to a rvalue reference.

While fixing this issue also found a copy-paste error in test6, which is also
fixed.

Differential Revision: https://reviews.llvm.org/D71806
2020-01-01 20:02:18 +01:00
Mark de Wever f022a5a792 Adds fixit hints to the -Wrange-loop-analysis
Differential Revision: https://reviews.llvm.org/D68913
2020-01-01 20:02:00 +01:00
Mark de Wever 8dc7b982b4 [NFC] Fixes -Wrange-loop-analysis warnings
This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

Differential Revision: https://reviews.llvm.org/D71857
2020-01-01 20:01:37 +01:00
Fangrui Song d2bb8c16e7 [MC][TargetMachine] Delete MCTargetOptions::MCPIECopyRelocations
clang/lib/CodeGen/CodeGenModule performs the -mpie-copy-relocations
check and sets dso_local on applicable global variables. We don't need
to duplicate the work in TargetMachine shouldAssumeDSOLocal.

Verified that -mpie-copy-relocations can still emit PC relative
relocations for external variable accesses.

clang -target x86_64 -fpie -mpie-copy-relocations -c => R_X86_64_PC32
clang -target aarch64 -fpie -mpie-copy-relocations -c => R_AARCH64_ADR_PREL_PG_HI21+R_AARCH64_LDST64_ABS_LO12_NC
2020-01-01 00:50:18 -08:00
Martin Storsjö b65ca8e5db Revert "[Diagnostic] Add ftabstop to -Wmisleading-indentation"
This reverts commit b47b35ff51.

This caused failed asserts (Assertion `FIDAndOffset.second >
ColNo && "Column number smaller than file offset?"' failed.)
on a source file with a single line containing
"int main (void) { for( int i = 0; i < 9; i++ ); return 0; }".
2019-12-31 21:38:43 +02:00
Alexey Bataev 8be5a0fe12 [OPENMP]Emit artificial threprivate vars as threadlocal, if possible.
It may improve performance for declare reduction constructs.
2019-12-31 14:11:36 -05:00
Craig Topper 5e5a1d2790 [CodeGen] Emit conj/conjf/confjl libcalls as fneg instructions if possible.
We already recognize the __builtin versions of these, might as well
recognize the libcall version.

Differential Revision: https://reviews.llvm.org/D72028
2019-12-31 10:41:00 -08:00
Stephen Kelly d89c4cb938 Match code following lambdas when ignoring invisible nodes
Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71976
2019-12-31 17:04:39 +00:00
Sven van Haastregt ff429c5eaf [OpenCL] Remove redundant foreach in OpenCLBuiltins.td; NFC
Remove various `foreach` declarations where the iterator is used only
once.  This makes the .td file more compact.
2019-12-31 15:30:02 +00:00
Craig Topper 70f8dd4cf6 [CodeGen] Use IRBuilder::CreateFNeg for __builtin_conj
This replaces the fsub -0.0 idiom with an fneg instruction. We didn't see to have a test that showed the current codegen. Just some tests for constant folding and a test that was only checking the declare lines for libcalls. The latter just checked that we did not have a declare for @conj when using __builtin_conj.

Differential Revision: https://reviews.llvm.org/D72012
2019-12-30 13:25:23 -08:00
Craig Topper 8b23b2bbd9 [CodeGen] Use CreateFNeg in buildFMulAdd
We have an fneg instruction now and should use it instead of the fsub -0.0 idiom. Looks like we had no test that showed that we handled the negation cases here so I've added new tests.

Differential Revision: https://reviews.llvm.org/D72010
2019-12-30 13:24:11 -08:00
Johannes Doerfert 10fedd94b4 [OpenMP] Use the OpenMPIRBuilder for `omp parallel`
This allows to use the OpenMPIRBuilder for parallel regions. Code was
extracted from D61953 and adapted to work with the new version (D70109).

All but one feature should be supported. An update of this patch will
provide test coverage and privatization other than shared.

Reviewed By: fghanim

Differential Revision: https://reviews.llvm.org/D70290
2019-12-30 13:57:13 -06:00
Eric Astor 4a7aa252a3 [X86][AsmParser] re-introduce 'offset' operator
Summary:
Amend MS offset operator implementation, to more closely fit with its MS counterpart:

    1. InlineAsm: evaluate non-local source entities to their (address) location
    2. Provide a mean with which one may acquire the address of an assembly label via MS syntax, rather than yielding a memory reference (i.e. "offset asm_label" and "$asm_label" should be synonymous
    3. address PR32530

Based on http://llvm.org/D37461

Fix broken test where the break appears unrelated.

- Set up appropriate memory-input rewrites for variable references.

- Intel-dialect assembly printing now correctly handles addresses by adding "offset".

- Pass offsets as immediate operands (using "r" constraint for offsets of locals).

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D71436
2019-12-30 14:35:26 -05:00
Sven van Haastregt 4a188fdfa7 [OpenCL] Add mipmap builtin functions
Add the mipmap builtin functions from the OpenCL extension
specification.

Patch by Pierre Gondois and Sven van Haastregt.
2019-12-30 10:47:58 +00:00
Tyker b47b35ff51 [Diagnostic] Add ftabstop to -Wmisleading-indentation
Summary:
this allow much better support of codebases like the linux kernel that mix tabs and spaces.

-ftabstop=//Width// allow specifying how large tabs are considered to be.

Reviewers: xbolva00, aaron.ballman, rsmith

Reviewed By: aaron.ballman

Subscribers: jyknight, riccibruno, rsmith, nathanchance

Differential Revision: https://reviews.llvm.org/D71037
2019-12-30 09:24:34 +01:00
Stephen Kelly f7d9584c56 Fix formatting in previous commits 2019-12-29 19:41:30 +00:00
Stephen Kelly bee973f4df Fix use of named values surrounded by newlines in clang-query 2019-12-29 14:58:56 +00:00
Stephen Kelly dc93540acb Fix handling of newlines in clang-query
Replace assert with diagnostic for missing newline.
2019-12-29 14:58:56 +00:00
Zachary Henkel 0acfc49317 Allow redeclaration of __declspec(uuid)
msvc allows a subsequent declaration of a uuid attribute on a
struct/class.  Mirror this behavior in clang-cl.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D71439
2019-12-28 13:13:46 -08:00
Alexey Bader 128f39da93 Fix crash in getFullyQualifiedName for inline namespace
Summary: The ICE happens when the most outer namespace is an inline namespace.

Reviewers: bkramer, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ebevhan, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71962
2019-12-28 16:35:51 +03:00
David Blaikie d8018233d1 Revert "CWG2352: Allow qualification conversions during reference binding."
This reverts commit de21704ba9.

Regressed/causes this to error due to ambiguity:

  void f(const int * const &);
  void f(int *);
  int main() {
    int * x;
    f(x);
  }

(in case it's important - the original case where this turned up was a
member function overload in a class template with, essentially:

  f(const T1&)
  f(T2*)

(where T1 == X const *, T2 == X))

It's not super clear to me if this ^ is expected behavior, in which case
I'm sorry about the revert & happy to look into ways to fix the original
code.
2019-12-27 12:27:20 -08:00
Yaxun (Sam) Liu 134ef0fb4b [OpenCL] Fix inconsistency between opencl and c11 atomic fetch max/min
There is some inconsistency between opencl and c11 atomic fetch max/min after

https://reviews.llvm.org/D46386

https://reviews.llvm.org/D55562

It is not reasonable to have such inconsistencies. This patch fixes that.

Differential Revision: https://reviews.llvm.org/D71725
2019-12-27 11:29:04 -05:00
Stephen Kelly f0722333dd Allow newlines in AST Matchers in clang-query files
Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71842
2019-12-27 15:25:57 +00:00
Anastasia Stulova 869d17d851 [OpenCL] Pretty print __private addr space
Add printing of __private address space to TypePrinter to allow
it appears in diagnostics and AST dumps as all other language
addr spaces.

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71272
2019-12-27 13:42:07 +00:00
Evgenii Stepanov 5ca97d0def Revert "Allow newlines in AST Matchers in clang-query files" + 1
Revert "Fix -Wunused-lambda-capture warnings."
This reverts commit 2369560f4a.
This reverts commit 522ee29a4f.

clang/lib/ASTMatchers/Dynamic/Parser.cpp:610:13: warning: implicit conversion turns string literal into bool: 'const char [35]' to 'bool' [-Wstring-conversion]
    assert(!"Newline should never be found here");
2019-12-26 18:07:20 -08:00
Eric Christopher 2369560f4a Fix -Wunused-lambda-capture warnings. 2019-12-26 15:27:21 -08:00
Stephen Kelly 522ee29a4f Allow newlines in AST Matchers in clang-query files
Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71842
2019-12-26 20:40:33 +00:00
Stephen Kelly 831b636861 Revert "Allow newlines in AST Matchers in clang-query files"
This reverts commit 6a3ecf4dc7.
2019-12-26 20:16:23 +00:00
Stephen Kelly 6a3ecf4dc7 Allow newlines in AST Matchers in clang-query files
Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71842
2019-12-26 20:00:59 +00:00
Johannes Doerfert 6c5d1f40ff [OpenMP][NFCI] Use the libFrontend ProcBindKind in Clang
This removes the OpenMPProcBindClauseKind enum in favor of
llvm::omp::ProcBindKind which lives in OpenMPConstants.h and was
introduced in D70109.

No change in behavior is expected.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D70289
2019-12-26 11:04:07 -06:00
Johannes Doerfert f9c3c5da19 [OpenMP][IR-Builder] Introduce the finalization stack
As a permanent and generic solution to the problem of variable
finalization (destructors, lastprivate, ...), this patch introduces the
finalization stack. The objects on the stack describe (1) the
(structured) regions the OpenMP-IR-Builder is currently constructing,
(2) if these are cancellable, and (3) the callback that will perform the
finalization (=cleanup) when necessary.

As the finalization can be necessary multiple times, at different source
locations, the callback takes the position at which code is currently
generated. This position will also encode the destination of the "region
exit" block *iff* the finalization call was issues for a region
generated by the OpenMPIRBuilder. For regions generated through the old
Clang OpenMP code geneneration, the "region exit" is determined by Clang
inside the finalization call instead (see getOMPCancelDestination).

As a first user, the parallel + cancel barrier interaction is changed.
In contrast to the temporary solution before, the barrier generation in
Clang does not need to be aware of the "CancelDestination" block.
Instead, the finalization callback is and, as described above, later
even that one does not need to be.

D70109 will be updated to use this scheme.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D70258
2019-12-25 16:57:08 -06:00
Alexey Bataev 3732f4e093 [OPENMP]Add extra checks and initialization for clause modifier.
Added initialization of the extra modifier to silence sanitizer. Added
extra checks to avoid such trouble in future.
2019-12-24 16:12:28 -05:00
Alexey Bataev 93dc40dddd [OPENMP50]Basic support for conditional lastprivate.
Added parsing/sema checks for conditional lastprivates.
2019-12-24 12:22:05 -05:00
Kevin P. Neal 0293b5d671 [NFC] Remove some dead code from CGBuiltin.cpp. 2019-12-24 09:38:34 -05:00
Whisperity 002e07208a [clang] [ast] CXXRecordDecl::getVisibleConversionFunctions() could be const
The function and its called static helpers don't modify the received
CXXRecordDecl arguments at all as the method's result is put into an
output parameter. Thus they can be const which allows for neatly
grabbing the conversion methods in a context where we only have a const
ASTUnit at hand.

Differential Revision: https://reviews.llvm.org/D71805
2019-12-24 11:09:24 +01:00
Gabor Horvath 379613d7c7 [CFG] Fix an assertion failure with static initializers
The CFGBlock::getLastCondition was not prepared for static initializer
branches.

This patch also revamps CFG unit tests. Earlier the lifetime of the AST
was smaller than the CFG. So all the AST pointers within the CFG blocks
were dangling. This was OK, since none of the tests dereferenced those
pointers. This was, however, a timed bomb. There were patches in the
past that were reverted partially due to this problem.

Differential revision: https://reviews.llvm.org/D71791
2019-12-23 16:35:37 -08:00
Craig Topper d35bcbbb5d [Sema][X86] Consider target attribute into the checks in validateOutputSize and validateInputSize.
The validateOutputSize and validateInputSize need to check whether
AVX or AVX512 are enabled. But this can be affected by the
target attribute so we need to factor that in.

This patch moves some of the code from CodeGen to create an
appropriate feature map that we can pass to the function.

Differential Revision: https://reviews.llvm.org/D68627
2019-12-23 11:23:30 -08:00
Alexey Bataev 0860db966a [OPENMP50]Codegen for nontemporal clause.
Summary:
Basic codegen for the declarations marked as nontemporal. Also, if the
base declaration in the member expression is marked as nontemporal,
lvalue for member decl access inherits nonteporal flag from the base
lvalue.

Reviewers: rjmccall, hfinkel, jdoerfert

Subscribers: guansong, arphaman, caomhin, kkwli0, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71708
2019-12-23 10:04:46 -05:00
Yaxun (Sam) Liu eca40066eb [NFC] Move OptionUtils from Basic to Driver
Differential Revision: https://reviews.llvm.org/D71802
2019-12-23 08:11:23 -05:00
Sven van Haastregt b714583fd0 [OpenCL] Add atomic builtin functions
Add atomic builtin functions from the OpenCL C specification.

Patch by Pierre Gondois and Sven van Haastregt.
2019-12-23 12:29:01 +00:00
Martin Storsjö 86c9831bb4 [ItaniumCXXABI] Don't mark an extern_weak init function as dso_local on windows
Since 6bf108d77a, we try to not mark extern_weak symbols as
dso_local, to allow using COFF stubs for references to those symbols
(as the symbol may be missing, resolving to an absolute address zero,
outside of the current DSO).

Differential Revision: https://reviews.llvm.org/D71716
2019-12-23 12:13:48 +02:00
Saar Raz df061c3e2b [Concepts] Constrained partial specializations and function overloads.
Added support for constraint satisfaction checking and partial ordering of constraints in constrained partial specialization and function template overloads.
Re-commit after fixing another crash (added regression test).

Differential Revision: https://reviews.llvm.org/D41910
2019-12-23 08:37:35 +02:00
Reid Kleckner 5128026467 [AST] Add missing MultiplexConsumer::CompleteExternalDeclaration 2019-12-22 19:00:48 -08:00
Yonghong Song e3d8ee35e4 reland "[DebugInfo] Support to emit debugInfo for extern variables"
Commit d77ae1552f
("[DebugInfo] Support to emit debugInfo for extern variables")
added deebugInfo for extern variables for BPF target.
The commit is reverted by 891e25b02d
as the committed tests using %clang instead of %clang_cc1 causing
test failed in certain scenarios as reported by Reid Kleckner.

This patch fixed the tests by using %clang_cc1.

Differential Revision: https://reviews.llvm.org/D71818
2019-12-22 18:28:50 -08:00
Reid Kleckner 891e25b02d Revert "[DebugInfo] Support to emit debugInfo for extern variables"
This reverts commit d77ae1552f.

The tests committed along with this change do not pass, and should be
changed to use %clang_cc1.
2019-12-22 12:54:06 -08:00
Reid Kleckner 79cc9e9b30 Revert "[Concepts] Constrained partial specializations and function overloads."
This reverts commit d3f5769d5e.

Causes crashes on Chromium. Have reproducer, will reduce and send along.
2019-12-22 11:40:07 -08:00
Mark de Wever b6d9e97662 [Analyzer] Fixes -Wrange-loop-analysis warnings
This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

Differential Revision: https://reviews.llvm.org/D71809
2019-12-22 19:13:34 +01:00
Eric Astor dc5b614fa9 [ms] [X86] Use "P" modifier on operands to call instructions in inline X86 assembly.
Summary:
This is documented as the appropriate template modifier for call operands.
Fixes PR44272, and adds a regression test.

Also adds support for operand modifiers in Intel-style inline assembly.

Reviewers: rnk

Reviewed By: rnk

Subscribers: merge_guards_bot, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D71677
2019-12-22 09:16:34 -05:00
Bruno Ricci 7394c15178
[Sema] SequenceChecker: C++17 sequencing rules for built-in operators <<, >>, .*, ->*, =, op=
Implement the C++17 sequencing rules for the built-in operators <<, >>, .*,
 ->*, = and op=.

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

Reviewed By: rsmith
2019-12-22 12:41:14 +00:00
Bruno Ricci 8a571538df
[Sema] SequenceChecker: Fix handling of operator ||, && and ?:
The current handling of the operators ||, && and ?: has a number of false
positive and false negative. The issues for operator || and && are:

1. We need to add sequencing regions for the LHS and RHS as is done for the
   comma operator. Not doing so causes false positives in expressions like
   `((a++, false) || (a++, false))` (from PR39779, see PR22197 for another
    example).

2. In the current implementation when the evaluation of the LHS fails, the RHS
   is added to a worklist to be processed later. This results in false negatives
   in expressions like `(a && a++) + a`.

Fix these issues by introducing sequencing regions for the LHS and RHS, and by
not deferring the visitation of the RHS.

The issues with the ternary operator ?: are similar, with the added twist that
we should not warn on expressions like `(x ? y += 1 : y += 2)` since exactly
one of the 2nd and 3rd expression is going to be evaluated, but we should still
warn on expressions like `(x ? y += 1 : y += 2) = y`.

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

Reviewed By: rsmith
2019-12-22 12:27:31 +00:00
Bruno Ricci b6eba31292
[Sema] SequenceChecker: Add some comments + related small NFCs
NFCs factored out of the following patches:
- Change all of the `Expr *` to `const Expr *` in SequenceChecker for
  const-correctness. SequenceChecker should not modify AST nodes.
- Add some comments.
- clang-format

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

Reviewed By: xbolva00
2019-12-22 12:07:26 +00:00
Saar Raz d3f5769d5e [Concepts] Constrained partial specializations and function overloads.
Added support for constraint satisfaction checking and partial ordering of constraints in constrained partial specialization and function template overloads.
Re-commit after fixing some crashes and warnings.

Differential Revision: https://reviews.llvm.org/D41910
2019-12-22 13:15:38 +02:00
Fangrui Song 527b0f8c74 [Driver] Allow -mnop-mcount for SystemZ and -mfentry for X86 and SystemZ
gcc/config/{i386,s390} support -mnop-mcount. We currently only support
-mnop-mcount for SystemZ. The function attribute "mnop-mcount" is
ignored on other targets.

gcc/config/{i386,s390} support -mfentry. We currently only support
-mfentry for X86 and SystemZ. TargetOpcode::FENTRY_CALL is not handled
on other targets.

  % clang -target aarch64 -pg -mfentry a.c -c
  fatal error: error in backend: Not supported instr: <MCInst 21>

-mfentry, -mrecord-mcount, and -mnop-mcount were invented for Linux
ftrace. Linux uses $(call cc-option-yn,-mrecord-mcount) to detect if the
specific feature is available. Reject unsupported features so that Linux
build system will not wrongly consider them available and cause
build/runtime failures.

Note, GCC has stricter checks that we do not implement, e.g. -fpic/-fpie
-fnop-mcount is not allowed on x86, -fpic/-fpie -mfentry is not allowed
on x86-32.
2019-12-22 00:01:42 -08:00
Fangrui Song 0792ef7256 [Driver] Verify -mrecord-mcount in Driver, instead of CodeGen after D71627
GCC's x86 and s390 ports support -mrecord-mcount. Other ports reject the
option.

  aarch64-linux-gnu-gcc: error: unrecognized command line option ‘-mrecord-mcount’

Allowing this option can cause failures when building Linux kernel for
aarch64, powerpc64, etc, which will think the feature is available if
the clang command returns 0.
2019-12-21 22:47:24 -08:00
Yaxun (Sam) Liu 7376d9eb38 [NFC] Separate getLastArgIntValue to Basic
getLastArgIntValue is a useful utility function to get command line argument as an integer.
Currently it is in Frontend so that it can only be used by clang -cc1. Move it to basic so
that it can also be used by clang driver.

Differential Revision: https://reviews.llvm.org/D71080
2019-12-21 20:39:31 -05:00
Michael Liao 7cee288586 Fix `-Wunused-variable` warning. NFC. 2019-12-21 11:10:35 -05:00
Mark de Wever 70d592d68c [Analyzer] Use a reference in a range-based for
This avoids unneeded copies when using a range-based for loops.

This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

Differential Revision: https://reviews.llvm.org/D70869
2019-12-21 14:52:29 +01:00
Mark de Wever be1a9b3863 [Wdocumentation] Implement \anchor
Differential revision: https://reviews.llvm.org/D69223
2019-12-21 14:52:21 +01:00
Stephen Kelly 5a79cfa32d Customize simplified dumping and matching of LambdaExpr
Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71680
2019-12-21 11:02:11 +00:00
Stephen Kelly 0378f3a903 Revert "Customize simplified dumping and matching of LambdaExpr"
This reverts commit 494b1318ca.
2019-12-20 21:33:31 +00:00
Stephen Kelly 494b1318ca Customize simplified dumping and matching of LambdaExpr
Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71680
2019-12-20 21:13:23 +00:00
Gabor Horvath 59878ec809 [analyzer] Add path notes to FuchsiaHandleCheck.
Differential Revision: https://reviews.llvm.org/D70725
2019-12-20 12:40:41 -08:00
Gabor Horvath 82923c71ef [analyzer] Add Fuchsia Handle checker
The checker can diagnose handle use after releases, double releases, and
handle leaks.

Differential Revision: https://reviews.llvm.org/D70470
2019-12-20 12:33:16 -08:00
Sid Manning d567b0ba84 Avoid unsupported LLD options
Differential Revision: https://reviews.llvm.org/D70919
2019-12-20 14:18:10 -06:00
Gabor Horvath fe17b30a79 [attributes][analyzer] Add annotations for handles.
These annotations will be used in an upcomming static analyzer check
that finds handle leaks, use after releases, and double releases.

Differential Revision: https://reviews.llvm.org/D70469
2019-12-20 11:47:55 -08:00
Kamlesh Kumar 304d1304b7 Apply the alignment specifier attribute to anonymous unions and structs. 2019-12-20 14:42:37 -05:00
Pierre Habouzit 42f9d0c0be [objc_direct] Tigthen checks for direct methods
Because the name of a direct method must be agreed upon by the caller
and the implementation, certain bad practices that one can get away with
when using dynamism are fatal with direct methods.

To avoid really weird and unscruttable linker error, tighten the
front-end error reporting.

Rule 1:
  Direct methods can only have at most one declaration in an @interface
  container. Any redeclaration is strictly forbidden.

  Today some amount of redeclaration is tolerated between the main
  interface and categories for dynamic methods, but we can't have that.

Rule 2:
  Direct method implementations can only be declared in a matching
  @interface container: when implemented in the primary @implementation
  then the declaration must be in the primary @interface or an
  extension, and when implemented in a category, the declaration must be
  in the @interface for the same category.

Also fix another issue with ObjCMethod::getCanonicalDecl(): when an
implementation lives in the primary @interface, then its canonical
declaration can be in any extension, even when it's not an accessor.

Add Sema tests to cover the new errors, and CG tests to beef up testing
around function names for categories and extensions.

Radar-Id: <rdar://problem/58054563>

Differential Revision: https://reviews.llvm.org/D71694
2019-12-20 10:57:36 -08:00
mydeveloperday 2f209ccfbe [clang-format] C# formatting a class with inheritance followed by an attribute specifier assume its a braces initializer
Summary:
https://bugs.llvm.org/show_bug.cgi?id=44340

The rule that prevents `... {} [[....]]`  being treated as a braced initializer for C++ causes problems for C# with attributes, causing it to be incorrectly classified and then messing up the subsequent formatting. (see bug for details of formatting)

Reviewers: mitchell-stellar, klimek, sammccall

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang-format, #clang

Differential Revision: https://reviews.llvm.org/D71769
2019-12-20 17:07:00 +00:00
Dmitri Gribenko 73f423e739 Parenthesized a logical expression.
This change fixes a warning on the ppc64be buildbot.
2019-12-20 14:36:21 +01:00
Dmitri Gribenko 9caf12e849 Use isa instead of dyn_cast 2019-12-20 14:36:21 +01:00
Kadir Cetinkaya c2377eae28
[clang][Tooling] Prefer -x over -std when interpolating
Summary:
Currently interpolation logic prefers -std over -x. But the latter is a
more strong signal, so this patch inverts the order and only makes use of -std
if -x didn't exist.

Fixes https://github.com/clangd/clangd/issues/185

Thanks @sammccall for tracking this down!

Reviewers: sammccall

Subscribers: ilya-biryukov, usaxena95, cfe-commits, sammccall

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71727
2019-12-20 11:10:36 +01:00
Karl-Johan Karlsson e8efac4b15 [clang] Fix the canonicalization of paths in -fdiagnostics-absolute-paths
In the current implementation of clang the canonicalization of paths in
diagnostic messages (when using -fdiagnostics-absolute-paths) only works
if the symbolic link is in the directory part of the filename, not if
the file itself is a symbolic link to another file.

This patch adds support to canonicalize the complete path including the
file.

Reviewers: rsmith, hans, rnk, ikudrin

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D70527
2019-12-20 09:16:33 +01:00
Richard Smith de21704ba9 CWG2352: Allow qualification conversions during reference binding.
The language wording change forgot to update overload resolution to rank
implicit conversion sequences based on qualification conversions in
reference bindings. The anticipated resolution for that oversight is
implemented here -- we order candidates based on qualification
conversion, not only on top-level cv-qualifiers.

For OpenCL/C++, this allows reference binding between pointers with
differing (nested) address spaces. This makes the behavior of reference
binding consistent with that of implicit pointer conversions, as is the
purpose of this change, but that pre-existing behavior for pointer
conversions is itself probably not correct. In any case, it's now
consistently the same behavior and implemented in only one place.
2019-12-19 18:37:55 -08:00
Richard Smith f4a45c2ce4 Fix crash on init-capture packs where the type of the initializer is non-dependent. 2019-12-19 15:20:10 -08:00
Artem Dergachev b284005072 [analyzer] Add a syntactic security check for ObjC NSCoder API.
Method '-[NSCoder decodeValueOfObjCType:at:]' is not only deprecated
but also a security hazard, hence a loud check.

Differential Revision: https://reviews.llvm.org/D71728
2019-12-19 14:54:29 -08:00
Tim Northover 85cb560b8a ConstrainedFP: use API compatible with opaque pointers.
This just updates an IRBuilder interface to take Functions instead of
Values so the type can be derived, and fixes some callsites in Clang to
call the updated API.
2019-12-19 21:50:47 +00:00
Richard Smith df2e2ab07b Implement latest C++ feature test macro recommendations.
We don't yet advertise init capture packs, because I found some bugs
while testing it. We reject-valid and then crash on both of these:

template<int ...a> auto x = [...y = a] {};
template<int ...a> auto x = [y = a...] {};
2019-12-19 12:59:13 -08:00
Warren Ristow 7fcd9e3f70 [X86] Mark various pointer arguments in builtins as const
Enabling `-Wcast-qual` identified many casts in various system headers
that were dropping the `const` qualifier.  Fixing those missing
qualifiers pointed out that a few of the definitions of the builtins
did not properly identify their arguments as `const` pointers.  This
commit fixes those builtin definitions, and the system header files
so that they no longer drop the qualifier.

Differential Revision: https://reviews.llvm.org/D71718
2019-12-19 11:42:11 -08:00
shafik 6a7df3a3f9 [ASTImporter][LLDB] Modifying ImportDeclContext(...) to ensure that we complete each FieldDecl of a RecordDecl when we are importing the definiton
This fix was motivated by a crashes in expression parsing during code generation in which we had a RecordDecl that had incomplete FieldDecl. During code generation when computing the layout for the RecordDecl we crash because we have several incomplete FieldDecl.

This fixes the issue by assuring that during ImportDefinition(...) for a RecordDecl we also import the definitions for each FieldDecl.

Differential Revision: https://reviews.llvm.org/D71378
2019-12-19 11:16:54 -08:00
Jonas Paulsson 2520bef865 [Clang FE, SystemZ] Recognize -mrecord-mcount CL option.
Recognize -mrecord-mcount from the command line and add a function attribute
"mrecord-mcount" when passed.

Only valid on SystemZ (when used with -mfentry).

Review: Ulrich Weigand
https://reviews.llvm.org/D71627
2019-12-19 08:51:55 -08:00
Hans Wennborg dde7b6bcda Re-land "Add an -fno-temp-file flag for compilation"
This time making sure to initialize FrontendOptions::UseTemporary.

Patch by Zachary Henkel!

Differential revision: https://reviews.llvm.org/D70615
2019-12-19 13:34:52 +01:00
Artem Dergachev f0ced2ddb4 [analysis] Re-discard type sugar when casting values retrieved from the Store.
Canonicalization was accidentally omitted in 6d3f43ec.
2019-12-18 18:00:57 -08:00
Jordan Rupprecht 553a727f5f [clang] Remove -Wexperimental-float-control.
Summary: Per D62731, the behavior of clang with `-frounding-math` is no worse than when the rounding flag was completely ignored, so remove this unnecessary warning.

Reviewers: mibintc, chandlerc, echristo, rjmccall, kpn, erichkeane, rsmith, andrew.w.kaylor

Reviewed By: mibintc

Subscribers: merge_guards_bot, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71671
2019-12-18 16:51:55 -08:00
Francis Visoiu Mistrih 07b8f8e5f5 [Remarks][Driver] Place temporary remark files next to temporary object files
On Darwin, when used for generating a linked binary from a source file
(through an intermediate object file), the driver will invoke `cc1` to
generate a temporary object file. The temporary remark file will now be
emitted next to the object file, which will then be picked up by
`dsymutil` and emitted in the .dSYM bundle.

This is available for all formats except YAML since by default, YAML
doesn't need a section and the remark file will be lost.
2019-12-18 16:42:02 -08:00
Thomas Lively 71eb8023d8 [WebAssembly] Add avgr_u intrinsics and require nuw in patterns
Summary:
The vector pattern `(a + b + 1) / 2` was previously selected to an
avgr_u instruction regardless of nuw flags, but this is incorrect in
the case where either addition may have an unsigned wrap. This CL
changes the existing pattern to require both adds to have nuw flags
and adds builtin functions and intrinsics for the avgr_u instructions
because the corrected pattern is not representable in C.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D71648
2019-12-18 15:31:38 -08:00
Vedant Kumar 5094e6dad6 Revert concepts changes from D41910
These changes caused LibcxxVariantDataFormatterTestCase in lldb to fail
with an assert:

Assertion failed: (Idx < size() && "Out-of-bounds Bit access."),
function operator[], file
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/ADT/SmallBitVector.h,
line 452.

In:

7  clang-10                 0x00000001094b79d9 isAtLeastAsSpecializedAs(clang::Sema&, clang::SourceLocation, clang::FunctionTemplateDecl*, clang::FunctionTemplateDecl*, clang::TemplatePartialOrderingContext, unsigned int) + 1865
8  clang-10                 0x00000001094b7111 clang::Sema::getMoreSpecializedTemplate(clang::FunctionTemplateDecl*, clang::FunctionTemplateDecl*, clang::SourceLocation, clang::TemplatePartialOrderingContext, unsigned int, unsigned int) + 97
9  clang-10                 0x000000010939bf88 clang::isBetterOverloadCandidate(clang::Sema&, clang::OverloadCandidate const&, clang::OverloadCandidate const&, clang::SourceLocation, clang::OverloadCandidateSet::CandidateSetKind) + 1128

Revert "[Concepts] Fix incorrect move out of temporary in D41910"

This reverts commit 11d5fa6e87.

Revert "[Concepts] Fix crash in D41910"

This reverts commit 12038be20e.

Revert "[Concepts] Constrained partial specializations and function overloads."

This reverts commit fc0731b98a.
2019-12-18 15:02:39 -08:00
Stephen Kelly 98e8f774eb Add method to ignore invisible AST nodes
Reviewers: aaron.ballman

Subscribers: mgorny, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70613
2019-12-18 22:33:23 +00:00
Francis Visoiu Mistrih d79b11fefb [Remarks][Driver] Run dsymutil when remarks are enabled
When clang is invoked with a source file without -c or -S, it creates a
cc1 job, a linker job and if debug info is requested, a dsymutil job. In
case of remarks, we should also create a dsymutil job to avoid losing
the remarks that will be generated in a tempdir that gets removed.

Differential Revision: https://reviews.llvm.org/D71675
2019-12-18 14:31:41 -08:00
Francis Visoiu Mistrih a8c678cb9a [Remarks][Driver][NFC] Make shouldEmitRemarks more available in the Driver
Move the function to Driver.h so that it can be re-used in other places.
2019-12-18 14:31:41 -08:00
Artem Dergachev bce1cce6bf [analyzer] Teach MismatchedDealloc about initWithBytesNoCopy with deallocator.
MallocChecker warns when memory is passed into -[NSData initWithBytesNoCopy]
but isn't allocated by malloc(), because it will be deallocated by free().
However, initWithBytesNoCopy has an overload that takes an arbitrary block
for deallocating the object. If such overload is used, it is no longer
necessary to make sure that the memory is allocated by malloc().
2019-12-18 14:19:17 -08:00
Richard Smith 3ced23976a Refactor CompareReferenceRelationship and its callers in preparation for
implementing the resolution of CWG2352.

No functionality change, except that we now convert the referent of a
reference binding to the underlying type of the reference in more cases;
we used to happen to preserve the type sugar from the referent if the
only type change was in the cv-qualifiers.

This exposed a bug in how we generate code for trivial assignment
operators: if the type sugar (particularly the may_alias attribute)
got lost during reference binding, we'd use the "wrong" TBAA information
for the load during the assignment.
2019-12-18 14:05:57 -08:00
Akira Hatanaka a6d57a8cd4 Use hasOffsetApplied to initialize member HasOffsetApplied
This is NFC since none of the constructor calls in trunk pass
hasOffsetApplied=true.
2019-12-18 13:56:59 -08:00
Reid Kleckner 71f9c30b53 Move TypeSourceInfo to Type.h
TypeSourceInfo is a thin wrapper around TypeLocs. Notionally, the best
place for it to live would be TypeLoc.h, but Decl.h requires it to be
complete, so it needs to be lower in the dependency graph. Type.h seems
like the next best place.

By itself, this change has no impact on build time, because it doesn't
remove a single dependency edge from a .cpp file to a .h file, but it is
an incremental step towards making the AST headers less interdependent.

Reviewers: rsmith

Differential Revision: https://reviews.llvm.org/D71427
2019-12-18 13:47:00 -08:00
Artem Dergachev badba5118f [analyzer] NonnullGlobalConstants: Add support for kCFNull.
It's a singleton in CoreFoundation that always contains a non-null CFNullRef.
2019-12-18 12:08:15 -08:00
Saar Raz 11d5fa6e87 [Concepts] Fix incorrect move out of temporary in D41910
Moves out of temporaries caused warnings that failed builds.
2019-12-18 21:43:53 +02:00
Saar Raz 12038be20e [Concepts] Fix crash in D41910
Differential Revision: https://reviews.llvm.org/D41910
2019-12-18 21:31:33 +02:00
Jonas Paulsson ca520592c0 [Clang FE, SystemZ] Don't add "true" value for the "mnop-mcount" attribute.
Let the "mnop-mcount" function attribute simply be present or non-present.
Update SystemZ backend as well to use hasFnAttribute() instead.

Review: Ulrich Weigand
https://reviews.llvm.org/D71669
2019-12-18 11:04:13 -08:00
Saar Raz fc0731b98a [Concepts] Constrained partial specializations and function overloads.
Added support for constraint satisfaction checking and partial ordering of constraints in constrained partial specialization and function template overloads.

Phabricator: D41910
2019-12-18 21:01:31 +02:00
Amy Huang a85f5efd95 Add support for the MS qualifiers __ptr32, __ptr64, __sptr, __uptr.
Summary:
This adds parsing of the qualifiers __ptr32, __ptr64, __sptr, and __uptr and
lowers them to the corresponding address space pointer for 32-bit and 64-bit pointers.
(32/64-bit pointers added in https://reviews.llvm.org/D69639)

A large part of this patch is making these pointers ignore the address space
when doing things like overloading and casting.

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

Reviewers: rnk, rsmith

Subscribers: jholewinski, jvesely, nhaehnle, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71039
2019-12-18 10:41:12 -08:00
Mitch Phillips b19d87b16f Revert "Add an -fno-temp-file flag for compilation"
This reverts commit d129aa1d53.

This broke the MSan buildbots. More information available in the
original PR: https://reviews.llvm.org/D70615
2019-12-18 09:05:09 -08:00
Hans Wennborg d129aa1d53 Add an -fno-temp-file flag for compilation
Our build system does not handle randomly named files created during
the build well. We'd prefer to write compilation output directly
without creating a temporary file. Function parameters already
existed to control this behavior but were not exposed all the way out
to the command line.

Patch by Zachary Henkel!

Differential revision: https://reviews.llvm.org/D70615
2019-12-18 15:07:43 +01:00
Ilya Biryukov c1bbefef9d [Syntax] Use a hash table to search for tokens by their location
This is both more efficient and avoids corner cases in
`SourceManager::isBeforeInTranslationUnit`.

The change is trivial and clearly a performance improvement on the hot
path of building the syntax tree, so sending without review.
2019-12-18 12:24:00 +01:00