Commit Graph

69247 Commits

Author SHA1 Message Date
Chandler Carruth d676ab1354 [clang-format] Switch to case-insensitive header matching and use it to
improve support for LLVM-style include sorting.

This really is a collection of improvements to the rules for LLVM
include sorting:
- We have gmock headers now, so it adds support for those to one of the
  categories.
- LLVM does use 'FooTest.cpp' files to test 'Foo.h' so it adds that
  suffix for finding a main header.
- At times the test file's case may not match the header file's case, so
  switch to case-insensitive regex matching of header names.

With this set of changes, I can't spot any misbehaviors when re-sorting
all of LLVM's unittest '#include' lines.

Thanks to Eric and Daniel for help testing and refining the patch during
review!

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

llvm-svn: 306759
2017-06-29 23:20:54 +00:00
Tim Shen b13eebe0ce [NewPM] Add Clang cc1 flag -fdebug-pass-manager for printing debug information.
Differential Revision: https://reviews.llvm.org/D34790

llvm-svn: 306757
2017-06-29 23:10:13 +00:00
Tim Shen 664706916b [ThinkLTO] Invoke build(Thin)?LTOPreLinkDefaultPipeline.
Previously it doesn't actually invoke the designated new PM builder
functions.

This patch moves NameAnonGlobalPass out from PassBuilder, as Chandler
points out that PassBuilder is used for non-O0 builds, and for
optimizations only.

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

llvm-svn: 306756
2017-06-29 23:08:38 +00:00
Richard Trieu 3e03d3ee54 [ODRHash] Improve typedef handling.
Follow typedef chains to find the root type when processing types, and also
keep track of qualifiers.

llvm-svn: 306753
2017-06-29 22:53:04 +00:00
Reid Kleckner b640ab92c2 Fix openmp-offload.c test on Windows
llvm-svn: 306751
2017-06-29 22:31:16 +00:00
Akira Hatanaka ea7611b02c Insert llvm_unreachable at the end of a function to silence gcc's
-Werror=return-type error.

This is an attempt to fix the following failing bot:

http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror

llvm-svn: 306739
2017-06-29 20:44:20 +00:00
George Karpenkov 3f984ecb45 [libFuzzer] Add Fuzzer to the list of sanitizers which support coverage.
Without this change, additional coverage flags specified after
-fsanitize=fuzzer would get discarded.

https://reviews.llvm.org/D34794

llvm-svn: 306734
2017-06-29 19:58:20 +00:00
George Karpenkov 2363fdd30f [libFuzzer] Do not link in libFuzzer with -fsanitize=fuzzer when producing a shared object
https://reviews.llvm.org/D34791

llvm-svn: 306733
2017-06-29 19:52:33 +00:00
Graydon Hoare f5fe36787d [ASTReader] Add test for previous change r306583 / 145692e.
Summary:
Add a test for the change to ASTReader that reproduces the
logic for consolidating multiple ObjC interface definitions to the
case of multiple ObjC protocol definitions.

This test is a modified copy of the test that accompanied the original
change to interfaces, in 2ba1979.

Reviewers: bruno

Reviewed By: bruno

Subscribers: cfe-commits

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

llvm-svn: 306732
2017-06-29 19:42:35 +00:00
Gheorghe-Teodor Bercea 7916da2347 [OpenMP] Fix test for revision D29645. NFC
llvm-svn: 306724
2017-06-29 18:49:16 +00:00
Akira Hatanaka cae83f78aa [Sema] Issue diagnostics if a new/delete expression generates a call to
a c++17 aligned allocation/deallocation function that is unavailable in
the standard library on Apple platforms.

The aligned functions are implemented only in the following versions or
later versions of the OSes, so clang issues diagnostics if the deployment
target being targeted is older than these:

macosx: 10.13
ios: 11.0
tvos: 11.0
watchos: 4.0

The diagnostics are issued whenever the aligned functions are selected
except when the selected function has a definition in the same file.
If there is a user-defined function available somewhere else, option
-Wno-aligned-allocation-unavailable can be used to silence the
diagnostics.

rdar://problem/32664169

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

