Commit Graph

71521 Commits

Author SHA1 Message Date
Aaron Ballman adf66b6174 Determine the attribute subject for diagnostics based on declarative information in DeclNodes.td. This greatly reduces the number of enumerated values used for more complex diagnostics; these are now only required when the "attribute only applies to" diagnostic needs to be generated manually as part of semantic processing.
This also clarifies some terminology used by the diagnostic (methods -> Objective-C methods, fields -> non-static data members, etc).

Many of the tests needed to be updated in multiple places for the diagnostic wording tweaks. The first instance of the diagnostic for that attribute is fully specified and subsequent instances cut off the complete list (to make it easier if additional subjects are added in the future for the attribute).

llvm-svn: 319002
2017-11-26 20:01:12 +00:00
Aleksei Sidorin b05f37afcb [ASTImporter] Support TypeTraitExpr
Patch by Takafumi Kubota!

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

llvm-svn: 318998
2017-11-26 17:04:06 +00:00
Oren Ben Simhon fec21ec0c6 Control-Flow Enforcement Technology - Shadow Stack and Indirect Branch Tracking support (Clang side)
Shadow stack solution introduces a new stack for return addresses only.
The stack has a Shadow Stack Pointer (SSP) that points to the last address to which we expect to return.
If we return to a different address an exception is triggered.
This patch includes shadow stack intrinsics as well as the corresponding CET header.
It includes CET clang flags for shadow stack and Indirect Branch Tracking.

For more information, please see the following:
https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf

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

Change-Id: I79ad0925a028bbc94c8ecad75f6daa2f214171f1
llvm-svn: 318995
2017-11-26 12:34:54 +00:00
Craig Topper 9e032ed55a [X86] Use separate builtins for fma4 scalar intrinsics. Use negations to remove some of the scalar fma3 builtins.
fma4 instructions zero the upper bits of the xmm register. fma3 instructions leave the bits unmodified. This requires separate builtins for the different semantics.

While we're cleaning up the scalar builtins this also removes the fma3 fmsub/fnmadd/fnmsub builtins by using negates in the header file.

llvm-svn: 318985
2017-11-25 19:32:12 +00:00
Devin Coughlin cc5915a5e1 [analyzer] Teach RetainCountChecker about CoreMedia APIs
Teach the retain-count checker that CoreMedia reference types use
CoreFoundation-style reference counting. This enables the checker
to catch leaks and over releases of those types.

rdar://problem/33599757

llvm-svn: 318979
2017-11-25 14:57:42 +00:00
Martin Probst c160cfaf66 clang-format: [JS] do not collapse short classes.
Summary:
clang-format does not collapse short records, interfaces, unions, etc.,
but fails to do so if the record is preceded by certain modifiers
(export, default, abstract, declare). This change skips over all
modifiers, and thus handles all record definitions uniformly.

Before:
    export class Foo { bar: string; }
    class Baz {
      bam: string;
    }

After:
    export class Foo {
      bar: string;
    }
    class Baz {
      bam: string;
    }

Reviewers: djasper

Subscribers: klimek

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

llvm-svn: 318976
2017-11-25 09:35:33 +00:00
Martin Probst e8e27ca866 clang-format: [JS] handle semis in generic types.
Summary:
TypeScript generic type arguments can contain object (literal) types,
which in turn can contain semicolons:

    const x: Array<{a: number; b: string;} = [];

Previously, clang-format would incorrectly categorize the braced list as
a block and terminate the line at the openening `{`, and then format the
entire expression badly.

With this change, clang-format recognizes `<` preceding a `{` as
introducing a type expression. In JS, `<` comparison with an object
literal can never be true, so the chance of introducing false positives
here is very low.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 318975
2017-11-25 09:33:47 +00:00
Martin Probst 6c38ef90fd clang-format: [JS] handle `for` as object label.
Summary: Previously, clang-format would fail formatting `{for: 1}`.

Reviewers: djasper

Subscribers: klimek

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

llvm-svn: 318974
2017-11-25 09:24:33 +00:00
Martin Probst 7e0f25b28d clang-format: [JS] disable ASI on decorators.
Summary:
Automatic Semicolon Insertion in clang-format tries to guess if a line
wrap should insert an implicit semicolong. The previous heuristic would
not trigger ASI if a token was immediately preceded by an `@` sign:

    function foo(@Bar  // <-- does not trigger due to preceding @
                baz) {}

However decorators can have arbitrary parameters:

    function foo(@Bar(param, param, param)  // <-- precending @ missed
                baz) {}

While it would be possible to precisely find the matching `@`, just
conversatively disabling ASI for the entire line is simpler, while also
not regressing ASI substatially.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 318973
2017-11-25 09:19:42 +00:00
Krasimir Georgiev f09c42857f [clang-format] Deduplicate using declarations
Summary: This deduplicated equivalent using declarations within a block.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

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

llvm-svn: 318960
2017-11-24 18:00:01 +00:00
Martin Probst ce2bd4dfd8 clang-format: [JS] do not break in ArrayType[].
Summary:
Wrapping between the type name and the array type indicator creates
invalid syntax in TypeScript.

Before:
    const xIsALongIdent:
        YJustBarelyFitsLinex
            [];  // illegal syntax.

After:
    const xIsALongIdent:
        YJustBarelyFitsLinex[];

Reviewers: djasper

Subscribers: klimek

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

llvm-svn: 318959
2017-11-24 17:05:56 +00:00
Martin Probst a5968aad3d clang-format: [JS] do not wrap before yield.
Summary: The same rules apply as for `return`.

Reviewers: djasper

Subscribers: klimek

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

llvm-svn: 318958
2017-11-24 17:05:35 +00:00
Martin Probst a2555114b6 clang-format: [JS] space between ! assert and in.
Summary:
Before:
    x = y!in z;
After:
    x = y! in z;

Reviewers: djasper

Subscribers: klimek

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

llvm-svn: 318957
2017-11-24 17:04:40 +00:00
Ilya Biryukov 8318f61bb8 Avoid copying the data of in-memory preambles
Summary: Preambles are large and we should avoid copying them.

Reviewers: bkramer, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 318945
2017-11-24 13:12:38 +00:00
Sam McCall b50a36c8bc [Tooling] Acknowledge that many CompilationDatabases don't support enumeration.
Summary: Provide default implementations so that only getCompileCommands() is mandatory.

Reviewers: ioeric

Subscribers: cfe-commits, bkramer, klimek

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

llvm-svn: 318943
2017-11-24 12:13:55 +00:00
Martin Probst 70cec59e23 clang-format: [JS] handle destructuring `of`.
Summary:
Previously, clang-format would drop a space character between `of` and
then following (non-identifier) token if the preceding token was part of
a destructuring assignment (`}` or `]`).

Before:
    for (const [a, b] of[]) {}

After:
    for (const [a, b] of []) {}

Reviewers: djasper

Subscribers: klimek

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

llvm-svn: 318942
2017-11-24 10:48:25 +00:00
Adam Balogh da488a65e2 [ASTMatchers] Matchers for new[] operators
Two new matchers for `CXXNewExpr` are added which may be useful e.g. in
`clang-tidy` checkers. One of them is `isArray` which matches `new[]` but not
plain `new`. The other one, `hasArraySize` matches `new[]` for a given size.

llvm-svn: 318909
2017-11-23 12:43:20 +00:00
Olivier Goffart 270ced2bce Do not perform the analysis based warning if the warnings are ignored
This saves some cycles when compiling with "-w".

(Also fix a potential crash on invalid code for tools that tries to recover from some
errors, because analysis might compute the CFG which crashes if the code contains
invalid declaration. This does not happen normally with because we also don't perform
these analysis if there was an error.)

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

llvm-svn: 318900
2017-11-23 08:15:22 +00:00
Serge Pavlov 842022a0f1 [DeclPrinter] Allow printing fully qualified name of function declaration
When requesting a tooltip for a function call in an IDE, the fully
qualified name helps to remove ambiguity in the function signature.

Patch by Nikolai Kosjar!

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

llvm-svn: 318896
2017-11-23 05:38:20 +00:00
Eugene Zelenko 5e5e564ca6 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318888
2017-11-23 01:20:07 +00:00
Eugene Zelenko 2f8e66bbd8 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318882
2017-11-22 21:32:07 +00:00
Alexey Bataev 16e798873e [OPENMP] Add support for cancel constructs in `target teams distribute
parallel for`.

Add support for cancel/cancellation point directives inside `target
teams distribute parallel for` directives.

llvm-svn: 318881
2017-11-22 21:12:03 +00:00
Alexey Bataev dcb4b8fbc1 [OPENMP] Add support for cancel constructs in [teams] distribute
parallel for directives.

Added codegen/sema support for cancel constructs in [teams] distribute
parallel for directives.

llvm-svn: 318872
2017-11-22 20:19:50 +00:00
Petr Hosek 32c9de009a Revert "[CodeGen] Fix vtable not receiving hidden visibility when using push(visibility)"
This reverts commit r318853: tests are failing on Windows bots

llvm-svn: 318866
2017-11-22 19:50:17 +00:00
Alexey Bataev 438388c2ad [OPENMP] Added missed checks for for [simd] based directives.
Added missed checks/analysis for safelen/simdlen clauses + linear clause
in for [simd] based directives.

llvm-svn: 318860
2017-11-22 18:34:02 +00:00
Peter Collingbourne 048ac83973 CachePruning: Allow limiting the number of files in the cache directory.
The default limit is 1000000 but it can be configured with a cache
policy. The motivation is that some filesystems (notably ext4) have
a limit on the number of files that can be contained in a directory
(separate from the inode limit).

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

llvm-svn: 318857
2017-11-22 18:27:31 +00:00
Petr Hosek 9696dbb988 [CodeGen] Fix vtable not receiving hidden visibility when using push(visibility)
This change should resolve https://bugs.llvm.org/show_bug.cgi?id=35022

Patch by Jake Ehrlich

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

llvm-svn: 318853
2017-11-22 17:59:30 +00:00
Alexey Bataev 7f96c375ac [OPENMP] General improvement of code, NFC.
llvm-svn: 318849
2017-11-22 17:19:31 +00:00
Alexey Bataev b45d43c397 [OPENMP] Do not mark captured variables as artificial in debug info.
Captured variables should not be marked as artificial parameters in
outlined functions in debug info.

llvm-svn: 318843
2017-11-22 16:02:03 +00:00
Jonas Hahnfeld 891c7fb19d [OpenMP] Adjust arguments of nvptx runtime functions
In the future the compiler will analyze whether the OpenMP
runtime needs to be (fully) initialized and avoid that overhead
if possible. The functions already take an argument to transfer
that information to the runtime, so pass in the default value 1.
(This is needed for binary compatibility with libomptarget-nvptx
currently being upstreamed.)

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

llvm-svn: 318836
2017-11-22 14:46:49 +00:00
Alexey Bataev f9fc42e50b [OPENMP] Codegen for `target teams` directive.
Added codegen of the clauses for `target teams` directive.

llvm-svn: 318834
2017-11-22 14:25:55 +00:00
Malcolm Parsons 72e5d69826 [Docs] Update list of languages clang-format can format
llvm-svn: 318827
2017-11-22 10:47:35 +00:00
Petr Hosek 5668d83e0e [Driver] Make the use of relax relocations a per target option
The support for relax relocations is dependent on the linker and
different toolchains within the same compiler can be using different
linkers some of which may or may not support relax relocations.

