]> granicus.if.org Git - clang/log
clang
5 years agoRemoved some questionable default arguments from setters
Dmitri Gribenko [Thu, 12 Sep 2019 12:16:43 +0000 (12:16 +0000)]
Removed some questionable default arguments from setters

Summary:
They can be confusing -- what does it mean to call a setter without a
value? Also, some setters, like `setPrintTemplateTree` had `false` as
the default value!

The callers are largely not using these default arguments anyway.

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371731 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoSwitch "windows" to "system-windows" in some XFAILs
Jeremy Morse [Thu, 12 Sep 2019 11:19:12 +0000 (11:19 +0000)]
Switch "windows" to "system-windows" in some XFAILs

The test failure mode appears to be due to the host machine rather than the
target. The PS4 buildbots are windows-hosted targeting x86_64-scei-ps4,
and are currently reporting these as unexpected failures:

  http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/28114

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371726 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemoved dead code from DiagnosticBuilder
Dmitri Gribenko [Thu, 12 Sep 2019 10:39:53 +0000 (10:39 +0000)]
Removed dead code from DiagnosticBuilder

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371723 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format] [PR43100] clang-format C# support does not add a space between "using...
Paul Hoad [Thu, 12 Sep 2019 10:18:53 +0000 (10:18 +0000)]
[clang-format] [PR43100] clang-format C#  support does not add a space between "using" and paren

Summary:
Addresses https://bugs.llvm.org/show_bug.cgi?id=43100

Formatting using statement in C# with clang-format removes the space between using and paren even when SpaceBeforeParens is !

```
using(FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize : 1))
```

this change simply overcomes this for when using C# settings in the .clang-format file

```
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize : 1))
```

All FormatTests pass..

```
[==========] 688 tests from 21 test cases ran. (88508 ms total)
[  PASSED  ] 688 tests.
```

Reviewers: djasper, klimek, owenpan

Reviewed By: owenpan

Subscribers: llvm-commits, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371720 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format] Add new style option IndentGotoLabels
Paul Hoad [Thu, 12 Sep 2019 10:07:14 +0000 (10:07 +0000)]
[clang-format] Add new style option IndentGotoLabels

Summary:
This option determines whether goto labels are indented according to scope. Setting this option to false causes goto labels to be flushed to the left.
This is mostly copied from [[ http://lists.llvm.org/pipermail/cfe-dev/2015-September/045014.html | this patch ]] submitted by Christian Neukirchen that didn't make its way into trunk.

```
     true:                                  false:
     int f() {                      vs.     int f() {
       if (foo()) {                           if (foo()) {
       label1:                              label1:
         bar();                                 bar();
       }                                      }
     label2:                                label2:
       return 1;                              return 1;
     }                                      }
```

Reviewers: klimek, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang, #clang-tools-extra

Patch by: tetsuo-cpp

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371719 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Delete duplicate REQUIRES line
Heejin Ahn [Thu, 12 Sep 2019 06:56:17 +0000 (06:56 +0000)]
[WebAssembly] Delete duplicate REQUIRES line

r371710 and r371711 committed the same line, so this deletes one of
them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371712 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Make wasm-eh.cpp requires WebAssembly
Heejin Ahn [Thu, 12 Sep 2019 06:52:24 +0000 (06:52 +0000)]
[WebAssembly] Make wasm-eh.cpp requires WebAssembly

D67208 added a new test line to wasm-eh.cpp that invokes the LLVM
backend and this test fails on bots that don't have WebAssembly target.
This makes wasm-eh.cpp explicitly require WebAssembly so this will be
skipped on those targets.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371711 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Add REQUIRES to test
David Zarzycki [Thu, 12 Sep 2019 06:50:33 +0000 (06:50 +0000)]
[WebAssembly] Add REQUIRES to test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371710 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Add -fwasm-exceptions for wasm EH
Heejin Ahn [Thu, 12 Sep 2019 04:01:37 +0000 (04:01 +0000)]
[WebAssembly] Add -fwasm-exceptions for wasm EH

Summary:
This adds `-fwasm-exceptions` (in similar fashion with
`-fdwarf-exceptions` or `-fsjlj-exceptions`) that turns on everything
with wasm exception handling from the frontend to the backend.

We currently have `-mexception-handling` in clang frontend, but this is
only about the architecture capability and does not turn on other
necessary options such as the exception model in the backend. (This can
be turned on with `llc -exception-model=wasm`, but llc is not invoked
separately as a command line tool, so this option has to be transferred
from clang.)

Turning on `-fwasm-exceptions` in clang also turns on
`-mexception-handling` if not specified, and will error out if
`-mno-exception-handling` is specified.

Reviewers: dschuff, tlively, sbc100

Subscribers: aprantl, jgravelle-google, sunfish, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371708 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-scan-deps] Add dependency targets
Jan Korous [Thu, 12 Sep 2019 00:48:45 +0000 (00:48 +0000)]
[clang-scan-deps] Add dependency targets

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371697 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Enable -mprefer-vector-width=256 by default for Skylake-avx512 and later Intel...
Craig Topper [Wed, 11 Sep 2019 23:54:36 +0000 (23:54 +0000)]
[X86] Enable -mprefer-vector-width=256 by default for Skylake-avx512 and later Intel CPUs.

AVX512 instructions can cause a frequency drop on these CPUs. This
can negate the performance gains from using wider vectors. Enabling
prefer-vector-width=256 will prevent generation of zmm registers
unless explicit 512 bit operations are used in the original source
code.

I believe gcc and icc both do something similar to this by default.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371694 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix up a test updated in r371655 - require case-insensitive file system.
Volodymyr Sapsai [Wed, 11 Sep 2019 21:19:27 +0000 (21:19 +0000)]
Fix up a test updated in r371655 - require case-insensitive file system.

On case-sensitive file systems include with wrong case is not found instead of
showing a warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371665 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-scan-deps] cast Result to ErrorOr<unique_ptr<vfs::File>> explicitly to avoid...
Alex Lorenz [Wed, 11 Sep 2019 21:00:13 +0000 (21:00 +0000)]
[clang-scan-deps] cast Result to ErrorOr<unique_ptr<vfs::File>> explicitly to avoid s390x-linux buildbot failure

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371664 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoStart porting ivfsoverlay tests to Windows
Reid Kleckner [Wed, 11 Sep 2019 20:56:25 +0000 (20:56 +0000)]
Start porting ivfsoverlay tests to Windows

Part of PR43272, the changes are:

1. Use @ as the sed pattern delimiter instead of : so that the drive
letter in lit substitutions isn't an issue.

2. Use the %/t and %/S substitutions to get paths with forward slashes
to work around string quoting issues in the yaml file.

3. Replace REQUIRES:shell with XFAIL:windows. These tests should pass on
Windows, but do not for reasons that are not yet understood. We would
like to know if they pass unexpectedly.