llvm-svn: 306722
2017-06-29 18:48:40 +00:00
Yaxun Liu e9e5c4f975 CodeGen: Fix invalid bitcast for coerced function argument
Clang assumes coerced function argument is in address space 0, which is not always true and results in invalid bitcasts.

This patch fixes failure in OpenCL conformance test api/get_kernel_arg_info with amdgcn---amdgizcl triple, where non-zero alloca address space is used.

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

llvm-svn: 306721
2017-06-29 18:47:45 +00:00
Stephan Bergmann 743de46043 Fixed -Wexceptions derived-to-base false positives
...as introduced with recent <https://reviews.llvm.org/D33333> "Emit warning
when throw exception in destruct or dealloc functions which has a (possible
implicit) noexcept specifier".  (The equivalent of the goodReference case hit
when building LibreOffice.)

(These warnings are apparently only emitted when no errors have yet been
encountered, so it didn't work to add the test code to the end of the existing
clang/test/SemaCXX/exceptions.cpp.)

llvm-svn: 306715
2017-06-29 17:58:59 +00:00
Alexey Bataev 1fdfdf7155 [OPENMP][DEBUG] Generate second function with correct arg types.
Currently, if the some of the parameters are captured by value, this
argument is converted to uintptr_t type and thus we loosing the debug
info about real type of the argument (captured variable):
```
void @.outlined_function.(uintptr %par);

...
%a = alloca i32
%a.casted = alloca uintptr
%cast = bitcast uintptr* %a.casted to i32*
%a.val = load i32, i32 *%a
store i32 %a.val, i32 *%cast
%a.casted.val = load uintptr, uintptr* %a.casted
call void @.outlined_function.(uintptr %a.casted.val)
...
```

To resolve this problem, in debug mode a speciall external wrapper
function is generated, that calls the outlined function with the correct
parameters types:
```
void @.wrapper.(uintptr %par) {
  %a = alloca i32
  %cast = bitcast i32* %a to uintptr*
  store uintptr %par, uintptr *%cast
  %a.val = load i32, i32* %a
  call void @.outlined_function.(i32 %a)
  ret void
}
void @.outlined_function.(i32 %par);

...
%a = alloca i32
%a.casted = alloca uintptr
%cast = bitcast uintptr* %a.casted to i32*
%a.val = load i32, i32 *%a
store i32 %a.val, i32 *%cast
%a.casted.val = load uintptr, uintptr* %a.casted
call void @.wrapper.(uintptr %a.casted.val)
...
```

llvm-svn: 306697
2017-06-29 16:43:05 +00:00
Vassil Vassilev 809328c114 Initialize variable and silence potentially uninitialized warning.
Patch by Liza Sakellari!

llvm-svn: 306692
2017-06-29 16:08:10 +00:00
Gheorghe-Teodor Bercea 3addb7d850 [OpenMP] Pass -fopenmp-is-device to preprocessing and machine specific code generation stages
Summary: The preprocessing and code generation and optimization stages of the compiler are also passed the "-fopenmp-is-device" flag. This is used to trigger machine specific preprocessing and code generation when performing device offloading to an NVIDIA GPU via OpenMP directives.

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

Reviewed By: Hahnfeld

Subscribers: Hahnfeld, rengolin

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

llvm-svn: 306691
2017-06-29 15:59:19 +00:00
Gheorghe-Teodor Bercea 59d7b77b16 [OpenMP] Add support for auxiliary triple specification
Summary: Device offloading requires the specification of an additional flag containing the triple of the //other// architecture the code is being compiled on if such an architecture exists. If compiling for the host, the auxiliary triple flag will contain the triple describing the device and vice versa.

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

Reviewed By: Hahnfeld

Subscribers: rengolin, cfe-commits

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

llvm-svn: 306689
2017-06-29 15:49:03 +00:00
Alex Lorenz 98d220e0a5 Fix NSAPI constants to reflect the current state of
NSStringMethodKind/NSDictionaryMethodKind enums

Patch by Vladimir Voskresensky!

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

llvm-svn: 306680
2017-06-29 14:18:26 +00:00
Michael Zuckerman a046ef4c26 [Clang][X86][Goldmont]Adding new target-cpu: Goldmont
[Clang-side] Connecting the GoldMont processor to his feature.


