Commit Graph

69142 Commits

Author SHA1 Message Date
Peter Wu 2bbed50a45 [ASTMatchers] Add support for floatLiterals
Summary:
Needed to support something like "floatLiteral(equals(1.0))". The
parser for floating point numbers is kept simple, so instead of ".1" you
have to use "0.1".

Reviewed By: aaron.ballman

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

llvm-svn: 305021
2017-06-08 22:00:50 +00:00
Peter Wu c04b198c50 [ASTMatchers] Add support for boolean literals
Summary:
Recognize boolean literals for future extensions ("equals(true)").
Note that a specific VariantValue constructor is added to resolve
ambiguity (like "Value = 5") between unsigned and bool.

Reviewed By: aaron.ballman

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

llvm-svn: 305020
2017-06-08 22:00:38 +00:00
Alexander Shaposhnikov 108ca94fa8 [clang] Fix format specifiers fixits
This diff fixes printf "fixits" in the case when there is 
a wrapping macro and the format string needs multiple replacements. 
In the presence of a macro there is an extra logic in EditedSource.cpp
to handle multiple uses of the same macro argument 
(see the old comment inside EditedSource::canInsertInOffset)
which was mistriggerred when the argument was used only once 
but required multiple adjustments), as a result the "fixit" 
was breaking down the format string
by dropping the second format specifier, i.e. 
Log1("test 4: %s %s", getNSInteger(), getNSInteger()) 
was getting replaced with 
Log1("test 4: %ld ", (long)getNSInteger(), (long)getNSInteger()) 
(if one removed the macro and used printf directly it would work fine).
In this diff we track the location where the macro argument is used and 
(as it was before) the modifications originating from all the locations 
except the first one are rejected, but multiple changes are allowed.

Test plan: make check-all

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

llvm-svn: 305018
2017-06-08 21:44:45 +00:00
George Burgess IV 5f6ab9a8bf [Sema] Refactor OverloadCandidate::BuiltinTypes. NFC.
As promised in r304996.

llvm-svn: 305013
2017-06-08 20:55:21 +00:00
Nikolai Bozhenov 1c36934883 Revert "Frontend support for Nios2 target"
As it breaks many buildbots.

llvm-svn: 305002
2017-06-08 18:36:35 +00:00
Galina Kistanova 1d36e833e1 Added llvm_unreachable to make sure the switch is always exhaustive.
llvm-svn: 304997
2017-06-08 18:20:32 +00:00
George Burgess IV c07c389a94 [Sema] Remove unused field from OverloadCandidate.
The only use in-tree I can find for BuiltinTypes.ResultTy is a single
store to it. We otherwise just recompute what it should be later on (and
sometimes do things like argument conversions in the process of
recomputing it).

Since it's impossible to test if the value stored there is sane, and we
don't use it anyway, we should probably just drop the field.

I'll do a follow-up patch to rename BuiltinTypes.ParamTypes ->
BuiltinParamTypes in a bit. Wanted to keep this patch relatively
minimal.

Thanks to Petr Kudryavtsev for bringing this up!

llvm-svn: 304996
2017-06-08 18:19:25 +00:00
Nikolai Bozhenov 32dc6c8540 Frontend support for Nios2 target.
Summary:
- Implements TargetInfo class for Nios2 target.
- Enables handling of -march and -mcpu options for Nios2 target.
- Definition of Nios2 builtin functions.

Reviewed By: craig.topper

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

Author: belickim <mateusz.belicki@intel.com>
llvm-svn: 304994
2017-06-08 17:40:30 +00:00
Alexander Potapenko dc5b95b553 [sanitizer-coverage] Allow using KASAN instrumentation with sancov
llvm-svn: 304984
2017-06-08 16:24:21 +00:00
Sven van Haastregt e891042105 [libclang] Expose typedef and address space functions
Expose the following functions:
 - clang_getTypedefName
 - clang_getAddressSpace

Patch by Simon Perretta.

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

llvm-svn: 304978
2017-06-08 14:22:04 +00:00
Serge Pavlov 79271ab154 Do not inherit default arguments for friend function in class template.
A function declared in a friend declaration may have declarations prior
to the containing class definition. If such declaration defines default
argument, the friend function declaration inherits them. This behavior
causes problems if the class where the friend is declared is a template:
during the class instantiation the friend function looks like if it had
default arguments, so error is triggered.

With this change friend functions declared in class templates do not
inherit default arguments. Actual set of them will be defined at the
point where the containing class is instantiated.

This change fixes PR12724.

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

llvm-svn: 304965
2017-06-08 06:31:19 +00:00
Serge Pavlov 673f44c769 Improve diagnostics if friend function redefines file-level function.
Clang makes check for function redefinition after it merged the new
declaration with the existing one. As a result, it produces poor
diagnostics in the case of a friend function defined inline, as in
the code:
```
    void func() {}
    class C { friend void func() {} };
```
Error message in this case states that `inline declaration of 'func'
follows non-inline definition`, which is misleading, as `func` does
not have explicit `inline` specifier.

With this changes compiler reports function redefinition if the new
function is a friend defined inline and it does not have explicit
`inline` specifier.

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

llvm-svn: 304964
2017-06-08 06:07:07 +00:00
Serge Pavlov 0c64e27207 Catch invalid bitwise operation on vector of floats
Bitwise complement applied to vector of floats described with
attribute `ext_vector_type` is not diagnosed as error. Attempt to
compile such construct causes assertion violation in Instruction.cpp.
With this change the complement is treated similar to the case of
vector type described with attribute `vector_size`.

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

llvm-svn: 304963
2017-06-08 05:25:19 +00:00
Richard Trieu 24f7dd9c72 [ODRHash] Make diagnostic message more readable.
Change the diagnostic message from r304956 to be less confusing by reordering
the flow of information.

llvm-svn: 304962
2017-06-08 04:47:29 +00:00
Richard Smith 4a7ac59b37 Simplify.
llvm-svn: 304960
2017-06-08 02:05:55 +00:00
Richard Smith 4f440e3af5 Weaken restriction in r304862 to allow implicit deduction guides to reference
the injected-class-name of a specialization that uses a partial / explicit
specialization.

llvm-svn: 304957
2017-06-08 01:08:50 +00:00
Richard Trieu 708859a713 [ODRHash] Change the fall-back diagnostic error.
Provide a little more information when a ODR violation is detected, but the
specific error could not be diagnosed.

llvm-svn: 304956
2017-06-08 00:56:21 +00:00
Petar Jovanovic 9b5d3b6a9f Reapply r304929 [mips] Add runtime options to enable/disable madd/sub.fmt
The test in r304929 broke multiple buildbots as it expected mips target to
be registered and available (which is not necessarily true). Updating the
test with this condition.

Original commit:

  [mips] Add runtime options to enable/disable madd.fmt and msub.fmt

  Add options to clang: -mmadd4 and -mno-madd4, use it to enable or disable
  generation of madd.fmt and similar instructions respectively, as per GCC.

  Patch by Stefan Maksimovic.

llvm-svn: 304953
2017-06-07 23:51:52 +00:00
John McCall 27c11dd57e When determining the target function of an explicit instantiation, make
sure that non-template functions don't end up in the candidate set.

Fixes PR14211.

Patch by Don Hinton!

llvm-svn: 304951
2017-06-07 23:00:05 +00:00
Richard Smith cd19815bc2 [c++1z] Support deducing B in noexcept(B).
This is not required by the standard (yet), but there seems to be reasonable
support for this being a defect according to CWG discussion, and libstdc++ 7.1
relies on it working.

llvm-svn: 304946
2017-06-07 21:46:22 +00:00
Simon Dardis d95df13399 Finish revert of "r304929, [mips] Add runtime options to enable/disable madd/sub.fmt"
The r304935 missed deleting the test case.

llvm-svn: 304936
2017-06-07 20:02:24 +00:00
Petar Jovanovic 53900b0221 Revert r304929 [mips] Add runtime options to enable/disable madd/sub.fmt
Revert r304929 since the test broke buildbots.

Original commit:

  [mips] Add runtime options to enable/disable madd.fmt and msub.fmt

  Add options to clang: -mmadd4 and -mno-madd4, use it to enable or disable
  generation of madd.fmt and similar instructions respectively, as per GCC.

  Patch by Stefan Maksimovic.