I was able to remove the XFAILs from two tests, since they already pass
with my sed fix:
  clang/test/VFS/module_missing_vfs.m
  clang/test/VFS/test_nonmodular.c

Reviewers: amccarth

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371663 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] NFC: Move PathDiagnostic classes to libAnalysis.
Artem Dergachev [Wed, 11 Sep 2019 20:54:27 +0000 (20:54 +0000)]
[analyzer] NFC: Move PathDiagnostic classes to libAnalysis.

At this point the PathDiagnostic, PathDiagnosticLocation, PathDiagnosticPiece
structures no longer rely on anything specific to Static Analyzer, so we can
move them out of it for everybody to use.

PathDiagnosticConsumers are still to be handed off.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371661 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] NFC: Move resetDiagnosticLocationToMainFile() to BugReporter.
Artem Dergachev [Wed, 11 Sep 2019 20:54:24 +0000 (20:54 +0000)]
[analyzer] NFC: Move resetDiagnosticLocationToMainFile() to BugReporter.

This method of PathDiagnostic is a part of Static Analyzer's particular
path diagnostic construction scheme. As such, it doesn't belong to
the PathDiagnostic class, but to the Analyzer.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371660 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] NFC: Move getStmt() and createEndOfPath() out of PathDiagnostic.
Artem Dergachev [Wed, 11 Sep 2019 20:54:21 +0000 (20:54 +0000)]
[analyzer] NFC: Move getStmt() and createEndOfPath() out of PathDiagnostic.

These static functions deal with ExplodedNodes which is something we don't want
the PathDiagnostic interface to know anything about, as it's planned to be
moved out of libStaticAnalyzerCore.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371659 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] NFC: Re-implement stack hints as a side map in BugReport.
Artem Dergachev [Wed, 11 Sep 2019 20:54:17 +0000 (20:54 +0000)]
[analyzer] NFC: Re-implement stack hints as a side map in BugReport.

That's one of the few random entities in the PathDiagnostic interface that
are specific to the Static Analyzer. By moving them out we could let
everybody use path diagnostics without linking against Static Analyzer.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371658 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-scan-deps] add skip excluded conditional preprocessor block preprocessing...
Alex Lorenz [Wed, 11 Sep 2019 20:40:31 +0000 (20:40 +0000)]
[clang-scan-deps] add skip excluded conditional preprocessor block preprocessing optimization

This commit adds an optimization to clang-scan-deps and clang's preprocessor that skips excluded preprocessor
blocks by bumping the lexer pointer, and not lexing the tokens until reaching appropriate #else/#endif directive.
The skip positions and lexer offsets are computed when the file is minimized, directly from the minimized tokens.

On an 18-core iMacPro with macOS Catalina Beta I got 10-15% speed-up from this optimization when running clang-scan-deps on
the compilation database for a recent LLVM and Clang (3511 files).

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371656 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix -Wnonportable-include-path suppression for header maps with absolute paths.
Volodymyr Sapsai [Wed, 11 Sep 2019 20:39:04 +0000 (20:39 +0000)]
Fix -Wnonportable-include-path suppression for header maps with absolute paths.

In `DirectoryLookup::LookupFile` parameter `HasBeenMapped` doesn't cover
the case when clang finds a file through a header map but doesn't remap
the lookup filename because the target path is an absolute path. As a
result, -Wnonportable-include-path suppression for header maps
introduced in r301592 wasn't triggered.

Change parameter `HasBeenMapped` to `IsInHeaderMap` and use parameter
`MappedName` to track the filename remapping. This way we can handle
both relative and absolute paths in header maps, and account for their
specific properties, like filename remapping being a property preserved
across lookups in multiple directories.

rdar://problem/39516483

Reviewers: dexonsmith, bruno

Reviewed By: dexonsmith

Subscribers: jkorous, cfe-commits, ributzka

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371655 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Added triple to test file to avoid arm buildbots failures
David Bolvansky [Wed, 11 Sep 2019 18:55:56 +0000 (18:55 +0000)]
[NFC] Added triple to test file to avoid arm buildbots failures

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371646 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[MS] Consder constexpr globals to be inline, as in C++17
Reid Kleckner [Wed, 11 Sep 2019 18:09:10 +0000 (18:09 +0000)]
[MS] Consder constexpr globals to be inline, as in C++17

Summary:
Microsoft seems to do this regardless of the language mode, so we must
also do it in order to be ABI compatible.

Fixes PR36125

Reviewers: thakis

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371642 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Clang][Bundler] Replace std::vector by SmallVector [NFC]
Sergey Dmitriev [Wed, 11 Sep 2019 16:28:47 +0000 (16:28 +0000)]
[Clang][Bundler] Replace std::vector by SmallVector [NFC]

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371637 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReland "clang-misexpect: Profile Guided Validation of Performance Annotations in...
Petr Hosek [Wed, 11 Sep 2019 16:19:50 +0000 (16:19 +0000)]
Reland "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"

This patch contains the basic functionality for reporting potentially
incorrect usage of __builtin_expect() by comparing the developer's
annotation against a collected PGO profile. A more detailed proposal and
discussion appears on the CFE-dev mailing list
(http://lists.llvm.org/pipermail/cfe-dev/2019-July/062971.html) and a
prototype of the initial frontend changes appear here in D65300

We revised the work in D65300 by moving the misexpect check into the
LLVM backend, and adding support for IR and sampling based profiles, in
addition to frontend instrumentation.

We add new misexpect metadata tags to those instructions directly
influenced by the llvm.expect intrinsic (branch, switch, and select)
when lowering the intrinsics. The misexpect metadata contains
information about the expected target of the intrinsic so that we can
check against the correct PGO counter when emitting diagnostics, and the
compiler's values for the LikelyBranchWeight and UnlikelyBranchWeight.
We use these branch weight values to determine when to emit the
diagnostic to the user.

A future patch should address the comment at the top of
LowerExpectIntrisic.cpp to hoist the LikelyBranchWeight and
UnlikelyBranchWeight values into a shared space that can be accessed
outside of the LowerExpectIntrinsic pass. Once that is done, the
misexpect metadata can be updated to be smaller.

In the long term, it is possible to reconstruct portions of the
misexpect metadata from the existing profile data. However, we have
avoided this to keep the code simple, and because some kind of metadata
tag will be required to identify which branch/switch/select instructions
are influenced by the use of llvm.expect

Patch By: paulkirth
Differential Revision: https://reviews.llvm.org/D66324

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371635 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Clang][Bundler] Fix for a potential memory leak [NFC]
Sergey Dmitriev [Wed, 11 Sep 2019 16:03:21 +0000 (16:03 +0000)]
[Clang][Bundler] Fix for a potential memory leak [NFC]

