Commit Graph

68685 Commits

Author SHA1 Message Date
Evgeniy Stepanov c39f67bb2e Fix clang_cl argument in fsanitize.c driver test.
llvm-svn: 302594
2017-05-09 22:28:57 +00:00
Eric Fiselier b0bac2dafb [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member
Summary: This patch implements http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 which reverts Core 496.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 302593
2017-05-09 22:21:24 +00:00
Eric Fiselier a34cb77273 Update Clang C++ DR documentation for new issue list
llvm-svn: 302592
2017-05-09 22:17:23 +00:00
Evgeniy Stepanov d991cdd50b [asan] A clang flag to enable ELF globals-gc.
This feature is subtly broken when the linker is gold 2.26 or
earlier. See the following bug for details:
  https://sourceware.org/bugzilla/show_bug.cgi?id=19002

Since the decision needs to be made at compilation time, we can not
test the linker version. The flag is off by default on ELF targets,
and on otherwise.

llvm-svn: 302591
2017-05-09 21:57:43 +00:00
Evgeniy Stepanov b86ca11b57 Remove unnecessary calls to MakeArgString.
llvm-svn: 302590
2017-05-09 21:57:39 +00:00
Serge Guelton 29405c94e6 Fix CGObjCGNU::init bug introduced by r302572
llvm-svn: 302588
2017-05-09 21:19:44 +00:00
Martin Probst 101ec894c3 clang-format: [JS] Don't indent JavaScript IIFEs.
Because IIFEs[1] are often used like an anonymous namespace around large
sections of JavaScript code, it's useful not to indent to them (which
effectively reduces the column limit by the indent amount needlessly).

It's also common for developers to wrap these around entire files or
libraries. When adopting clang-format, changing the indent entire file
can reduce the usefulness of the blame annotations.

Patch by danbeam, thanks!

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

llvm-svn: 302580
2017-05-09 20:04:09 +00:00
Adrian Prantl dfa7f613ed Update testcase for upstream LLVM changes (r302469).
llvm-svn: 302577
2017-05-09 19:47:41 +00:00
Serge Guelton 1d993270b3 Suppress all uses of LLVM_END_WITH_NULL. NFC.
Use variadic templates instead of relying on <cstdarg> + sentinel.

This enforces better type checking and makes code more readable.

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

llvm-svn: 302572
2017-05-09 19:31:30 +00:00
Sam Clegg 8f0129c407 [WebAssembly] Fix failing wasm-toolchain test
This test was broken in r302558.

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

llvm-svn: 302569
2017-05-09 18:44:23 +00:00
Simon Pilgrim 073c4e66b0 [X86][LWP] Remove MSVC LWP intrinsics stubs.
Now provided in lwpintrin.h

llvm-svn: 302559
2017-05-09 17:50:16 +00:00
Sam Clegg 27ea1567a4 [WebAssembly] Fix location and -flavor when running lld
Add the toolchain installation directory to the program
path so that lld can be found.

Change -flavor to wasm.  Although this new flavor hasn't
yet landed in upstream lld yet there are no point in
passing wasm objects the gnu flavor.

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

llvm-svn: 302558
2017-05-09 17:47:50 +00:00
Simon Pilgrim 7855510ae3 [X86][LWP] Removing LWP todo comment. NFCI.
LWP / lwpintrin.h is now supported

llvm-svn: 302557
2017-05-09 17:43:16 +00:00
Adrian Prantl 1cc3474ec1 Build the Apple-style stage2 with modules
Green dragon had a green stage2 modules bot for a long time now[1] and
it is time to retire it and make a modules build the default for
Apple-style stage2 builds.

This patch turns on LLVM_ENABLE_MODULES.

[1] http://green.lab.llvm.org/green/job/clang-stage2-cmake-modulesRDA_build/
rdar://problem/28672159

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

llvm-svn: 302556
2017-05-09 17:27:03 +00:00
Petar Jovanovic 753267b750 Revert r302547 ([mips] Impose a threshold for coercion of aggregates)
Reverting
  Modified MipsABIInfo::classifyArgumentType so that it now coerces
  aggregate structures only if the size of said aggregate is less than 16/64
  bytes, depending on the ABI.
as it broke clang-with-lto-ubuntu builder.

llvm-svn: 302555
2017-05-09 17:20:06 +00:00
Petar Jovanovic 125c03070e [mips] Impose a threshold for coercion of aggregates
Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate
structures only if the size of said aggregate is less than 16/64 bytes,
depending on the ABI.

Patch by Stefan Maksimovic.

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

llvm-svn: 302547
2017-05-09 16:24:03 +00:00
Alex Lorenz f7f6f823a4 [CodeCompletion] Complete platform names in @available expressions
rdar://32074504

llvm-svn: 302545
2017-05-09 16:05:04 +00:00
Hans Wennborg fb82abd845 Revert r302476 "Update testcase for upstream LLVM changes."
That test update was for r302469, which was reverted in r302533 due to PR32977.

llvm-svn: 302542
2017-05-09 15:55:39 +00:00
Alex Lorenz e1fb64e5e2 Add support for pretty platform names to `@available`/
`__builtin_available`

This commit allows us to use the macOS/iOS/tvOS/watchOS platform names in
`@available`/`__builtin_available`.

rdar://32067795

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

llvm-svn: 302540
2017-05-09 15:34:46 +00:00
Martin Probst 2083f31b88 clang-format: [JS] keep triple slash directives intact.
Summary:
TypeScript uses triple slash directives of the form:
    /// <reference path="..."/>

For various non-source instructions that should not be wrapped.

Reference:
https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 302523
2017-05-09 12:45:48 +00:00
Vassil Vassilev f8622dff7a PR5935: Adjust documentation.
https://reviews.llvm.org/D31867

Patch by Johannes Altmanninger!

llvm-svn: 302521
2017-05-09 12:37:15 +00:00
Vassil Vassilev 64e1e1ea0a Reland "Warn about unused static file scope function template declarations."
This patch reinstates r299930, reverted in r299956, as a separate diagnostic
option (-Wunused-template). 

llvm-svn: 302518
2017-05-09 11:25:41 +00:00
Faisal Vali 40fd4cebf8 Fix PR32638 : Make sure we switch Sema's CurContext to the substituted FunctionDecl when instantiating the exception specification.
This fixes the bug: https://bugs.llvm.org/show_bug.cgi?id=32638

  int main()
  {
    [](auto x) noexcept(noexcept(x)) { } (0);
  }

In the above code, prior to this patch, when substituting into the noexcept expression, i.e. transforming the DeclRefExpr that represents 'x' - clang attempts to capture 'x' because Sema's CurContext is still pointing to the pattern FunctionDecl (i.e. the templated-decl set in FinishTemplateArgumentDeduction) which does not match the substituted 'x's DeclContext, which leads to an attempt to capture and an assertion failure.  