llvm-svn: 304935
2017-06-07 18:57:56 +00:00
Petar Jovanovic c6d9b04cc3 [mips] Add runtime options to enable/disable madd.fmt and msub.fmt
Add options to clang: -mmadd4 and -mno-madd4, use it to enable or disable
generation of madd.fmt and similar instructions respectively, as per GCC.

Patch by Stefan Maksimovic.

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

llvm-svn: 304929
2017-06-07 17:17:57 +00:00
Krasimir Georgiev e151882273 [clang-format] Fix alignment of preprocessor trailing comments
Summary:
This patch is a follow-up of https://reviews.llvm.org/rL304687, which fixed an
overflow in the comment alignment code in clang-format. The token length of
trailing comments of preprocessor directives is calculated incorrectly by
including the text between consecutive directives. That causes them to not being
aligned.

For example, in this code with column limit 20
```
#if A
#else  // A
int iiii;
#endif // B
```
the length of the token `// A` was wrongly calculated as 14 = 5 (the size of `// A\n`) plus 9 (the size of `int iiii;`) and so `// A` wouldn't be aligned with `// B` and this was produced:
```
#if A
#else // A
int iiii;
#endif // B
```

This patch fixes this case.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, klimek

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

llvm-svn: 304912
2017-06-07 14:05:06 +00:00
Martin Probst d96a052cb1 clang-format: [JS] recognize exported type definitions.
Summary: Support "export type T = {...};", in addition to just "type T = {...};".

Reviewers: klimek

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

llvm-svn: 304904
2017-06-07 12:53:22 +00:00
Dimitry Andric 0527c32be8 Only print registered targets for `--version`
Summary:
In D33900, I added printing of the registered targets in clang's
`PrintVersion` function, which is not only used for `--version` output,
but also for `-v` (verbose mode) and `-###`.  Especially the latter
seems to trip up some test cases, so it is probably better to only print
the registered targets for `--version`.

Reviewers: nemanjai, mehdi_amini

Reviewed By: nemanjai

Subscribers: cfe-commits

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

llvm-svn: 304899
2017-06-07 12:05:41 +00:00
Florian Hahn cc524bf6ac [CodeGen] Add thumb-mode to target-features for arm/thumb triples.
Summary:
The thumb-mode target feature is used to force Thumb or ARM code
generation on a per-function basis. Explicitly adding +thumb-mode to
functions for thumbxx triples enables mixed ARM/Thumb code generation in
places where compilation units with thumbxx and armxx triples are merged
together (e.g. the IR linker or LTO).

For armxx triples, -thumb-mode is added in a similar fashion.

Reviewers: echristo, t.p.northover, kristof.beyls, rengolin

Reviewed By: echristo

Subscribers: rinon, aemerson, mehdi_amini, javed.absar, cfe-commits

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

llvm-svn: 304897
2017-06-07 11:50:45 +00:00
Benjamin Kramer 97e7c33fd6 [Sema] Silence unused variable warning.
llvm-svn: 304892
2017-06-07 10:23:17 +00:00
Javed Absar 15b80a5b23 [ARM] Fix Neon vector type alignment to 64-bit
This is restricted version of patch - https://reviews.llvm.org/D33205
that I reverted as it was leading to ABI breaks on darwin etc.
This patch restricts the fix to AAPCS (Android remains 128-bit).
Reviewed by: Renato Golin, Stephen Hines
Differential Revision: https://reviews.llvm.org/D33786

llvm-svn: 304889
2017-06-07 10:02:02 +00:00
Maxim Ostapenko 154a4fd5dc [Driver] Add test to cover case when LSan is not supported
This commit adds a testcase for uncovered code paths in LSan options parsing logic in driver.

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

llvm-svn: 304880
2017-06-07 08:51:15 +00:00
Galina Kistanova be3ba9dae9 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304872
2017-06-07 06:31:55 +00:00
Galina Kistanova 3779cb3c14 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304870
2017-06-07 06:25:05 +00:00
NAKAMURA Takumi 92c99cd6dc Update libdeps to add BinaryFormat, introduced in r304864.
llvm-svn: 304869
2017-06-07 04:48:49 +00:00
NAKAMURA Takumi ef9d9481b5 Reorder and reformat.
llvm-svn: 304868
2017-06-07 04:48:45 +00:00
Galina Kistanova b4b16556e3 Fixed warning: 'virtual void clang::ExternalASTSource::CompleteType(clang::ObjCInterfaceDecl*)' was hidden.
llvm-svn: 304863
2017-06-07 02:44:42 +00:00
Richard Smith e6d4b773de Fix a couple of class template argument deduction crashes with libc++'s tuple.
RecursiveASTVisitor was not properly recursing through a
SubstTemplateTypeParmTypes, resulting in crashes in pack expansion where we
couldn't always find an unexpanded pack within a pack expansion.

We also have an issue where substitution of deduced template arguments for an
implicit deduction guide creates the "impossible" case of naming a
non-dependent member of the current instantiation, but within a specialization
that is actually instantiated from a different (partial/explicit)
specialization of the template. We resolve this by declaring that constructors
that do so can only be used to deduce specializations of the primary template.
I'm running this past CWG to see if people agree this is the right thing to do.

llvm-svn: 304862
2017-06-07 02:42:27 +00:00
Dan Gohman 7dee171f69 [WebAssembly] Set MaxAtomicInlineWidth to 64.
The WebAssembly threads proposal has changed such that C++
implementations can now declare that atomics up to 64 bits are
"lock free" in C++'s terms.

llvm-svn: 304859
2017-06-07 02:22:40 +00:00
Richard Smith 17c59472e8 Improve error recovery for missing 'template' keyword in contexts where the
template is valid with or without it (with different meanings).

If we see "dependent.x<...", and what follows the '<' is a valid expression,
we must parse the '<' as a comparison rather than a template angle bracket.
When we later come to instantiate, if we find that the LHS of the '<' actually
names an overload set containing function templates, produce a diagnostic
suggesting that the 'template' keyword was missed rather than producing a
mysterious diagnostic saying that the function must be called (and pointing
at what looks to already be a function call!).

llvm-svn: 304852
2017-06-07 00:29:44 +00:00
Ekaterina Romanova cb3603a4eb [DOXYGEN] Corrected several typos and incorrect parameters description that Sony's techinical writer found during review.
I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.

llvm-svn: 304840
2017-06-06 22:58:01 +00:00
Dimitry Andric 81c40421fe Print registered targets in clang's version information
Summary:
Other llvm tools display their registered targets when showing version
information, but for some reason clang has never done this.

To support this, D33899 adds the llvm parts, which make it possible to
print version information to arbitrary raw_ostreams.  This change adds
a call to printRegisteredTargetsForVersion in clang's PrintVersion, and
adds a raw_ostream parameter to two other PrintVersion functions.

Reviewers: beanz, chandlerc, dberris, mehdi_amini, zturner

Reviewed By: mehdi_amini

Subscribers: cfe-commits

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

llvm-svn: 304836
2017-06-06 21:54:21 +00:00
Mandeep Singh Grang 4d4cd8bb97 [clang] Remove double semicolons. NFC.
Reviewers: rsmith, craig.topper, efriedma

Reviewed By: efriedma

Subscribers: efriedma, cfe-commits

Tags: #clang-c

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

llvm-svn: 304823
2017-06-06 19:47:56 +00:00
Martin Probst 384232766b clang-format: [JS] Correctly Indent Nested JavaScript Literals.
Nested literals are sometimes only indented by 2 spaces, instead of
respecting the IndentWidth option.
There are existing unit tests (FormatTestJS.ArrayLiterals) that only
pass because the style used to test them uses an IndentWidth of 2.
This change removes the magic 2 and always uses the IndentWidth.
I've added 6 tests. The first 4 of these tests fail before this change,
while the last 2 already pass, but were added just to make sure it the
change works with all types of braces.

Patch originally by Jared Neil, thanks!

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

llvm-svn: 304791
2017-06-06 12:38:29 +00:00
Florian Hahn 28f03bbcbb [ARM] Add support for target("arm") and target("thumb").
Summary:
This patch adds support for the target("arm") and target("thumb")
attributes, which can be used to force the compiler to generated ARM or
Thumb code for a function.