Bundler leaks memory if it is called with -type=o but given input isn't an object file (though it has to have a known binary type like IR, archive, etc...). Memory leak is happening when binary object returned by the createBinary(...) call cannot be casted to an ObjectFile type. In this case returned BinaryOrErr object releases ownership of the binary, but no one is taking it (see line 626).

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371633 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP] Update the diagnosis message for canonical loop form, by Chi
Alexey Bataev [Wed, 11 Sep 2019 15:44:06 +0000 (15:44 +0000)]
[OPENMP] Update the diagnosis message for canonical loop form, by Chi
Chun Chen.

The previous patch (https://reviews.llvm.org/D54441) support the
relational-op != very well for openmp canonical loop form, however,
it didn't update the diagnosis message. So this patch is simply
update the diagnosis message by adding !=, update the test
related to it, and update the section number for canonical loop
form for OpenMP 5.0 in comment.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371631 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Updated status page, NFC.
Alexey Bataev [Wed, 11 Sep 2019 14:44:30 +0000 (14:44 +0000)]
[OPENMP]Updated status page, NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371627 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Diagnostics] Add -Wsizeof-array-div
David Bolvansky [Wed, 11 Sep 2019 10:59:47 +0000 (10:59 +0000)]
[Diagnostics] Add -Wsizeof-array-div

Summary: Clang version of https://www.viva64.com/en/examples/v706/

Reviewers: rsmith

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371605 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "clang-misexpect: Profile Guided Validation of Performance Annotations in...
Dmitri Gribenko [Wed, 11 Sep 2019 09:16:17 +0000 (09:16 +0000)]
Revert "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"

This reverts commit r371584. It introduced a dependency from compiler-rt
to llvm/include/ADT, which is problematic for multiple reasons.

One is that it is a novel dependency edge, which needs cross-compliation
machinery for llvm/include/ADT (yes, it is true that right now
compiler-rt included only header-only libraries, however, if we allow
compiler-rt to depend on anything from ADT, other libraries will
eventually get used).

Secondly, depending on ADT from compiler-rt exposes ADT symbols from
compiler-rt, which would cause ODR violations when Clang is built with
the profile library.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371598 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ARM] Take into account -mcpu and -mfpu options while handling 'crypto' feature
Diogo N. Sampaio [Wed, 11 Sep 2019 09:06:17 +0000 (09:06 +0000)]
[ARM] Take into account -mcpu and -mfpu options while handling 'crypto' feature

Submittin in behalf of krisb (Kristina Bessonova) <ch.bessonova@gmail.com>

Summary:
'+crypto' means '+aes' and '+sha2' for arch >= ARMv8 when they were
not disabled explicitly. But this is correctly handled only in case of
'-march' option, though the feature may also be specified through
the '-mcpu' or '-mfpu' options. In the following example:

  $ clang -mcpu=cortex-a57 -mfpu=crypto-neon-fp-armv8

'aes' and 'sha2' are disabled that is quite unexpected:

  $ clang -cc1 -triple armv8--- -target-cpu cortex-a57
    <...> -target-feature -sha2 -target-feature -aes -target-feature +crypto

This exposed by https://reviews.llvm.org/D63936 that makes
the 'aes' and 'sha2' features disabled by default.

So, while handling the 'crypto' feature we need to take into account:
  - a CPU name, as it provides the information about architecture
    (if no '-march' option specified),
  - features, specified by the '-mcpu' and '-mfpu' options.

Reviewers: SjoerdMeijer, ostannard, labrinea, dnsampaio

Reviewed By: dnsampaio

Subscribers: ikudrin, javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

Author: krisb

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371597 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CodeGen] Add alias for cpu_dispatch function with IFunc & Fix resolver linkage type
Fangrui Song [Wed, 11 Sep 2019 01:54:48 +0000 (01:54 +0000)]
[CodeGen] Add alias for cpu_dispatch function with IFunc & Fix resolver linkage type

Multi-versioned functions defined by cpu_dispatch and implemented with IFunc
can not be called outside the translation units where they are defined due to
lack of symbols. This patch add function aliases for these functions and thus
make them visible outside.

Differential Revision: https://reviews.llvm.org/D67058
Patch by Senran Zhang

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371586 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoclang-misexpect: Profile Guided Validation of Performance Annotations in LLVM
Petr Hosek [Wed, 11 Sep 2019 01:09:16 +0000 (01:09 +0000)]
clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

This patch contains the basic functionality for reporting potentially
incorrect usage of __builtin_expect() by comparing the developer's
annotation against a collected PGO profile. A more detailed proposal and
discussion appears on the CFE-dev mailing list
(http://lists.llvm.org/pipermail/cfe-dev/2019-July/062971.html) and a
prototype of the initial frontend changes appear here in D65300

We revised the work in D65300 by moving the misexpect check into the
LLVM backend, and adding support for IR and sampling based profiles, in
addition to frontend instrumentation.

We add new misexpect metadata tags to those instructions directly
influenced by the llvm.expect intrinsic (branch, switch, and select)
when lowering the intrinsics. The misexpect metadata contains
information about the expected target of the intrinsic so that we can
check against the correct PGO counter when emitting diagnostics, and the
compiler's values for the LikelyBranchWeight and UnlikelyBranchWeight.
We use these branch weight values to determine when to emit the
diagnostic to the user.

A future patch should address the comment at the top of
LowerExpectIntrisic.cpp to hoist the LikelyBranchWeight and
UnlikelyBranchWeight values into a shared space that can be accessed
outside of the LowerExpectIntrinsic pass. Once that is done, the
misexpect metadata can be updated to be smaller.

In the long term, it is possible to reconstruct portions of the
misexpect metadata from the existing profile data. However, we have
avoided this to keep the code simple, and because some kind of metadata
tag will be required to identify which branch/switch/select instructions
are influenced by the use of llvm.expect

Patch By: paulkirth
Differential Revision: https://reviews.llvm.org/D66324

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371584 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoEmit -Wmicrosoft-enum-value warning instead of error in MS ABI
Reid Kleckner [Wed, 11 Sep 2019 01:01:06 +0000 (01:01 +0000)]
Emit -Wmicrosoft-enum-value warning instead of error in MS ABI

Summary:
The first NFC change is to replace a getCXXABI().isMicrosoft() check
with getTriple().isWindowsMSVCEnvironment(). This code takes effect in
non-C++ compilations, so it doesn't make sense to check the C++ ABI. In
the MS ABI, enums are always considered to be "complete" because the
underlying type of an unfixed enum will always be 'int'. This behavior
was moved from -fms-compatibility to MS ABI back in r249656.

The second change is functional, and it downgrades an error to a warning
when the MS ABI is used rather than only under -fms-compatibility. The
reasoning is that it's unreasonable for the following code to reject the
following code for all MS ABI targets with -fno-ms-compatibility:
  enum Foo { Foo_Val = 0xDEADBEEF };
This is valid code for any other target, but in the MS ABI, Foo_Val just
happens to be negative. With this change, clang emits a
-Wmicrosoft-enum-value warning on this code, but compiles it without
error.

Fixes PR38478

Reviewers: hans, rsmith, STL_MSFT

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371581 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-scan-deps][NFC] Fix tests - prevent FileCheck matching test dir path
Jan Korous [Wed, 11 Sep 2019 00:30:26 +0000 (00:30 +0000)]
[clang-scan-deps][NFC] Fix tests - prevent FileCheck matching test dir path

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371578 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format] Apply BAS_AlwaysBreak to C++11 braced lists
Owen Pan [Tue, 10 Sep 2019 23:26:45 +0000 (23:26 +0000)]
[clang-format] Apply BAS_AlwaysBreak to C++11 braced lists