We fix this by adjusting Sema's CurContext to point to the substituted FunctionDecl under which the noexcept specifier's argument should be transformed, and so the ParmVarDecl that 'x' refers to has the same declcontext and no capture is attempted. 

I briefly investigated whether the SwitchContext should occur right after VisitMethodDecl creates the new substituted FunctionDecl, instead of only during instantiating the exception specification - but seeing no other code that seemed to rely on that, I decided to leave it just for the duration of the exception specification instantiation.

llvm-svn: 302507
2017-05-09 04:17:15 +00:00
George Burgess IV 1dbfa856b1 [Sema] Make typeof(OverloadedFunctionName) not a pointer.
We were sometimes doing a function->pointer conversion in
Sema::CheckPlaceholderExpr, which isn't the job of CheckPlaceholderExpr.

So, when we saw typeof(OverloadedFunctionName), where
OverloadedFunctionName referenced a name with only one function that
could have its address taken, we'd give back a function pointer type
instead of a function type. This is incorrect.

I kept the logic for doing the function pointer conversion in
resolveAndFixAddressOfOnlyViableOverloadCandidate because it was more
consistent with existing ResolveAndFix* methods.

llvm-svn: 302506
2017-05-09 04:06:24 +00:00
Richard Trieu b35ef2a599 [ODRHash] Loosen checks on typedefs.
When a type in a class is from a typedef, only check the canonical type.  Skip
checking the intermediate underlying types.  This is in response to PR 32965

llvm-svn: 302505
2017-05-09 03:24:34 +00:00
Akira Hatanaka 2cd7e8652c [Sema][ObjC] Clean up possible null dereference.
It appears that the code is actually dead since unbridged-cast
placeholder types are created by calling CastOperation::complete and
ImplicitCastExprs are never passed to it.

Spotted by Vedant Kumar.

rdar://problem/31542226

llvm-svn: 302503
2017-05-09 01:54:51 +00:00
Tom Stellard 9c52dfebfe docs: Fix Sphinx detection with out-of-tree builds
Adapt to changes made in r302499.

llvm-svn: 302500
2017-05-09 01:42:33 +00:00
Akira Hatanaka 855d70cb67 [CodeGen][ObjC] Emit @objc_retain at -O0 for variables captured by
blocks.

r302270 made changes to avoid emitting clang.arc.use at -O0 and instead
emit @objc_release. We also have to emit @objc_retain for the captured
variable at -O0 to match the @objc_release instead of just storing the
pointer to the capture field.

llvm-svn: 302495
2017-05-09 01:20:05 +00:00
Dean Michael Berris 42af651358 [XRay] Add __xray_customeevent(...) as a clang-supported builtin
Summary:
We define the `__xray_customeevent` builtin that gets translated to
IR calls to the correct intrinsic. The default implementation of this is
a no-op function. The codegen side of this follows the following logic:

- When `-fxray-instrument` is not provided in the driver, we elide all
calls to `__xray_customevent`.
- When `-fxray-instrument` is enabled and a function is marked as "never
instrumented", we elide all calls to `__xray_customevent` in that
function; if either marked as "always instrumented" or subject to
threshold-based instrumentation, we emit a call to the
`llvm.xray.customevent` intrinsic from LLVM for each
`__xray_customevent` occurrence in the function.

This change depends on D27503 (to land in LLVM first).

Reviewers: echristo, rsmith

Subscribers: mehdi_amini, pelikan, lrl, cfe-commits

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

llvm-svn: 302492
2017-05-09 00:45:40 +00:00
Bruno Cardoso Lopes d6e3289cb2 [Modules] Allow umbrella frameworks to define private submodules for subframeworks
In r298391 we fixed the umbrella framework model to work when submodules
named "Private" are used. This complements the work by allowing the
umbrella framework model to work in general.

rdar://problem/31790067

llvm-svn: 302491
2017-05-09 00:41:38 +00:00
Vedant Kumar 94cb34b6a1 Rename a method. NFC.
llvm-svn: 302490
2017-05-09 00:12:33 +00:00
Adrian Prantl 4fa6a33ff6 Update testcase for upstream LLVM changes.
llvm-svn: 302476
2017-05-08 22:44:00 +00:00
Vedant Kumar a9d8be68c1 [Driver] Don't enable -fsanitize-use-after-scope when ASan is disabled
When enabling any sanitizer, -fsanitize-use-after-scope is enabled by
default. This doesn't actually turn ASan on, because we've been getting
lucky and there are extra checks in BackendUtil that stop this from
happening.

However, this has been causing a behavior change: extra lifetime markers
are emitted in some cases where they aren't needed or expected.

llvm-svn: 302468
2017-05-08 21:11:55 +00:00
Richard Smith 4a3751ff24 If we are building a module, and we read a second description of the same
module from a different module map, ignore it.

This happens during builds of preprocessed modules (where it is harmless).

llvm-svn: 302463
2017-05-08 20:30:47 +00:00
Simon Pilgrim 0fd1b6c0dc [X86][LWP] Add __LWP__ macro tests
Missed in rL302418

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

llvm-svn: 302445
2017-05-08 17:25:48 +00:00
Jonathan Roelofs f358d48f23 Fix grammar in comment. NFC
llvm-svn: 302443
2017-05-08 17:06:17 +00:00
Malcolm Parsons 2eac1d881a [AST] Fix copy&paste error in comment. NFC.
llvm-svn: 302440
2017-05-08 16:43:29 +00:00
Anastasia Stulova f16634c884 [Sema] Fix typos handling in an overloadable call.
In C typos in arguments in a call of an overloadable function lead
to a failure of construction of CallExpr and following recovery does
not handle created delayed typos. This causes an assertion fail in
Sema::~Sema since Sema::DelayedTypos remains not empty.

The patch fixes that behavior by handling a call with arguments
having dependant types in the way that C++ does.

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

Patch by Dmitry Borisenkov!

llvm-svn: 302435
2017-05-08 16:05:54 +00:00
Daniel Jasper 7fdbb3feda [clang-format] Convert AlignEscapedNewlinesLeft to an enum, adding
DontAlign

This converts the clang-format option AlignEscapedNewlinesLeft from a
boolean to an enum, named AlignEscapedNewlines, with options Left (prev.
true), Right (prev. false), and a new option DontAlign.

When set to DontAlign, the backslashes are placed just after the last token in each line:
  #define EXAMPLE \
    do { \
        int x = aaaaa; \
        int b; \
        int dddddddddd; \
    } while (0)

Patch by jtbandes. Thank you!

llvm-svn: 302428
2017-05-08 15:08:00 +00:00
Daniel Jasper 988e7e4fe8 [clang-format] Don’t propagate AvoidBinPacking into argument
subexpressions

This is an attempt to fix the issue described in a recent email:
http://lists.llvm.org/pipermail/cfe-dev/2017-April/053632.html