Give toolchains the option to control whether they want to use relax
relocations in addition to the existing (global) build system option.

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

llvm-svn: 318816
2017-11-22 01:38:31 +00:00
Erich Keane 0a340ab31c [X86] Update CPUSupports code to reuse LLVM .def file [NFC]
llvm-svn: 318815
2017-11-22 00:54:01 +00:00
Eugene Zelenko 21fadadbf3 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318813
2017-11-21 23:26:08 +00:00
Richard Trieu 430c96b67a [OpenMP] Fix tests after r318789
Update use of __tgt_target that had some 32bit types updated to 64bit.

llvm-svn: 318811
2017-11-21 22:53:19 +00:00
Nirav Dave 61ffc9c0eb Avoid unecessary opsize byte in segment move to memory
Segment moves to memory are always 16-bit. Remove invalid 32 and 64
bit variants.

Recommiting with missing clang inline assembly test change.

Fixes PR34478.

Reviewers: rnk, craig.topper

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 318797
2017-11-21 19:28:13 +00:00
Aaron Ballman 52a3ca9e29 The offsetof macro is intended to work with subobjects rather than simple identifiers designating a member, making the -Wextended-offsetof diagnostic obsolete as this construct is not an extension. Implements WG14 DR496.
llvm-svn: 318796
2017-11-21 19:25:38 +00:00
Aaron Ballman 5f8980a995 Add an AST matcher for hasDefaultArgument() to match on parameter declarations that have a default value.
Patch by Julie Hockett.

llvm-svn: 318794
2017-11-21 19:22:34 +00:00
George Rokos 63bc9d6f66 [Clang][OpenMP] New clang/libomptarget map interface: new function signatures, clang-side
This clang patch changes the __tgt_* API function signatures in preparation for the new map interface.
Changes are: Device IDs 32bits --> 64bits, Flags 32bits --> 64bits

Differential revision: https://reviews.llvm.org/D40281

llvm-svn: 318789
2017-11-21 18:25:12 +00:00
Hans Wennborg 14e8a5a32d Add -finstrument-function-entry-bare flag
This is an instrumentation flag that's similar to
-finstrument-functions, but it only inserts calls on function entry, the
calls are inserted post-inlining, and they don't take any arugments.

This is intended for users who want to instrument function entry with
minimal overhead.

(-pg would be another alternative, but forces frame pointer emission and
affects link flags, so is probably best left alone to be used for
generating gcov data.)

Differential revision: https://reviews.llvm.org/D40276

llvm-svn: 318785
2017-11-21 17:30:34 +00:00
Alexey Bataev 7828b25251 [OPENMP] Initial support for asynchronous data update, NFC.
OpenMP 5.0 introduces asynchronous data update/dependecies clauses on
target data directives. Patch adds initial support for outer task
regions to use task-based codegen for future async target data
directives.

llvm-svn: 318781
2017-11-21 17:08:48 +00:00
Jonas Hahnfeld cfd162d8e5 Fix test/OpenMP/nvptx_data_sharing.cpp
This was an oversight that stayed in the test from development.

llvm-svn: 318779
2017-11-21 16:49:11 +00:00
Aleksei Sidorin 2697f8e4b2 [ASTImporter] Support new AST nodes:
* UnresolvedUsingType
 * EmptyDecl
 * NamespaceAliasDecl
 * UsingDecl
 * UsingShadowDecl
 * UsingDirectiveDecl
 * UnresolvedUsingValueDecl
 * UnresolvedUsingTypenameDecl

Refactor error handling in ImportTemplateArgumentLoc() method.
Add a test for inline namespaces.

llvm-svn: 318776
2017-11-21 16:08:41 +00:00
Gheorghe-Teodor Bercea eb89b1d46f [OpenMP] Add implicit data sharing support when offloading to NVIDIA GPUs using OpenMP device offloading
Summary:
This patch is part of the development effort to add support in the current OpenMP GPU offloading implementation for implicitly sharing variables between a target region executed by the team master thread and the worker threads within that team.

This patch is the first of three required for successfully performing the implicit sharing of master thread variables with the worker threads within a team. The remaining two patches are:
- Patch D38978 to the LLVM NVPTX backend which ensures the lowering of shared variables to an device memory which allows the sharing of references;
- Patch (coming soon) is a patch to libomptarget runtime library which ensures that a list of references to shared variables is properly maintained.

A simple code snippet which illustrates an implicit data sharing situation is as follows:

```
#pragma omp target
{
   // master thread only
   int v;
   #pragma omp parallel
   {
      // worker threads
      // use v
   }
}
```

Variable v is implicitly shared from the team master thread which executes the code in between the target and parallel directives. The worker threads must operate on the latest version of v, including any updates performed by the master.

The code generated in this patch relies on the LLVM NVPTX patch (mentioned above) which prevents v from being lowered in the thread local memory of the master thread thus making the reference to this variable un-shareable with the workers. This ensures that the code generated by this patch is correct.
Since the parallel region is outlined the passing of arguments to the outlined regions must preserve the original order of arguments. The runtime therefore maintains a list of references to shared variables thus ensuring their passing in the correct order. The passing of arguments to the outlined parallel function is performed in a separate function which the data sharing infrastructure constructs in this patch. The function is inlined when optimizations are enabled.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, Hahnfeld, ABataev, caomhin

Reviewed By: ABataev

Subscribers: cfe-commits, jholewinski

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

llvm-svn: 318773
2017-11-21 15:54:54 +00:00
Jonas Hahnfeld 4609b25dde Add target triples to openmp-offload-gpu.c
This might fix the failure on Green Dragon.

llvm-svn: 318767
2017-11-21 15:06:28 +00:00
Jonas Hahnfeld 7c78cc5273 [OpenMP] Consistently use cubin extension for nvlink
This was previously done in some places, but for example not for
bundling so that single object compilation with -c failed. In
addition cubin was used for all file types during unbundling which
is incorrect for assembly files that are passed to ptxas.
Tighten up the tests so that we can't regress in that area.

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

llvm-svn: 318763
2017-11-21 14:44:45 +00:00
Martell Malone 051e966e49 [MINGW] normalize WIN32 macros
move _WIN64 and _WIN32 defines to lib/Basic/Targets/OSTargets.h
move WIN32, WIN64 and __MINGW64__ to addMinGWDefines

fixes __MINGW64__ not being defined for aarch64
adds WIN32 definition for x64

Reviewers: mstorsjo

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

llvm-svn: 318755
2017-11-21 11:28:29 +00:00
Aleksei Sidorin 124f5de841 [Analyzer] Stable iteration on indirect goto LabelDecl's to avoid non-determinism (attempt 2)
CFG wass built in non-deterministic order due to the fact that indirect
goto labels' declarations (LabelDecl's) are stored in the llvm::SmallSet
container. LabelDecl's are pointers, whose order is not deterministic,
and llvm::SmallSet sorts them by their non-deterministic addresses after
"small" container is exceeded. This leads to non-deterministic processing
of the elements of the container.

The fix is to use llvm::SmallSetVector that was designed to have
deterministic iteration order.

Patch by Ilya Palachev!

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

llvm-svn: 318754
2017-11-21 11:27:47 +00:00
Aleksei Sidorin 7ac9be1ab7 [Analyzer] Revert r318750 because incorrect files were added for commit.
Sorry for the noise.

llvm-svn: 318753
2017-11-21 11:20:07 +00:00
Ivan A. Kosarev 5d9d32e820 [CodeGen] Generate TBAA type descriptors in a more reliable manner
This patch introduces a couple of helper functions that make it
possible to handle the caching logic in a single place.

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

llvm-svn: 318752
2017-11-21 11:18:06 +00:00
Aleksei Sidorin 3c3454b9d1 [Analyzer] Non-determinism: stable iteration on indirect goto LabelDecl's
CFG wass built in non-deterministic order due to the fact that indirect
goto labels' declarations (LabelDecl's) are stored in the llvm::SmallSet
container. LabelDecl's are pointers, whose order is not deterministic,
and llvm::SmallSet sorts them by their non-deterministic addresses after
"small" container is exceeded. This leads to non-deterministic processing
of the elements of the container.

The fix is to use llvm::SmallSetVector that was designed to have 
deterministic iteration order.

Patch by Ilya Palachev!

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

llvm-svn: 318750
2017-11-21 11:05:28 +00:00
Hamza Sood 81fe14e4c3 [Modules TS] Added module re-export support.
This implements [dcl.modules.export] from the C++ Modules TS, which lets a module re-export another module with the "export import" syntax.
Differential Revision: https://reviews.llvm.org/D40270

llvm-svn: 318744
2017-11-21 09:42:42 +00:00
Coby Tayree afdaa6704f [x86][inline-asm] allow recognition of MPX regs inside ms inline-asm blob
Differential Revision: https://reviews.llvm.org/D38445

llvm-svn: 318739
2017-11-21 08:50:10 +00:00
Martell Malone dca72fc4ea [MS] add an init test for thumbv7-windows-msvc
llvm-svn: 318736
2017-11-21 08:09:59 +00:00
Reid Kleckner 13a3d9eb7b [MS] Increase default new alignment for win64 and test it
Summary:
This raises __STDCPP_DEFAULT_NEW_ALIGNMENT__ from 8 to 16 on Win64.
This matches platforms that follow the usual `2 * sizeof(void*)`
alignment requirement for malloc. We might want to consider making that
the default rather than relying on long double alignment.

Fixes PR35356

Reviewers: STL_MSFT, rsmith

Subscribers: cfe-commits

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

llvm-svn: 318723
2017-11-21 01:25:56 +00:00
Zachary Turner 79708b54f2 Re-revert "Refactor debuginfo-tests."
This is still breaking greendragon.

At this point I give up until someone can fix the greendragon
bots, and I will probably abandon this effort in favor of using
a private github repository.

llvm-svn: 318722
2017-11-21 01:20:28 +00:00
David Blaikie 1de35438e4 ASTMatchers{,Macros}.h: Add some extra macros to use for decl/def of matchers
Fix ODR violations caused by using internal linkage variables in
non-internal inline functions. (also removes duplicate definitions, etc)

llvm-svn: 318720
2017-11-21 01:09:18 +00:00
David Blaikie 76ff65eb29 FormatInternal.h: Add missing includes.
llvm-svn: 318719
2017-11-21 01:09:17 +00:00
Craig Topper 0ff0fbbd6b [X86] Remove 'mm3now' from isValidFeatureName.
The correct spelling is '3dnow' which is already in the list.

llvm-svn: 318716
2017-11-21 00:33:26 +00:00
Alexander Shaposhnikov 8ee899d42e [analyzer] Diagnose stack leaks via block captures
This diff extends StackAddrEscapeChecker
to catch stack addresses leaks via block captures
if the block is executed asynchronously or
returned from a function.

Differential revision: https://reviews.llvm.org/D39438

llvm-svn: 318705
2017-11-20 22:53:30 +00:00
Erich Keane 523edb0a3a Revert r318669/318694
Broke some libclang tests, so reverting for now.

