Commit Graph

75176 Commits

Author SHA1 Message Date
Ilya Biryukov 008eda0807 [Tooling] Restore working dir in ClangTool.
Summary:
And add an option to disable this behavior. The option is only used in
AllTUsExecutor to avoid races when running concurrently on multiple
threads.

This fixes PR38869 introduced by r340937.

Reviewers: ioeric, steveire

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 341910
2018-09-11 07:29:09 +00:00
Douglas Yung 28ea6775c7 Make test more robust in case the expected output appears in clang version string.
llvm-svn: 341907
2018-09-11 06:48:45 +00:00
Bruno Cardoso Lopes 6fc8a564cf [Modules] Add imported modules to the output of -module-file-info
Fix a bug in the deserialization of IMPORTS section and allow for
imported modules to also be printed with -module-file-info.

rdar://problem/43867753

llvm-svn: 341902
2018-09-11 05:17:13 +00:00
Saleem Abdulrasool b69ce1fcd0 clang-check: rename the local FixItAction
Resolve the ambiguity in the FixItAction definition by renaming the type.  With
Xcode 9.2, you would fail to build this with:

  llvm/tools/clang/tools/clang-check/ClangCheck.cpp:183:48: error: reference to 'FixItAction' is ambiguous
      FrontendFactory = newFrontendActionFactory<FixItAction>();
                                                 ^

llvm-svn: 341877
2018-09-10 22:57:26 +00:00
Erik Pilkington 4257857bf8 [Sema][ObjC] Infer availability of +new from availability of -init.
When defined in NSObject, +new will call -init. If -init has been marked
unavailable, diagnose uses of +new.

rdar://18335828

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

llvm-svn: 341874
2018-09-10 22:20:09 +00:00
Erich Keane 33428d98f7 Fix test regression in r341862
The commit updates when AES is enabled, but failed to update the tests.
This patch fixes them.

llvm-svn: 341871
2018-09-10 21:57:53 +00:00
Erik Pilkington c587164422 [AST] Fix a crash on invalid.
Problem was that we were appending to the source location info buffer in the
copy assignment operator (instead of overwriting).

rdar://42746401

llvm-svn: 341869
2018-09-10 21:54:04 +00:00
Erich Keane 7582222691 Move AESNI generation to Skylake and Goldmont
The instruction set first appeared with Westmere, but not all processors
in that and the next few generations have the instructions. According to
Wikipedia[1], the first generation in which all SKUs have AES
instructions are Skylake and Goldmont. I can't find any Skylake,
Kabylake, Kabylake-R or Cannon Lake currently listed at
https://ark.intel.com that says "Intel® AES New Instructions" "No".

This matches GCC commit
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01940.html

[1] https://en.wikipedia.org/wiki/AES_instruction_set

Patch By: thiagomacieira
Differential Revision: https://reviews.llvm.org/D51510

llvm-svn: 341862
2018-09-10 21:12:21 +00:00
JF Bastien e77b48b078 Implement -Watomic-implicit-seq-cst
Summary:
_Atomic and __sync_* operations are implicitly sequentially-consistent. Some
codebases want to force explicit usage of memory order instead. This warning
allows them to know where implicit sequentially-consistent memory order is used.
The warning isn't on by default because _Atomic was purposefully designed to
have seq_cst as the default: the idea was that it's the right thing to use most
of the time. This warning allows developers who disagree to enforce explicit
usage instead.

A follow-up patch will take care of C++'s std::atomic. It'll be different enough
from this patch that I think it should be separate: for C++ the atomic
operations all have a memory order parameter (or two), but it's defaulted. I
believe this warning should trigger when the default is used, but not when
seq_cst is used explicitly (or implicitly as the failure order for cmpxchg).

<rdar://problem/28172966>

Reviewers: rjmccall

Subscribers: dexonsmith, cfe-commits

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

llvm-svn: 341860
2018-09-10 20:42:56 +00:00
Richard Smith 8eeb16f5d1 Enhance -Wc++14-compat for class template argument deduction to list the
deduced type (if known).

llvm-svn: 341858
2018-09-10 20:31:03 +00:00
Alexandre Ganea f8acd723e8 [clang-cl] Enable -march option
This change allows usage of -march when using the clang-cl driver. This is similar to MSVC's /arch; however -march can target precisely all supported CPUs, while /arch has a more restricted set.

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

llvm-svn: 341847
2018-09-10 17:54:32 +00:00
Adrian Prantl 05a623eb87 Remove all uses of DIFlagBlockByrefStruct
This patch removes the last reason why DIFlagBlockByrefStruct from
Clang by directly implementing the drilling into the member type done
in DwarfDebug::DbgVariable::getType() into the frontend.