Patch by jtbandes. Thank you!
Review: https://reviews.llvm.org/D32475

llvm-svn: 302427
2017-05-08 15:07:52 +00:00
Aaron Ballman b6d8070205 Correct the attribute spelling for guarded_var and pt_guarded_var.
Patch by Roman Lebedev.

llvm-svn: 302419
2017-05-08 12:39:17 +00:00
Simon Pilgrim 3511348dbb [X86][LWP] Add clang support for LWP instructions.
This patch adds support for the the LightWeight Profiling (LWP) instructions which are available on all AMD Bulldozer class CPUs (bdver1 to bdver4).

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

llvm-svn: 302418
2017-05-08 12:09:45 +00:00
Sven van Haastregt 511f0b8d02 [OpenCL] Check that global samplers are const
Patch by Simon Perretta.

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

llvm-svn: 302411
2017-05-08 09:29:06 +00:00
Eric Fiselier d3ff21cf42 Update LanguageExtensions doc to refer to C++14 instead of C++1y
llvm-svn: 302364
2017-05-06 23:26:04 +00:00
Kostya Serebryany 50fb618b93 [sanitizer-coverage] implement -fsanitize-coverage=no-prune,... instead of a hidden -mllvm flag. clang part.
llvm-svn: 302320
2017-05-05 23:28:18 +00:00
Tim Northover 23bcad226c AArch64: fix weird edge case in ABI.
It turns out there are some sort-of-but-not-quite empty structs that break all
the rules. For example:

struct SuperEmpty { int arr[0]; };
struct SortOfEmpty { struct SuperEmpty e; };

Both of these have sizeof == 0, even in C++ mode, for GCC compatibility. The
first one also doesn't occupy a register when passed by value in GNU C++ mode,
unlike everything else.

On Darwin, we want to ignore the lot (and especially don't want to try to use
an i0 as we were).

llvm-svn: 302313
2017-05-05 22:36:06 +00:00
Richard Smith ce03732ec8 Permit keywords in module names in #pragma clang module *.
This is necessary to be able to build a libc++ module from preprocessed source
(due to the submodule std.new).

llvm-svn: 302312
2017-05-05 22:34:07 +00:00
Richard Smith 8128f3327f Add support for building modules from preprocessed source.
To support this, an optional marker "#pragma clang module contents" is
recognized in module map files, and the rest of the module map file from that
point onwards is treated as the source of the module. Preprocessing a module
map produces the input module followed by the marker and then the preprocessed
contents of the module.

Ignoring line markers, a preprocessed module might look like this:

  module A {
    header "a.h"
  }
  #pragma clang module contents
  #pragma clang module begin A
  // ... a.h ...
  #pragma clang module end

The preprocessed output generates line markers, which are not accepted by the
module map parser, so -x c++-module-map-cpp-output should be used to compile
such outputs.

A couple of major parts do not work yet:

1) The files that are listed in the module map must exist on disk, in order to
   build the on-disk header -> module lookup table in the PCM file. To fix
   this, we need the preprocessed output to track the file size and other stat
   information we might use to build the lookup table.

2) Declaration ownership semantics don't work properly yet, since mapping from
   a source location to a module relies on mapping from FileIDs to modules,
   which we can't do if module transitions can occur in the middle of a file.

llvm-svn: 302309
2017-05-05 22:18:51 +00:00
Jonathan Roelofs c8e377c326 Multilib: add dump methods
llvm-svn: 302296
2017-05-05 21:30:13 +00:00
Jakub Kuderski 64b6c78e94 Add cxxStdInitializerListExpr AST matcher
Summary:
This adds a new ASTMatcher for CXXStdInitializerListExprs that matches C++ initializer list expressions.