See PR18455.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371571 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReland "Change the X86 datalayout to add three address spaces
Amy Huang [Tue, 10 Sep 2019 23:15:38 +0000 (23:15 +0000)]
Reland "Change the X86 datalayout to add three address spaces
 for 32 bit signed, 32 bit unsigned, and 64 bit pointers."
This reverts 57076d3199fc2b0af4a3736b7749dd5462cacda5.

Original review at https://reviews.llvm.org/D64931.
Review for added fix at https://reviews.llvm.org/D66843.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371568 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoActually reorder not and env in crash-recovery-modules.m
Reid Kleckner [Tue, 10 Sep 2019 21:54:16 +0000 (21:54 +0000)]
Actually reorder not and env in crash-recovery-modules.m

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371559 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoWhen evaluating a __builtin_constant_p conditional, always enter
Richard Smith [Tue, 10 Sep 2019 21:24:09 +0000 (21:24 +0000)]
When evaluating a __builtin_constant_p conditional, always enter
constant-folding mode regardless of the original evaluation mode.

In order for this to be correct, we need to track whether we're checking
for a potential constant expression or checking for undefined behavior
separately from the evaluation mode enum, since we don't want to clobber
those states when entering constant-folding mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371557 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP5.0]Allow teams directive outside of the target directives.
Alexey Bataev [Tue, 10 Sep 2019 20:19:58 +0000 (20:19 +0000)]
[OPENMP5.0]Allow teams directive outside of the target directives.

According to OpenMP 5.0, teams directives are allowed not only in the
target context, but also in the implicit parallel regions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371553 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRe-land Remove REQUIRES:shell from tests that pass for me on Windows
Reid Kleckner [Tue, 10 Sep 2019 20:15:45 +0000 (20:15 +0000)]
Re-land Remove REQUIRES:shell from tests that pass for me on Windows

This reverts r371497 (git commit 3d7e9ab7b9f8c53aa41420c54970f0fb421004a2)

Reorder `not` with `env` in these two tests so they pass:
  Driver/rewrite-map-in-diagnostics.c
  Index/crash-recovery-modules.m.

This will not be necessary after D66531 lands.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371552 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix for PR43175: compiler crash when trying to emit noncapturable
Alexey Bataev [Tue, 10 Sep 2019 19:16:56 +0000 (19:16 +0000)]
Fix for PR43175: compiler crash when trying to emit noncapturable
constant.

If the constexpr variable is partially initialized, the initializer can
be emitted as the structure, not as an array, because of some early
optimizations. The llvm variable gets the type from this constant and,
thus, gets the type which is pointer to struct rather than pointer to an
array. We need to convert this type to be truely array, otherwise it may
lead to the compiler crash when trying to emit array subscript
expression.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371548 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoDon't emit .gnu_pubnames when tuning for LLDB.
Adrian Prantl [Tue, 10 Sep 2019 15:53:18 +0000 (15:53 +0000)]
Don't emit .gnu_pubnames when tuning for LLDB.

LLDB reads the various .apple* accelerator tables (and in the near
future: the DWARF 5 accelerator tables) which should make
.gnu_pubnames redundant. This changes the Clang driver to no longer
pass -ggnu-pubnames when tuning for LLDB.

Thanks to David Blaikie for pointing this out!
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190422/thread.html#646062

rdar://problem/50142073

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371530 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang][codegen][NFC] Make test patterns more permissive.
Clement Courbet [Tue, 10 Sep 2019 14:20:08 +0000 (14:20 +0000)]
[clang][codegen][NFC] Make test patterns more permissive.

See the discussion in:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190909/692736.html

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371522 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert Remove REQUIRES:shell from tests that pass for me on Windows
James Henderson [Tue, 10 Sep 2019 08:48:33 +0000 (08:48 +0000)]
Revert Remove REQUIRES:shell from tests that pass for me on Windows

This reverts r371478 (git commit a9980f60ce083fa6d5fd03c12c58ca0b293e3d60)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371497 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[RISCV] Make -march=rv{32,64}gc the default in RISC-V Linux
Roger Ferrer Ibanez [Tue, 10 Sep 2019 08:16:24 +0000 (08:16 +0000)]
[RISCV] Make -march=rv{32,64}gc the default in RISC-V Linux

This is the logical follow-up of D65634.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371496 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[RISCV] Default to ilp32d/lp64d in RISC-V Linux
Roger Ferrer Ibanez [Tue, 10 Sep 2019 07:57:36 +0000 (07:57 +0000)]
[RISCV] Default to ilp32d/lp64d in RISC-V Linux

When running clang as a native compiler in RISC-V Linux the flag
-mabi=ilp32d / -mabi=lp64d is always mandatory. This change makes it the
default there.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371494 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[RISCV] Move architecture parsing code into its own function
Roger Ferrer Ibanez [Tue, 10 Sep 2019 07:47:34 +0000 (07:47 +0000)]
[RISCV] Move architecture parsing code into its own function

I plan to reuse it in a later patch.

This is almost NFC except a small change in control flow when diagnosing
+d without +f.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371492 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "clang-misexpect: Profile Guided Validation of Performance Annotations in...
Petr Hosek [Tue, 10 Sep 2019 06:25:13 +0000 (06:25 +0000)]
Revert "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"

This reverts commit r371484: this broke sanitizer-x86_64-linux-fast bot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371488 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoclang-misexpect: Profile Guided Validation of Performance Annotations in LLVM
Petr Hosek [Tue, 10 Sep 2019 03:11:39 +0000 (03:11 +0000)]
clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