Reviewers:
1. igorb
2. delena
3. zvi


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

llvm-svn: 306673
2017-06-29 13:41:04 +00:00
Krasimir Georgiev feeba61006 [clang-format] Fix parsing of msg{field}-style proto options
Summary:
This patch makes the `{` in `msg_field{field: OK}` in a proto option scope be
treated as an assignment operator. Previosly the added test case was formatted
as:
```
option (MyProto.options) = {
  field_a: OK
  field_b{field_c: OK} field_d: OKOKOK field_e: OK
}
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 306672
2017-06-29 13:30:41 +00:00
NAKAMURA Takumi 0a6f749845 Revert r306653, "[OpenCL] Allow function declaration with empty argument list."
It broke bots.

llvm-svn: 306660
2017-06-29 10:47:23 +00:00
Alex Lorenz e2863eca2a [Tooling] FixedCompilationDatabase should be able to strip positional
arguments when `-fsyntax-only` is used

Previously, Clang failed to create a fixed compilation database when the
compilation arguments use -fsyntax-only instead of -c. This commit fixes the
issue by forcing Clang to look at the compilation job when stripping the
positional arguments.

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

llvm-svn: 306659
2017-06-29 10:43:44 +00:00
Alexey Bader 3d0c97883a [OpenCL] Allow function declaration with empty argument list.
Summary:
does it make sense to enable K&R function declaration style for OpenCL?
clang throws following error message for the declaration w/o arguments:

```
int my_func();
error: function with no prototype cannot use the spir_function calling convention
```

Current way to fix this issue is to specify that parameter list is empty by using 'void':

```
int my_func(void);
```

Let me know what do you think about this patch.

Reviewers: Anastasia, yaxunl

Reviewed By: Anastasia

Subscribers: cfe-commits, echuraev

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

llvm-svn: 306653
2017-06-29 08:44:10 +00:00
Gabor Horvath 7848b388ee Factor out a functionality from isBeforeInTranslationUnit
The first user of this API will be the cross translation unit
functionality of the Static Analyzer which will be committed in a
follow-up patch. 

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

llvm-svn: 306648
2017-06-29 06:53:13 +00:00
Richard Smith f3f846162a Track the set of module maps read while building a .pcm file and reload those when preprocessing from that .pcm file.
llvm-svn: 306628
2017-06-29 02:19:42 +00:00
Saleem Abdulrasool 9f83f3b251 CodeGen: handle missed case of COMDAT handling
When Protocol references are constructed, we need to add the reference
symbol to a COMDAT group on non-MachO object file formats (MachO handles
this by having a coalesced attribute).  This adds the missing case.

llvm-svn: 306622
2017-06-29 00:54:44 +00:00
Graydon Hoare e0a68355f2 [ASTReader] Treat multiple defns of ObjC protocols the same as interfaces.
Summary:
In change 2ba19793512, the ASTReader logic for ObjC interfaces was modified to
preserve the first definition-data read, "merging" later definitions into it
rather than overwriting it (though this "merging" is, in practice, a no-op that
discards the later definition-data).

Unfortunately this change was only made to ObjC interfaces, not protocols; this
means that when (for example) loading a protocol that references an interface,
if both the protocol and interface are multiply defined (as can easily happen
if the same header is read from multiple contexts), an _inconsistent_ pair of
definitions is loaded: first-read for the interface and last-read for the
protocol.

This in turn causes very subtle downstream bugs in the Swift ClangImporter,
which filters the results of name lookups based on the owning module of a
definition; inconsistency between a pair of related definitions causes name
lookup failures at various stages of compilation.

To fix these downstream issues, this change replicates the logic applied to
interfaces in change 2ba19793512, but for ObjC protocols.

rdar://30851899

Reviewers: doug.gregor, rsmith

Reviewed By: doug.gregor

Subscribers: jordan_rose, cfe-commits

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

llvm-svn: 306583
2017-06-28 18:36:27 +00:00
Yuka Takahashi 28782bea88 [Bash-autocompletion] Invoke clang where user called
Summary:
When user build clang and used completion Eg. `build/bin/clang -fno[tab]`, we want to invoke `build/bin/clang --autocomplete=-fno`, rather than `clang --autocomplete=-fno`.

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

llvm-svn: 306559
2017-06-28 16:29:26 +00:00
Yuka Takahashi 79d21c2a74 [Bash-autocompletion] Check clang version in Bash
Summary:
Add check if user's clang version supports --autocomplete or not.
If not, we just autocomplete files.

Reviewers: ruiu, v.g.vassilev, teemperor

Subscribers: cfe-commits

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

llvm-svn: 306555
2017-06-28 15:59:55 +00:00
Ilya Biryukov afdadf5627 Use vfs::FileSystem in ASTUnit when creating CompilerInvocation.
Summary: It used to always call into the RealFileSystem before.

Reviewers: bkramer, krasimir, klimek, bruno

Reviewed By: klimek

Subscribers: bruno, cfe-commits

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

llvm-svn: 306549
2017-06-28 15:06:34 +00:00
Karthik Bhat e1ae1b23c9 Fix crash in clang while handling __has_trivial_destructor.
Fix crash in clang when an array of unknown bounds of an incomplete type is passed to __has_trivial_destructor.

Patch by Puneetha
https://reviews.llvm.org/D34198

llvm-svn: 306519
2017-06-28 08:52:08 +00:00
NAKAMURA Takumi af18fb20d3 DiagnosticRenderer.h: Prune \param SM, corresponding to rL306384. [-Wdocumentation]
llvm-svn: 306511
2017-06-28 06:46:23 +00:00
Vedant Kumar 99b312994c Remove a redundant call to ArgList::hasFlag. NFC.
llvm-svn: 306497
2017-06-28 01:56:07 +00:00
Akira Hatanaka 46dd7dbc8c [CodeGen] Fix assertion failure in EmitCallArg.
The assertion was failing when a method of a parameterized class was
called and the types of the argument and parameter didn't match. To fix
the failure, move the assertion in EmitCallArg to its only caller
EmitCallArgs and require the argument and parameter types match only
when the method is not parameterized.

rdar://problem/32874473

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

llvm-svn: 306494
2017-06-28 00:42:48 +00:00
Mandeep Singh Grang 2fd6b1651d [COFF, ARM64] Add support for Windows ARM64 COFF format
Summary: This is the clang part of the initial implementation to support Windows ARM64 COFF format.

Reviewers: ruiu, t.p.northover, rnk, compnerd

Reviewed By: ruiu, compnerd

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

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

llvm-svn: 306489
2017-06-27 23:56:34 +00:00
Jonathan Coe 0a5b03b659 [libclang] Support for querying the exception specification type through libclang
Summary: This patch exposes the exception specification type (noexcept,
etc.) of a C++ function through libclang and Python clang.cindex.

Reviewers: rsmith, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: jbcoe, cfe-commits

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

Patch by Andrew Bennieston

llvm-svn: 306483
2017-06-27 22:54:56 +00:00
George Burgess IV d3cf025ae2 [Sema] Allow unmarked overloadable functions.
This patch extends the `overloadable` attribute to allow for one
function with a given name to not be marked with the `overloadable`
attribute. The overload without the `overloadable` attribute will not
have its name mangled.

So, the following code is now legal:

  void foo(void) __attribute__((overloadable));
  void foo(int);
  void foo(float) __attribute__((overloadable));

In addition, this patch fixes a bug where we'd accept code with
`__attribute__((overloadable))` inconsistently applied. In other words,
we used to accept:

  void foo(void);
  void foo(void) __attribute__((overloadable));

But we will do this no longer, since it defeats the original purpose of
requiring `__attribute__((overloadable))` on all redeclarations of a
function.

This breakage seems to not be an issue in practice, since the only code
I could find that had this pattern often looked like:

  void foo(void);
  void foo(void) __attribute__((overloadable)) __asm__("foo");
  void foo(int) __attribute__((overloadable));

...Which can now be simplified by simply removing the asm label and
overloadable attribute from the redeclaration of `void foo(void);`

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

llvm-svn: 306467
2017-06-27 21:31:31 +00:00
Saleem Abdulrasool 6a92381c50 test: fix test for release builds
Use a regex capture to avoid hardcoding the name.  This should repair
the failing buildbot.

llvm-svn: 306447
2017-06-27 18:57:50 +00:00
Saleem Abdulrasool da6784e8ff CodeGen: load indirect ObjC ARC arguments in prologue
When generating a prologue, add loads for ARC arguments passed
indirectly.

Patch by Dave Lee!

llvm-svn: 306444
2017-06-27 18:37:51 +00:00
Dehao Chen 874bc749a2 Update the test comment to clarify the intention of the test.
llvm-svn: 306434
2017-06-27 17:45:40 +00:00
Sanjay Patel d53f6a8980 [x86] weaken test checks that shouldn't be here in the first place
This test would fail after the proposed change in:
https://reviews.llvm.org/D34242

llvm-svn: 306433
2017-06-27 17:39:46 +00:00
Dehao Chen bc8c7dc054 Update test for enabling ICP for AutoFDO.
Summary: This is the test update patch for https://reviews.llvm.org/D34662

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: cfe-commits, sanjoy, mehdi_amini, eraman, llvm-commits

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

llvm-svn: 306430
2017-06-27 17:23:42 +00:00
Alexey Bataev 5d1c3f6add [OPENMP] Use MapVector instead of DenseMap for stable codegen, NFC.
llvm-svn: 306419
2017-06-27 15:46:42 +00:00
Krasimir Georgiev 3d4c8127a7 [clang-format] Fix a clang-tidy warning, NFC
llvm-svn: 306409
2017-06-27 14:07:45 +00:00
Krasimir Georgiev 0b41fcb6b7 [clang-format] Fix a buildbot failure after r306406
llvm-svn: 306408
2017-06-27 13:58:41 +00:00
Krasimir Georgiev ff747be4d5 [clang-format] Support <>-style proto message fields
Summary:
This patch adds support for <>-style proto message fields inside proto options.
Previously these were wrongly treated as binary operators and as such were
working only by chance for a limited number of cases.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 306406
2017-06-27 13:43:07 +00:00
Artem Dergachev 7caff0e9e1 [analyzer] Move zero-size allocation checks to optin.portability.
This is a new checker package. It contains checkers that highlight
well-documented implementation-defined behavior. Such checkers are only useful
to developers that intend to write portable code. Code that is only compiled for
a single platform should be allowed to rely on this platform's specific
documented behavior.

rdar://problem/30545046

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

llvm-svn: 306396
2017-06-27 11:14:39 +00:00
Alex Lorenz 99bee7f4a1 Recommit r306103: PR26195: Set correct NestedNameSpecifierLoc for the
dependent initializer

This commit fixes incorrect source positions of dependent c'tor initializers
like in the following code:

template<typename MyBase>
struct Derived: MyBase::InnerIterator
{

Derived() : MyBase::InnerIterator() {} /// This line is problematic: all positions point to InnerIterator and nothing points to MyBase
};

Patch by Serge Preis!

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

llvm-svn: 306392
2017-06-27 10:35:30 +00:00
Krasimir Georgiev 9451e67158 [clang-format] Add a test for associative map proto buffer fields
Summary:
The test suite was missing a test about associative maps:
https://developers.google.com/protocol-buffers/docs/proto3#maps

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 306386
2017-06-27 10:06:40 +00:00
Christof Douma fb4a0450db Revert "Revert "[NFC] Refactor DiagnosticRenderer to use FullSourceLoc""
This reverts commit r305688 meaning it reintroduces r305684. To repeat:

[NFC] Refactor DiagnosticRenderer to use FullSourceLoc

Move the DiagnosticRenderer and its dependents to using FullSourceLocs
instead of a SourceLocation and SourceManager pointer. The changeset is
rather large but entirely mechanical.

This is step one to allow DiagnosticRenderer to take either
llvm::SMLocs or clang::SourceLocations.

This breaks clang-tidy and clng-query which will be fixed in a commit
soon after.

Patch by Sanne Wouda

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

llvm-svn: 306384
2017-06-27 09:50:38 +00:00