llvm-svn: 318698
2017-11-20 21:46:29 +00:00
Zachary Turner 8b6ef88e7e Resubmit "Refactor debuginfo-tests" again.
This was reverted due to the tests being run twice on some
build bots.  Each run had a slightly different configuration
due to the way in which it was being invoked.  This fixes
the problem (albeit in a somewhat hacky way).  Hopefully in
the future we can get rid of the workflow of running
debuginfo-tests as part of clang, and then this hack can
go away.

llvm-svn: 318697
2017-11-20 21:41:36 +00:00
Erich Keane 86785bb0bb Include test files for rL318668
Forgotten when doing my SVN commit.

llvm-svn: 318694
2017-11-20 21:15:01 +00:00
Carlo Bertolli 62fae15600 [OpenMP] Initial implementation of code generation for pragma 'teams distribute parallel for' on host
https://reviews.llvm.org/D40187

This patch implements code gen for 'teams distribute parallel for' on the host, including all its clauses and related regression tests.

llvm-svn: 318692
2017-11-20 20:46:39 +00:00
Mandeep Singh Grang 8f54ae15a0 [AutoComplete] Use stronger sort predicate for autocomplete candidates to remove non-deterministic ordering
Summary: This fixes the failure in test/Driver/autocomplete.c uncovered by D39245.

Reviewers: yamaguchi, teemperor, ruiu

Reviewed By: yamaguchi, ruiu

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 318681
2017-11-20 18:49:14 +00:00
Craig Topper 164186617e [Docs] Regenerate the command line option reference.
llvm-svn: 318672
2017-11-20 18:07:43 +00:00
Erich Keane 5c086c7626 For Linux/gnu compatibility, preinclude <stdc-predef.h> if the file is available
As reported in llvm bugzilla 32377.
Here’s a patch to add preinclude of stdc-predef.h.

The gcc documentation says “On GNU/Linux, <stdc-predef.h> is pre-included.” 
See https://gcc.gnu.org/gcc-4.8/porting_to.html;

The preinclude is inhibited with –ffreestanding.

Basically I fixed the failing test cases by adding –ffreestanding which inhibits
this behavior.

I fixed all the failing tests, including some in extra/test, there's a separate
patch for that which is linked here

Patch By: mibintc

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

llvm-svn: 318669
2017-11-20 17:57:42 +00:00
Hans Wennborg 59ad150939 Revert r318456 "Issue -Wempty-body warnings for else blocks"
This caused warnings also when the if or else comes from macros. There was an
attempt to fix this in r318556, but that introduced new problems and was
reverted. Reverting this too until the whole issue is sorted.

> This looks like it was just an oversight.
>
> Fixes http://llvm.org/pr35319
>
> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318456 91177308-0d34-0410-b5e6-96231b3b80d8

llvm-svn: 318667
2017-11-20 17:48:54 +00:00
Hans Wennborg 9541975071 Revert r318556 "Loosen -Wempty-body warning"
It seems this somehow made -Wempty-body fire in some macro cases where
it didn't before, e.g.

  ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  error: if statement has empty body [-Werror,-Wempty-body]
      ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
      ^
  ../../third_party/ffmpeg\libavutil/internal.h(276,80):  note: expanded from macro 'ff_dlog'
  #   define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
                                                                                 ^
  ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  note: put the
  semicolon on a separate line to silence this warning

Reverting until this can be figured out.

> Do not show it when `if` or `else` come from macros.
> E.g.,
>
>     #define USED(A) if (A); else
>     #define SOME_IF(A) if (A)
>
>     void test() {
>       // No warnings are shown in those cases now.
>       USED(0);
>       SOME_IF(0);
>     }
>
> Patch by Ilya Biryukov!
>
> Differential Revision: https://reviews.llvm.org/D40185

llvm-svn: 318665
2017-11-20 17:38:16 +00:00
Craig Topper 402b431051 [CodeGen] Move Reciprocals option from TargetOptions to CodeGenOptions
Diffrential Revision: https://reviews.llvm.org/D40226

llvm-svn: 318662
2017-11-20 17:09:22 +00:00
Peter Smith 931c9fa8fe [ARM] For assembler files recognize -Xassembler or -Wa, -mthumb
Attempt to fix warning picked up by buildbot.

llvm-svn: 318648
2017-11-20 13:53:55 +00:00
Peter Smith 3947cb3cf0 [ARM] For assembler files recognize -Xassembler or -Wa, -mthumb
The Unified Arm Assembler Language is designed so that the majority of
assembler files can be assembled for both Arm and Thumb with the choice
made as a compilation option.

The way this is done in gcc is to pass -mthumb to the assembler with either
-Wa,-mthumb or -Xassembler -mthumb. This change adds support for these
options to clang. There is no assembler equivalent of -mno-thumb, -marm or
-mno-arm so we don't need to recognize these.

Ideally we would do all of the processing in
CollectArgsForIntegratedAssembler(). Unfortunately we need to change the
triple and at that point it is too late. Instead we look for the option
earlier in ComputeLLVMTriple().
    
Fixes PR34519
    
Differential Revision: https://reviews.llvm.org/D40127

llvm-svn: 318647
2017-11-20 13:43:55 +00:00
Ivan A. Kosarev fa03a6a034 [Driver] Add a cc1 flag for the new TBAA metadata format
This patch starts a series of changes to add support for the new
TBAA metadata format proposed in this llvm-dev thread:

http://lists.llvm.org/pipermail/llvm-dev/2017-November/118748.html

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

llvm-svn: 318644
2017-11-20 11:16:16 +00:00
Craig Topper fc1b8b12c7 [X86] Make sure 'knm' is accepted by -target-cpu
llvm-svn: 318620
2017-11-19 04:12:35 +00:00
Craig Topper e12ec3fc43 [X86] Make sure 'knm' and 'cannonlake' are accepted by builtin_cpu_is
llvm-svn: 318619
2017-11-19 04:12:33 +00:00
Craig Topper 546cee4170 [X86] Add icelake CPU support for -march.
llvm-svn: 318617
2017-11-19 02:55:15 +00:00
Craig Topper 222c1725cd [X86] Set __corei7__ preprocessor defines for skylake server and cannonlake.
This is the resolution we came to in D38824.

llvm-svn: 318616
2017-11-19 02:55:14 +00:00
Saleem Abdulrasool b3a66f7641 Driver: remove `SupportsObjCGC` (NFC)
This option is not used in the frontend.  Remove the method.

llvm-svn: 318609
2017-11-19 00:45:33 +00:00
Martell Malone 13c5d7379a [Driver] add initial support for alpine linux
set -pie as default for musl linux targets
add detection of alpine linux
append appropriate compile flags for alpine

Reviewers: rnk

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

llvm-svn: 318608
2017-11-19 00:08:12 +00:00
Jonas Hahnfeld 87d4426988 [OpenMP] Show error if VLAs are not supported
Some target devices (e.g. Nvidia GPUs) don't support dynamic stack
allocation and hence no VLAs. Print errors with description instead
of failing in the backend or generating code that doesn't work.

This patch handles explicit uses of VLAs (local variable in target
or declare target region) or implicitly generated (private) VLAs
for reductions on VLAs or on array sections with non-constant size.

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

llvm-svn: 318601
2017-11-18 21:00:46 +00:00
Sanjay Patel 7b61dc7a23 [CodeGen] change const-ness of complex calls
After clarification about the C standard, POSIX, and implementations:
The C standard allows errno-setting, and it's (unfortunately for optimization) even 
more clearly stated in the newer additions to the standards.