This patch contains the basic functionality for reporting potentially
incorrect usage of __builtin_expect() by comparing the developer's
annotation against a collected PGO profile. A more detailed proposal and
discussion appears on the CFE-dev mailing list
(http://lists.llvm.org/pipermail/cfe-dev/2019-July/062971.html) and a
prototype of the initial frontend changes appear here in D65300

We revised the work in D65300 by moving the misexpect check into the
LLVM backend, and adding support for IR and sampling based profiles, in
addition to frontend instrumentation.

We add new misexpect metadata tags to those instructions directly
influenced by the llvm.expect intrinsic (branch, switch, and select)
when lowering the intrinsics. The misexpect metadata contains
information about the expected target of the intrinsic so that we can
check against the correct PGO counter when emitting diagnostics, and the
compiler's values for the LikelyBranchWeight and UnlikelyBranchWeight.
We use these branch weight values to determine when to emit the
diagnostic to the user.

A future patch should address the comment at the top of
LowerExpectIntrisic.cpp to hoist the LikelyBranchWeight and
UnlikelyBranchWeight values into a shared space that can be accessed
outside of the LowerExpectIntrinsic pass. Once that is done, the
misexpect metadata can be updated to be smaller.

In the long term, it is possible to reconstruct portions of the
misexpect metadata from the existing profile data. However, we have
avoided this to keep the code simple, and because some kind of metadata
tag will be required to identify which branch/switch/select instructions
are influenced by the use of llvm.expect

Patch By: paulkirth
Differential Revision: https://reviews.llvm.org/D66324

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371484 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove REQUIRES:shell from tests that pass for me on Windows
Reid Kleckner [Tue, 10 Sep 2019 00:50:32 +0000 (00:50 +0000)]
Remove REQUIRES:shell from tests that pass for me on Windows

I see in the history for some of these tests REQUIRES:shell was used as
a way to disable tests on Windows because they are flaky there. I tried
not to re-enable such tests, but it's possible that I missed some and
this will re-enable flaky tests on Windows. If so, we should disable
them with UNSUPPORTED:system-windows and add a comment that they are
flaky there. So far as I can tell, the lit internal shell is capable of
running all of these tests, and we shouldn't use REQUIRES:shell as a
proxy for Windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371478 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix crash mangling an explicit lambda non-type template parameter pack
Richard Smith [Tue, 10 Sep 2019 00:39:53 +0000 (00:39 +0000)]
Fix crash mangling an explicit lambda non-type template parameter pack
that is not a pack expansion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371476 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoPR43242: Fix crash when typo-correcting to an operator() that should not
Richard Smith [Mon, 9 Sep 2019 23:07:22 +0000 (23:07 +0000)]
PR43242: Fix crash when typo-correcting to an operator() that should not
have been visible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371468 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] NFC: Simplify bug report equivalence classes to not be ilists.
Artem Dergachev [Mon, 9 Sep 2019 20:34:44 +0000 (20:34 +0000)]
[analyzer] NFC: Simplify bug report equivalence classes to not be ilists.

Use a vector of unique pointers instead.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371451 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] NFC: Introduce sub-classes for path-sensitive and basic reports.
Artem Dergachev [Mon, 9 Sep 2019 20:34:40 +0000 (20:34 +0000)]
[analyzer] NFC: Introduce sub-classes for path-sensitive and basic reports.

Checkers are now required to specify whether they're creating a
path-sensitive report or a path-insensitive report by constructing an
object of the respective type.

This makes BugReporter more independent from the rest of the Static Analyzer
because all Analyzer-specific code is now in sub-classes.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371450 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Driver] Handle default case in refactored addOpenMPRuntime
Pirama Arumuga Nainar [Mon, 9 Sep 2019 19:52:39 +0000 (19:52 +0000)]
[Driver] Handle default case in refactored addOpenMPRuntime

Summary:
Appease failed builds (due to -Werror and -Wswitch) where OMPRT_Unknown
is not handled in the switch statement (even though it's handled by the
early exit).

This fixes -Wswitch triggered by r371442.

Reviewers: srhines, danalbert, jdoerfert

Subscribers: guansong, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371444 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Driver] Add -static-openmp driver option
Pirama Arumuga Nainar [Mon, 9 Sep 2019 18:31:41 +0000 (18:31 +0000)]
[Driver] Add -static-openmp driver option

Summary:
For Gnu, FreeBSD and NetBSD, this option forces linking with the static
OpenMP host runtime (similar to -static-libgcc and -static-libstdcxx).

Android's NDK will start the shared OpenMP runtime in addition to the static
libomp.  In this scenario, the linker will prefer to use the shared library by
default.  Add this option to enable linking with the static libomp.

Reviewers: Hahnfeld, danalbert, srhines, joerg, jdoerfert

Subscribers: guansong, cfe-commits

Tags: #clang

Fixes https://github.com/android-ndk/ndk/issues/1028

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371437 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Allow _MM_FROUND_CUR_DIRECTION and _MM_FROUND_NO_EXC to be used together on...
Craig Topper [Mon, 9 Sep 2019 17:48:05 +0000 (17:48 +0000)]
[X86] Allow _MM_FROUND_CUR_DIRECTION and _MM_FROUND_NO_EXC to be used together on instructions that only support SAE and not embedded rounding.

Current for SAE instructions we only allow _MM_FROUND_CUR_DIRECTION(bit 2) or _MM_FROUND_NO_EXC(bit 3) to be used as the immediate passed to the inrinsics. But these instructions don't perform rounding so _MM_FROUND_CUR_DIRECTION is just sort of a default placeholder when you don't want to suppress exceptions. Using _MM_FROUND_NO_EXC by itself is really bit equivalent to (_MM_FROUND_NO_EXC | _MM_FROUND_TO_NEAREST_INT) since _MM_FROUND_TO_NEAREST_INT is 0. Since we aren't rounding on these instructions we should also accept (_MM_FROUND_CUR_DIRECTION | _MM_FROUND_NO_EXC) as equivalent to (_MM_FROUND_NO_EXC). icc allows this, but gcc does not.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371430 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Add aacps bitfields access test
Diogo N. Sampaio [Mon, 9 Sep 2019 15:39:45 +0000 (15:39 +0000)]
[NFC] Add aacps bitfields access test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371410 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMerge note_ovl_builtin_candidate diagnostics; NFC
Sven van Haastregt [Mon, 9 Sep 2019 14:39:20 +0000 (14:39 +0000)]
Merge note_ovl_builtin_candidate diagnostics; NFC

There is no difference between the unary and binary case, so
merge them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371403 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMove prop-sink branch to monorepo.
Gabor Borsik [Sun, 8 Sep 2019 19:23:43 +0000 (19:23 +0000)]
Move prop-sink branch to monorepo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371342 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NewPM][Sancov] Create the Sancov Pass after building the pipelines
Leonard Chan [Sun, 8 Sep 2019 07:30:17 +0000 (07:30 +0000)]
[NewPM][Sancov] Create the Sancov Pass after building the pipelines

We're running into linker errors from missing sancov sections:

```
ld.lld: error: relocation refers to a discarded section: __sancov_guards
>>> defined in user-arm64-ubsan-sancov-full.shlib/obj/third_party/ulib/scudo/scudo.wrappers_c.cc.o
>>> referenced by common.h:26 (../../zircon/third_party/ulib/scudo/common.h:26)
... many other references
```