The primary motivation is to use it to fix [[ https://bugs.llvm.org/show_bug.cgi?id=32896 | PR32896 ]] (review here [[ https://reviews.llvm.org/D32767 | D32767 ]]).

Reviewers: alexfh, Prazek, aaron.ballman

Reviewed By: alexfh, aaron.ballman

Subscribers: malcolm.parsons, cfe-commits, klimek

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

llvm-svn: 302287
2017-05-05 21:01:12 +00:00
Richard Trieu 7dd8073284 [ODRHash] Fix typo, NFC
NestedNameSpecifer to NestedNameSpecifier.  This was not a problem before since
one of the included headers transitively brought in the definition of the class
and only manifested as a problem when using the typoed NestedNameSpecifer and
getting an incomplete type error instead of a typo correction.

llvm-svn: 302284
2017-05-05 20:47:50 +00:00
Aaron Ballman 05fd05ac52 Do not redefine the THREAD_ANNOTATION_ATTRIBUTE__ macro in the documentation.
Patch by Roman Lebedev.

llvm-svn: 302275
2017-05-05 19:56:09 +00:00
Weiming Zhao be380c711c [ARM] Limit the diagnose when an ISR calls a regular function
Summary:
When the function is compiled with soft-float or on CPU with no FPU, we
don't need to diagnose for a call from an ISR to a regular function.

Reviewers: jroelofs, eli.friedman

Reviewed By: jroelofs

Subscribers: aemerson, rengolin, javed.absar, cfe-commits

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

llvm-svn: 302274
2017-05-05 19:25:29 +00:00
Saleem Abdulrasool d95f625000 CodeGen: avoid use of @clang.arc.use intrinsic at O0
The clang.arc.use intrinsic is removed via the ARC Contract Pass.  This
pass is only executed in optimized builds (>= opt level 1).  Prevent the
optimization implemented in SVN r301667 from triggering at optimization
level 0 like every other ARC use intrinsic usage.

llvm-svn: 302270
2017-05-05 18:39:06 +00:00
Nico Weber 050af67ea8 ANSIfy more. Still no behavior change.
llvm-svn: 302259
2017-05-05 17:16:58 +00:00
Nico Weber 0a234047eb ANSIfy. No behavior change.
llvm-svn: 302258
2017-05-05 17:15:08 +00:00
Nico Weber 469891e7a2 Warn that the [] spelling of uuid(...) is deprecated.
https://reviews.llvm.org/D32879

llvm-svn: 302255
2017-05-05 17:05:56 +00:00
Alex Lorenz 9c5c2bfe54 Add a fix-it for -Wunguarded-availability
This patch adds a fix-it for the -Wunguarded-availability warning. This fix-it
is similar to the Swift one: it suggests that you wrap the statement in an
`if (@available)` check. The produced fixits are indented (just like the Swift
ones) to make them look nice in Xcode's fix-it preview.

rdar://31680358

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

llvm-svn: 302253
2017-05-05 16:42:44 +00:00
Alex Lorenz 9282483b11 [ObjC] Don't disallow vector parameters/return values in methods
whose introduced version is lower than the allowed version.

We should just rely on the target version as this introduced version can lead
to false positives (e.g. deprecated declarations).

rdar://31964333

llvm-svn: 302250
2017-05-05 16:15:17 +00:00
Nico Weber d7ba86b6bf Introduce Wzero-as-null-pointer-constant.
Add an opt-in warning that fires when 0 is used as a null pointer. 
gcc has this warning, and there's some demand for it.

https://reviews.llvm.org/D32914

llvm-svn: 302247
2017-05-05 16:11:08 +00:00
Alex Lorenz 921ab75854 [Driver] Add a "-mmacos_version_min" option that's an alias for
"-mmacosx_version_min"

The option -mmacosx_version_min will still be the canonical option for now, but
in the future we will switch over to -mmacos_version_min and make
-mmacosx_version_min an alias instead.

rdar://27043820

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

llvm-svn: 302240
2017-05-05 14:52:48 +00:00
Krasimir Georgiev 024b0644a6 [Tooling] Remove redundant check, NFCi
Summary: The Database check looks redundant.

Reviewers: bkramer

Subscribers: klimek, cfe-commits

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

llvm-svn: 302236
2017-05-05 14:07:23 +00:00
Jonathan Roelofs 55bec44c9c Document that Multilib flags must be actual flags
This is because -print-multi-lib depends on them being flags for correctness.

Fixes a case of this in the arm-android multilib selection logic.

llvm-svn: 302207
2017-05-05 00:18:27 +00:00
James Y Knight 7f3190118b Fix whitespace before token-paste of an argument.
The whitespace should come from the argument name in the macro
expansion, rather than from the token passed to the macro (same as it
does when not pasting).

Added a new test case for the change in behavior to stringize_space.c.

FileCheck'ized macro_paste_commaext.c, tweaked the test case, and
added a comment; no behavioral change to this test.

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

llvm-svn: 302195
2017-05-04 21:31:17 +00:00
Nico Weber 9ed65da6ad Turn on -Wmicrosoft-enum-forward-reference by default.
clang-cl already errs or warns on everything that cl
warns on in /permissive- mode, except for enum foward
declarations (and ATL attributes).
So warn on enum forward declarations by default.

llvm-svn: 302190
2017-05-04 19:54:50 +00:00
Reid Kleckner f1deb837ee Fix bugs checking va_start in lambdas and erroneous contexts
Summary:
First, getCurFunction looks through blocks and lambdas, which is wrong.
Inside a lambda, va_start should refer to the lambda call operator
prototype. This fixes PR32737.

Second, we shouldn't use any of the getCur* methods, because they look
through contexts that we don't want to look through (EnumDecl,
CapturedStmtDecl). We can use CurContext directly as the calling
context.

Finally, this code assumed that CallExprs would never appear outside of
code contexts (block, function, obj-c method), which is wrong. Struct
member initializers are an easy way to create and parse exprs in a
non-code context.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 302188
2017-05-04 19:51:05 +00:00
Nico Weber dea97cfbf9 Turn -Wmicrosoft-enum-value off by default.
The warning is currently way too noisy to be useful. The plan is
to make it warn when an MS enum that's negative is compared to
something, but until that's done the warning shouldn't default
to on.

llvm-svn: 302187
2017-05-04 19:36:26 +00:00
Saleem Abdulrasool c5728ca3e1 Driver: only inject libstdc++ paths when needed on CrossWindows
When building with libc++ don't bother with injecting the libstdc++
search paths into the linker search path.  This will make it easier to
switch between ld and lld.

llvm-svn: 302184
2017-05-04 19:18:21 +00:00
Reid Kleckner 6d2ea6ec80 [ms-inline-asm] Use the frontend size only for ambiguous instructions
This avoids problems on code like this:
  char buf[16];
  __asm {
    movups xmm0, [buf]
    mov [buf], eax
  }

The frontend size in this case (1) is wrong, and the register makes the
instruction matching unambiguous. There are also enough bytes available
that we shouldn't complain to the user that they are potentially using
an incorrectly sized instruction to access the variable.

Supersedes D32636 and D26586 and fixes PR28266

llvm-svn: 302179
2017-05-04 18:19:52 +00:00
Peter Collingbourne 9667b91b13 Re-apply r302108, "IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI."
with a fix for the clang backend.

llvm-svn: 302176
2017-05-04 18:03:25 +00:00
Alexander Kornienko bde6fa9ca7 [Tooling] add a createReplacement overload for StringRef
llvm-svn: 302159
2017-05-04 15:34:06 +00:00
Martin Probst 4ef0370e6d clang-format: [JS] exponentiation operator
Summary: While its precedence should be higher than multiplicative, LLVM does not have a level for that, so for the time being just treat it as multiplicative.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 302156
2017-05-04 15:04:04 +00:00
Alex Lorenz ce4518f21d DiagnosticsEngine should clear DelayedDiagID before reporting the
delayed diagnostic

This fix avoids an infinite recursion that was uncovered in one of our internal
tests by r301992. The testcase is the most reduced version of that
auto-generated test.

This is an improved version of the reverted commit r302037. The previous fix
actually managed to expose another subtle bug whereby `fatal_too_many_errors`
error was reported twice, with the second report setting the
`FatalErrorOccurred` flag. That prevented the notes that followed the diagnostic
the caused `fatal_too_many_errors` to be emitted. This commit ensures that notes
that follow `fatal_too_many_errors` but that belong to the diagnostic that
caused `fatal_too_many_errors` won't be emitted by setting the
`FatalErrorOccurred` when emitting `fatal_too_many_errors`.

rdar://31962618

llvm-svn: 302151
2017-05-04 13:56:51 +00:00
Sylvestre Ledru 6cf800a6f7 Add support of the next Ubuntu (Ubuntu 17.10 - Artful Aardvark)
llvm-svn: 302143
2017-05-04 12:46:38 +00:00
Eric Liu b064f6b0ad Revert "IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI."
This reverts commit r302108.

llvm-svn: 302141
2017-05-04 12:05:40 +00:00
Alex Lorenz 9e2fea198c [Index] The relation between the declarations in template
specializations that 'override' declarations in the base template should use
the 'specializationOf' relation instead of 'specializationOf | overrideOf'.

The indexer relations are meant to be orthogonal, so 'specializationOf' is
better than the combined relation.

llvm-svn: 302136
2017-05-04 10:42:06 +00:00
Sam Parker b9ea36f9c1 [ARM] ACLE Chapter 9 intrinsics
Implemented the remaining integer data processing intrinsics from
the ARM ACLE v2.1 spec, such as parallel arithemtic and DSP style
multiplications.

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

llvm-svn: 302131
2017-05-04 08:37:59 +00:00
Xiuli Pan be6da4bbdb [OpenCL] Add intel_reqd_sub_group_size attribute support
Summary:
Add intel_reqd_sub_group_size attribute support as intel extension  cl_intel_required_subgroup_size from
https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_required_subgroup_size.txt

Reviewers: Anastasia, bader, hfinkel, pxli168

Reviewed By: Anastasia, bader, pxli168

Subscribers: cfe-commits, yaxunl

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

llvm-svn: 302125
2017-05-04 07:31:20 +00:00
Peter Collingbourne 5f85a9deda IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI.
When profiling a no-op incremental link of Chromium I found that the functions
computeImportForFunction and computeDeadSymbols were consuming roughly 10% of
the profile. The goal of this change is to improve the performance of those
functions by changing the map lookups that they were previously doing into
pointer dereferences.

This is achieved by changing the ValueInfo data structure to be a pointer to
an element of the global value map owned by ModuleSummaryIndex, and changing
reference lists in the GlobalValueSummary to hold ValueInfos instead of GUIDs.
This means that a ValueInfo will take a client directly to the summary list
for a given GUID.

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

llvm-svn: 302108
2017-05-04 03:36:16 +00:00
Richard Smith d13863008b Add #pragma clang module begin/end pragmas and generate them when preprocessing a module.
These pragmas are intended to simulate the effect of entering or leaving a file
with an associated module. This is not completely implemented yet: declarations
between the pragmas will not be attributed to the correct module, but macro
visibility is already functional.

Modules named by #pragma clang module begin must already be known to clang (in
some module map that's either loaded or on the search path).

llvm-svn: 302098
2017-05-04 00:29:54 +00:00
Ahmed Bougacha 7e131f02c8 [Driver] Update AArch64 testcase to match llvm r302078.
llvm-svn: 302079
2017-05-03 20:34:32 +00:00
Tim Northover 4c1104e199 Tests: strengthen CHECK line to avoid picking up stray path.
A bot had "-LTO" in its working directory, which matched the regex used in this
test. Since the arg is quoted, we can exploit that instead. Still broken if
there's a path with a quote in, but I think that's pretty niche.

llvm-svn: 302066
2017-05-03 19:20:45 +00:00
Reid Kleckner a0b45f4bfc [IR] Abstract away ArgNo+1 attribute indexing as much as possible
Summary:
Do three things to help with that:
- Add AttributeList::FirstArgIndex, which is an enumerator currently set
  to 1. It allows us to change the indexing scheme with fewer changes.
- Add addParamAttr/removeParamAttr. This just shortens addAttribute call
  sites that would otherwise need to spell out FirstArgIndex.
- Remove some attribute-specific getters and setters from Function that
  take attribute list indices.  Most of these were only used from
  BuildLibCalls, and doesNotAlias was only used to test or set if the
  return value is malloc-like.

I'm happy to split the patch, but I think they are probably easier to
review when taken together.

This patch should be NFC, but it sets the stage to change the indexing
scheme to this, which is more convenient when indexing into an array:
  0: func attrs
  1: retattrs
  2...: arg attrs

Reviewers: chandlerc, pete, javed.absar

Subscribers: david2050, llvm-commits

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

llvm-svn: 302060
2017-05-03 18:17:31 +00:00
Alex Lorenz 5191e80b87 Revert r302037
The commit caused the following two buildbot failures:

    Clang :: Misc/error-limit-multiple-notes.cpp
    Clang :: Misc/error-limit.c

llvm-svn: 302046
2017-05-03 16:22:16 +00:00
Alex Lorenz d7dfec818b DiagnosticsEngine should clear DelayedDiagID before reporting the
delayed diagnostic

This avoids an infinite loop that was uncovered in one of our internal tests
by r301992. The testcase is the most reduced version of that auto-generated
test.

rdar://31962618

llvm-svn: 302037
2017-05-03 15:41:16 +00:00
Carlo Bertolli d8844b9d43 [OpenMP] Extended parse for 'always' map modifier
https://reviews.llvm.org/D32807

This patch allows the map modifier 'always' to be separated by the map type (to, from, tofrom) only by a whitespace, rather than strictly by a comma as in current trunk.

llvm-svn: 302031
2017-05-03 15:28:48 +00:00
Oren Ben Simhon bada0d4628 Reusing an existing attribute diagnostic
In a previous patch, a new generic error diagnostic for inconsistent attributes was added.
In this commit I reuse this diagnostic for ns_returns_retained attribute check.

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

llvm-svn: 302024
2017-05-03 14:05:00 +00:00
Artem Dergachev b6a513d1b2 [analyzer] Fix memory error bug category capitalization.
It was written as "Memory Error" in most places and as "Memory error" in a few
other places, however it is the latter that is more consistent with
other categories (such as "Logic error").

rdar://problem/31718115

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

llvm-svn: 302016
2017-05-03 11:47:13 +00:00
Daniel Jasper b2bf741e9a Undo turning ExtBehavior into a bitfield.
This produces warnings that I can't explain in a GCC build:

In file included from ../tools/clang/include/clang/Lex/LexDiagnostic.h:13:0,
                 from /usr/local/google/home/djasper/llvm/tools/clang/lib/Lex/PTHLexer.cpp:19:
../tools/clang/include/clang/Basic/Diagnostic.h:219:34: warning: ‘clang::DiagnosticsEngine::DiagState::ExtBehavior’ is too small to hold all values of ‘enum class clang::diag::Severity’ [enabled by default]
     diag::Severity ExtBehavior : 4;     // Map extensions to warnings or errors?
                                  ^

While I don't think this warning makes sense, I'd like to get this back to being
warning-free. This only seems to trigger for "enum class".

Reproducer:
https://godbolt.org/g/P2ekVd

llvm-svn: 302012
2017-05-03 11:27:34 +00:00
Daniel Jasper 6e254b5f38 Fix tests after speculatable intrinsics patch
These were relying on the attribute group numbering

llvm-svn: 302009
2017-05-03 10:04:25 +00:00
Daniel Jasper ba9aefc0ec Silences gcc's -Wnarrowing.
I think this is a false positive in GCC's warning, but nonetheless, we
should try to be warning-free. Smaller reproducer (reproduces with GCC
6.3):
https://godbolt.org/g/cJuO2z

llvm-svn: 302003
2017-05-03 07:48:27 +00:00
Yuka Takahashi 5511fc2eb3 Revert rL301998: "Fix a bug that -isysroot is completely ignored on Unix"
This reverts commit because it broke
sanitizer-x86_64-linux-autoconf bot and
clang-ppc64be-linux-multistage  bot.

llvm-svn: 302000
2017-05-03 06:02:45 +00:00
Yuka Takahashi 79d310713a Fix a bug that -isysroot is completely ignored on Unix
-isysroot is the flag which set the system root directory.
This bug report https://bugs.llvm.org//show_bug.cgi?id=11503
shows that -isysroot is not handled at all on Unix, so fixed this bug.

After this diff, I could get this result https://pastebin.com/TeCmn9mj .

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

llvm-svn: 301998
2017-05-03 04:58:39 +00:00
Matt Arsenault 7c4c1cb2f5 Fix tests after speculatable intrinsics patch
These were relying on the attribute group numbering

llvm-svn: 301996
2017-05-03 03:04:40 +00:00
Kostya Serebryany 8955efc36f [sanitizer-coverage] add a deprecation warning to the old sanitizer-coverage flag combinations
llvm-svn: 301994
2017-05-03 01:27:28 +00:00
Richard Smith e37391c4fe [modules] Round-trip -Werror flag through explicit module build.
The intent for an explicit module build is that the diagnostics produced within
the module are those that were configured when the module was built, not those
that are enabled within a user of the module. This includes diagnostics that
don't actually show up until the module is used (for instance, diagnostics
produced during template instantiation and weird cases like -Wpadded).