We can leave these functions as always constant ('c') because they don't 
actually do any math and therefore won't set errno:
cimag ( http://en.cppreference.com/w/c/numeric/complex/cimag )
creal ( http://en.cppreference.com/w/c/numeric/complex/creal )
cproj ( http://en.cppreference.com/w/c/numeric/complex/cproj )
conj (http://en.cppreference.com/w/c/numeric/complex/conj ) 

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

llvm-svn: 318598
2017-11-18 19:31:57 +00:00
Eugene Zelenko 821f6983dc [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318582
2017-11-18 01:47:41 +00:00
Hans Wennborg 989a65cd29 Fix some -Wunused-variable warnings
llvm-svn: 318578
2017-11-18 00:49:18 +00:00
Eugene Zelenko fd70e5de39 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318570
2017-11-17 23:43:46 +00:00
Anna Zaks 8ffd1932d0 Change code owner for Clang Static Analyzer to Devin Coughlin.
Differential Revision: https://reviews.llvm.org/D39964

llvm-svn: 318567
2017-11-17 23:19:04 +00:00
Michal Gorny ba996aba01 [cmake] Use llvm-lit directory when provided for stand-alone build
After the recent lit test changes, clang attempts to run its tests
via llvm-lit by default. However, the llvm-lit binary is not present
when performing stand-alone build resulting in a failure out of the box.

To solve that, add the llvm-lit directory to CMake when performing
a stand-alone build and LLVM sources are provided. This includes
the CMake rules generating the llvm-lit binary and effectively makes
it possible for clang to use it.

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

llvm-svn: 318562
2017-11-17 22:21:23 +00:00
Reid Kleckner 66f58909f8 Fix coverage test on Windows bot
llvm-svn: 318559
2017-11-17 21:55:23 +00:00
Reid Kleckner c0a81071d3 Loosen -Wempty-body warning
Do not show it when `if` or `else` come from macros.
E.g.,

    #define USED(A) if (A); else
    #define SOME_IF(A) if (A)

    void test() {
      // No warnings are shown in those cases now.
      USED(0);
      SOME_IF(0);
    }

Patch by Ilya Biryukov!

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

llvm-svn: 318556
2017-11-17 21:33:28 +00:00
Alex Lorenz 42a97a94ca [ObjC][ARC] Honor noescape attribute for -Warc-retain-cycles
rdar://35409566

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

llvm-svn: 318552
2017-11-17 20:44:25 +00:00
Ahmed Bougacha 5d0199a218 [CodeGen] Compute the objc EH vtable address point using inbounds GEP.
The object is provided by the objc runtime and is never visible in the
module itself, but even so, the address point we compute points into it,
and "+16" is guaranteed not to overflow.

This matches the c++ vtable IRGen.

Note that I'm not entirely convinced the 'i8*' type is correct here: at
the IR level, we're accessing memory that's outside the global object.
But we don't control the allocation, so it's not obviously wrong either.
But either way, this is only in a global initializer, so I don't think
it's going to be mucked with.  Filed PR35352 to discuss that.

llvm-svn: 318545
2017-11-17 19:46:47 +00:00
Eugene Zelenko ae304b0717 [AST] Partially revert r318341 to fix two broken tests on llvm-clang-x86_64-expensive-checks-win (NFC).
llvm-svn: 318538
2017-11-17 18:09:48 +00:00
Martin Probst a004b3f50f clang-format: remove trailing lines in lamdas and arrow functions.
Summary:
clang-format already removes empty lines at the beginning & end of
blocks:

    int x() {

      foo();  // lines before and after will be removed.

    }

However because lamdas and arrow functions are parsed as expressions,
the existing logic to remove empty lines in UnwrappedLineFormatter
doesn't handle them.

This change special cases arrow functions in ContinuationIndenter to
remove empty lines:

    x = []() {

      foo();  // lines before and after will now be removed.

    };

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 318537
2017-11-17 18:06:33 +00:00
Alexey Bataev f836537516 [OPENMP] Codegen for `target simd` construct.
Added codegen support for `target simd` directive.

llvm-svn: 318536
2017-11-17 17:57:25 +00:00
Stephan Bergmann 15b87c6de3 Indent code blocks so they are actually treated as such
llvm-svn: 318530
2017-11-17 16:34:36 +00:00
Dave Lee 984964a04f Fix skipping of flags in getClangStripDependencyFileAdjuster
Summary:
The ArgumentsAdjuster returned from `getClangStripDependencyFileAdjuster` will
skip dependency flags, and also their associated values for those flags that
take an argument. This change corrects the handling of the `-MD` and `-MMD`
flags, which do not take an argument.

Reviewers: saugustine, klimek, alexshap

Reviewed By: alexshap

Subscribers: cfe-commits

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

llvm-svn: 318529
2017-11-17 16:27:21 +00:00
Krasimir Georgiev 6649665d5a [clang-format] Add text proto filename detection
Summary: Adds text proto filename detection.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 318525
2017-11-17 15:10:49 +00:00
Manuel Klimek 7786614350 Implement more accurate penalty & trade-offs while breaking protruding tokens.
For each line that we break in a protruding token, compute whether the
penalty of breaking is actually larger than the penalty of the excess
characters. Only break if that is the case.

llvm-svn: 318515
2017-11-17 11:17:15 +00:00
Ilya Biryukov dd9ea751e1 Use llvm-config.h instead of config.h
To fix standalone builds broken by r318411 (config.h is private to llvm).

llvm-svn: 318514
2017-11-17 10:09:02 +00:00
Martin Storsjo ec82128971 [MinGW] Define __ARM_DWARF_EH__ for MinGW/ARM
Since SVN r318510, the MinGW/ARM configuration defaults to
dwarf exception handling.

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

llvm-svn: 318511
2017-11-17 08:06:49 +00:00
Bruno Cardoso Lopes b5b0c02249 Change path used in a test from r318503 to work on windows
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/13565

llvm-svn: 318507
2017-11-17 04:26:07 +00:00
Bruno Cardoso Lopes a66a325bbc [PCH+Modules] Improve diagnosticts to help out users pass an extra header search path
When mixing PCH and Implicit Modules, missing a header search path
can lead to the implicit built PCM to complaint about not finding its
matching module map.

Instead of adding more magic to implicit modules engine, add a note to
help the user add the appropriate path.

rdar://problem/33388847

llvm-svn: 318503
2017-11-17 03:24:11 +00:00
Justin Lebar 370c766e40 [CUDA] Remove implementations of nexttoward.
Summary:
__builtin_nexttoward lowers to a libcall, e.g. nexttowardf(), that CUDA
does not have.

Rather than try to implement it, we simply remove these functions --
nvcc doesn't support them either, and nextafter, which does work, does
essentially the same thing on GPUs, because GPUs don't have long double.

Reviewers: tra

Subscribers: cfe-commits, sanjoy

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

llvm-svn: 318494
2017-11-17 01:15:43 +00:00
David Blaikie 68d00b0b67 Update for layering fix in LLVM CodeGen<>Target
llvm-svn: 318491
2017-11-17 01:07:20 +00:00
Zachary Turner b5c237ec3d Re-revert "Refactor debuginfo-tests"
This is still broken because it causes certain tests to be
run twice with slightly different configurations, which is
wrong in some cases.

You can observe this by running:

  ninja -nv check-all | grep debuginfo-tests

And seeing that it passes clang/test and clang/test/debuginfo-tests
to lit, which causes it to run debuginfo-tests twice.  The fix is
going to involve either:

  a) figuring out that we're running in this "deprecated" configuration,
     and then deleting the clang/test/debuginfo-tests path, which should
     cause it to behave identically to before, or:
  b) make lit smart enough that it doesn't descend into a sub-suite if
     that sub-suite already has a lit.cfg file.

llvm-svn: 318486
2017-11-17 00:41:18 +00:00
Richard Smith e2467b7aed PR22763: if a defaulted (non-user-provided) special member function is
explicitly instantiated, still emit it with each use.

We don't emit a definition of the member with an explicit instantiation
definition (and indeed it appears that we're not allowed to, since an explicit
instantiation definition does not constitute an odr-use and only odr-use
permits definition for defaulted special members). So we still need to emit a
weak definition with each use.

This also makes defaulted-in-class declarations behave more like
implicitly-declared special members, which matches their design intent.
And it matches the way this problem was solved in GCC.

llvm-svn: 318474
2017-11-16 23:54:56 +00:00
Reid Kleckner adefb760a8 Issue -Wempty-body warnings for else blocks
This looks like it was just an oversight.

Fixes http://llvm.org/pr35319

llvm-svn: 318456
2017-11-16 21:26:18 +00:00
Ben Hamilton 7838101678 [VirtualFileSystem] Support creating directories then adding files inside
Summary:
In https://reviews.llvm.org/D39572 , I added support for specifying
`Type` when invoking `InMemoryFileSystem::addFile()`.

However, I didn't account for the fact that when `Type` is
`directory_file`, we need to construct an `InMemoryDirectory`, not an
`InMemoryFile`, or else clients cannot create files inside that
directory.

This diff fixes the bug and adds a test.

Test Plan: New test added. Ran test with:

  % make -j12 check-clang-tools

Reviewers: bkramer, hokein

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 318445
2017-11-16 19:34:08 +00:00
Reid Kleckner 06239e42c6 [MS] Apply adjustments after storing 'this'
Summary:
The MS ABI convention is that the 'this' pointer on entry is the address
of the vfptr that was used to make the virtual method call. In other
words, the pointer on entry always points to the base subobject that
introduced the virtual method. Consider this hierarchy:

  struct A { virtual void f() = 0; };
  struct B { virtual void g() = 0; };
  struct C : A, B {
    void f() override;
    void g() override;
  };

On entry to C::g, [ER]CX will contain the address of C's B subobject,
and C::g will have to subtract sizeof(A) to recover a pointer to C.

Before this change, we applied this adjustment in the prologue and
stored the new value into the "this" local variable alloca used for
debug info. However, MSVC does not do this, presumably because it is
often profitable to fold the adjustment into later field accesses. This
creates a problem, because the debugger expects the variable to be
unadjusted. Unfortunately, CodeView doesn't have anything like DWARF
expressions for computing variables that aren't in the program anymore,
so we have to declare 'this' to be the unadjusted value if we want the
debugger to see the right value.

This has the side benefit that, in optimized builds, the 'this' pointer
will usually be available on function entry because it doesn't require
any adjustment.

Reviewers: hans

Subscribers: aprantl, cfe-commits

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

llvm-svn: 318440
2017-11-16 19:09:36 +00:00
Zachary Turner 5e420717a1 Resubmit "Refactor debuginfo-tests"
This was reverted due to some failures on specific darwin buildbots,
the issue being that the new lit configuration was not setting the
SDKROOT environment variable.  We've tested a fix locally and confirmed
that it works, so this patch resubmits everything with the fix
applied.

llvm-svn: 318435
2017-11-16 18:26:20 +00:00
Alexey Bataev 2139ed638b [OPENMP] Add support for cancelling inside target parallel for
directive.

Added missed support for cancelling of target parallel for construct.

llvm-svn: 318434
2017-11-16 18:20:21 +00:00
Yaxun Liu abf5b27f7a Update tests for llvm.invariant.group.barrier becoming mangled
Differential Revision: https://reviews.llvm.org/D40062

llvm-svn: 318414
2017-11-16 16:33:04 +00:00
Ilya Biryukov 417085ac37 Allow to store precompiled preambles in memory.
Summary:
These preambles are built by ASTUnit and clangd. Previously, preambles
were always stored on disk.

In-memory preambles are routed back to the compiler as virtual files in
a custom VFS.

Interface of ASTUnit does not allow to use in-memory preambles, as
ASTUnit::CodeComplete receives FileManager as a parameter, so we can't
change VFS used by the compiler inside the CodeComplete method.

A follow-up commit will update clangd in clang-tools-extra to use
in-memory preambles.

Reviewers: klimek, sammccall, bkramer

Reviewed By: klimek

Subscribers: ioeric, cfe-commits

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

llvm-svn: 318411
2017-11-16 16:25:01 +00:00
Eric Christopher f18016c640 Add NDEBUG checks around LLVM_DUMP_METHOD functions for Wunused-function warnings.
llvm-svn: 318371
2017-11-16 03:18:09 +00:00
Alex Lorenz dc616faa44 [DeclPrinter] Extract function PrintConstructorInitializers, NFC
Patch by Nikolai Kosjar!

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

llvm-svn: 318367
2017-11-16 01:31:27 +00:00
Alex Lorenz 35019dbe6b [DeclPrinter] Honor TerseOutput for constructors
Patch by Nikolai Kosjar!

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

llvm-svn: 318365
2017-11-16 01:28:25 +00:00
NAKAMURA Takumi 194d1a621d clang/module.modulemap: clang/Basic/X86Target.def may be textual header.
llvm-svn: 318347
2017-11-15 23:04:44 +00:00
Erich Keane bc4679880c Add X86Target.def that was forgotten in r30734
llvm-svn: 318345
2017-11-15 22:36:24 +00:00
Erich Keane 6da1108659 Split x86 "Processor" info into its own def file. [NFC]
A first step toward removing the repetition of
features/CPU info in the x86 target info, this
patch pulls all the processor information out into
its own .def file.

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

llvm-svn: 318343
2017-11-15 22:25:39 +00:00
Eugene Zelenko 11a7ef8559 [AST, Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318341
2017-11-15 22:00:04 +00:00
Hans Wennborg 0abe0cacc4 Try to fix test/SemaCXX/deleted-operator.cpp after r318309
The number of 'built-in candidate' notes now varies since __float128 may
or may not be a candidate depending on the target.

llvm-svn: 318314
2017-11-15 17:47:58 +00:00
Hans Wennborg 8237141be1 BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on the target (PR35174)
In the PR, Clang ended up in a situation where it tried to mangle the
__float128 type, which isn't supported when targetingt MSVC, because
Clang instantiated a variable template with that type when searching for
a conversion to use in an arithmetic expression.

Differential revision: https://reviews.llvm.org/D39579

llvm-svn: 318309
2017-11-15 17:11:53 +00:00
David Blaikie ac7e3d6451 ASTMatchers.h: Fix ODR violations by avoiding internal linkage variables in headers
Internal linkage variables ODR referenced from inline functions create
ODR violations (the same inline function ends up having different
definitions in each TU, since it references different variables - rather
than one definition).

This also happens to break modular code generation - so this is the last
fix to allow clang to compile with modular code generation.

llvm-svn: 318304
2017-11-15 16:52:12 +00:00
Benjamin Kramer 99f9759d96 [libclang] Fix cursors for in-class initializer of field declarations
Fixes PR33745.

Patch by Nikolai Kosjar!

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

llvm-svn: 318292
2017-11-15 12:20:41 +00:00
Alexey Bader bed400957b [OpenCL] Fix code generation of function-scope constant samplers.
Summary:
Constant samplers are handled as static variables and clang's code generation
library, which leads to llvm::unreachable. We bypass emitting sampler variable
as static since it's translated to a function call later.

Reviewers: yaxunl, Anastasia

Reviewed By: yaxunl, Anastasia

Subscribers: cfe-commits

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

llvm-svn: 318290
2017-11-15 11:38:17 +00:00
Sam McCall 1102a861f5 [clang] Expose orderedString from CodeCompletionResult. NFC
llvm-svn: 318286
2017-11-15 09:15:06 +00:00
NAKAMURA Takumi 14d7cf66a1 ASTMatchers.h: Avoid warnings due to "@throw". [-Wdocumentation]
llvm-svn: 318274
2017-11-15 06:53:45 +00:00
Richard Smith efdb50375f PR35214: don't crash if we see an array of unknown bound added to an empty but invalid designator.
llvm-svn: 318258
2017-11-15 03:03:56 +00:00
Richard Smith 85567ddaba [modules] Fix crash in complex class merging scenario.
When we merge together class definitions, we can end up with the canonical
declaration of a field not being the one that was lexically within the
canonical definition of the class. Additionally, when we merge class
definitions via update records (eg, for a template specialization whose
declaration is instantiated in one module and whose definition is instantiated
in multiple others), we can end up with the list of lexical contents for the
class not including a particular declaration of a field whose lexical parent is
that class definition. In the worst case, we have a field whose canonical
declaration's lexical parent has no fields, and in that case this attempt to
number the fields by walking the fields in the declaration of the class that
contained one of the canonical fields will fail.

Instead, when numbering fields in a class, do the obvious thing: walk the
fields in the definition.

I'm still trying to reduce a testcase; the setup that leads to the above
scenario seems to be quite fragile.

llvm-svn: 318245
2017-11-15 01:33:46 +00:00
Erich Keane 8202521cf5 Simplify CpuIs code to use include from LLVM
LLVM exposes a file in the backend (X86TargetParser.def) that
contains information about the correct list of CpuIs values.

This patch removes 2 of the copied and pasted versions of this
list from clang and instead includes the data from the .def file.

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

llvm-svn: 318234
2017-11-15 00:11:24 +00:00
Vedant Kumar 6186971a4a [PGO] Detect more structural changes with the stable hash
Lifting from Bob Wilson's notes: The hash value that we compute and
store in PGO profile data to detect out-of-date profiles does not
include enough information. This means that many significant changes to
the source will not cause compiler warnings about the profile being out
of date, and worse, we may continue to use the outdated profile data to
make bad optimization decisions.  There is some tension here because
some source changes won't affect PGO and we don't want to invalidate the
profile unnecessarily.

This patch adds a new hashing scheme which is more sensitive to loop
nesting, conditions, and out-of-order control flow. Here are examples
which show snippets which get the same hash under the current scheme,
and different hashes under the new scheme:

Loop Nesting Example
--------------------

  // Snippet 1
  while (foo()) {
    while (bar()) {}
  }

  // Snippet 2
  while (foo()) {}
  while (bar()) {}

Condition Example
-----------------

  // Snippet 1
  if (foo())
    bar();
  baz();

  // Snippet 2
  if (foo())
    bar();
  else
    baz();

Out-of-order Control Flow Example
---------------------------------

  // Snippet 1
  while (foo()) {
    if (bar()) {}
    baz();
  }

  // Snippet 2
  while (foo()) {
    if (bar())
      continue;
    baz();
  }

In each of these cases, it's useful to differentiate between the
snippets because swapping their profiles gives bad optimization hints.

The new hashing scheme considers some logical operators in an effort to
detect more changes in conditions. This isn't a perfect scheme. E.g, it
does not produce the same hash for these equivalent snippets:

  // Snippet 1
  bool c = !a || b;
  if (d && e) {}

  // Snippet 2
  bool f = d && e;
  bool c = !a || b;
  if (f) {}

This would require an expensive data flow analysis. Short of that, the
new hashing scheme looks reasonably complete, based on a scan over the
statements we place counters on.

Profiles which use the old version of the PGO hash remain valid and can
be used without issue (there are tests in tree which check this).

rdar://17068282

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

llvm-svn: 318229
2017-11-14 23:56:53 +00:00
Eugene Zelenko 1eab6c12f7 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318221
2017-11-14 23:35:42 +00:00
Eugene Zelenko 4a5354fd36 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318216
2017-11-14 23:13:32 +00:00
Alex Lorenz 8337f81f68 [refactor][selection] canonicalize decl ref callee to the call expr
We would like to extract the full call when just the callee function is
selected

llvm-svn: 318215
2017-11-14 23:10:50 +00:00
Hans Wennborg 57dd59d472 Try to fix the instrument-functions tests
On e.g. PPC the return value and argument were marked 'signext'. This
makes the test expectations a bit more flexible.

Follow-up to r318199.

llvm-svn: 318214
2017-11-14 23:10:04 +00:00
Alex Lorenz f64d0a4d00 [refactor][selection] canonicalize member expr callee to the full
member call expression

We would like to extract the full call when just the callee is selected.

llvm-svn: 318205
2017-11-14 22:06:55 +00:00
Hans Wennborg 76c26c1dca Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes
This updates -mcount to use the new attribute names (LLVM r318195), and
switches over -finstrument-functions to also use these attributes rather
than inserting instrumentation in the frontend.

It also adds a new flag, -finstrument-functions-after-inlining, which
makes the cygprofile instrumentation get inserted after inlining rather
than before.

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

llvm-svn: 318199
2017-11-14 21:13:27 +00:00
Alexey Bataev 817d7f36e9 [OPENMP] Fix DSA analysis for threadprivates after deserialization.
If threadprivate vaible is deserialized, it is not marked as
threadprivate in DSAStack.

llvm-svn: 318194
2017-11-14 21:01:01 +00:00
Alex Lorenz cc55754a79 [refactor][extract] avoid extracting expressions from types in functions
llvm-svn: 318169
2017-11-14 18:59:01 +00:00
Sam McCall ed1b3f71ff [tooling] Make compile_flags.txt negative test more hermetic
llvm-svn: 318154
2017-11-14 15:22:34 +00:00
Dave Lee be39868bfc Make isDefinition matcher support ObjCMethodDecl
Summary:
Allow the `isDefinition()` matcher to apply to `ObjCMethodDecl` nodes, in
addition to those it already supports. For whatever reason, `ObjCMethodDecl`
does not inherit from `FunctionDecl` and so this is specialization is necessary.

Reviewers: aaron.ballman, malcolm.parsons, alexshap

Reviewed By: aaron.ballman

Subscribers: cfe-commits, klimek

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

llvm-svn: 318152
2017-11-14 14:17:26 +00:00
Gabor Horvath 328d3afc3b Make DiagnosticIDs::getAllDiagnostics static. NFC.
Patch by: Andras Leitereg!

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

llvm-svn: 318150
2017-11-14 12:14:49 +00:00
Gabor Horvath 7a91c08414 [ASTImporter] TypeAliasTemplate and PackExpansion importing capability
Patch by: Zoltan Gera!

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

llvm-svn: 318147
2017-11-14 11:30:38 +00:00
Erik Verbruggen 3cc3911cc0 [libclang] Allow crash recovery with LIBCLANG_NOTHREADS
Enabled crash recovery for some libclang operations on a calling thread even
when LIBCLANG_NOTHREAD is specified.

Previously it would only run under crash recovery if LIBCLANG_NOTHREAD is not
set. Moved handling of LIBCLANG_NOTHREAD env variable into RunSafely from its
call sites.

llvm-svn: 318142
2017-11-14 09:34:39 +00:00
Manuel Klimek 45ab559ee7 Refactor ContinuationIndenter's breakProtrudingToken logic.
Create more orthogonal pieces. The restructuring made it easy to try out
several alternatives to D33589, and while none of the alternatives
turned out to be the right solution, the underlying simplification of
the structure is helpful.

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

llvm-svn: 318141
2017-11-14 09:19:53 +00:00
Craig Topper 926b95c4dd [NewPassManager] Pass the -fdebug-pass-manager flag setting into the Analysis managers to match what we do in opt
Summary: Currently the -fdebug-pass-manager flag for clang doesn't enable the debug logging in the analysis managers. This is different than what the switch does when passed to opt.

Reviewers: chandlerc

Reviewed By: chandlerc

Subscribers: cfe-commits

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

llvm-svn: 318140
2017-11-14 08:48:28 +00:00
Chandler Carruth 77c8bb19db [PM] Require a registered x86 target for this test which uses the x86
triple.

llvm-svn: 318137
2017-11-14 05:20:03 +00:00
Chandler Carruth a8bd4e3816 [PM] Wire up support for the bounds checking sanitizer with the new PM.
Not much interesting here. Mostly wiring things together.

One thing worth noting is that the approach is substantially different
from the old PM. Here, the -O0 case works fundamentally differently in
that we just directly build the pipeline without any callbacks or other
cruft. In some ways, this is nice and clean. However, I don't like that
it causes the sanitizers to be enabled with different changes at
different times. =/ Suggestions for a better way to do this are welcome.

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

llvm-svn: 318131
2017-11-14 01:59:18 +00:00
Chandler Carruth afce44949a [PM] Add a missing header that I had in the next commit but was needed
in r318128. Should fix the build.

llvm-svn: 318130
2017-11-14 01:47:24 +00:00
Alex Lorenz f3df1f7bf1 [completion] complete ObjC interface names in an expression
Objective-C interfaces can be used in a class property expression.

rdar://26982192

llvm-svn: 318129
2017-11-14 01:46:24 +00:00
Chandler Carruth 00a301d568 [PM] Port BoundsChecking to the new PM.
Registers it and everything, updates all the references, etc.

Next patch will add support to Clang's `-fexperimental-new-pass-manager`
path to actually enable BoundsChecking correctly.

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

llvm-svn: 318128
2017-11-14 01:30:04 +00:00
Mandeep Singh Grang e66d232c05 [Sema] Stable sort OverloadCandidates to remove non-deterministic ordering
Summary: This fixes failure in Misc/diag-template-diffing.cpp uncovered by D39245.

Reviewers: rjmccall, rsmith

Reviewed By: rjmccall

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 318121
2017-11-14 00:22:24 +00:00
Zachary Turner faf04a09f6 Revert "Update test_debuginfo.pl script to point to new tree location."
This reverts the aforementioned patch and 2 subsequent follow-ups,
as some buildbots are still failing 2 tests because of it.
Investigation is ongoing into the cause of the failures.

llvm-svn: 318112
2017-11-13 23:33:29 +00:00
Hans Wennborg 656c8629e2 Update link to protobuf
llvm-svn: 318110
2017-11-13 23:27:55 +00:00
Hans Wennborg 5fd1f17370 Update a link to the old code.google.com bug tracker
llvm-svn: 318109
2017-11-13 23:27:54 +00:00
Hans Wennborg 6ad65fcd70 Update link to the Chromium Clang page
llvm-svn: 318108
2017-11-13 23:27:53 +00:00
Eugene Zelenko de0215ccf3 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318101
2017-11-13 23:01:27 +00:00
Matt Arsenault a5888a730d OpenCL: Assume inline asm is convergent
Already done for CUDA.

llvm-svn: 318098
2017-11-13 22:40:55 +00:00
Sanjay Patel 33f83995a8 [CodeGen] fix const-ness of cbrt and fma
cbrt() is always constant because it can't overflow or underflow. Therefore, it can't set errno.

fma() is not always constant because it can overflow or underflow. Therefore, it can set errno.
But we know that it never sets errno on GNU / MSVC, so make it constant in those environments.

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

llvm-svn: 318093
2017-11-13 22:11:49 +00:00
Mandeep Singh Grang 789b19a6b6 [clang] Remove redundant return [NFC]
Reviewers: rsmith, sfantao, mcrosier

Reviewed By: mcrosier

Subscribers: jholewinski, cfe-commits

Tags: #clang

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

llvm-svn: 318074
2017-11-13 19:29:31 +00:00
Devin Coughlin 5df6b94381 [analyzer] ObjCGenerics: Don't warn on cast conversions involving explicit cast
The ObjCGenerics checker warns on a cast when there is no subtyping relationship
between the tracked type of the value and the destination type of the cast. It
does this even if the cast was explicitly written. This means the user can't
write an explicit cast to silence the diagnostic.

This commit treats explicit casts involving generic types as an indication from
the programmer that the Objective-C type system is not rich enough to express
the needed invariant. On explicit casts, the checker now removes any existing
information inferred about the type arguments. Further, it no longer assumes
the casted-to specialized type because the invariant the programmer specifies
in the cast may only hold at a particular program point and not later ones. This
prevents a suppressing cast from requiring a cascade of casts down the
line.

rdar://problem/33603303

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

llvm-svn: 318054
2017-11-13 17:35:29 +00:00
Teresa Johnson 4cd016ab7c [ThinLTO] Handle -fdebug-pass-manager for backend invocations via clang
Recommit of r317951 and r317951 along with what I believe should fix
the remaining buildbot failures - the target triple should be specified
for both the ThinLTO pre-thinlink compile and backend (post-thinlink)
compile to ensure it is consistent.

Original description:
The LTO Config field wasn't being set when invoking a ThinLTO backend
via clang (i.e. for distributed builds).

llvm-svn: 318042
2017-11-13 15:38:33 +00:00
Uriel Korach 5b2b71d909 [X86] test/testn intrinsics lowering to IR. clang side
Change Header files of the intrinsics for lowering test and testn intrinsics to IR code.
Removed test and testn builtins from clang

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

llvm-svn: 318035
2017-11-13 12:50:52 +00:00
Jina Nahias aecd4f5f9d Change
// CHECK: shufflevector <8 x double> %0, <8 x double> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 8, i32 9>
To
// CHECK: shufflevector <8 x double> %{{.*}}, <8 x double> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 8, i32 9>
for fixing 318025 commit warning

Change-Id: Id48a1fe1f247fe6a0b84e7189f18d2e637678e79
llvm-svn: 318031
2017-11-13 11:41:41 +00:00
Gabor Horvath 5cfada60b4 [analyzer] Document the issue hash debugging facility
Differential Revision: https://reviews.llvm.org/D39543

llvm-svn: 318030
2017-11-13 11:13:02 +00:00
Jina Nahias dca979194d [x86][AVX512] Lowering shuffle i/f intrinsics to LLVM IR
This patch, together with a matching llvm patch (https://reviews.llvm.org/D38671), implements the lowering of X86 shuffle i/f intrinsics to IR.

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

Change-Id: I9b3c2f2b34323bd9ccb21d0c1832f848b88ec047
llvm-svn: 318025
2017-11-13 09:15:31 +00:00
Dave Lee bfb990b783 Fix AST matcher documentation typo
llvm-svn: 317993
2017-11-11 23:53:27 +00:00
Dave Lee 0934fdc3a5 Add ObjC exception statement AST matchers
Summary: Add AST matchers for Objective-C @throw, @try, @catch and @finally.

Reviewers: aaron.ballman, malcolm.parsons, alexshap, compnerd

Reviewed By: aaron.ballman

Subscribers: cfe-commits, klimek

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

llvm-svn: 317992
2017-11-11 22:46:15 +00:00
Michal Gorny 3495440e45 [python] [tests] Fix test_linkage for unique external linkage
Starting with r314037, anonymous namespaces no longer give
unique-external linkage to variables. However, this linkage can still be
achieved by using a type which is not exterally visible,
e.g. through being declared in an anonymous namespace but used outside
it. Fix the test to take advantage of that.

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

llvm-svn: 317986
2017-11-11 20:01:41 +00:00
Faisal Vali 1f3a2af902 Adjust r316292 - remove the anonymous union for sharing a bitfield in FunctionDecl.
The anonymous union did NOT save us storage, but instead behaved as if we added an additional integer data member to FunctionDecl.  

For additional context, the anonymous union renders the bit fields as non-adjacent and prevents them from sharing the same 'memory location' (i.e. bit-storage) by requiring the anonymous union object to be appropriately aligned.

This was confirmed through discussion with Richard Smith in Albuquerque (ISO C++ Meeting)

https://reviews.llvm.org/rL316292

llvm-svn: 317984
2017-11-11 18:02:29 +00:00
Richard Smith be49c048c1 [cxx_status] Add resolution of CWG issue 1581, since it's an important, visible change.
llvm-svn: 317983
2017-11-11 18:00:16 +00:00
Richard Smith 137f657031 [cxx_status] Update for moved Albuquerque papers.
llvm-svn: 317982
2017-11-11 17:54:46 +00:00
Gor Nishanov 04491bd8f3 [coroutines] Promote cleanup.dest.slot allocas to registers to avoid storing it in the coroutine frame
Summary:
We don't want to store cleanup dest slot saved into the coroutine frame (as some of the cleanup code may
access them after coroutine frame destroyed).

This is an alternative to https://reviews.llvm.org/D37093

It is possible to do this for all functions, but, cursory check showed that in -O0, we get slightly longer function (by 1-3 instructions), thus, we are only limiting cleanup.dest.slot elimination to coroutines.

Reviewers: rjmccall, hfinkel, eric_niebler

Reviewed By: eric_niebler

Subscribers: EricWF, cfe-commits

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

llvm-svn: 317981
2017-11-11 17:00:43 +00:00
Justin Lebar 7c56dfe441 [CUDA] Fix std::min on device side to return the min, not the max.
Summary:
How embarrassing.

This is tested in the test-suite -- fix to come there in a separate
patch.

Reviewers: tra

Subscribers: sanjoy, cfe-commits

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

llvm-svn: 317961
2017-11-11 01:25:44 +00:00
Jake Ehrlich c451cf240b Add CLANG_DEFAULT_OBJCOPY to allow Clang to use llvm-objcopy for dwarf fission
llvm-objcopy is getting to where it can be used in non-trivial ways
(such as for dwarf fission in clang). It now supports dwarf fission but
this feature hasn't been thoroughly tested yet. This change allows
people to optionally build clang to use llvm-objcopy rather than GNU
objcopy. By default GNU objcopy is still used so nothing should change.

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

llvm-svn: 317960
2017-11-11 01:15:41 +00:00
Teresa Johnson 93838a5bd1 Revert "[ThinLTO] Handle -fdebug-pass-manager for backend invocations via clang"
This reverts commit r317951 and r317952. The new test is aborting on
some bots and I'll need to investigate later.

llvm-svn: 317959
2017-11-11 01:06:41 +00:00
Richard Trieu 931638ecb6 Handle lambda captures of variable length arrays in profiling and printing.
From http://reviews.llvm.org/D4368 these cases were thought to not be reachable
and the checks removed before the rest of the code was committed in r216649.
However, these cases are reachable and the checks are added back.

llvm-svn: 317957
2017-11-11 00:54:25 +00:00
Eugene Zelenko b7d89107cd [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317953
2017-11-11 00:08:50 +00:00
Teresa Johnson 56def791bc Add x86-registered-target to REQUIRES for new test
Should fix test added in r317951.

llvm-svn: 317952
2017-11-11 00:05:39 +00:00
Teresa Johnson 140c1a0966 [ThinLTO] Handle -fdebug-pass-manager for backend invocations via clang
Summary:
The LTO Config field wasn't being set when invoking a ThinLTO backend
via clang (i.e. for distributed builds).

Reviewers: danielcdh

Subscribers: mehdi_amini, inglorion, eraman, cfe-commits

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

llvm-svn: 317951
2017-11-10 23:37:39 +00:00
Hans Wennborg 7bf8201009 Remove declaration of EmitMCountInstrumentation(). NFC
The definition was removed in r280355.

llvm-svn: 317944
2017-11-10 22:34:23 +00:00
Zachary Turner 4abbbcc199 Fix for skipped CMake configuration on debuginfo-tests.
This should have been part of the change to debuginfo-tests, but
it was left out.  This should get the buildbots green.

llvm-svn: 317931
2017-11-10 22:12:04 +00:00
Zachary Turner 0f2ce11df7 [debuginfo-tests] Make debuginfo-tests work in a standard configuration.
Previously, debuginfo-tests was expected to be checked out into
clang/test and then the tests would automatically run as part of
check-clang.  This is not a standard workflow for handling
external projects, and it brings with it some serious drawbacks
such as the inability to depend on things other than clang, which
we will need going forward.

The goal of this patch is to migrate towards a more standard
workflow.  To ease the transition for build bot maintainers,
this patch tries not to break the existing workflow, but instead
simply deprecate it to give maintainers a chance to update
the build infrastructure.

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

llvm-svn: 317925
2017-11-10 20:57:57 +00:00
Konstantin Zhuravlyov bfd6c1c016 AMDGPU: Add -mxnack/-mno-xnack options that set +/-xnack feature
Differential Revision: https://reviews.llvm.org/D39878

llvm-svn: 317917
2017-11-10 19:28:25 +00:00
Konstantin Zhuravlyov 8914a6d50e AMDGPU/NFC: Move getAMDGPUTargetFeatures to AMDGPU toolchain
Differential Revision: https://reviews.llvm.org/D39877

llvm-svn: 317909
2017-11-10 19:09:57 +00:00
Daniel Jasper 028d815e28 [clang-format] Handle leading comments in using declaration
This fixes clang-format internal assertion for the following code:

  /* override */ using std::string;

Patch by Igor Sugak. Thank you.

llvm-svn: 317901
2017-11-10 17:11:18 +00:00
Carlo Bertolli 8760acb8e3 [NFC] Pacify bbot for OpenMP 'teams distribute parallel for'
llvm-svn: 317898
2017-11-10 16:49:09 +00:00
Michal Gorny 084e43bfbf [python] [tests] Rewrite to use standard unittest module
Rewrite the tests from using plain 'assert' mixed with some nosetests
methods to the standard unittest module layout. Improve the code
to use the most canonical assertion methods whenever possible.

This has a few major advantages:

- the code uses standard methods now, resulting in a reduced number
of WTFs whenever someone with basic Python knowledge gets to read it,

- completely unnecessary dependency on nosetests is removed since
the standard library supplies all that is necessary for the tests
to run,

- the tests can be run via any test runner, including the one built-in
in Python,

- the failure output for most of the tests is improved from 'assertion
x == y failed' to actually telling the values.

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

llvm-svn: 317897
2017-11-10 16:44:12 +00:00
Carlo Bertolli 3808ff743e [OpenMP] Parse+Sema for copyin clause of 'teams distribute parallel for'
https://reviews.llvm.org/D39902

Simply leverage existing implementation and verify correct functioning with two regression tests.

llvm-svn: 317893
2017-11-10 16:05:00 +00:00
Alexey Bataev 77aed73c2d [OpenMP] diagnose assign to firstprivate const, patch by Joel E. Denny
Summary:
[OpenMP] diagnose assign to firstprivate const

Clang does not diagnose assignments to const variables declared
firstprivate.  Furthermore, codegen is broken such that, at run time,
such assignments simply have no effect.  For example, the following
prints 0 not 1:

int main() {
  const int i = 0;
  #pragma omp parallel firstprivate(i)
  { i=1; printf("%d\n", i); }
  return 0;
}

This commit makes these assignments a compile error, which is
consistent with other OpenMP compilers I've tried (pgcc 17.4-0, gcc
6.3.0).

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: cfe-commits

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

llvm-svn: 317891
2017-11-10 15:39:50 +00:00
Krasimir Georgiev 410ed245f6 [clang-format] Support python-style comments in text protos
Summary: This patch adds support for python-style comments in text protos.

Reviewers: djasper

Reviewed By: djasper

Subscribers: bkramer, cfe-commits, klimek

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

llvm-svn: 317886
2017-11-10 12:50:09 +00:00
Dean Michael Berris 46d0cd3413 Revert "[XRay][darwin] Initial XRay in Darwin Support"
This reverts r317875.

llvm-svn: 317877
2017-11-10 07:00:55 +00:00
Dean Michael Berris bfd111bca5 [XRay][darwin] Initial XRay in Darwin Support
Summary:
This change implements the changes required in both clang and
compiler-rt to allow building XRay-instrumented binaries in Darwin. For
now we limit this to x86_64. We also start building the XRay runtime
library in compiler-rt for osx.

A caveat to this is that we don't have the tests set up and running
yet, which we'll do in a set of follow-on changes.

This patch uses the monorepo layout for the coordinated change across
multiple projects.

Reviewers: kubamracek

Subscribers: mgorny, cfe-commits, llvm-commits

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

llvm-svn: 317875
2017-11-10 05:50:13 +00:00
Craig Topper b3d447356f [X86] Reduce the number of FMA builtins needed by the frontend by adding negates to operands of the fmadd and fmaddsub builtins.
The backend should be able to combine the negates to create fmsub, fnmadd, and fnmsub. faddsub converting to fsubadd still needs work I think, but should be very doable.

This matches what we already do for the masked builtins.

This only covers the packed builtins. Scalar builtins will be done after FMA4 is fixed.

llvm-svn: 317873
2017-11-10 05:20:32 +00:00
Steven Wu 9278019eb3 [Driver] Make clang/cc conforms to UNIX standard
Summary:
This is basically reverting r261774 with a tweak for clang-cl. UNIX
standard states:
When c99 encounters a compilation error that causes an object file not
to be created, it shall write a diagnostic to standard error and
continue to compile other source code operands, but it shall not perform
the link phase and it shall return a non-zero exit status

The same goes for c89 or cc. And they are all alias or shims pointing to
clang on Darwin.

The original commit was intended for CUDA so the error message doesn't
get emit twice for both host and device. It seems that the clang driver
has been changed to model the CUDA dependency differently. Now the
driver behaves the same without this commit.

rdar://problem/32223263

Reviewers: thakis, dexonsmith, tra

Reviewed By: tra

Subscribers: jlebar, cfe-commits

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

llvm-svn: 317860
2017-11-10 01:32:47 +00:00
Eugene Zelenko 8998f10e55 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317854
2017-11-10 00:59:22 +00:00
George Karpenkov 8ee82ed81b [analyzer] [NFC] Minor ExprEngineC refactoring
Move a repeated block of code into a function.

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

llvm-svn: 317849
2017-11-09 23:33:37 +00:00
George Karpenkov d860e7a6b8 [analyzer] do not crash when trying to convert an APSInt to an unexpected type
This is the issue breaking the postgresql bot, purely by chance exposed
through taint checker, somehow appearing after
https://reviews.llvm.org/D38358 got committed.

The backstory is that the taint checker requests SVal for the value of
the pointer, and analyzer has a "fast path" in the getter to return a
constant when we know that the value is constant.
Unfortunately, the getter requires a cast to get signedness correctly,
and for the pointer `void *` the cast crashes.

This is more of a band-aid patch, as I am not sure what could be done
here "correctly", but it should be applied in any case to avoid the
crash.

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

llvm-svn: 317839
2017-11-09 21:49:38 +00:00
Alex Lorenz 41856684c1 [index] tag declarations should use the decl role instead of ref
The 'decl' role is more canonical than the 'ref'. This helps us establish the
'specialization-of' relation just by looking at decls or defs.

rdar://31884960

llvm-svn: 317832
2017-11-09 20:50:59 +00:00
Michal Gorny fe5ae8e471 [python] [tests] Update priority values in code completion test
The priority for destructors and operators was reduced in r314019.
Adjust the values used in the test appropriately to fix the test
failure.

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

llvm-svn: 317828
2017-11-09 20:17:41 +00:00
George Karpenkov bbb66ad7b2 [analyzer] assume bitwise arithmetic axioms
Patches the solver to assume that bitwise OR of an unsigned value with a
constant always produces a value larger-or-equal than the constant, and
bitwise AND with a constant always produces a value less-or-equal than
the constant.

This patch is especially useful in the context of using bitwise
arithmetic for error code encoding: the analyzer would be able to state
that the error code produced using a bitwise OR is non-zero.

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

llvm-svn: 317820
2017-11-09 19:06:22 +00:00
Alexey Bataev 5d7edca316 [OPENMP] Codegen for `#pragma omp target parallel for simd`.
Added codegen for `#pragma omp target parallel for simd` and clauses.

llvm-svn: 317813
2017-11-09 17:32:15 +00:00
Alexey Bataev 9a5e64f56a [OPENMP] Treat '#pragma omp target parallel for simd' as simd directive.
`#pragma omp target parallel for simd` mistakenly was not treated as a
simd directive, fixed this problem.

llvm-svn: 317811
2017-11-09 17:01:35 +00:00
Ben Hamilton e5af5bde71 [VirtualFileSystem] InMemoryFileSystem::addFile(): Type and Perms
Summary:
This implements a FIXME in InMemoryFileSystem::addFile(), allowing
clients to specify User, Group, Type, and/or Perms when creating a
file in an in-memory filesystem.

New tests included. Ran tests with:

% ninja BasicTests && ./tools/clang/unittests/Basic/BasicTests

Fixes PR#35172 (https://bugs.llvm.org/show_bug.cgi?id=35172)

Reviewers: bkramer, hokein

Reviewed By: bkramer, hokein

Subscribers: alexfh

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

llvm-svn: 317800
2017-11-09 16:01:16 +00:00
Krasimir Georgiev d4102df9ad [clang-format] Keep Sphinx happy after r317794
llvm-svn: 317799
2017-11-09 15:54:59 +00:00
Krasimir Georgiev 818da9bb29 [clang-format] Sort using declarations by splitting on '::'
Summary: This patch improves using declarations sorting.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

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

llvm-svn: 317794
2017-11-09 15:41:23 +00:00
Krasimir Georgiev 1696bb6523 [clang-format] Apply a clang-tidy suggestion, NFC
llvm-svn: 317793
2017-11-09 15:12:17 +00:00
Krasimir Georgiev 112c2e96c8 [clang-format] Fix a clang-tidy finding, NFC
llvm-svn: 317784
2017-11-09 13:22:03 +00:00
Krasimir Georgiev 0fcb580bb1 [clang-format] Fix argument name comment, NFC
llvm-svn: 317783
2017-11-09 13:19:14 +00:00
Sam McCall 60d74e4588 [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.
Summary:
This is an alternative to JSONCompilationDatabase for simple projects that
don't use a build system such as CMake.
(You can also drop one in ~, to make your tools use e.g. C++11 by default)

There's no facility for varying flags per-source-file or per-machine.
Possibly this could be accommodated backwards-compatibly using cpp, but even if
not the simplicity seems worthwhile for the cases that are addressed.

Tested with clangd, works great! (requires clangd restart)

Reviewers: klimek

Subscribers: ilya-biryukov, cfe-commits

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

llvm-svn: 317777
2017-11-09 10:37:39 +00:00
John McCall 26d55e0346 Fix a bug with the use of __builtin_bzero in a conditional expression.
Patch by Bharathi Seshadri!

llvm-svn: 317776
2017-11-09 09:32:32 +00:00
Craig Topper e5b84ec2a1 [X86] Rename the VEX scalar fma builtins to end with a '3' to match gcc
I think we need to use different builtins for the FMA4 instructions since those instructions zero the upper bits and FMA3 instructions pass the bits through.

So this moves the existing builtins to be the FMA3 versions. New versions will be added for FMA4.

llvm-svn: 317766
2017-11-09 04:10:46 +00:00
Vedant Kumar f9a0d44eea [Coverage] Emit deferred regions in headers
There are some limitations with emitting regions in macro expansions
because we don't gather file IDs within the expansions. Fix the check
that prevents us from emitting deferred regions in expansions to make an
exception for headers, which is something we can handle.

rdar://35373009

llvm-svn: 317760
2017-11-09 02:33:40 +00:00
Vedant Kumar 8046d22a36 [Coverage] Complete top-level deferred regions before labels
The area immediately after a terminated region in the function top-level
should have the same count as the label it precedes.

This solves another problem with wrapped segments. Consider:

  1| a:
  2|   return 0;
  3| b:
  4|   return 1;

Without a gap area starting after the first return, the wrapped segment
from line 2 would make it look like line 3 is executed, when it's not.

rdar://35373009

llvm-svn: 317759
2017-11-09 02:33:39 +00:00
Vedant Kumar 2e8c875905 [Coverage] Emit a gap area after if conditions
The area immediately after the closing right-paren of an if condition
should have a count equal to the 'then' block's count. Use a gap region
to set this count, so that region highlighting for the 'then' block
remains precise.

This solves a problem we have with wrapped segments. Consider:

  1| if (false)
  2|   foo();

Without a gap area starting after the condition, the wrapped segment
from line 1 would make it look like line 2 is executed, when it's not.

rdar://35373009

llvm-svn: 317758
2017-11-09 02:33:38 +00:00
Alex Lorenz 343982316f Remove redundant copy-pasted comment in test file from r317736
llvm-svn: 317737
2017-11-08 22:47:15 +00:00
Alex Lorenz 1ee711633d [ObjC] Fix function signature handling for blocks literals with attributes
Block literals can have a type with attributes in its signature, e.g.
ns_returns_retained. The code that inspected the type loc of the block when
declaring its parameters didn't account for this fact, and only looked through
paren type loc. This commit ensures that getAsAdjusted is used instead of
IgnoreParens to find the block's FunctionProtoTypeLoc. This ensures that
block parameters are declared correctly in the block and avoids the
'undeclared identifier' error.

rdar://35416160

llvm-svn: 317736
2017-11-08 22:44:34 +00:00
Alex Lorenz 49370ac7e2 [ObjC] Boxed strings should use the nullability from stringWithUTF8String's return type
Objective-C NSString has a class method stringWithUTF8String that creates a new
NSString from a C string. Objective-C box expression @(...) can be used to
create an NSString instead of invoking the stringWithUTF8String method directly
(The compiler lowers it down to the invocation though). This commit ensures that
the type of @(string-value) gets the same nullability attributes as the return
type of stringWithUTF8String to ensure that the diagnostics are consistent
between the two.

rdar://33847186

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

llvm-svn: 317727
2017-11-08 21:33:15 +00:00
Alexey Bataev fb0ebecf0e [OPENMP] Codegen for `#pragma omp target parallel for`.
llvm-svn: 317719
2017-11-08 20:16:14 +00:00
David L. Jones db9d254c1a Add a missing "REQUIRES: system-windows" to a Windows-only test.
This un-breaks builds on other platforms. Otherwise, they fail due to warnings like:

warning: unable to find a Visual Studio installation; try running Clang from a developer command prompt [-Wmsvc-not-found]
llvm-svn: 317716
2017-11-08 20:03:11 +00:00
Marco Castelluccio a3efbb0836 Add CoreOption flag to "-coverage" option to make it available for clang-cl
Summary:
The -coverage option is not a CoreOption, so it is not available to clang-cl.
This patch adds the CoreOption flag to "-coverage" to allow it to be used with clang-cl.

Reviewers: rnk

Reviewed By: rnk

Subscribers: cfe-commits

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

llvm-svn: 317709
2017-11-08 19:21:54 +00:00
Masud Rahman cff22e5081 [bindings] fix TLS test failure
Since cfe commit r237337, '__declspec(thread)' and 'thread_local' have
been the same since MSVC 2015.  i.e. they are both considered to supply
a dynamic TLS kind, not a static TLS kind.

This test originally did not specify which version of MS compatibility
to assume.  As a result, the test was brittle, since changing the
default compatibility version could break the test.

This commit adds a specific version when building up the flags used to
parse the translation unit, and tests both versions.

llvm-svn: 317706
2017-11-08 19:17:27 +00:00
Artem Dergachev 5904fba8c9 [analyzer] Fix a crash on logical operators with vectors.
Do not crash when trying to compute x && y or x || y where x and y are
of a vector type.

For now we do not seem to properly model operations with vectors. In particular,
operations && and || on a pair of vectors are not short-circuit, unlike regular
logical operators, so even our CFG is incorrect.

Avoid the crash, add respective FIXME tests for later.

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

rdar://problem/34317663

llvm-svn: 317700
2017-11-08 17:27:58 +00:00
Haojian Wu f6c0678db7 [clang-refactor] Get rid of OccurrencesFinder in RenamingAction, NFC
Summary:
The OccurrencesFinder is only used in RenameOccurrences to find symbol
occurrences, there is no need to inherit RefactoringRule.

Replace it with a single utility function to avoid code misleading.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

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

llvm-svn: 317696
2017-11-08 14:53:08 +00:00
Ilya Biryukov 5df0d12733 Workaround reverse-iteration buildbot breakages. Filed PR35244.
Clang's completion output is non-deterministic, causing test failures
with turned on LLVM_REVERSE_ITERATION.
The workaround is to use CHECK-DAGs for now, will remove them when
PR35244 gets fixed.

llvm-svn: 317687
2017-11-08 13:05:52 +00:00
Ilya Biryukov b5da91c875 Avoid printing some redundant name qualifiers in completion
Summary:
Adjusted PrintingPolicy inside code completion to avoid printing some
redundant name qualifiers.

Before this change, typedefs that were written unqualified in source
code were printed with qualifiers in completion. For example, in the
following code

    struct foo {
        typedef int type;
        type method();
    };

completion item for `method` had return type of `foo::type`, even
though the original code used `type` without qualifiers.
After this change, the completion item has return type `type`, as
originally written in the source code.

Note that this change does not suppress qualifiers written by the
user. For example, in the following code

    typedef int type;
    struct foo {
        typedef int type;
        ::type method(foo::type);
    };

completion item for `method` has return type of `::type` and
parameter type of `foo::type`, as originally written in the source
code.

Reviewers: arphaman, bkramer, klimek

Reviewed By: arphaman

Subscribers: mgorny, eraman, cfe-commits

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

llvm-svn: 317677
2017-11-08 10:39:09 +00:00
Ilya Biryukov cc3cf58cd2 Moved QualTypeNames.h from Tooling to AST.
Summary:
For code reuse in SemaCodeComplete.
Note that the tests for QualTypeNames are still in Tooling as they use
Tooling's common testing code.

Reviewers: rsmith, saugustine, rnk, klimek, bkramer

Reviewed By: rnk

Subscribers: cfe-commits, mgorny

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

llvm-svn: 317676
2017-11-08 10:39:03 +00:00
Haojian Wu 200458f342 [clang-refactor] Introduce a new rename rule for qualified symbols
Summary: Prototype of a new rename rule for renaming qualified symbol.

Reviewers: arphaman, ioeric, sammccall

Reviewed By: arphaman, sammccall

Subscribers: jklaehn, cfe-commits, klimek

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

llvm-svn: 317672
2017-11-08 08:56:56 +00:00
Craig Topper 23a302256a [X86] Add masked vcvtps2ph builtins to CheckX86BuiltinFunctionCall.
This ensures that only immediates that fit in 8-bits are used. This matches what we do for the unmasked versions.

llvm-svn: 317664
2017-11-08 04:54:26 +00:00
Eugene Zelenko b8c9e2aae5 [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317648
2017-11-08 01:03:16 +00:00
Eugene Zelenko 0d00c89995 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317644
2017-11-08 00:39:18 +00:00
Sriraman Tallam fe34d6d8cd Change noplt.c to work for non-x86 targets.
Differential Revision: https://reviews.llvm.org/D39759

llvm-svn: 317627
2017-11-07 22:34:55 +00:00
Justin Lebar da9e0bd3a2 [NVPTX] Implement __nvvm_atom_add_gen_d builtin.
Summary:
This just seems to have been an oversight.  We already supported the f64
atomic add with an explicit scope (e.g. "cta"), but not the scopeless
version.

Reviewers: tra

Subscribers: jholewinski, sanjoy, cfe-commits, llvm-commits, hiraditya

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

llvm-svn: 317623
2017-11-07 22:10:54 +00:00
Alex Lorenz bbe51d86ec [ObjC++] Don't warn about pessimizing move for __block variables
rdar://33316951

llvm-svn: 317620
2017-11-07 21:40:11 +00:00
Mitch Phillips 512fa40b3e Update SanitizerSpecialCaseList to use renamed functions in base class.
Note: This change has a cyclical dependency on D39485. Both these changes must be submitted at the same time to avoid a build breakage.

Reviewers: vlad.tsyrklevich

Subscribers: llvm-commits

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

llvm-svn: 317616
2017-11-07 21:16:37 +00:00
Sriraman Tallam 5c65148565 New clang option -fno-plt which avoids the PLT and lazy binding while making external calls.
Differential Revision: https://reviews.llvm.org/D39079

llvm-svn: 317605
2017-11-07 19:37:51 +00:00
Alex Lorenz f4bf4227b7 [refactor] rename field references in __builtin_offsetof
rdar://33875453

llvm-svn: 317599
2017-11-07 18:30:23 +00:00
George Rokos 065755d23d Clang/libomptarget map interface flag renaming - NFC patch
This patch renames some of the flag names of the clang/libomptarget map interface. The old names are slightly misleading, whereas the new ones describe in a better way what each flag is about.

Only the macros within the enumeration are renamed, there is no change in functionality therefore there are no updated regression tests.

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

llvm-svn: 317598
2017-11-07 18:27:04 +00:00
Alex Lorenz 1c628e3c3e [index] __builtin_offset's field reference is located at the end location
The starting location is the location of the '.'

llvm-svn: 317596
2017-11-07 18:25:36 +00:00
Alex Lorenz 7b760095cb [index] index field references in __builtin_offset
rdar://35109556

llvm-svn: 317593
2017-11-07 17:29:11 +00:00
Arnold Schwaighofer 612d693c64 SystemZ Swift TargetInfo: swifterror support in the backend is broken
Return false for swifterror support until the backend is fixed.

llvm-svn: 317589
2017-11-07 16:40:51 +00:00
Sanjay Patel 040fbe3027 [CodeGen] split math and complex tests into separate files; NFCI
The files are already large, and we may need to add even more RUNs to 
distinguish differences based on OS, environment, or other platform things.

llvm-svn: 317583
2017-11-07 15:13:22 +00:00
Eric Liu c47fd014ae [clang-refactor] Use ClangTool more explicitly by making refaroing actions AST frontend actions.
Summary: This is a refactoring change. NFC

Reviewers: arphaman, hokein

Reviewed By: arphaman, hokein

Subscribers: cfe-commits

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

llvm-svn: 317577
2017-11-07 14:35:03 +00:00
Artem Dergachev 0b5b1f14fd [analyzer] pr34779: CStringChecker: Accept non-standard headers.
Do not crash when trying to define and call a non-standard
strcpy(unsigned char *, unsigned char *) during analysis.

At the same time, do not try to actually evaluate the call.

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

llvm-svn: 317565
2017-11-07 10:51:15 +00:00
Sjoerd Meijer 167f2e34d5 [docs] Add section 'Half-Precision Floating Point'
This documents the differences/interactions between _Float16 and __fp16
and is a companion change for the _Float16 type implementation (r312794).

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

llvm-svn: 317558
2017-11-07 10:09:45 +00:00
George Karpenkov 166548c0dc [analyzer] [NFC] Remove unused typedef from SVals.h
Differential Revision: https://reviews.llvm.org/D39620

llvm-svn: 317537
2017-11-07 02:02:10 +00:00
Alex Lorenz 4e30b96834 Clarify the error message for unsupported aliases on Darwin
rdar://35109556

llvm-svn: 317532
2017-11-07 00:31:19 +00:00
Devin Coughlin 046833e5fb [analyzer] Model correct dispatch_once() 'done' value in BodyFarm
The analyzer's BodyFarm models dispatch_once() by comparing the passed-in
predicate against a known 'done' value. If the predicate does not have that
value, the model updates the predicate to have that value and executes the
passed in block.

Unfortunately, the current model uses the wrong 'done' value: 1 instead of ~0.
This interferes with libdispatch's static inline function _dispatch_once(),
which enables a fast path if the block has already been executed. That function
uses __builtin_assume() to tell the compiler that the done flag is set to ~0 on
exit. When r302880 added modeling of __builtin_assume(), this caused the
analyzer to assume 1 == ~0. This in turn caused the analyzer to never explore any code after a call to dispatch_once().

This patch regains the missing coverage by updating BodyFarm to use the correct
'done' value.

rdar://problem/34413048

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

llvm-svn: 317516
2017-11-06 22:12:19 +00:00
Dave Lee f96bedfce3 Vary Windows toolchain selection by -fuse-ld
Summary:
This change allows binutils to be used for linking with MSVC. Currently, when
using an MSVC target and `-fuse-ld=bfd`, the driver produces an invalid linker
invocation.

Reviewers: rnk, compnerd

Reviewed By: compnerd

Subscribers: smeenai, cfe-commits

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

llvm-svn: 317511
2017-11-06 21:18:05 +00:00
Craig Topper 57f96ac6dc [X86] Replace the mask cmpeq/cmple/cmplt/cmpgt/cmpge/cmpneq intrinsics with macros that just pass the right comparison predicate value to the regular cmp intrinsic. Remove mask cmpeq/cmpgt builtins that are now unused.
This shortens the intrinsic headers a little and allows us to get rid of the cmpeq and cmpgt handling from CGBuiltin.cpp.

llvm-svn: 317506
2017-11-06 21:00:49 +00:00