In LLVM, ARM or Thumb code generation can be controlled by the
thumb-mode target feature. But GCC already uses target("arm") and
target("thumb"), so we have to substitute "arm" with -thumb-mode and
"thumb" with +thumb-mode.


Reviewers: echristo, pcc, kristof.beyls

Reviewed By: echristo

Subscribers: ahatanak, aemerson, javed.absar, kristof.beyls, cfe-commits

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

llvm-svn: 304781
2017-06-06 09:26:15 +00:00
Sylvestre Ledru 121224d4a4 Fix a mistake in the clang format documentation (BreakBeforeTernaryOperators)
Patch sent through github by Jason Hsu

llvm-svn: 304776
2017-06-06 07:26:19 +00:00
Shoaib Meenai 462f36d36d [Driver] Don't force .exe suffix for lld
When cross-compiling to Windows using lld, we want the driver to invoke
it as lld-link rather than lld-link.exe. On Windows, the LLVM fs
functions take care of adding the .exe suffix where necessary, so we can
just drop the addition in the toolchain entirely.

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

llvm-svn: 304761
2017-06-06 02:06:28 +00:00
Richard Smith b301806c4b PR33318: Add missing full-expression checking to static_assert expression.
This fixes missing lambda-captures for variables referenced only inside a
static_assert (!), among other things.

llvm-svn: 304760
2017-06-06 01:34:24 +00:00
Richard Smith 1893475d95 Retain header search and preprocessing options from AST file when emitting
preprocessed text for an AST file.

llvm-svn: 304756
2017-06-06 00:32:01 +00:00
Richard Smith 3092d728cd Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls
replaced by visible decls.

Make sure that all paths through checkCorrectionVisibility set the
RequiresImport flag appropriately, so we don't end up using a stale value.
Patch by Jorge Gorbe!

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

llvm-svn: 304745
2017-06-05 22:29:36 +00:00
Richard Smith f878a84cc4 Fix memory leak exposed by r304726.
When giving a ContentCache a null buffer, ignore the DoNotFree flag rather than
inheriting it onto whatever buffer we end up using for the file. Also ensure
that the main buffer is properly destroyed.

llvm-svn: 304740
2017-06-05 22:05:31 +00:00
Richard Smith 27e5aa0892 Factor out and unify emission of "module is unavailable" diagnostics.
Inspired by post-commit review of r304190.

llvm-svn: 304728
2017-06-05 18:57:56 +00:00
Richard Smith 6b19934915 Attempt to fix Windows buildbot failure due to mismatching directory separators in preprocessed output.
llvm-svn: 304727
2017-06-05 18:39:31 +00:00
Richard Smith ab75597dda Rather than rejecting attempts to run preprocessor-only actions on AST files,
replay the steps taken to create the AST file with the preprocessor-only action
installed to produce preprocessed output.

This can be used to produce the preprocessed text for an existing .pch or .pcm
file.

llvm-svn: 304726
2017-06-05 18:10:11 +00:00
Michal Gorny 997f7764be [test] Fix baremetal test to allow any -resource-dir
The baremetal test (r303873) has been added with expectance of very
specific -resource-dir. However, the test itself nor the BareMetal
driver does not enforce any specific -resource-dir, making this
constraint invalid. It already has been altered twice -- in r303910 for
Windows compatibility, and in r304085 for systems using lib64. To
account for even more systems, just use [[RESOURCE_DIR]] like a number
of other tests do. This is needed for Gentoo where RESOURCE_DIR starts
with ../ (uses relative path to a parent directory).

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

llvm-svn: 304715
2017-06-05 14:13:37 +00:00
Artem Dergachev 7c0ab86932 [analyzer] Don't add arrow to the inlined function's decl when it has no body.
In plist output mode with alternate path diagnostics, when entering a function,
we draw an arrow from the caller to the beginning of the callee's declaration.
Upon exiting, however, we draw the arrow from the last statement in the
callee function. The former makes little sense when the declaration is
not a definition, i.e. has no body, which may happen in case the body
is coming from a body farm, eg. Objective-C autosynthesized property accessor.

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

llvm-svn: 304713
2017-06-05 13:36:28 +00:00
Artem Dergachev fbe891ee05 [analyzer] Nullability: fix notes around synthesized ObjC property accessors.
Nullable-to-nonnull checks used to crash when the custom bug visitor was trying
to add its notes to autosynthesized accessors of Objective-C properties.

Now we avoid this, mostly automatically outside of checker control, by
moving the diagnostic to the parent stack frame where the accessor has been
called.

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

llvm-svn: 304710
2017-06-05 12:40:03 +00:00
Anastasia Stulova b3398936ab [OpenCL] Fix pipe size in TypeInfo.
Pipes are now the size of pointers rather than the size
of the type that they contain.

Patch by Simon Perretta!

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

llvm-svn: 304708
2017-06-05 11:27:03 +00:00
Javed Absar 2a67c9ee39 Add support for #pragma clang section
This patch provides a means to specify section-names for global variables, 
functions and static variables, using #pragma directives. 
This feature is only defined to work sensibly for ELF targets.
One can specify section names as:
#pragma clang section bss="myBSS" data="myData" rodata="myRodata" text="myText"
One can "unspecify" a section name with empty string e.g.
#pragma clang section bss="" data="" text="" rodata=""

Reviewers: Roger Ferrer, Jonathan Roelofs, Reid Kleckner
Differential Revision: https://reviews.llvm.org/D33412

llvm-svn: 304705
2017-06-05 10:11:57 +00:00
Renato Golin de72b918f3 Revert "[sanitizer-coverage] one more flavor of coverage: -fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting yet. (clang part)"
This reverts commit r304631, as it broke ARM/AArch64 bots for 2 days.

llvm-svn: 304697
2017-06-05 07:35:45 +00:00
Krasimir Georgiev 59ed77b813 [clang-format] Don't align too long broken trailing comments
Summary:
This patch fixes a bug where clang-format will align newly broken trailing
comments even if this will make them exceed the line limit. The bug was caused
by a combination of unsigned arithmetic overflow and an imprecise computation
of the length of broken comment lines.

Reviewers: djasper, alexfh

Reviewed By: alexfh

Subscribers: klimek

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

llvm-svn: 304687
2017-06-04 19:27:02 +00:00
Serge Pavlov 10673c98bd Implement isDefined by call to isThisDeclarationADefinition.
Modifies FunctionDecl::isThisDeclarationADefinition so that it covers
all the cases checked by FunctionDecl::isDefined. Implements the latter
method by call to isThisDeclarationADefinition.

This change is a part of the patch D30170.

llvm-svn: 304684
2017-06-04 12:53:12 +00:00
Galina Kistanova 8a338ea43a Fixed warning: enum constant in boolean context.
llvm-svn: 304663
2017-06-03 16:47:06 +00:00
Saleem Abdulrasool 3347b3ab83 tests: silence -Wobjc-root-class warnings
Silence warnings about no ObjC class root for the types defined for the
tests.

llvm-svn: 304662
2017-06-03 16:18:13 +00:00
Saleem Abdulrasool 13d73d53c4 CodeGen: fix section names for different file formats
This changes the codegen to match the section names according to the
ObjC rewriter as well as the runtime.  The changes to the test are
simply whitespace changes to the section attributes and names and are
functionally equivalent (the whitespace is ignored by the linker).

llvm-svn: 304661
2017-06-03 16:18:09 +00:00
Galina Kistanova ddcd2812f5 Added missing break.
llvm-svn: 304653
2017-06-03 06:40:10 +00:00
Galina Kistanova 96088f4d41 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304652
2017-06-03 06:38:22 +00:00
Galina Kistanova 333991138b Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304651
2017-06-03 06:35:06 +00:00
Galina Kistanova f87496d107 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304650
2017-06-03 06:31:42 +00:00
Galina Kistanova 0872d6c275 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304649
2017-06-03 06:30:46 +00:00
Galina Kistanova efa712444c Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304648
2017-06-03 06:30:08 +00:00
Galina Kistanova 4c7705c849 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304647
2017-06-03 06:29:40 +00:00
Galina Kistanova 27daec6870 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304646
2017-06-03 06:29:16 +00:00
Galina Kistanova e37ad5a79e Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304645
2017-06-03 06:27:16 +00:00
Galina Kistanova a65d5785d8 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304644
2017-06-03 06:26:27 +00:00
Galina Kistanova 39edaaa65c Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304643
2017-06-03 06:25:47 +00:00
Galina Kistanova d321611bfb Added LLVM_FALLTHROUGH to address warning: this statement may fall through + formatted. NFC.
llvm-svn: 304642
2017-06-03 06:25:29 +00:00
Galina Kistanova de7e22123a Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304641
2017-06-03 06:23:51 +00:00
Galina Kistanova 83b8a6c170 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304640
2017-06-03 06:23:19 +00:00
Kostya Serebryany e425aada63 [sanitizer-coverage] one more flavor of coverage: -fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting yet. (clang part)
llvm-svn: 304631
2017-06-03 01:36:23 +00:00
Eric Fiselier de7943b947 [coroutines] Fix rebuilding of dependent coroutine parameters
Summary:
We were not handling correctly rebuilding of parameter and were not creating copies for them.
Now we will always rebuild parameter moves in TreeTransform's TransformCoroutineBodyStmt.