I believe this is due to a pass in the default pipeline that somehow discards
these sections. The ModuleSanitizerCoveragePass was initially added at the
start of the pipeline. This now adds it to the end of the pipeline for
optimized and unoptimized builds.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371326 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFixes an assertion while instantiating a template with an incomplete typo-corrected...
Aaron Ballman [Sat, 7 Sep 2019 20:14:09 +0000 (20:14 +0000)]
Fixes an assertion while instantiating a template with an incomplete typo-corrected type.

Fixes PR35682. When a template in instantiated with an incomplete typo corrected type an assertion can trigger if the -ferror-limit is used to reduce the number of errors.

Patch by Mark de Wever.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371320 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove stale TLI Module level pass registration
Teresa Johnson [Sat, 7 Sep 2019 03:09:46 +0000 (03:09 +0000)]
Remove stale TLI Module level pass registration

Clang patch to adapt to LLVM changes in D66428 that make the TLI
require a Function. There is no longer a module-level
TargetLibraryAnalysis, so remove its registration

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371285 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang][DependencyFileGenerator] Fix missing -MT option handling
Jan Korous [Sat, 7 Sep 2019 00:59:13 +0000 (00:59 +0000)]
[clang][DependencyFileGenerator] Fix missing -MT option handling

Targets in DependencyFileGenerator don't necessarily come from -MT option.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371279 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix thunks.cpp test, don't FileCheck for anon namespace id
Reid Kleckner [Sat, 7 Sep 2019 00:41:08 +0000 (00:41 +0000)]
Fix thunks.cpp test, don't FileCheck for anon namespace id

The anon namespace id is a hash of the main input path to the compiler,
which varies in the test suite because the input path is absolute.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371277 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema][ObjC] Mark C union fields that have non-trivial ObjC ownership
Akira Hatanaka [Sat, 7 Sep 2019 00:34:47 +0000 (00:34 +0000)]
[Sema][ObjC] Mark C union fields that have non-trivial ObjC ownership
qualifications as unavailable if the union is declared in a system
header

r365985 stopped marking those fields as unavailable, which caused the
union's NonTrivialToPrimitive* bits to be set to true. This patch
restores the behavior prior to r365985, except that users can explicitly
specify the ownership qualification of the field to instruct the
compiler not to mark it as unavailable.

rdar://problem/53420753

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371276 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema] Diagnose default-initialization, destruction, and copying of
Akira Hatanaka [Sat, 7 Sep 2019 00:34:43 +0000 (00:34 +0000)]
[Sema] Diagnose default-initialization, destruction, and copying of
non-trivial C union types

This recommits r365985, which was reverted because it broke a few
projects using unions containing non-trivial ObjC pointer fields in
system headers. We now have a patch to fix the problem (see
https://reviews.llvm.org/D65256).

Original commit message:

This patch diagnoses uses of non-trivial C unions and structs/unions
containing non-trivial C unions in the following contexts, which require
default-initialization, destruction, or copying of the union objects,
instead of disallowing fields of non-trivial types in C unions, which is
what we currently do:

- function parameters.
- function returns.
- assignments.
- compound literals.
- block captures except capturing of `__block` variables by non-escaping blocks.
- local and global variable definitions.
- lvalue-to-rvalue conversions of volatile types.

See the discussion in https://reviews.llvm.org/D62988 for more background.

rdar://problem/50679094

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371275 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoUse musttail for variadic method thunks when possible
Reid Kleckner [Fri, 6 Sep 2019 22:55:26 +0000 (22:55 +0000)]
Use musttail for variadic method thunks when possible

This avoids cloning variadic virtual methods when the target supports
musttail and the return type is not covariant. I think we never
implemented this previously because it doesn't handle the covariant
case. But, in the MS ABI, there are some cases where vtable thunks must
be emitted even when the variadic method defintion is not available, so
it looks like we need to implement this. Do it for both ABIs, since it's
a nice size improvement and simplification for Itanium.

Emit an error when emitting thunks for variadic methods with a covariant
return type. This case is essentially not implementable unless the ABI
provides a way to perfectly forward variadic arguments without a tail
call.

Fixes PR43173.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371269 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Add minimal support for fix-it hints.
Artem Dergachev [Fri, 6 Sep 2019 20:55:29 +0000 (20:55 +0000)]
[analyzer] Add minimal support for fix-it hints.

Allow attaching fixit hints to Static Analyzer BugReports.

Fixits are attached either to the bug report itself or to its notes
(path-sensitive event notes or path-insensitive extra notes).

Add support for fixits in text output (including the default text output that
goes without notes, as long as the fixit "belongs" to the warning).

Add support for fixits in the plist output mode.

Implement a fixit for the path-insensitive DeadStores checker. Only dead
initialization warning is currently covered.

Implement a fixit for the path-sensitive VirtualCall checker when the virtual
method is not pure virtual (in this case the "fix" is to suppress the warning
by qualifying the call).

Both fixits are under an off-by-default flag for now, because they
require more careful testing.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371257 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] pr43179: Make CallDescription defensive against C variadic functions.
Artem Dergachev [Fri, 6 Sep 2019 20:55:24 +0000 (20:55 +0000)]
[analyzer] pr43179: Make CallDescription defensive against C variadic functions.

Most functions that our checkers react upon are not C-style variadic functions,
and therefore they have as many actual arguments as they have formal parameters.

However, it's not impossible to define a variadic function with the same name.
This will crash any checker that relies on CallDescription to check the number
of arguments but silently assumes that the number of parameters is the same.

Change CallDescription to check both the number of arguments and the number of
parameters by default.

If we're intentionally trying to match variadic functions, allow specifying
arguments and parameters separately (possibly omitting any of them).
For now we only have one CallDescription which would make use of those,
namely __builtin_va_start itself.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371256 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoUpdate comment for <template-param-decl> mangling to match extended mangling rule...
Richard Smith [Fri, 6 Sep 2019 20:32:01 +0000 (20:32 +0000)]
Update comment for <template-param-decl> mangling to match extended mangling rule in r371004.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371252 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang][Index][NFC] Put IndexingOptions to a separate header
Jan Korous [Fri, 6 Sep 2019 20:08:32 +0000 (20:08 +0000)]
[clang][Index][NFC] Put IndexingOptions to a separate header

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371250 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[LifetimeAnalysis] don't use raw string literals in macros
Matthias Gehre [Fri, 6 Sep 2019 19:15:02 +0000 (19:15 +0000)]
[LifetimeAnalysis] don't use raw string literals in macros

