Commit Graph

81923 Commits

Author SHA1 Message Date
Richard Smith 45d70806f4 PR42694 Support explicit(bool) in older language modes as an extension.
This needs somewhat careful disambiguation, as C++2a explicit(bool) is a
breaking change. We only enable it in cases where the source construct
could not possibly be anything else.
2020-01-15 18:38:23 -08:00
Yuanfang Chen 6e24c6037f Revert "[Support] make report_fatal_error `abort` instead of `exit`"
This reverts commit 647c3f4e47.

Got bots failure from sanitizer-windows and maybe others.
2020-01-15 17:52:25 -08:00
Yuanfang Chen 647c3f4e47 [Support] make report_fatal_error `abort` instead of `exit`
Summary:
This patch could be treated as a rebase of D33960. It also fixes PR35547.
A fix for `llvm/test/Other/close-stderr.ll` is proposed in D68164. Seems
the consensus is that the test is passing by chance and I'm not
sure how important it is for us. So it is removed like in D33960 for now.
The rest of the test fixes are just adding `--crash` flag to `not` tool.

** The reason it fixes PR35547 is

`exit` does cleanup including calling class destructor whereas `abort`
does not do any cleanup. In multithreading environment such as ThinLTO or JIT,
threads may share states which mostly are ManagedStatic<>. If faulting thread
tearing down a class when another thread is using it, there are chances of
memory corruption. This is bad 1. It will stop error reporting like pretty
stack printer; 2. The memory corruption is distracting and nondeterministic in
terms of error message, and corruption type (depending one the timing, it
could be double free, heap free after use, etc.).

Reviewers: rnk, chandlerc, zturner, sepavloff, MaskRay, espindola

Reviewed By: rnk, MaskRay

Subscribers: wuzish, jholewinski, qcolombet, dschuff, jyknight, emaste, sdardis, nemanjai, jvesely, nhaehnle, sbc100, arichardson, jgravelle-google, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, lenary, s.egerton, pzheng, cfe-commits, MaskRay, filcab, davide, MatzeB, mehdi_amini, hiraditya, steven_wu, dexonsmith, rupprecht, seiya, llvm-commits

Tags: #llvm, #clang

Differential Revision: https://reviews.llvm.org/D67847
2020-01-15 17:05:13 -08:00
Richard Smith e8f198dd9e Fix pack deduction to only deduce the arity of packs that are actually
expanded by the deduced pack.

We recently started also deducing the arity of separately-expanded packs
that are merely mentioned within the pack in question, which is
incorrect.
2020-01-15 16:21:08 -08:00
Amy Huang 44560762c6 Revert "Further implement CWG 2292"
This reverts commit ee0f1f1edc because it
causes an error on valid code.
See https://reviews.llvm.org/rGee0f1f1edc3ec0d4e698d50cc3180217448802b7.
2020-01-15 15:46:07 -08:00
Alexey Bataev b841b9e96e [OPENMP]Use regular processing of vtable used when TU is a prefix.
If current kind of the translation unit is TU_Prefix and it is not
complete, cannot decide what to do with virtual members/table at that
time, need to delay it to later stages.
2020-01-15 18:42:23 -05:00
Amy Huang 3d210ed3d1 Revert "Allow system header to provide their own implementation of some builtin"
This reverts commit 921f871ac4 because it
causes libc++ code to trigger __warn_memset_zero_len.

See https://reviews.llvm.org/D71082.
2020-01-15 15:03:45 -08:00
Alexey Bataev 6b29aa2118 Revert "[OPENMP]Do not use RTTI by default for NVPTX devices."
This reverts commit 23058f9dd4. It breaks
builds of cuda code somehow in some cases.
2020-01-15 17:42:26 -05:00
Richard Smith b72a8c65e4 PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer.
Summary:
See proposal on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2019-April/062030.html

Reviewers: SjoerdMeijer, eli.friedman

Subscribers: kristof.beyls, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D67678
2020-01-15 13:14:57 -08:00
Richard Smith 388eaa1270 Work around PR43337: don't try to use the vec_sel overloads for vector long long, since clang's <altivec.h> doesn't provide it yet! 2020-01-15 13:14:57 -08:00
Nico Weber 8e5018e990 Replace CLANG_SPAWN_CC1 env var with a driver mode flag
Flags are clang's default UI is flags.