Reviewers: rsmith, GorNishanov

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 304620
2017-06-03 00:22:18 +00:00
Richard Trieu d064d1b6e8 Revert r304592
r304592 - [ODRHash] Add support for TemplateArgument types.
Possibly causing one of the errors in modules build bot.

llvm-svn: 304618
2017-06-03 00:11:23 +00:00
Richard Smith f8ba3fd8e6 Fix assertion failure if we can't deduce a template argument for a variable
template partial specialization.

In passing, fix the deduction-crash.cpp test to actually run all the tests. Due
to a typo, the last third of the file was being skipped by the parser and some
of the tests were not actually testing anything as a result. Switch from
FileCheck to -verify to make the problem more obvious and prevent this
happening again.

llvm-svn: 304604
2017-06-02 22:53:06 +00:00
Richard Trieu 24c302b915 [ODRHash] Add support for TemplateArgument types.
llvm-svn: 304592
2017-06-02 20:35:29 +00:00
Alexey Bader 037dbe9535 [OpenCL] Harden function pointer diagnostics.
Summary: Improve OpenCL type checking by rejecting function pointer types.

Reviewers: Anastasia, yaxunl

Reviewed By: Anastasia

Subscribers: cfe-commits

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

llvm-svn: 304575
2017-06-02 18:08:58 +00:00
Benjamin Kramer ee021d54d7 [Modules] Fix use after scope.
Found by asan.

llvm-svn: 304568
2017-06-02 17:30:24 +00:00
Alex Lorenz bbf4f7091f ASTPrinter: Objective-C method declarations don't need a space after
the return type

rdar://32332039

llvm-svn: 304553
2017-06-02 15:02:59 +00:00
Alex Lorenz 01bf58d6ec Tie the macOS tests in test/Integration to the latest macOS SDK
This change will ensure that these tests won't fail when a new SDK that
utilizes new compiler features is used.
See https://reviews.llvm.org/D32178 for more context.

llvm-svn: 304542
2017-06-02 11:26:35 +00:00
Alex Lorenz 0bafa02709 Avoid calling report_fatal_error in the destructor of raw_fd_ostream
when saving a module timestamp file

This commit doesn't include a test as it requires a test that reproduces
a file write/close error that couldn't really be constructed artificially.

rdar://31860650

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

llvm-svn: 304538
2017-06-02 10:36:56 +00:00
NAKAMURA Takumi c226303d3e clang/test/CodeGenCXX/unaligned-member-qualifier.cpp: Satisfy x86_thiscallcc.
llvm-svn: 304535
2017-06-02 09:53:05 +00:00
Roger Ferrer Ibanez b4aef7963e Remove file that I forgot to remove as part of rL304523
llvm-svn: 304524
2017-06-02 07:21:27 +00:00
Roger Ferrer Ibanez fd9384a229 Mangle __unaligned in Itanium ABI
__unaligned is not currently mangled in any way in the Itanium ABI. This causes
failures when using -fms-extensions and C++ in targets using Itanium ABI.

As suggested by @rsmith the simplest thing to do here is actually mangle the
qualifier as a vendor extension.

This patch also removes the change done in D31976 and updates its test to the
new reality.

This fixes
  https://bugs.llvm.org/show_bug.cgi?id=33080
  https://bugs.llvm.org/show_bug.cgi?id=33178

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

llvm-svn: 304523
2017-06-02 07:14:34 +00:00
Richard Trieu 5fb874a484 Minor fixes to for-loop warning.
The warning for unchanged loop variables outputted a diagnostic that was
dependent on iteration order from a pointer set, which is not always
deterministic.  Switch to a set vector, which allows fast querying and
preserves ordering.

Also make other minor changes in this area.
Use more range-based for-loops.
Remove limitation on SourceRanges that no logner exists.

llvm-svn: 304519
2017-06-02 04:24:46 +00:00
Richard Smith 040e12662a Support lazy stat'ing of files referenced by module maps.
This patch adds support for a `header` declaration in a module map to specify
certain `stat` information (currently, size and mtime) about that header file.
This has two purposes:

- It removes the need to eagerly `stat` every file referenced by a module map.
  Instead, we track a list of unresolved header files with each size / mtime
  (actually, for simplicity, we track submodules with such headers), and when
  attempting to look up a header file based on a `FileEntry`, we check if there
  are any unresolved header directives with that `FileEntry`'s size / mtime and
  perform deferred `stat`s if so.

- It permits a preprocessed module to be compiled without the original files
  being present on disk. The only reason we used to need those files was to get
  the `stat` information in order to do header -> module lookups when using the
  module. If we're provided with the `stat` information in the preprocessed
  module, we can avoid requiring the files to exist.

Unlike most `header` directives, if a `header` directive with `stat`
information has no corresponding on-disk file the enclosing module is *not*
marked unavailable (so that behavior is consistent regardless of whether we've
resolved a header directive, and so that preprocessed modules don't get marked
unavailable). We could actually do this for all `header` directives: the only
reason we mark the module unavailable if headers are missing is to give a
diagnostic slightly earlier (rather than waiting until we actually try to build
the module / load and validate its .pcm file).

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

llvm-svn: 304515
2017-06-02 01:55:39 +00:00
Vedant Kumar a44a6ac81f Revert "[AArch64] Add ARMv8.2-A FP16 vefctor intrinsics"
This reverts commit r304493. It breaks all the Darwin bots:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental_check/37168

Failure:
Failing Tests (2):
    Clang :: CodeGen/aarch64-v8.2a-neon-intrinsics.c
    Clang :: CodeGen/arm_neon_intrinsics.c

llvm-svn: 304509
2017-06-02 01:22:14 +00:00
Akira Hatanaka 13b333108e [Sema] Improve -Wstrict-prototypes diagnostic message for blocks.
Print "this block declaration is not a prototype" for non-prototype
declarations of blocks instead of "this function declaration ...".

rdar://problem/32461723

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

llvm-svn: 304507
2017-06-02 01:07:08 +00:00
Richard Smith 4b46f72c7f PR32848: There isn't necessarily a FileChanged or FileSkipped for every InclusionDirective callback.
In particular, you don't get one if the inclusion directive encountered an
error. Don't assert in that case.

llvm-svn: 304506
2017-06-02 01:05:44 +00:00
Tim Shen a70ed1d693 [ThinLTO] Add x86 requires to thin_link_bitcode. NFC.
It already specifies the triples, so the intention was to test x86 for
now (or then).

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

llvm-svn: 304501
2017-06-02 00:08:58 +00:00
Davide Italiano 77378e42b3 [CodeGen] Surround assertion with parentheses.
This should placate GCC's -Wparentheses.

llvm-svn: 304499
2017-06-01 23:55:18 +00:00
Tim Shen 50fedec147 [ThinLTO] Wire up ThinLTO and new PM
Summary: This patch teaches clang to use and propagate new PM in ThinLTO.

Reviewers: davide, chandlerc, tejohnson

Subscribers: mehdi_amini, Prazek, inglorion, cfe-commits

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

llvm-svn: 304496
2017-06-01 23:27:51 +00:00
Abderrazek Zaafrani a44e5f601d [AArch64] Add ARMv8.2-A FP16 vefctor intrinsics
llvm-svn: 304493
2017-06-01 23:22:29 +00:00
Vedant Kumar 7f2e3d1eba Relax test to try and appease builders. NFC.
I'm not sure why, but on some bots, the order of two instructions are
swapped (as compared to the output on my machine). Loosen up the
CHECK-NEXT directives to deal with this.