They broke the AArch64 bots (gcc does not support it)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371241 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFCI] Unbreak buildbots
David Bolvansky [Fri, 6 Sep 2019 16:30:44 +0000 (16:30 +0000)]
[NFCI] Unbreak buildbots

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371226 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Added new tests for r371222
David Bolvansky [Fri, 6 Sep 2019 16:18:18 +0000 (16:18 +0000)]
[NFC] Added new tests for r371222

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371223 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Diagnostics] Refactor code for -Wsizeof-pointer-div, catch more cases; also add...
David Bolvansky [Fri, 6 Sep 2019 16:12:48 +0000 (16:12 +0000)]
[Diagnostics] Refactor code for -Wsizeof-pointer-div, catch more cases; also add -Wsizeof-array-div

Previously, -Wsizeof-pointer-div failed to catch:
const int *r;
sizeof(r) / sizeof(int);

Now fixed.
Also introduced -Wsizeof-array-div which catches bugs like:
sizeof(r) / sizeof(short);

(Array element type does not match type of sizeof operand).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371222 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC][CodeGen][UBSan] EmitCheckedInBoundsGEP(): pass a vector to EmitCheck()
Roman Lebedev [Fri, 6 Sep 2019 14:19:04 +0000 (14:19 +0000)]
[NFC][CodeGen][UBSan] EmitCheckedInBoundsGEP(): pass a vector to EmitCheck()

Will be easier to add a new 'check' in a follow-up.

This was originally part of https://reviews.llvm.org/D67122

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371208 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC][CodeGen][UBSan] EmitCheckedInBoundsGEP(): refactor EmitGEPOffsetInBytes() helper
Roman Lebedev [Fri, 6 Sep 2019 14:18:57 +0000 (14:18 +0000)]
[NFC][CodeGen][UBSan] EmitCheckedInBoundsGEP(): refactor EmitGEPOffsetInBytes() helper

It shouldn't really be inlined into the EmitCheckedInBoundsGEP().
Refactoring it beforehand will make follow-up changes more obvious.

This was originally part of https://reviews.llvm.org/D67122

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371207 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC][CodeGen][UBSan] EmitCheckedInBoundsGEP(): add some comments to pointer-overflow...
Roman Lebedev [Fri, 6 Sep 2019 14:18:49 +0000 (14:18 +0000)]
[NFC][CodeGen][UBSan] EmitCheckedInBoundsGEP(): add some comments to pointer-overflow check

It's rather eye-twiching, some comments may help here..

This was originally part of https://reviews.llvm.org/D67122

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371206 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agolibclang depends on ClangDriverOptions since r352803
Nico Weber [Fri, 6 Sep 2019 13:57:12 +0000 (13:57 +0000)]
libclang depends on ClangDriverOptions since r352803

Without this, the build would sometimes fail with

    In file included from clang/tools/libclang/CIndexer.cpp:17:
    In file included from clang/include/clang/Driver/Driver.h:15:
    clang/include/clang/Driver/Options.h:44:10: fatal error:
        'clang/Driver/Options.inc' file not found
    #include "clang/Driver/Options.inc"
             ^~~~~~~~~~~~~~~~~

if Options.inc wasn't generated before libclang was built
by coincidence.

(In the GN build, this works because lib/Driver there declares
the dep on tablegen as a public_dep since the generated file
is part of Driver's public interface, and then things work out
automatically without every client of Driver having to be careful.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371205 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReland [LifetimeAnalysis] Support more STL idioms (template forward declaration and...
Matthias Gehre [Fri, 6 Sep 2019 08:56:30 +0000 (08:56 +0000)]
Reland [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)

Reland after https://reviews.llvm.org/D66806 fixed the false-positive diagnostics.

Summary:
This fixes inference of gsl::Pointer on std::set::iterator with libstdc++ (the typedef for iterator
on the template is a DependentNameType - we can only put the gsl::Pointer attribute
on the underlaying record after instantiation)

inference of gsl::Pointer on std::vector::iterator with libc++ (the class was forward-declared,
we added the gsl::Pointer on the canonical decl (the forward decl), and later when the
template was instantiated, there was no attribute on the definition so it was not instantiated).

and a duplicate gsl::Pointer on some class with libstdc++ (we first added an attribute to
a incomplete instantiation, and then another was copied from the template definition
when the instantiation was completed).

We now add the attributes to all redeclarations to fix thos issues and make their usage easier.

Reviewers: gribozavr

Subscribers: Szelethus, xazax.hun, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371182 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Prevent passing vectors of __int128 as <X x i128> in llvm IR
Craig Topper [Fri, 6 Sep 2019 06:02:13 +0000 (06:02 +0000)]
[X86] Prevent passing vectors of __int128 as <X x i128> in llvm IR

As far as I can tell, gcc passes 256/512 bit vectors __int128 in memory. And passes a vector of 1 _int128 in an xmm register. The backend considers <X x i128> as an illegal type and will scalarize any arguments with that type. So we need to coerce the argument types in the frontend to match to avoid the illegal type.

I'm restricting this to change to Linux and NetBSD based on the
how similar ABI changes have been handled in the past.
PS4, FreeBSD, and Darwin are unaffected. I've also added a
new -fclang-abi-compat version to restore the old behavior.

This issue was identified in PR42607. Though even with the types changed, we still seem to be doing some unnecessary stack realignment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371169 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Pre-commit vector of __int128 test cases for D64672.
Craig Topper [Fri, 6 Sep 2019 06:02:06 +0000 (06:02 +0000)]
[X86] Pre-commit vector of __int128 test cases for D64672.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371168 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoImplement Microsoft-compatible mangling for decomposition declarations.
Nico Weber [Thu, 5 Sep 2019 21:08:50 +0000 (21:08 +0000)]
Implement Microsoft-compatible mangling for decomposition declarations.

Match cl.exe's mangling for decomposition declarations.

Decomposition declarations are considered to be anonymous structs,
and use the same convention as for anonymous struct/union declarations.

Naming confirmed to match https://godbolt.org/z/K2osJa

Patch from Eric Astor <epastor@google.com>!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371124 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Diagnostics] Minor improvements for -Wxor-used-as-pow
David Bolvansky [Thu, 5 Sep 2019 20:50:48 +0000 (20:50 +0000)]
[Diagnostics] Minor improvements for -Wxor-used-as-pow

Extracted from D66397; implemented suggestion for 2^64; tests revisited.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371122 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang][Index] Replace CodegenNameGenerator with ASTNameGenerator
Jan Korous [Thu, 5 Sep 2019 20:33:52 +0000 (20:33 +0000)]
[clang][Index] Replace CodegenNameGenerator with ASTNameGenerator

Follow-up to: 3ff8c3b73f6d5d15b4c1fd

Should be NFC since the original patch just moved the code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371117 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them...
Alexandre Ganea [Thu, 5 Sep 2019 20:12:20 +0000 (20:12 +0000)]
Revert: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371113 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AST][NFC] Doc comments for ASTNameGenerator
Jan Korous [Thu, 5 Sep 2019 20:04:11 +0000 (20:04 +0000)]
[AST][NFC] Doc comments for ASTNameGenerator

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371112 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artif...
Alexandre Ganea [Thu, 5 Sep 2019 15:24:49 +0000 (15:24 +0000)]
[DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371080 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ARM] Add support for the s,j,x,N,O inline asm constraints
David Candler [Thu, 5 Sep 2019 15:17:25 +0000 (15:17 +0000)]
[ARM] Add support for the s,j,x,N,O inline asm constraints