rdar://problem/31629055

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

llvm-svn: 341842
2018-09-10 16:14:28 +00:00
Erich Keane 659c871a1b Prevent cpu-specific/cpu-dispatch from giong on a lambda.
It is non-sensical to use cpu-specific/cpu-dispatch multiversioning
on a lambda, so prevent it when trying to add the attribute.

llvm-svn: 341833
2018-09-10 14:31:56 +00:00
Kadir Cetinkaya a32d253f10 [clang] Make sure codecompletion is called for calls even when inside a token.
Summary:
Currently CodeCompleteCall only gets called after a comma or parantheses. This
patch makes sure it is called even at the cases like:
```foo(1^);```

Reviewers: ilya-biryukov, ioeric, hokein

Reviewed By: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 341824
2018-09-10 13:46:28 +00:00
Adam Balogh bf77ab7f0e [Analyzer] Commit fix for rL341790/rC341790
Test file was accidentally not added for rL341790/rC341790 and subsequant patches.

llvm-svn: 341795
2018-09-10 09:19:54 +00:00
Adam Balogh 2e7cb34d0f [Analyzer] Iterator Checker - Part 8: Support for assign, clear, insert, emplace and erase operations
This patch adds support for the following operations in the iterator checkers: assign, clear, insert, insert_after, emplace, emplace_after, erase and erase_after. This affects mismatched iterator checks ("this" and parameter must match) and invalidation checks (according to the standard).

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

llvm-svn: 341794
2018-09-10 09:07:47 +00:00
Adam Balogh 9a48ba6b4a [Analyzer] Iterator Checker - Part 7: Support for push and pop operations
This patch adds support for the following operations in the iterator checkers: push_back, push_front, emplace_back, emplace_front, pop_back and pop_front. This affects iterator range checks (range is extended after push and emplace and reduced after pop operations) and invalidation checks (according to the standard).

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

llvm-svn: 341793
2018-09-10 09:06:31 +00:00
Adam Balogh 3659f7a8a9 [Analyzer] Iterator Checker - Part 6: Mismatched iterator checker for constructors and comparisons
Extension of the mismatched iterator checker for constructors taking range of first..last (first and last must be iterators of the same container) and also for comparisons of iterators of different containers (one does not compare iterators of different containers, since the set of iterators is partially ordered, there are no relations between iterators of different containers, except that they are always non-equal).

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

llvm-svn: 341792
2018-09-10 09:05:31 +00:00
Adam Balogh 6b23b1a74f [Analyzer] Iterator Checker - Part 5: Move Assignment of Containers
If a container is moved by its move assignment operator, according to the standard all their iterators except the past-end iterators remain valid but refer to the new container. This patch introduces support for this case in the iterator checkers.

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

llvm-svn: 341791
2018-09-10 09:04:27 +00:00
Adam Balogh 21583b733a [Analyzer] Iterator Checker - Part 4: Mismatched iterator checker for function parameters
New check added to the checker which checks whether iterator parameters of template functions typed by the same template parameter refer to the same container.

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

llvm-svn: 341790
2018-09-10 09:03:22 +00:00
Hans Wennborg 0aa0d91e98 ReleaseNotes: update links to use https
llvm-svn: 341786
2018-09-10 08:51:25 +00:00
Richard Smith 4576a77b80 PR33222: Require the declared return type not the actual return type to
match when checking for redeclaration of a function template.

This properly handles differences in deduced return types, particularly
when performing redeclaration checks for a friend function template.

llvm-svn: 341778
2018-09-10 06:35:32 +00:00
Richard Smith 4ced5d751b Part of PR33222: defer enforcing return type mismatch for dependent
friend function declarations of class templates.

llvm-svn: 341775
2018-09-10 05:32:13 +00:00
Kelvin Li bc38e63718 [OpenMP] Add support for nested 'declare target' directives
Add the capability to nest multiple declare target directives 
- including header files within a declare target region.

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

Patch by Patrick Lyster

llvm-svn: 341766
2018-09-10 02:07:09 +00:00
Fangrui Song aadc93c887 [Sema] Make typo correction slightly more efficient
edit_distance returns UpperBound+1 if the distance will exceed UpperBound. We can subtract 1 from UpperBound and change >= to > in the if condition. The threshold does not change but edit_distance will have more opportunity to bail out earlier.