Failing bot: http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3097

llvm-svn: 304486
2017-06-01 22:27:39 +00:00
Galina Kistanova 53ab424c0b Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304481
2017-06-01 21:29:45 +00:00
Galina Kistanova 387ab8b6da Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304479
2017-06-01 21:28:26 +00:00
Galina Kistanova 474f2ceff1 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304478
2017-06-01 21:26:38 +00:00
Galina Kistanova 1aead4f56e Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304477
2017-06-01 21:23:52 +00:00
Galina Kistanova 6ef911c417 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304475
2017-06-01 21:21:49 +00:00
Galina Kistanova d819d5bd68 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304473
2017-06-01 21:19:06 +00:00
Galina Kistanova 7767425168 Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304472
2017-06-01 21:15:34 +00:00
Keno Fischer 41d4b4e588 [CGDebugInfo] Finalize SubPrograms when we're done with them
`GenerateVarArgsThunk` in `CGVTables` clones a function before the frontend
is done emitting the compilation unit. Because of the way that DIBuilder
works, this means that the attached subprogram had incomplete (temporary)
metadata. Cloning such metadata is semantically disallowed, but happened
to work anyway due to bugs in the cloning logic. rL304226 attempted to fix
up that logic, but in the process exposed the incorrect API use here and
had to be reverted. To be able to fix this, I added a new method to
DIBuilder in rL304467, to allow finalizing a subprogram independently
of the entire compilation unit. Use that here, in preparation of re-applying
rL304226.

Reviewers: aprantl, dblaikie
Differential Revision: https://reviews.llvm.org/D33705

llvm-svn: 304470
2017-06-01 21:14:03 +00:00
Simon Pilgrim a5dbbc6ead Don't assume that a store source is a vector type just because the destination is (PR26099)
llvm-svn: 304465
2017-06-01 20:13:34 +00:00
Richard Smith c784e96eac Escape filenames in module map line marker directives, to unbreak Windows build bots.
llvm-svn: 304464
2017-06-01 20:10:35 +00:00
Vedant Kumar 85a83c2ced [Modules] Handle sanitizer feature mismatches when importing modules
This patch makes it an error to have a mismatch between the enabled
sanitizers in a CU, and in any module being imported into the CU. Only
mismatches between non-modular sanitizers are treated as errors.

This patch also includes non-modular sanitizers in module hashes, in
order to ensure module rebuilds occur when -fsanitize=X is toggled on
and off for non-modular sanitizers, and to cut down on module rebuilds
when the option is toggled for modular sanitizers.

This fixes a longstanding issue with implicit modules and sanitizers,
which Duncan originally diagnosed.

When building with implicit modules it's possible to hit a scenario
where modules are built without -fsanitize=address, and are subsequently
imported into CUs with -fsanitize=address enabled. This causes strange
failures at runtime. The case Duncan found affects libcxx, since its
vector implementation behaves differently when ASan is enabled.

Implicit module builds should "just work" when -fsanitize=X is toggled
on and off across multiple compiler invocations, which is what this
patch does.

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

llvm-svn: 304463
2017-06-01 20:01:01 +00:00
Vedant Kumar a125eb55cb [ubsan] Add a check for pointer overflow UB
Check pointer arithmetic for overflow.

For some more background on this check, see:

  https://wdtz.org/catching-pointer-overflow-bugs.html
  https://reviews.llvm.org/D20322

Patch by Will Dietz and John Regehr!

This version of the patch is different from the original in a few ways:

  - It introduces the EmitCheckedInBoundsGEP utility which inserts
    checks when the pointer overflow check is enabled.

  - It does some constant-folding to reduce instrumentation overhead.

  - It does not check some GEPs in CGExprCXX. I'm not sure that
    inserting checks here, or in CGClass, would catch many bugs.

Possible future directions for this check:

  - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
    accessing structures.

Testing: Apart from the added lit test, I ran check-llvm and check-clang
with a stage2, ubsan-instrumented clang. Will and John have also done
extensive testing on numerous open source projects.

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

llvm-svn: 304459
2017-06-01 19:22:18 +00:00
David Blaikie e16745f4e6 Add compatibility alias for -Wno-#warnings
GCC uses -Wno-cpp for this, so seems reasonable to add an alias to
match.

llvm-svn: 304456
2017-06-01 19:08:34 +00:00
Piotr Padlewski 4446e508ed Fixed broken test (strict-vtable-pointers)
llvm-svn: 304455
2017-06-01 19:08:05 +00:00
Keno Fischer 4792222fb5 [SemaCXX] Add diagnostics to require_constant_initialization
Summary:
This hooks up the detailed diagnostics of why constant initialization was
not possible if require_constant_initialization reports an error.
I have updated the test to account for the new notes.

Reviewed By: EricWF
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D24371

llvm-svn: 304451
2017-06-01 18:54:16 +00:00
Akira Hatanaka 14149bfa41 [CodeGen][ObjC] Fix assertion failure in EmitARCStoreStrongCall.
The assertion fails because EmitValueForIvarAtOffset doesn't get the
correct type of the ivar when the class the ivar belongs to is
parameterized. This commit fixes the function to compute the ivar's type
based on the type argument provided to the parameterized class.

rdar://problem/32461723

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

llvm-svn: 304449
2017-06-01 18:41:25 +00:00
Piotr Padlewski c1d26062f7 Emit invariant.group.barrier when using union field
Summary:
We need to emit barrier if the union field
is CXXRecordDecl because it might have vptrs. The testcode
was wrongly devirtualized. It also proves that having different
groups for different dynamic types is not sufficient.

Reviewers: rjmccall, rsmith, mehdi_amini

Subscribers: amharc, cfe-commits

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

llvm-svn: 304448
2017-06-01 18:39:34 +00:00
Simon Pilgrim fb9662ae71 Strip trailing whitespace. NFCI.
llvm-svn: 304445
2017-06-01 18:17:18 +00:00
Simon Pilgrim f940987a4e Remove late nullptr pointer test (PR32447)
IgnoreNarrowingConversion should never return nullptr, but I've added an assert just in case.

llvm-svn: 304444
2017-06-01 18:13:02 +00:00
Yaron Keren 1d498f26c6 Increase the limit for the number of DiagnosticLexKinds.td diags.
300 was reached in r304190, 400 should be enough for a while.

llvm-svn: 304411
2017-06-01 12:46:59 +00:00
Alexander Kornienko c7a0b672b8 Make the clang-cl test less restrictive.
Make the test less restrictive to allow directory layout used in our test setup.

llvm-svn: 304408
2017-06-01 11:41:21 +00:00
Piotr Padlewski 055477494b Fixed warnings
llvm-svn: 304397
2017-06-01 09:24:36 +00:00
Pekka Jaaskelainen 2eb0bcc9e6 [OpenCL] spir_kern by defaul: fix old test cases
llvm-svn: 304396
2017-06-01 08:19:43 +00:00
Piotr Padlewski d3b1cbd17f Emit available_externally vtables opportunistically
Summary:
We can emit vtable definition having inline function
if they are all emitted.

Reviewers: rjmccall, rsmith

Subscribers: cfe-commits

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

llvm-svn: 304394
2017-06-01 08:04:05 +00:00
Kristof Beyls 348df0de15 Adapt tests after making mcpu=generic the default for armv7-a and armv8-a.
llvm-svn: 304391
2017-06-01 07:31:50 +00:00
Pekka Jaaskelainen fc2629a65a [OpenCL] Makes kernels use the SPIR_KERNEL CC by default.
Rationale: OpenCL kernels are called via an explicit runtime API
with arguments set with clSetKernelArg(), not as normal sub-functions.
Return SPIR_KERNEL by default as the kernel calling convention to ensure
the fingerprint is fixed such way that each OpenCL argument gets one
matching argument in the produced kernel function argument list to enable
feasible implementation of clSetKernelArg() with aggregates etc. In case
we would use the default C calling conv here, clSetKernelArg() might
break depending on the target-specific conventions; different targets
might split structs passed as values to multiple function arguments etc.

https://reviews.llvm.org/D33639