A number of inline assembly constraints are currently supported by LLVM, but rejected as invalid by Clang:

Target independent constraints:

s: An integer constant, but allowing only relocatable values

ARM specific constraints:

j: An immediate integer between 0 and 65535 (valid for MOVW)
x: A 32, 64, or 128-bit floating-point/SIMD register: s0-s15, d0-d7, or q0-q3
N: An immediate integer between 0 and 31 (Thumb1 only)
O: An immediate integer which is a multiple of 4 between -508 and 508. (Thumb1 only)

This patch adds support to Clang for the missing constraints along with some checks to ensure that the constraints are used with the correct target and Thumb mode, and that immediates are within valid ranges (at least where possible). The constraints are already implemented in LLVM, but just a couple of minor corrections to checks (V8M Baseline includes MOVW so should work with 'j', 'N' and 'O' shouldn't be valid in Thumb2) so that Clang and LLVM are in line with each other and the documentation.

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

Change-Id: I18076619e319bac35fbb60f590c069145c9d9a0a

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371079 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd -m(no)-spe to clang
Justin Hibbits [Thu, 5 Sep 2019 13:38:46 +0000 (13:38 +0000)]
Add -m(no)-spe to clang

Summary:
r337347 added support for the Signal Processing Engine (SPE) to LLVM.
This follows that up with the clang side.

This adds -mspe and -mno-spe, to match GCC.

Subscribers: nemanjai, kbarton, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371066 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL] Add image type handling for builtins
Sven van Haastregt [Thu, 5 Sep 2019 10:01:24 +0000 (10:01 +0000)]
[OpenCL] Add image type handling for builtins

Image types were previously available, but not working.  This patch
adds image type handling.

Rename the image type definitions in the .td file to make them
consistent with other type names.  Use abstract types to represent the
unqualified types.  Instantiate access-qualified image types at the
point of use using, e.g. `ImageType<Image2d, "RO">`.

Add/update TableGen definitions for the read_image/write_image
builtin functions.

Patch by Pierre Gondois and Sven van Haastregt.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371046 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[libclang] Refactored SharedParsedRegionsStorage
Dmitri Gribenko [Thu, 5 Sep 2019 09:48:39 +0000 (09:48 +0000)]
[libclang] Refactored SharedParsedRegionsStorage

Summary:
Removed the `PPRegionSetTy` typedef because it is only used 3 times, and
obscures code more than it helps.

Renamed SharedParsedRegionsStorage to ThreadSafeParsedRegions, because
that better reflects the reason for this type to exist.

Replaced the `copyTo()` method that had an out parameter with a getter.

Renamed the `merge()` method to `addParsedRegions()`.

Renamed `ParsedSrcLocationsTracker::ParsedRegions` to
`ParsedRegionsSnapshot`, which better reflects its role.

Subscribers: arphaman, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371041 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema] Refactor LookupVisibleDecls. NFC
Ilya Biryukov [Thu, 5 Sep 2019 08:59:06 +0000 (08:59 +0000)]
[Sema] Refactor LookupVisibleDecls. NFC

Summary:
We accumulated some configuration parameters for LookupVisibleDecls that
are being passed unchanged to recursive calls, e.g. LoadExternal and
IncludeDependentBases.

At the same time, there is a bunch of parameters that can change in the
recursive invocations.

It is hard to tell the difference between those groups, making the code
hard to follow.

This change introduces a helper struct and factors out the non-changing
bits into fields, making recursive calls in the implementation code easier
to read.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: riccibruno, doug.gregor, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371032 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert r361885 "[Driver] Fix -working-directory issues"
Hans Wennborg [Thu, 5 Sep 2019 08:43:00 +0000 (08:43 +0000)]
Revert r361885 "[Driver] Fix -working-directory issues"

This made clang unable to open files using relative paths on network shares on
Windows (PR43204). On the bug it was pointed out that createPhysicalFileSystem()
is not terribly mature, and using it is risky. Reverting for now until there's
a clear way forward.

> Currently the `-working-directory` option does not actually impact the working
> directory for all of the clang driver, it only impacts how files are looked up
> to make sure they exist.  This means that that clang passes the wrong paths
> to -fdebug-compilation-dir and -coverage-notes-file.
>
> This patch fixes that by changing all the places in the driver where we convert
> to absolute paths to use the VFS, and then calling setCurrentWorkingDirectory on
> the VFS.  This also changes the default VFS for `Driver` to use a virtualized
> working directory, instead of changing the process's working directory.
>
> Differential Revision: https://reviews.llvm.org/D62271

This also revertes the part of r369938 which checked that -working-directory works.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371027 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRename of constants in ASTImporterVisibilityTest. NFC.
Balazs Keri [Thu, 5 Sep 2019 07:59:45 +0000 (07:59 +0000)]
Rename of constants in ASTImporterVisibilityTest. NFC.

Reviewers: martong, a.sidorin, shafik

Reviewed By: shafik

Subscribers: shafik, rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371021 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAMDGPU: Add builtins for is_shared/is_private
Matt Arsenault [Thu, 5 Sep 2019 03:00:43 +0000 (03:00 +0000)]
AMDGPU: Add builtins for is_shared/is_private

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371010 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[c++20] Fix some ambiguities in our mangling of lambdas with explicit
Richard Smith [Thu, 5 Sep 2019 01:23:47 +0000 (01:23 +0000)]
[c++20] Fix some ambiguities in our mangling of lambdas with explicit
template parameters.

This finishes the implementation of the proposal described in
https://github.com/itanium-cxx-abi/cxx-abi/issues/31. (We already
implemented the <lambda-sig> extensions, but didn't take them into
account when computing mangling numbers, and didn't deal properly with
expanded parameter packs, and didn't disambiguate between different
levels of template parameters in manglings.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371004 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] scan-build: handle --sysroot=/path in addition to --sysroot /path.
Artem Dergachev [Thu, 5 Sep 2019 00:44:56 +0000 (00:44 +0000)]
[analyzer] scan-build: handle --sysroot=/path in addition to --sysroot /path.

Current code assumes flags in CompilerLinkerOptionMap don't use =,
which isn't always true.

Patch by Chris Laplante!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371002 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFor PR43213, track whether template parameters are implicit through
Richard Smith [Wed, 4 Sep 2019 22:14:50 +0000 (22:14 +0000)]
For PR43213, track whether template parameters are implicit through
template instantiation so we know whether to mangle them in
lambda-expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@370991 91177308-0d34-0410-b5e6-96231b3b80d8