We can have an env var in addition to that, but in D69825 nobody has yet
mentioned why this needs an env var, so omit it for now.  If someone
needs to set the flag via env var, the existing CCC_OVERRIDE_OPTIONS
mechanism works for it (set CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1
for example).

Also mention the cc1-in-process change in the release notes.

Also spruce up the test a bit so it actually tests something :)

Differential Revision: https://reviews.llvm.org/D72769
2020-01-15 12:22:40 -05:00
Mark Murray da9d57d2c2 [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics.
Summary: Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics and unit tests.

Reviewers: simon_tatham, miyuki, dmgreen

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D72761
2020-01-15 17:20:15 +00:00
Teresa Johnson 76b92cc7c1 Fix bot by adjusting wildcard matching
I noticed one bot failure due to
24a00ef240 because the wildcard matching
was not working as intended, fixed it to act similar to other checks of
CGSCCToFunctionPassAdaptor.
2020-01-15 08:37:15 -08:00
Teresa Johnson 24a00ef240 Restore "[ThinLTO] Add additional ThinLTO pipeline testing with new PM"
This restores 2af97be802 (reverted at
6288f86e87), with all the fixes I had
applied at the time, along with a new fix for non-determinism in the
ordering of a couple of passes due to being accessed as parameters on
the same call.

I've also added --dump-input=fail to the new tests so I can more
thoroughly fix any additional failures.
2020-01-15 07:33:08 -08:00
Simon Tatham ada01d1b86 [clang] New __attribute__((__clang_arm_mve_strict_polymorphism)).
This is applied to the vector types defined in <arm_mve.h> for use
with the intrinsics for the ARM MVE vector architecture.

Its purpose is to inhibit lax vector conversions, but only in the
context of overload resolution of the MVE polymorphic intrinsic
functions. This solves an ambiguity problem with polymorphic MVE
intrinsics that take a vector and a scalar argument: the scalar
argument can often have the wrong integer type due to default integer
promotions or unsuffixed literals, and therefore, the type of the
vector argument should be considered trustworthy when resolving MVE
polymorphism.

As part of the same change, I've added the new attribute to the
declarations generated by the MveEmitter Tablegen backend (and
corrected a namespace issue with the other attribute while I was
there).

Reviewers: aaron.ballman, dmgreen

Reviewed By: aaron.ballman

Subscribers: kristof.beyls, JDevlieghere, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72518
2020-01-15 15:04:10 +00:00
Soumi Manna ee0f1f1edc Further implement CWG 2292
The core issue is that simple-template-id is ambiguous between class-name
and type-name. This fixes PR43966.
2020-01-15 08:49:44 -05:00
Hans Wennborg 5852475e2c Bump the trunk major version to 11
and clear the release notes.
2020-01-15 13:38:01 +01:00
Simon Pilgrim eb82226f33 Fix Wdocumentation warning. NFC. 2020-01-15 12:18:12 +00:00
Scott Egerton a90ea38698 [Lexer] Allow UCN for dollar symbol '\u0024' in identifiers when using -fdollars-in-identifiers flag.
Summary:
Previously, the -fdollars-in-identifiers flag allows the '$' symbol to be used
in an identifier but the universal character name equivalent '\u0024' is not
allowed.
This patch changes this, so that \u0024 is valid in identifiers.

Reviewers: rsmith, jordan_rose

Reviewed By: rsmith

Subscribers: dexonsmith, simoncook, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71758
2020-01-15 11:28:57 +00:00
Scott Egerton cbe681bd83 Revert "[RISCV] Add Clang frontend support for Bitmanip extension"
This reverts commit 57cf6ee9c8.
2020-01-15 10:43:42 +00:00
Reid Kleckner c42116cc65 Fix up ms-pch-macro.c test to pass on non-Windows 2020-01-14 22:19:30 -08:00
Fangrui Song 5ca24d09ae [Driver][X86] Add -malign-branch* and -mbranches-within-32B-boundaries
These driver options perform some checking and delegate to MC options -x86-align-branch* and -x86-branches-within-32B-boundaries.

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D72463
2020-01-14 21:57:06 -08:00
Weverything a60e892729 [ODRHash] Fix wrong error message with bitfields and mutable.
Add a check to bitfield mismatches that may have caused Clang to
give an error about the bitfield instead of being mutable.
2020-01-14 21:12:15 -08:00
Pierre Habouzit d18fbfc097 Relax the rules around objc_alloc and objc_alloc_init optimizations.
Today the optimization is limited to:
- `[ClassName alloc]`
- `[self alloc]` when within a class method

However it means that when code is written this way:

```
    @interface MyObject
    - (id)copyWithZone:(NSZone *)zone
    {
        return [[self.class alloc] _initWith...];
    }

    @end
```

... then the optimization doesn't kick in and `+[NSObject alloc]` ends
up in IMP caches where it could have been avoided. It turns out that
`+alloc` -> `+[NSObject alloc]` is the most cached SEL/IMP pair in the
entire platform which is rather silly).