llvm-svn: 341763
2018-09-09 17:20:03 +00:00
Hamza Sood fd1dc75b40 Fix build bots after a mistake in r341760
llvm-svn: 341761
2018-09-09 13:12:53 +00:00
Hamza Sood e05bf60631 [Tooling] Improve handling of CL-style options
This patch fixes the handling of clang-cl options in InterpolatingCompilationDatabase.
They were previously ignored completely, which led to a lot of bugs:

Additional options were being added with the wrong syntax. E.g. a file was
specified as C++ by adding -x c++, which causes an error in CL mode.

The args were parsed and then rendered, which means that the aliasing information
was lost. E.g. /W4 was rendered to -Wall, which in CL mode means -Weverything.

CL options were ignored when checking things like -std=, so a lot of logic was
being bypassed.

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

llvm-svn: 341760
2018-09-09 12:06:35 +00:00
Akira Hatanaka 9bd2452708 Revert r341754.
The commit broke a couple of bots:

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/12347
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/7310

llvm-svn: 341757
2018-09-09 05:22:49 +00:00
Fangrui Song c14cb73c54 [Parser] Remove an unnecessary `mutable`
llvm-svn: 341756
2018-09-09 01:54:18 +00:00
Nico Weber e2dd15785b ms: Insert $$Z in mangling between directly consecutive parameter packs.
Fixes PR38783.
Differential Revision: https://reviews.llvm.org/D51784

llvm-svn: 341755
2018-09-08 20:58:39 +00:00
Akira Hatanaka 2e00b98027 Distinguish `__block` variables that are captured by escaping blocks
from those that aren't.

This patch changes the way __block variables that aren't captured by
escaping blocks are handled:

- Since non-escaping blocks on the stack never get copied to the heap
  (see https://reviews.llvm.org/D49303), Sema shouldn't error out when
  the type of a non-escaping __block variable doesn't have an accessible
  copy constructor.

- IRGen doesn't have to use the specialized byref structure (see
  https://clang.llvm.org/docs/Block-ABI-Apple.html#id8) for a
  non-escaping __block variable anymore. Instead IRGen can emit the
  variable as a normal variable and copy the reference to the block
  literal. Byref copy/dispose helpers aren't needed either.

rdar://problem/39352313

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

llvm-svn: 341754
2018-09-08 20:03:00 +00:00
Richard Smith da3729d1e6 Do not use optimized atomic libcalls for misaligned atomics.
Summary:
The optimized (__atomic_foo_<n>) libcalls assume that the atomic object
is properly aligned, so should never be called on an underaligned
object.

This addresses one of several problems identified in PR38846.

Reviewers: jyknight, t.p.northover

Subscribers: jfb, cfe-commits

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

llvm-svn: 341734
2018-09-07 23:57:54 +00:00
George Karpenkov 3310893288 [analyzer] [NFC] Move methods for dumping the coverage in HTMLDiagnostics into the class
Differential Revision: https://reviews.llvm.org/D51513

llvm-svn: 341724
2018-09-07 22:13:35 +00:00
George Karpenkov e4707e7a4a [analyzer] [NFC] Use StringRef when returning a large string literal in HTMLDiagnostics
(NB: could be a clang-tidy / analyzer check)

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

llvm-svn: 341723
2018-09-07 22:13:15 +00:00
George Karpenkov 5577cb70e1 [analyzer] Remove the "postponed" hack, deal with derived symbols using an extra map
The "derived" symbols indicate children fields of a larger symbol.
As parents do not have pointers to their children, the garbage
collection algorithm the analyzer currently uses adds such symbols into
a "postponed" category, and then keeps running through the worklist
until the fixed point is reached.

The current patch rectifies that by instead using a helper map which
stores pointers from parents to children, so that no fixed point
calculation is necessary.

The current patch yields ~5% improvement in running time on sqlite.

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

llvm-svn: 341722
2018-09-07 22:07:57 +00:00
George Karpenkov 8a88c83593 Revert "Revert "Revert "Revert "[analyzer] Add coverage information to plist output, update tests""""
This reverts commit 2f5d71d9fa135be86bb299e7d773036e50bf1df6.

Hopefully fixing tests on Windows.

llvm-svn: 341719
2018-09-07 21:58:24 +00:00
Richard Smith edb9fbb78a Make -Watomic-alignment say whether the atomic operation was oversized
or misaligned.

llvm-svn: 341710
2018-09-07 21:24:27 +00:00
Richard Smith 8ed7776bc4 PR38870: Add warning for zero-width unicode characters appearing in
identifiers.

llvm-svn: 341700
2018-09-07 19:25:39 +00:00
Craig Topper ecf2e2fe31 [X86] Custom emit __builtin_rdtscp so we can emit an explicit store for the out parameter
This is the clang side of D51803. The llvm intrinsic now returns two results. So we need to emit an explicit store in IR for the out parameter. This is similar to addcarry/subborrow/rdrand/rdseed.

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

llvm-svn: 341699
2018-09-07 19:14:24 +00:00
Alex Lorenz 49c2add9fb warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'
Addresses first post-commit feedback for r335081 from Nico

llvm-svn: 341697
2018-09-07 18:59:45 +00:00
Craig Topper 52a61fc2ac [X86] Modify addcarry/subborrow builtins to emit an 2 result and intrinsic and an store instruction.
This is the clang side of D51769. The llvm intrinsics now return two results instead of using an out parameter.

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

llvm-svn: 341678
2018-09-07 16:58:57 +00:00
Alexey Bataev 47b2ed2e16 Revert "[OPENMP][NVPTX] Disable runtime-type info for CUDA devices."
Still need the RTTI for NVPTX target to pass sema checks.

llvm-svn: 341668
2018-09-07 14:50:25 +00:00
Ilya Biryukov 832c4afe00 [CodeComplete] Clearly distinguish signature help and code completion.
Summary:
Code completion in clang is actually a mix of two features:
- Code completion is a familiar feature. Results are exposed via the
  CodeCompleteConsumer::ProcessCodeCompleteResults callback.
- Signature help figures out if the current expression is an argument of
  some function call and shows corresponding signatures if so.
  Results are exposed via CodeCompleteConsumer::ProcessOverloadCandidates.

This patch refactors the implementation to untangle those two from each
other and makes some naming tweaks to avoid confusion when reading the
code.

The refactoring is required for signature help fixes, see D51038.

The only intended behavior change is the order of callbacks.
ProcessOverloadCandidates is now called before ProcessCodeCompleteResults.

Reviewers: sammccall, kadircet

Reviewed By: sammccall

Subscribers: cfe-commits

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

llvm-svn: 341660
2018-09-07 14:04:39 +00:00
Ivan Donchevskii 38bdf54b49 [libclang] Return the proper pointee type for 'auto' deduced to pointer
Currently the resulting type is always invalid in such case.

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

llvm-svn: 341656
2018-09-07 13:23:51 +00:00
Kristina Brooks 8f060aac2f Differential Revision: https://reviews.llvm.org/D50246
[RISCV] Add support for computing sysroot for riscv32-unknown-elf

Extends r338385 to allow the driver to compute the sysroot when an explicit path is not provided. This allows the linker to find C runtime files and the correct include directory for header files.

Patch by lewis-revill (Lewis Revill)

llvm-svn: 341655
2018-09-07 13:03:31 +00:00
Nico Weber 50824c9caf Reland r341390 clang-cl: Pass /Brepro to linker if it was passed to the compiler
The test was missing  '--' on mac as pointed out by -Wslash-u-filename:
<stdin>:5:69: note: possible intended match here
clang: warning: '/Users/thakis/src/llvm-mono/clang/test/Driver/msvc-link.c' treated as the '/U' option [-Wslash-u-filename]

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

llvm-svn: 341654
2018-09-07 12:47:02 +00:00
Simon Pilgrim b746df0b0a Revert "Revert "Revert "[analyzer] Add coverage information to plist output, update tests"""
Reverts analyzer tests from rL341627 again as they still broke windows buildbots

llvm-svn: 341648
2018-09-07 10:27:16 +00:00
Diogo N. Sampaio bac6c88da2 Replaces __inline by __inline__ / C89 compatible
llvm-svn: 341644
2018-09-07 09:37:27 +00:00
Alexander Potapenko d49c32ce3f [MSan] add KMSAN support to Clang driver
Boilerplate code for using KMSAN instrumentation in Clang.

We add a new command line flag, -fsanitize=kernel-memory, with a
corresponding SanitizerKind::KernelMemory, which, along with
SanitizerKind::Memory, maps to the memory_sanitizer feature.

KMSAN is only supported on x86_64 Linux.

It's incompatible with other sanitizers, but supports code coverage
instrumentation.

llvm-svn: 341641
2018-09-07 09:21:09 +00:00
Akira Hatanaka 2ccb31977c [Sema] Check that the destructor for each element of class type is
accessible from the context where aggregate initialization occurs.

rdar://problem/38168772

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

llvm-svn: 341629
2018-09-07 02:38:01 +00:00