We serialized and restored the diagnostic state for individual warning groups,
but previously did not track the state for flags like -Werror and -Weverything,
which are implemented as separate bits rather than as part of the diagnostics
mapping information.

llvm-svn: 301992
2017-05-03 00:28:49 +00:00
Richard Trieu 0255227a58 [ODRHash] Add support for array and decayed types, and parameter names and types.
llvm-svn: 301989
2017-05-02 23:58:52 +00:00
Vedant Kumar d919115983 [ubsan] Skip overflow checks on safe arithmetic (fixes PR32874)
Currently, ubsan emits overflow checks for arithmetic that is known to
be safe at compile-time, e.g:

  1 + 1 => CheckedAdd(1, 1)

This leads to breakage when using the __builtin_prefetch intrinsic. LLVM
expects the arguments to @llvm.prefetch to be constant integers, and
when ubsan inserts unnecessary checks on the operands to the intrinsic,
this contract is broken, leading to verifier failures (see PR32874).

Instead of special-casing __builtin_prefetch for ubsan, this patch fixes
the underlying problem, i.e that clang currently emits unnecessary
overflow checks.

Testing: I ran the check-clang and check-ubsan targets with a stage2,
ubsan-enabled build of clang. I added a regression test for PR32874, and
some extra checking to make sure we don't regress runtime checking for
unsafe arithmetic. The existing ubsan-promoted-arithmetic.cpp test also
provides coverage for this change.