There's two theoretical risks allowing this optimization:

1. if the receiver is nil (which it can't be today), but it turns out
   that `objc_alloc()`/`objc_alloc_init()` cope with a nil receiver,

2. if the `Clas` type for the receiver is a lie. However, for such a
   code to work today (and not fail witn an unrecognized selector
   anyway) you'd have to have implemented the `-alloc` **instance
   method**.

   Fortunately, `objc_alloc()` doesn't assume that the receiver is a
   Class, it basically starts with a test that is similar to

       `if (receiver->isa->bits & hasDefaultAWZ) { /* fastpath */ }`.

   This bit is only set on metaclasses by the runtime, so if an instance
   is passed to this function by accident, its isa will fail this test,
   and `objc_alloc()` will gracefully fallback to `objc_msgSend()`.

   The one thing `objc_alloc()` doesn't support is tagged pointer
   instances. None of the tagged pointer classes implement an instance
   method called `'alloc'` (actually there's a single class in the
   entire Apple codebase that has such a method).

Differential Revision: https://reviews.llvm.org/D71682
Radar-Id: rdar://problem/58058316
Reviewed-By: Akira Hatanaka
Signed-off-by: Pierre Habouzit <phabouzit@apple.com>
2020-01-14 19:48:33 -08:00
Richard Smith 1b5404aff3 PR44540: Prefer an inherited default constructor over an initializer
list constructor when initializing from {}.

We would previously pick between calling an initializer list constructor
and calling a default constructor unstably in this situation, depending
on whether the inherited default constructor had already been used
elsewhere in the program.
2020-01-14 19:29:50 -08:00
Douglas Yung c6e69880ae Modify test to use -S instead of -c so that it works when an external assembler is used that is not present. 2020-01-14 18:58:18 -08:00
Saar Raz ff1e0fce81 [Concepts] Type Constraints
Add support for type-constraints in template type parameters.
Also add support for template type parameters as pack expansions (where the type constraint can now contain an unexpanded parameter pack).

Differential Revision: https://reviews.llvm.org/D44352
2020-01-15 04:02:39 +02:00
Reid Kleckner 8e780252a7 [X86] ABI compat bugfix for MSVC vectorcall
Summary:
Before this change, X86_32ABIInfo::classifyArgument would be called
twice on vector arguments to vectorcall functions. This function has
side effects to track GPR register usage, and this would lead to
incorrect GPR usage in some cases.  The specific case I noticed is from
running out of XMM registers with mixed FP and vector arguments and no
aggregates of any kind. Consider this prototype:

  void __vectorcall vectorcall_indirect_vec(
      double xmm0, double xmm1, double xmm2, double xmm3, double xmm4,
      __m128 xmm5,
      __m128 ecx,
      int edx,
      __m128 mem);

classifyArgument has no effects when called on a plain FP type, but when
called on a vector type, it modifies FreeRegs to model GPR consumption.
However, this should not happen during the vector call first pass.

I refactored the code to unify vectorcall HVA logic with regcall HVA
logic. The conventions pass HVAs in registers differently (expanded vs.
not expanded), but if they do not fit in registers, they both pass them
indirectly by address.

Reviewers: erichkeane, craig.topper

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72110
2020-01-14 17:49:13 -08:00
Zachary Henkel 0f9cf42fac Allow /D flags absent during PCH creation under msvc-compat
Summary:
Before this patch adding a new /D flag when compiling a source file that consumed a PCH with clang-cl would issue a diagnostic and then fail.  With the patch, the diagnostic is still issued but the definition is accepted.  This matches the msvc behavior.  The fuzzy-pch-msvc.c is a clone of the existing fuzzy-pch.c tests with some msvc specific rework.

msvc diagnostic:
  warning C4605: '/DBAR=int' specified on current command line, but was not specified when precompiled header was built

Output of the CHECK-BAR test prior to the code change:
  <built-in>(1,9): warning: definition of macro 'BAR' does not match definition in precompiled header [-Wclang-cl-pch]
  #define BAR int
          ^
  D:\repos\llvm\llvm-project\clang\test\PCH\fuzzy-pch-msvc.c(12,1): error: unknown type name 'BAR'
  BAR bar = 17;
  ^
  D:\repos\llvm\llvm-project\clang\test\PCH\fuzzy-pch-msvc.c(23,4): error: BAR was not defined
  #  error BAR was not defined
     ^
  1 warning and 2 errors generated.

Reviewers: rnk, thakis, hans, zturner

Subscribers: mikerice, aganea, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72405
2020-01-14 17:26:01 -08:00
Rong Xu c9ee5e996e Fix windows bot failures in c410adb092c9cb51ddb0b55862b70f2aa8c5b16f
(clang diagnostic handler for IR input files)
2020-01-14 16:32:17 -08:00
Rong Xu 60d3947922 [remark][diagnostics] Using clang diagnostic handler for IR input files
For IR input files, we currently use LLVM diagnostic handler even the
compilation is from clang. As a result, we are not able to use -Rpass
to get the transformation reports. Some warnings are not handled
properly either: We found many mysterious warnings in our ThinLTO backend
compilations in SamplePGO and CSPGO. An example of the warning:
"warning: net/proto2/public/metadata_lite.h:51:21: 0.02% (1 / 4999)"

This turns out to be a warning by Wmisexpect, which is supposed to be
filtered out by default. But since the filter is in clang's
diagnostic hander, we emit these incomplete warnings from LLVM's
diagnostic handler.

This patch uses clang diagnostic handler for IR input files. We create
a fake backendconsumer just to install the diagnostic handler.

With this change, we will have proper handling of all the warnings and we can
use -Rpass* options in IR input files compilation.
Also note that with is patch, LLVM's diagnostic options, like
"-mllvm -pass-remarks=*", are no longer be able to get optimization remarks.

Differential Revision: https://reviews.llvm.org/D72523
2020-01-14 15:44:57 -08:00
Alexey Bataev 23058f9dd4 [OPENMP]Do not use RTTI by default for NVPTX devices.
NVPTX does not support RTTI, so disable it by default.
2020-01-14 18:12:06 -05:00
Luboš Luňák cbc9d22e49 make -fmodules-codegen and -fmodules-debuginfo work also with PCHs
Allow to build PCH's (with -building-pch-with-obj and the extra .o file)
with -fmodules-codegen -fmodules-debuginfo to allow emitting shared code
into the extra .o file, similarly to how it works with modules. A bit of
a misnomer, but the underlying functionality is the same. This saves up
to 20% of build time here.

Differential Revision: https://reviews.llvm.org/D69778
2020-01-15 00:01:08 +01:00
Luboš Luňák b5b2cf7af4 fix recent -fmodules-codegen fix test 2020-01-14 23:51:07 +01:00
Luboš Luňák 729530f68f -fmodules-codegen should not emit extern templates
If a header contains 'extern template', then the template should be provided
somewhere by an explicit instantiation, so it is not necessary to generate
a copy. Worse, this can lead to an unresolved symbol, because the codegen's
object file will not actually contain functions from such a template
because of the GVA_AvailableExternally, but the object file for the explicit
instantiation will not contain them either because it will be blocked
by the information provided by the module.

Differential Revision: https://reviews.llvm.org/D69779
2020-01-14 23:39:50 +01:00
Alexey Bataev a48600c0a6 [OPENMP]Do not emit special virtual function for NVPTX target.
There are no special virtual function handlers (like __cxa_pure_virtual)
defined for NVPTX target, so just emit such functions as null pointers
to prevent issues with linking and unresolved references.
2020-01-14 16:59:22 -05:00
Michael Liao a3490e3e3d Remove trailing `;`. NFC. 2020-01-14 16:52:20 -05:00
Fangrui Song 1ca51c0672 [Driver][test] Fix Driver/hexagon-toolchain-elf.c for -DCLANG_DEFAULT_LINKER=lld builds
Reviewed By: nathanchance, sidneym

Differential Revision: https://reviews.llvm.org/D72668
2020-01-14 13:18:23 -08:00
Jan Korous 986202fad4 [clang][test][NFC] Use more widely supported sanitizer for file dependency tests
The tests aren't concerned at all by the actual sanitizer - only by blacklist being reported as a dependency.
We're unfortunately limited by platform support for any particular sanitizer but we can at least use one that is widely supported.

Post-commit review:
https://reviews.llvm.org/D72729
2020-01-14 12:55:11 -08:00
Amy Huang 651128f557 [DebugInfo] Add option to clang to limit debug info that is emitted for classes.
Summary:
This patch adds an option to limit debug info by only emitting complete class
type information when its constructor is emitted. This applies to classes
that have nontrivial user defined constructors.

I implemented the option by adding another level to `DebugInfoKind`, and
a flag `-flimit-debug-info-constructor`.

Total object file size on Windows, compiling with RelWithDebInfo:
  before: 4,257,448 kb
  after:  2,104,963 kb

And on Linux
  before: 9,225,140 kb
  after:  4,387,464 kb

According to the Windows clang.pdb files, here is a list of types that are no
longer complete with this option enabled: https://reviews.llvm.org/P8182

Reviewers: rnk, dblaikie

Subscribers: aprantl, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72427
2020-01-14 12:40:21 -08:00
Joe Ranieri 5ee616a710 [analyzer] Fix SARIF column locations
Differential revision: https://reviews.llvm.org/D70689
2020-01-14 15:38:30 -05:00
Fangrui Song 5d1b3ba687 [Driver] Ignore -fno-semantic-interposition
Fedora wants to build projects with -fno-semantic-interposition (e.g.
https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup),
which is supported by GCC>=5.

Clang's current behavior is similar to -fno-semantic-interposition and
the end goal is to make it more so
(https://lists.llvm.org/pipermail/llvm-dev/2016-November/107625.html).
Ignore this option.

We should let users know -fsemantic-interposition is not currently
supported, so it should remain a hard error.

Reviewed By: serge-sans-paille

Differential Revision: https://reviews.llvm.org/D72724
2020-01-14 12:09:13 -08:00
Alexey Bataev 48bad08aa3 [OPENMP]Improve handling of possibly incorrectly mapped types.
Need to analayze the type of the expression for mapping, not the type of
the declaration.
2020-01-14 14:47:34 -05:00
Alexandre Ganea 88b8cb7215 Fix NetBSD bot after b4a99a061f ([Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation) 2020-01-14 14:26:50 -05:00
Dmitri Gribenko 2948ec5ca9 Removed PointerUnion3 and PointerUnion4 aliases in favor of the variadic template 2020-01-14 18:56:29 +01:00
Scott Egerton 57cf6ee9c8 [RISCV] Add Clang frontend support for Bitmanip extension
Summary: This adds the __riscv_bitmanip macro and the 'b' target feature to enable it.

Reviewers: asb, simoncook, lewis-revill, PaoloS, lenary

Reviewed By: lenary

Subscribers: Jim, rbar, johnrusso, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71553
2020-01-14 17:45:45 +00:00
Simon Pilgrim cfd366ba74 Fix "pointer is null" static analyzer warnings. NFCI.
Use castAs<> instead of getAs<> since the pointer is dereferenced immediately in all cases and castAs will perform the null assertion for us.
2020-01-14 16:31:17 +00:00
Simon Pilgrim ab9dbc1d12 Fix "pointer is null" clang static analyzer warnings. NFCI.
Use cast<>/castAs<> instead of dyn_cast<>/getAs<> since the pointers are always dereferenced and cast<>/castAs<> will perform the null assertion for us.
2020-01-14 16:31:17 +00:00
Jinsong Ji e2b8e2113a [clang][OpenCL] Fix covered switch warning
-Werror clang build is broken now.

tools/clang/lib/Sema/OpenCLBuiltins.inc:11824:5: error: default label in
switch which covers all enumeration values
[-Werror,-Wcovered-switch-default]
    default:

We don't need default now, since all enumeration values are covered.

Reviewed By: svenvh

Differential Revision: https://reviews.llvm.org/D72707
2020-01-14 16:21:42 +00:00
Ilya Biryukov 013c07f697 [Syntax] Unset IsOriginal flag on nodes removed from the tree
And add a corresponding test.
Only nodes inside the TranslationUnit subtree can be marked as original,
computeReplacements() relies on this.
2020-01-14 17:00:33 +01:00