llvm-svn: 304389
2017-06-01 07:18:49 +00:00
Peter Collingbourne 6d007c9747 docs: Document LLD's cache dir argument.
llvm-svn: 304385
2017-06-01 03:48:12 +00:00
Gor Nishanov 050e79e958 CGCleanup: (NFC) add another test for r304335 - Don't try to spill static allocas
Summary:
Coroutine related test that used to trigger broken IR prior to r304335.

```
%x = alloca i32, align 4
store i32* %x, i32** %tmp.exprcleanup, align 4 ; <===== HERE
%ref.tmp3 = alloca %struct.A, align 1
%agg.tmp5 = alloca %"struct.std::experimental::coroutines_v1::coroutine_handle.0", align 4
%tmp.exprcleanup = alloca i32*, align 4
%allocapt = bitcast i32 undef to i32
store i32 %0, i32* %.addr, align 4
```

Fixed with r304335

Subscribers: cfe-commits

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

llvm-svn: 304380
2017-06-01 01:15:25 +00:00
Richard Smith f03e9084c1 PR33232: implement support for MSVC's __is_trivially_destructible trait.
Unlike the GCC-compatible __has_trivial_destructor trait, this one computes the
right answer rather than performing the quirky set of checks described in GCC's
documentation (https://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html).

MSVC also has a __has_trivial_destructor trait which is the same as its (and
now Clang's) __is_trivially_destructible trait; we might want to consider
changing the behavior of __has_trivial_destructor if we're targeting an MSVC
platform, but I'm not doing so for now.

While implementing this I found that we were incorrectly rejecting
__is_destructible queries on arrays of unknown bound of incomplete types; that
too is fixed, and I've added similar tests for other traits for good measure.

llvm-svn: 304376
2017-06-01 00:28:16 +00:00
Eric Fiselier 84ee7ff741 [coroutines] Fix checking for prvalue-ness of `await_suspend` return type
Summary:
@rsmith Does this correctly address the issues mentioned in https://reviews.llvm.org/D33625#inline-292971 ?



Reviewers: rsmith, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits, rsmith

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

llvm-svn: 304373
2017-05-31 23:41:11 +00:00
Richard Smith 8b70610494 [modules] When compiling a preprocessed module map, look for headers relative
to the original module map.

Also use the path and name of the original module map when emitting that
information into the .pcm file. The upshot of this is that the produced .pcm
file will track information for headers in their original locations (where the
module was preprocessed), not relative to whatever directory the preprocessed
module map was in when it was built.

llvm-svn: 304346
2017-05-31 20:56:55 +00:00
Reid Kleckner 8ea89eaf7d [clang-cl] Expose -nostdinc and -nobuiltininc
These are already wired up to work in the MSVC toolchain header search
code. However, they were unreachable from clang-cl. A user attempted to
use them in https://bugs.llvm.org/show_bug.cgi?id=33205, so let's expose
them.

llvm-svn: 304345
2017-05-31 20:42:43 +00:00
Reid Kleckner 1d4cde6283 Fix cl-diagnostics.c test by hardcoding the version of MSVC to mimic
llvm-svn: 304337
2017-05-31 20:07:36 +00:00
Reid Kleckner 2918a2000b Add test case for r304316 which implemented clang-cl /diagnostics:*
llvm-svn: 304336
2017-05-31 20:02:27 +00:00
Reid Kleckner 0449316ea0 Don't try to spill static allocas when emitting expr cleanups with branches
Credit goes to Gor Nishanov for putting together the fix in
https://reviews.llvm.org/D33733!

This patch is essentially me patching it locally and writing some test
cases to convince myself that it was necessary for GNU statement
expressions with branches as well as coroutines. I'll ask Gor to land
his patch with just the coroutines test.

During LValue expression evaluation, references can be bound to
anything, really: call results, aggregate temporaries, local variables,
global variables, or indirect arguments. We really only want to spill
instructions that were emitted as part of expression evaluation, and
static allocas are not that.

llvm-svn: 304335
2017-05-31 19:59:41 +00:00
Eric Fiselier 37b8a374d9 [coroutines] Fix assertion during -Wuninitialized analysis
Summary: @rsmith Is there a better place to put this test?

Reviewers: GorNishanov, rsmith

Reviewed By: GorNishanov

Subscribers: cfe-commits, rsmith

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

llvm-svn: 304331
2017-05-31 19:36:59 +00:00
Craig Topper 0064858b0e [TableGen] Clang changes to support Record::getValueAsString and getValueAsListOfStrings returning StringRef instead of std::string
This is the clang version of D33710.

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

llvm-svn: 304326
2017-05-31 19:01:22 +00:00
Davide Italiano 5e458adf76 [CodeGen] Surround assertion with parens and format.
This should placate GCC7 with -Werror.

llvm-svn: 304322
2017-05-31 18:51:36 +00:00
Reid Kleckner ca77dd591e [clang-cl] Implement /diagnostic: flag
This flag has three possible values: caret, column, and classic.

"caret" corresponds to clang's default mode, "column" removes the caret
and code snippet, and "classic" emits nothing.

Documentation is here:
https://docs.microsoft.com/en-us/cpp/build/reference/diagnostics-compiler-diagnostic-options

Implements the last part of PR33237

llvm-svn: 304316
2017-05-31 17:37:49 +00:00
Reid Kleckner 6344f10fa9 Fix incorrect spelling of calling conv flag and add -Wno-msvc-not-found to test
llvm-svn: 304308
2017-05-31 15:50:35 +00:00
Erik Pilkington 608164077e [Sema][ObjC] Don't emit availability diags for category @implementations
These diagnostics can't be disabled, and can't actually catch any bugs.
rdar://32427296

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

llvm-svn: 304306
2017-05-31 15:45:57 +00:00
Reid Kleckner 4b2f3269ab [clang-cl] Improve default calling convention flag handling
Ignore default CC flags that don't make sense for the target arch. This
is consistent with MSVC.

Addresses part of PR33237

llvm-svn: 304305
2017-05-31 15:39:28 +00:00
Reid Kleckner 36438ba651 [clang-cl] Ignore /Zc:ternary, clang behaves this way already
Addresses part of PR33237

llvm-svn: 304303
2017-05-31 14:50:28 +00:00
Alexander Kornienko 50e3e123e8 Enable the ARM Neon intrinsics test by default.
The test being marked 'REQUIRES: long-tests' doesn't make sense. It's not the
first time the test is broken without being noticed by the committer. If the
test is too long, it should be shortened, split in multiple ones or removed
altogether. Keeping it as is is actively harmful.
(BTW, on my machine `ninja check-clang` takes 90-92 seconds with and without
this test. The difference in times is below the spread caused by random
factors.)

llvm-svn: 304302
2017-05-31 14:35:50 +00:00
Alexander Kornienko 915e3ab8f6 Revert "[ARM] Update long-test after r304201."
This reverts commit 304208, since r304201 has been reverted as well.

The test needs to be turned on by default to detect breakages earlier. Will
commit this change separately.

llvm-svn: 304301
2017-05-31 14:33:29 +00:00
Martin Probst 95ed8e7928 clang-format: [JS] improve calculateBraceType heuristic
Summary:

calculateBraceTypes decides for braced init for empty brace pairs ({}).
In context of a function declaration, this incorrectly classifies empty
function or method bodies as braced inits, leading to missing wraps:

    class C {
      foo() {}[bar]() {}
    }

Where code should have wrapped after "}", before "[". This change adds
another piece of contextual information in that braces following closing
parentheses must always be the opening braces of function blocks. This
fixes brace detection for methods immediately followed by brackets
(computed property declarations), but also curlies.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 304290
2017-05-31 09:29:40 +00:00
Richard Trieu 96b4962c8d [ODRHash] Support TemplateSpecializationType
llvm-svn: 304261
2017-05-31 00:31:58 +00:00
Richard Smith 567b81a042 [modules] Minor documentation clarification for behavior of requires-declaration.
llvm-svn: 304253
2017-05-30 23:05:23 +00:00
Richard Smith 2e374b6c72 Add an explicit -std= to test to unbreak on PS4 targets.
llvm-svn: 304237
2017-05-30 20:13:34 +00:00
Alexey Bataev 9780faaf8f [OpenMP][Driver] Put target binary for each offload target into a
separate section, by Sergey Dmitriev

Linker script that is generated by the clang driver for creating fat binary puts target binaries for all offload targets into a single ELF section .omp_offloading. This is not convenient because it greatly complicates operations with the final fat binary once it is linked. For example extracting target binary for a particular target from such fat executable would not be an easy task if you have more than one offload target.

Attached patch changes clang driver to put target binary for each
offload target into a separate ELF section .omp_offloading.<target
triple>.

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

llvm-svn: 304229
2017-05-30 18:57:51 +00:00
Javed Absar 089f678784 Reverting Neon vector type 64-alignment fix
The patch caused ABI breaks on darwin/others.
Reverting to come back with a more restrictive patch.

llvm-svn: 304220
2017-05-30 17:09:47 +00:00
Alexey Bataev 95b64a9826 [OPENMP] Allow 'use_device_ptr' clause in 'target data' alone.
According to OpenMP 5.0 at least one 'map' or 'use_device_ptr' clause
must be specified for 'target data' construct. Patch adds support for
this feature.

llvm-svn: 304216
2017-05-30 16:00:04 +00:00
Erik Verbruggen 346066b68c [libclang] Allow to suspend a translation unit.
A suspended translation unit uses significantly less memory but on the
other side does not support any other calls than
clang_reparseTranslationUnit to resume it or
clang_disposeTranslationUnit to dispose it completely.

This helps IDEs to reduce the memory footprint. The data that is freed
by a call to clang_suspendTranslationUnit will be re-generated on the
next (re)parse anyway. Used with a preamble, this allows pretty fast
resumption of the translation unit for further use (compared to disposal
of the translation unit and a parse from scratch).

Patch by Nikolai Kosjar!

llvm-svn: 304212
2017-05-30 14:25:54 +00:00
Diana Picus 6d5ac7af4a Fixup r304205 - Require PowerPC target
llvm-svn: 304211
2017-05-30 14:05:33 +00:00
Javed Absar 0841d620c5 Fix issue with test that caused bildbot failure
These tests did not specify the target. 
The failure was triggered by change - 
https://reviews.llvm.org/D33205
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/7314

which sets vector alignment to 8-byte for arm-targets (except for Android).
So, fixing the test to make it target specific. 

llvm-svn: 304210
2017-05-30 13:34:26 +00:00
Benjamin Kramer 88d73626cd [ARM] Update long-test after r304201.
llvm-svn: 304208
2017-05-30 12:44:48 +00:00
Erik Verbruggen b34c79ff27 Allow for unfinished #if blocks in preambles
Previously, a preamble only included #if blocks (and friends like
ifdef) if there was a corresponding #endif before any declaration or
definition. The problem is that any header file that uses include guards
will not have a preamble generated, which can make code-completion very
slow.

To prevent errors about unbalanced preprocessor conditionals in the
preamble, and unbalanced preprocessor conditionals after a preamble
containing unfinished conditionals, the conditional stack is stored
in the pch file.

This fixes PR26045.

Differential Revision: http://reviews.llvm.org/D15994

llvm-svn: 304207
2017-05-30 11:54:55 +00:00
Benjamin Kramer c796245431 [PPC] Make altivec conversion function macros.
The second argument must be a constant, otherwise instruction selection
will fail. always_inline is not enough for isel to always fold
everything away at -O0.

Sadly the overloading turned this into a big macro mess. Fixes PR33212.

llvm-svn: 304205
2017-05-30 11:37:29 +00:00
Javed Absar 3d92d7ab36 [ARM] Fix Neon vector type alignment to 64-bit
The maximum alignment for ARM NEON data types should be 64-bits as specified
in ARM procedure call standard document Sec. A.2 Notes.
This patch fixes it from its current larger natural default values, except
for Android (so as not to break existing ABI).
Reviewed by: Stephen Hines, Renato Golin.
Differential Revision: https://reviews.llvm.org/D33205

llvm-svn: 304201
2017-05-30 10:12:15 +00:00
Egor Churaev f59d921622 [OpenCL] Added diagnostic for implicit declaration of function in OpenCL
Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: bader, yaxunl

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

llvm-svn: 304193
2017-05-30 05:57:52 +00:00
Egor Churaev 707e37fb0d [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element
Summary:
This is the fix for patch https://reviews.llvm.org/D33353
@uweigand, could you please verify that everything will be good on SystemZ?
I added triple spir-unknown-unknown.
Thank you in advance!

Reviewers: uweigand

Reviewed By: uweigand

Subscribers: yaxunl, cfe-commits, bader, Anastasia, uweigand

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

llvm-svn: 304191
2017-05-30 05:32:03 +00:00
Richard Smith 51d09c512b Diagnose attempts to build a preprocessed module that defines an unavailable submodule.
The errors we would otherwise get are incomprehensible, as we would enter the
module but not make its contents visible to itself.

llvm-svn: 304190
2017-05-30 05:22:59 +00:00
Hiroshi Inoue d7b94d3840 [trivial] fix a typo in comment, NFC
llvm-svn: 304188
2017-05-30 05:06:46 +00:00
Richard Smith c5247e67e8 [modules] When we #include a local submodule header that we've already built,
and it has an include guard, produce callbacks for a module import, not for a
skipped non-modular header.

Fixes -E output when preprocessing a module to list these cases as a module
import, rather than suppressing the #include and losing the import side effect.

llvm-svn: 304183
2017-05-30 02:03:19 +00:00
Gor Nishanov 75a8ea5e88 CGCoroutine.cpp: (NFC) clang-format misplaced brace
llvm-svn: 304176
2017-05-29 21:15:31 +00:00
Artem Dergachev 4917f894fd [analyzer] Fix immutable map factory lifetime for partial taint.
This should fix the leaks found by asan buildbot in r304162.

Also don't store a reference to the factory with every map value,
which is the only difference between ImmutableMap and ImmutableMapRef.

llvm-svn: 304170
2017-05-29 18:54:02 +00:00
Benjamin Kramer e524ddeef3 Unbreak long test after r304127.
llvm-svn: 304167
2017-05-29 18:11:11 +00:00
Artem Dergachev eed7a3102c [analyzer] Support partially tainted records.
The analyzer's taint analysis can now reason about structures or arrays
originating from taint sources in which only certain sections are tainted.

In particular, it also benefits modeling functions like read(), which may
read tainted data into a section of a structure, but RegionStore is incapable of
expressing the fact that the rest of the structure remains intact, even if we
try to model read() directly.

Patch by Vlad Tsyrklevich!

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

llvm-svn: 304162
2017-05-29 15:42:56 +00:00
Artem Dergachev 8fa639ecf0 [analyzer] Initial commit for the upcoming refactoring of the IteratorChecker.
The new checker currently contains the very core infrastructure for tracking
the state of iterator-type objects in the analyzer: relating iterators to
their containers, tracking symbolic begin and end iterator values for
containers, and solving simple equality-type constraints over iterators.
A single specific check over this infrastructure is capable of finding usage of
out-of-range iterators in some simple cases.

Patch by Ádám Balogh!

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

llvm-svn: 304160
2017-05-29 15:03:20 +00:00
Artem Dergachev 7791593138 [analyzer] PthreadLockChecker: model failed pthread_mutex_destroy() calls.
pthread_mutex_destroy() may fail, returning a non-zero error number, and
keeping the mutex untouched. The mutex can be used on the execution branch
that follows such failure, so the analyzer shouldn't warn on using
a mutex that was previously destroyed, when in fact the destroy call has failed.

Patch by Malhar Thakkar!

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

llvm-svn: 304159
2017-05-29 14:51:39 +00:00
Martin Probst 816a9668bb clang-format: [JS] do not clean up duplicated commas.
Summary:
In JavaScript, duplicated commas have semantic meaning.
    x = [a,,b];

The statement above creates an array with three entries, the middle being undefined. Because clang-format should not change semantics, disable this cleanup in JS.

Reviewers: djasper

Subscribers: klimek

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

llvm-svn: 304141
2017-05-29 08:41:11 +00:00
Martin Probst b2f06eae8d clang-format: [JS] fix indenting bound functions.
Summary:
The previous fix to force build style wrapping if the previous token is a closing parenthesis broke a peculiar pattern where users parenthesize the function declaration in a bind call:
    fn((function() { ... }).bind(this));

This restores the previous behaviour by reverting that change, but narrowing the special case for unindenting closing parentheses to those followed by semicolons and opening braces, i.e. immediate calls and function declarations.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 304135
2017-05-29 07:50:52 +00:00
Egor Churaev dd7d82c408 [OpenCL] Test on half immediate support.
Reviewers: Anastasia

Reviewed By: Anastasia

Subscribers: yaxunl, cfe-commits, bader

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

llvm-svn: 304134
2017-05-29 07:44:22 +00:00
Mehdi Amini 6aa9e9b41a IRGen: Add optnone attribute on function during O0
Amongst other, this will help LTO to correctly handle/honor files
compiled with O0, helping debugging failures.
It also seems in line with how we handle other options, like how
-fnoinline adds the appropriate attribute as well.

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

llvm-svn: 304127
2017-05-29 05:38:20 +00:00
Eric Fiselier e38cea026b [coroutines] Support "coroutines" feature in module map requires clause
Summary: In order for libc++ to add `<experimental/coroutine>` to its module map, there has to be a feature that can be used to detect if coroutines support is enabled in Clang. 

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 304107
2017-05-28 21:07:22 +00:00
Eric Fiselier d978e53c6d [coroutines] Diagnose invalid result types for `await_resume` and `await_suspend` and add missing conversions.
Summary:
The expression `await_ready` is required to be contextually convertible to bool and `await_suspend` must be a prvalue of either `void` or `bool`.
This patch adds diagnostics for when those requirements are violated.

It also correctly performs the contextual conversion to bool on the result of `await_ready`



Reviewers: GorNishanov, rsmith

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

llvm-svn: 304094
2017-05-28 18:21:12 +00:00
Gor Nishanov b87931e983 [coroutines] www/cxx_status.html: add non-breaking hyphen
Reviewers: GorNishanov

Reviewed By: GorNishanov

Subscribers: EricWF, rsmith, cfe-commits

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

llvm-svn: 304092
2017-05-28 17:35:23 +00:00
Gor Nishanov 6ecbe540c6 [coroutines] www/cxx_status.html: add non-breaking hyphen
Reviewers: GorNishanov

Reviewed By: GorNishanov

Subscribers: EricWF, rsmith, cfe-commits

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

llvm-svn: 304091
2017-05-28 16:25:31 +00:00
Ismail Donmez fd934c29d3 baremetal.cpp: Fix tests where lib suffix is 64
llvm-svn: 304085
2017-05-28 06:15:42 +00:00
Gor Nishanov b5543e5b32 [coroutines] Mark cxx_status.html of Coroutines TS as (SVN)
Summary: It is time!

Reviewers: GorNishanov, rsmith

Reviewed By: GorNishanov, rsmith

Subscribers: EricWF, rsmith, cfe-commits

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

llvm-svn: 304081
2017-05-27 22:54:52 +00:00
Eric Fiselier 9208dd63ef Revert "[coroutines] Support "coroutines" feature in module map requires clause"
This reverts commit r304054.

llvm-svn: 304057
2017-05-27 03:04:51 +00:00
George Rokos 29d0f00340 [OpenMP] Create COMDAT group for OpenMP offload registration code to avoid multiple copies
Thanks to Sergey Dmitriev for submitting the patch.

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

llvm-svn: 304056
2017-05-27 03:03:13 +00:00
Eric Fiselier 0bb3bcd0ef [coroutines] Support "coroutines" feature in module map requires clause
Summary: In order for libc++ to add `<experimental/coroutine>` to its module map, there has to be a feature that can be used to detect if coroutines support is enabled in Clang. 

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 304054
2017-05-27 02:46:17 +00:00
Konstantin Zhuravlyov 1f144a18ff Resubmit r303861.
[AMDGPU] add __builtin_amdgcn_s_getpc

Patch by Tim Corringham

llvm-svn: 304033
2017-05-26 21:08:20 +00:00
Benjamin Kramer 5097a1184b Remove unused diagnostics. NFC.
llvm-svn: 304030
2017-05-26 20:14:12 +00:00
Benjamin Kramer 674d579271 Make helper functions static. NFC.
llvm-svn: 304028
2017-05-26 20:08:24 +00:00
Petr Hosek 5326bb4a77 [scan-build] Patch to scan-build tool to support "--target=<value>" flag
The scan-build script provided by clang can be used to detect defects in
code in the compile time. However, we discovered that the
"--target=<value>" flag in clang is not properly handled by this script,
which results in failures when analyzing projects that have used this
flag in their makefile.

This single line of change allows scan-build script to properly handle
the "--target=<value>" flag.

Patch by Haowei Wu

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

llvm-svn: 304025
2017-05-26 19:25:32 +00:00
Arnold Schwaighofer 634e320376 CodeGen: Define Swift's legal vector types for AArch64, ARM
rdar://32401301

llvm-svn: 304017
2017-05-26 18:11:54 +00:00
Reid Kleckner a40b38a637 Only define __SIZEOF_FLOAT128__ on x86 as intended in r304012
GCC only defines it on x86.

llvm-svn: 304013
2017-05-26 17:48:01 +00:00
Reid Kleckner 9eabbb6066 Enable __float128 for mingw for GCC compatibility and define __SIZEOF_FLOAT128__ on x86
GCC defines __FLOAT128__ on Power and __SIZEOF_FLOAT128__ on x86. We're
just following the inconsistency for now so users have some way to test.

Effectively merges this patch as requested by Martell Malone:
https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-clang/0107-enable-__float128-for-X86-MinGW.patch

llvm-svn: 304012
2017-05-26 17:38:15 +00:00
Reid Kleckner 9e2584aa52 Update MS mangling EBNF, NFC
llvm-svn: 304006
2017-05-26 17:11:10 +00:00
Aaron Ballman 5c0d113fb9 Adding a const overload of DesignatedInitExpr::getDesignator().
llvm-svn: 304000
2017-05-26 15:55:52 +00:00
Renato Golin c058cc6511 Revert "[OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element"
This reverts commit r303986 as it broke all ARM and AArch64 buildbots...

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-39vma/builds/7007
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/6705
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/7509
etc.

llvm-svn: 303996
2017-05-26 15:32:45 +00:00
Egor Churaev 1adf265287 [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element
Reviewers: Anastasia

Reviewed By: Anastasia

Subscribers: cfe-commits, bader, yaxunl

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

llvm-svn: 303986
2017-05-26 13:30:26 +00:00
George Burgess IV a911cb4ec8 [docs] Point coroutine link to an actual document
Unsure if there's a better document, but what we had before led to a
404. :)

llvm-svn: 303962
2017-05-26 02:56:51 +00:00
Tim Northover 0150333a3c Create valid LValue to represent null pointers in constant exprs
We were leaving the SubobjectDesignator in a surprising situation, where
it was allegedly valid but didn't actually refer to a type. This caused
a crash later on.

This patch fills out the SubobjectDesignator with the pointee type (as
happens in other evaluations of constant pointers) so that we don't
crash later.

llvm-svn: 303957
2017-05-26 02:16:00 +00:00
Richard Smith 1d60987fd3 Factor resolving of header directives -> files out of module map parser.
llvm-svn: 303945
2017-05-26 00:01:53 +00:00
Richard Trieu d3bc3e0138 "*" => "+" to avoid matching on empty string.
llvm-svn: 303934
2017-05-25 23:25:36 +00:00
Richard Trieu 13b12dc02d Make test/Driver/baremetal.cpp work when output directory isn't named 'bin'.
llvm-svn: 303932
2017-05-25 23:03:08 +00:00
Richard Smith 883dbc43d9 Switch from using a DiagnosticTrap and a note for "while defining a special
member function" context notes to registering an entry on the context stack.

Also reorder the steps within defining special members to be consistent.

This has a few benefits: if multiple diagnostics are produced while checking
such a member, the note is now attached to the first such diagnostic rather
than the last, this prepares us for persisting these diagnostics between the
point at which we require the implicit instantiation of a template and the
point at which that instantiation is actually performed, and this fixes some
cases where we would fail to produce a full note stack leading back to user
code in the case of such a diagnostic.

The reordering exposed a case where we could recursively attempt to define a
defaulted destructor while we're already defining one (and other such cases
also appear to be possible, with or without this change), so this change also
reuses the "willHaveBody" flag on function declarations to track that we're in
the middle of synthesizing a body for the function and bails out if we try to
define a function that we're already defining.

llvm-svn: 303930
2017-05-25 22:47:05 +00:00