llvm-svn: 301988
2017-05-02 23:46:56 +00:00
Reid Kleckner ee4930b688 Re-land r301697 "[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList"
This time, I fixed, built, and tested clang.

This reverts r301712.

llvm-svn: 301981
2017-05-02 22:07:37 +00:00
Faisal Vali 9a2df95d85 [NFC] Add original test that triggered crash post r301735
- this is added just for completeness sake (though the general case should be represented by the test added in the revision to that patch:  https://reviews.llvm.org/rL301972 )

llvm-svn: 301973
2017-05-02 21:02:46 +00:00
Faisal Vali 999f27e373 Fix PR32831 (Try Again): 'this' capture while instantiating generic lambda call operator specialization
When computing the appropriate cv-qualifiers for the 'this' capture, we have to examine each enclosing lambda - but when using the FunctionScopeInfo stack we have to ensure that the lambda below (outer) is the decl-context of the closure-class of the current lambda.

https://bugs.llvm.org/show_bug.cgi?id=32831

This patch was initially committed here: https://reviews.llvm.org/rL301735
Then reverted here: https://reviews.llvm.org/rL301916

The issue with the original patch was a failure to check that the closure type has been created within the LambdaScopeInfo before querying its DeclContext - instead of just assuming it has (silly!).  A reduced example such as this highlights the problem:
  struct X {
     int data;
     auto foo() { return [] { return [] -> decltype(data) { return 0; }; }; }
  };

When 'data' within decltype(data) tries to determine the type of 'this', none of the LambdaScopeInfo's have their closure types created at that point.

 

llvm-svn: 301972
2017-05-02 20:56:34 +00:00
George Burgess IV 7e7007d1c6 [Sema] Update function doc; NFC
llvm-svn: 301970
2017-05-02 20:24:56 +00:00
Reid Kleckner 2b0fa129d6 Simplify some va_start checking logic
Combine the logic doing the ms_abi/sysv_abi checks into one function so
that each check and its logical opposite are near each other. Now we
don't need two Sema entry points for MS va_start and regular va_start.

Refactor the code that checks if the va_start caller is a function,
block, or obj-c method. We do this in three places, and they are all
buggy for variadic lambdas (PR32737). After this change, I have one
place to apply the functional fix.

NFC

llvm-svn: 301968
2017-05-02 20:10:03 +00:00
Daniel Jasper ffdee09350 Revert r301822 (and dependent r301825), which tried to improve the
handling of constexprs with unknown bounds.

This triggers a corner case of the language where it's not yet clear
whether this should be an error:

  struct A {
    static void *const a[];
    static void *const b[];
  };
  constexpr void *A::a[] = {&b[0]};
  constexpr void *A::b[] = {&a[0]};

When discovering the initializer for A::a, the bounds of A::b aren't known yet.
It is unclear whether warning about errors should be deferred until the end of
the translation unit, possibly resolving errors that can be resolved. In
practice, the compiler can know the bounds of all arrays in this example.

Credits for reproducers and explanation go to Richard Smith. Richard, please
add more info in case my explanation is wrong.

llvm-svn: 301963
2017-05-02 19:21:42 +00:00
Vedant Kumar ee9c6ba1f6 Revert "[docs] UBSan: Mention that print_stacktrace=1 is unsupported on Darwin"
This reverts commit r300295.

It's no longer true, print_stacktrace=1 is supported on Darwin/Windows
as of r301839.

llvm-svn: 301960
2017-05-02 18:51:41 +00:00
Sanjay Patel 77f3b188a2 [CodeGen] remove/fix checks that will fail when r301923 is recommitted
Don't test the optimizer as part of front-end verification.

llvm-svn: 301928
2017-05-02 15:20:18 +00:00
Daniel Jasper 7a28368fab Revert r301735 (and subsequent r301786).
It leads to clang crashing, e.g. on this short code fragment (added to
test/SemaCXX/warn-thread-safety-parsing.cpp):

  class SomeClass {
  public:
    void foo() {
      auto l = [this] { auto l = [] EXCLUSIVE_LOCKS_REQUIRED(mu_) {}; };
    }
    Mutex mu_;
  };

llvm-svn: 301916
2017-05-02 12:38:27 +00:00
Daniel Marjamaki a43a8f5c5e [analyzer] Detect bad free of function pointers
Differential Revision: https://reviews.llvm.org/D31650

llvm-svn: 301913
2017-05-02 11:46:12 +00:00
Emilio Cobos Alvarez b7247b25bd Remove leftover test expectation from rL301902.
llvm-svn: 301906
2017-05-02 09:57:30 +00:00
Emilio Cobos Alvarez c7ed9d9f1c [libclang] Revert rL301328 and add tests for the regressions introduced.
Differential Revision: https://reviews.llvm.org/D32566

llvm-svn: 301902
2017-05-02 08:32:15 +00:00
NAKAMURA Takumi 9378752b67 clang/test/Modules/diag-flags.cpp: Appease targeting *-win32 with explicit triple. Fixes r301846.
MicrosoftRecordLayoutBuilder doesn't have ability of -Wpadded.

FIXME: Would other diag be available here?
llvm-svn: 301898
2017-05-02 05:12:55 +00:00
Nick Lewycky c190f96b7d Revert r301785 (and r301787) because they caused PR32864.
The fix is that ExprEvaluatorBase::VisitInitListExpr should handle transparent exprs instead of exprs with one element. Fixing that uncovers one testcase failure because the AST for "constexpr _Complex float test2 = {1};" is wrong (the _Complex prvalue should not be const-qualified), and a number of test failures in test/OpenMP where the captured stmt contains an InitListExpr that is in syntactic form.

llvm-svn: 301891
2017-05-02 01:06:16 +00:00
Kostya Serebryany 2a451c504f [sanitizer-coverage] update the SanitizerCoverage docs to reflect the current state
llvm-svn: 301888
2017-05-02 00:32:57 +00:00
Richard Smith 941a205119 New file missed from r301846.
llvm-svn: 301847
2017-05-01 22:11:08 +00:00
Richard Smith ea74148f9f Fix initial diagnostic state setup for an explicit module with no diagnostic pragmas.
If a file has no diagnostic pragmas, we build its diagnostic state lazily, but
in this case we never set up the root state to be the diagnostic state in which
the module was originally built, so the diagnostic flags for files in the
module with no diagnostic pragmas were incorrectly based on the user of the
module rather than the diagnostic state when the module was built.

llvm-svn: 301846
2017-05-01 22:10:47 +00:00
Richard Smith b35fc3df5d Put back REQUIRES: system-darwin to fix asan bot.
These tests do not appear to be Darwin-specific, and this REQUIRES: appears to
be hiding a real bug; this change is just restoring the prior state to get the
buildbots happy again while we investigate. (The system-darwin requirement is
covered by PR32851.)

llvm-svn: 301840
2017-05-01 21:49:54 +00:00
Peter Collingbourne c15d60b772 Object: Remove ModuleSummaryIndexObjectFile class.
Differential Revision: https://reviews.llvm.org/D32195

llvm-svn: 301832
2017-05-01 20:42:32 +00:00
Benjamin Kramer 5699969912 Silence unused variable warning. NFC.
llvm-svn: 301825
2017-05-01 20:00:23 +00:00
Kostya Serebryany 4a27c79a95 [sanitizer-coverage] add a deprecation note to coverage_direct=1
llvm-svn: 301824
2017-05-01 19:52:01 +00:00
Richard Smith eec904f849 Improve handling of arrays of unknown bound in constant expressions.
Do not spuriously reject constexpr functions that access elements of an array
of unknown bound; this may later become valid once the bound is known. Permit
array-to-pointer decay on such arrays, but disallow pointer arithmetic (since
we do not know whether it will have defined behavior).

The standard is not clear on how this should work, but this seems to be a
decent answer.

Patch by Robert Haberlach!

llvm-svn: 301822
2017-05-01 18:49:04 +00:00
Sanjoy Das e369bd92da Adapt to LLVM's rename of WeakVH to WeakTrackingVH; NFC
llvm-svn: 301815
2017-05-01 17:08:00 +00:00
Adrian Prantl 3b243608f5 Relax testcase to fix a PS4 buildbot failure.
llvm-svn: 301805
2017-05-01 15:49:40 +00:00
Aaron Ballman 6c60ed5a45 The -coverage-file flag was removed in r280306, and this piece was missed; NFC.
llvm-svn: 301796
2017-05-01 13:05:04 +00:00
Sanjoy Das 70a6051ddf Remove unneeded struct; NFC
Summary:
Unless I'm missing something, the DeferredGlobal struct's GV field is
unused, removing which makes the struct itself trivial.

Reviewers: rafael, chandlerc

Subscribers: mcrosier, llvm-commits

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

llvm-svn: 301789
2017-05-01 06:12:13 +00:00
Nick Lewycky 49675ac409 Fix test that was incorrected merged between patches.
llvm-svn: 301787
2017-05-01 02:20:06 +00:00
David Blaikie 1c7df0f3f0 Fix line endings (dos -> unix) and clang-format while I'm here
llvm-svn: 301786
2017-05-01 02:11:39 +00:00
Nick Lewycky 499968f8a5 Handle expressions with non-literal types like ignored expressions if we are supposed to continue evaluating them.
Also fix a crash casting a derived nullptr to a virtual base.

llvm-svn: 301785
2017-05-01 02:03:23 +00:00
Saleem Abdulrasool be4773c2c4 utils: Silence -Wpedantic warning
llvm/tools/clang/utils/TableGen/ClangAttrEmitter.cpp:1673:67: warning: default argument specified for lambda parameter [-Wpedantic]
                    const Record *Constraint = nullptr) {
                                               ^~~~~~~

Found by gcc 5.4.0.

llvm-svn: 301783
2017-05-01 00:26:59 +00:00
Simon Pilgrim 96d02f5503 [X86][AVX] Added support for _mm256_zext* helper intrinsics (PR32839)
llvm-svn: 301749
2017-04-29 17:17:06 +00:00
Nick Lewycky e7d6fbdfb7 Remove Sema::CheckForIntOverflow, and instead check all full-expressions.
CheckForIntOverflow used to implement a whitelist of top-level expressions to
send to the constant expression evaluator, which handled many more expressions
than the CheckForIntOverflow whitelist did.

llvm-svn: 301742
2017-04-29 09:33:46 +00:00
Faisal Vali 1f961df10c Fix PR32831: 'this capture while instantiating generic lambda call operator specialization
When computing the appropriate cv-qualifiers for the 'this' capture, we have to examine each enclosing lambda - but when using the FunctionScopeInfo stack we have to ensure that the lambda below (outer) is the decl-context of the closure-class of the current lambda.

https://bugs.llvm.org/show_bug.cgi?id=32831

llvm-svn: 301735
2017-04-29 03:49:17 +00:00
Richard Smith f893cc6bd3 Remove some apparently-unnecessary 'REQUIRES: system-darwin' from tests.
Let's see if any buildbots actually have trouble with these. (They at least pass on Linux.)

llvm-svn: 301732
2017-04-29 01:38:29 +00:00
Richard Smith d3935ae1f2 Fix "REQUIRES: system-darwin" failing tests after r301725.
Also remove the apparently-unneeded REQUIRES (the tests also pass on at least
Linux, and don't appear to have anything Darwin-specific in them).

llvm-svn: 301731
2017-04-29 01:29:44 +00:00
Richard Smith c7cacdc332 PR26771: don't forget the " 2" (returning from #included file) linemarker after including an empty file with -frewrite-includes.
llvm-svn: 301727
2017-04-29 00:54:03 +00:00
Richard Smith c51c38b4ec Add pragma to perform module import and use it in -E output.
Many of our supported configurations support modules but do not have any
first-class syntax to perform a module import. This leaves us with a problem:
there is no way to represent the expansion of a #include that imports a module
in the -E output for such languages. (We don't want to just leave it as a
#include because that requires the consumer of the preprocessed source to have
the same file system layout and include paths as the creator.)

This patch adds a new pragma:

  #pragma clang module import MODULE.NAME.HERE

that imports a module, and changes -E and -frewrite-includes to use it when
rewriting a #include that maps to a module import. We don't make any attempt
to use a native language syntax import if one exists, to get more consistent
output. (If in the future, @import and #include have different semantics in
some way, the pragma will track the #include semantics.)

llvm-svn: 301725
2017-04-29 00:34:47 +00:00
Nick Lewycky 19ae6dc853 ObjCBoxedExpr can't be evaluated by the constant expression evaluator.
A boxed expression evaluates its subexpr and then calls an objc method to transform it into another value with pointer type. The objc method can never be constexpr and therefore this expression can never be evaluated. Fixes a miscompile boxing expressions with side-effects.

Also make ObjCBoxedExpr handling a normal part of the expression evaluator instead of being the only case besides full-expression where we check for integer overflow.

llvm-svn: 301721
2017-04-29 00:07:27 +00:00
Adrian Prantl 6ee72d743b Adapt to LLVM API change (DINamespace no longer takes line/file info).
rdar://problem/17484998
https://reviews.llvm.org/D32648

llvm-svn: 301707
2017-04-28 22:25:53 +00:00
Richard Trieu 157ed94ee7 [ODRHash] Add testcase with different paramter names. NFC
llvm-svn: 301701
2017-04-28 22:03:28 +00:00
David Blaikie 9bb296cb05 Enable -fno-split-dwarf-inlining even when -gsplit-dwarf isn't specified.
Since -gsplit-dwarf is specified on a backend compile (in ThinLTO
parlance) it isn't passed during the frontend compile (because no ELF
object/dwo file is produced then), yet the -fno-split-dwarf-inlining
value needs to be encoded in the LLVM DebugInfo metadata to have
effect...

So let it be specified & it'll be silently ignored if -gsplit-dwarf
isn't used in the end, otherwise it'll be used on a per-cu basis
depending on where it's specified in the frontend compile actions.

llvm-svn: 301684
2017-04-28 20:50:25 +00:00
Akira Hatanaka a6b6dcc123 [CodeGen][ObjC] Don't retain captured Objective-C pointers at block
creation that are const-qualified.

When a block captures an ObjC object pointer, clang retains the pointer
to prevent prematurely destroying the object the pointer points to
before the block is called or copied.

When the captured object pointer is const-qualified, we can avoid
emitting the retain/release pair since the pointer variable cannot be
modified in the scope in which the block literal is introduced.

For example:

void test(const id x) {
    callee(^{ (void)x; });
}

This patch implements that optimization.

rdar://problem/28894510

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

llvm-svn: 301667
2017-04-28 18:50:57 +00:00
Ekaterina Romanova ea8702d393 [DOXYGEN] Minor improvements in doxygen comments.
- I removed doxygen comments for the intrinsics that "alias" the other existing documented intrinsics and that only sligtly differ in spelling (single underscores vs. double underscores). 
 #define _tzcnt_u16(a)     (__tzcnt_u16((a)))

It will be very hard to keep the documentation for these "aliases" in sync with the documentation for the intrinsics they alias to. Out of sync documentation will be more confusing than no documentation.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.

llvm-svn: 301652
2017-04-28 16:45:39 +00:00
Emilio Cobos Alvarez 485ad42521 [libclang] Expose some target information via the C API.
This allows users to query the target triple and target pointer width, which
would make me able to fix https://github.com/servo/rust-bindgen/issues/593 and
other related bugs in an elegant way (without having to manually parse the
target triple in the command line arguments).

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

llvm-svn: 301648
2017-04-28 15:56:39 +00:00
Alex Lorenz 499de32ad0 Use the -Wunknown-warning-option group for the "unknown warning group"
diagnostic in #pragma diagnostic

This matches the warning group that's specified for the unknown warning options
that are passed-in as command line arguments.

rdar://29526025

llvm-svn: 301647
2017-04-28 14:45:25 +00:00
Alex Lorenz baa9030de2 [Sema] Avoid an invalid redefinition error that was presented for
of a function whose previous definition was typo-corrected

rdar://28550928

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

llvm-svn: 301643
2017-04-28 12:30:05 +00:00
Simon Pilgrim 99ed27053d [X86][SSE] Add _mm_set_pd1 (PR32827)
Matches _mm_set_ps1 implementation

llvm-svn: 301637
2017-04-28 10:28:32 +00:00
Alex Lorenz 45c423bcdc [index] Handle vector types in USR generator
rdar://25339187

llvm-svn: 301635
2017-04-28 09:46:36 +00:00
NAKAMURA Takumi 6e256873e4 clang/test/ARCMT/remap-applying.c: Use %/s on the command line of echo(1).
llvm-svn: 301619
2017-04-28 05:02:52 +00:00
NAKAMURA Takumi 49e58e766b clang/test/Index/index-module.m: Relax expressions to satisfy DOSish path separator \\, since r301597.
llvm-svn: 301613
2017-04-28 04:17:31 +00:00
Richard Smith f74d946624 Move functionality for handling module maps as inputs from the -emit-module
action to the general FrontendAction infrastructure.

This permits applying -E, -ast-dump, -fsyntax-only, and so on to a module map
compilation. (The -E form is not currently especially useful yet as there's no
good way to take the output and use it to actually build a module.)

In order to support this, -cc1 now accepts -x <lang>-module-map in all cases
where it accepts -x <lang> for a language we can parse (not ir/ast). And for
uniformity, we also accept -x <lang>-header for all such languages (we used
to reject for cuda and renderscript), and -x <lang>-cpp-output for all such
languages (we used to reject for c, cl, and renderscript).

(None of these new alternatives are accepted by the driver yet, so no
user-visible changes.)

llvm-svn: 301610
2017-04-28 01:49:42 +00:00
Bruno Cardoso Lopes 95ff11b7d1 [ASTImporter] Move structural equivalence context to its own file. NFCI
Create a header and impl file for the structural equivalence context.
This is to allow other users outside clang importer. NFCI

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

rdar://problem/30167717

llvm-svn: 301604
2017-04-28 00:31:30 +00:00