Commit Graph

30829 Commits

Author SHA1 Message Date
Sanne Wouda 0479e69c91 [ARM] Add regression tests for Cortex-M23 and Cortex-M33
Reviewers: rengolin, t.p.northover

Reviewed By: t.p.northover

Subscribers: aemerson, llvm-commits

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

llvm-svn: 295647
2017-02-20 10:37:01 +00:00
Aleksei Sidorin ee0351631b [analyzer] Do not duplicate call graph nodes for functions that have definition and forward declaration
Patch by Ivan Sidorenko!

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

llvm-svn: 295644
2017-02-20 09:16:48 +00:00
Brad Smith 0561a5a7fe Enable support for __float128 in Clang on OpenBSD/X86
/usr/local/include/c++/4.9.4/type_traits:279:39: error: __float128 is not
supported on this target

llvm-svn: 295635
2017-02-20 03:18:15 +00:00
Brad Smith e2abc4c065 Always use --eh-frame-hdr on OpenBSD, even for -static
llvm-svn: 295614
2017-02-19 20:11:48 +00:00
Brad Smith 6a1b7a4acc Link static PIE programs against rcrt0.o on OpenBSD
Patch by Stefan Kempf.

llvm-svn: 295610
2017-02-19 19:33:26 +00:00
Justin Lebar 63152d10c9 [CUDA] Don't pass -stack-protector to NVPTX compilations.
We can't support stack-protector on NVPTX because NVPTX doesn't expose a
stack to the compiler!

Fixes PR32009.

llvm-svn: 295609
2017-02-19 19:05:32 +00:00
Craig Topper 117892098a [X86] Replace XOP vpcmov builtins with native vector logical operations.
llvm-svn: 295570
2017-02-18 21:15:30 +00:00
Matt Arsenault eb952fd93b AMDGPU: Add gfx900 and gfx901 processors
llvm-svn: 295556
2017-02-18 19:02:41 +00:00
Daniel Marjamaki dc53b680cb [analyzer] Revert 295545. There are buildbot failures.
llvm-svn: 295548
2017-02-18 16:31:35 +00:00
Daniel Marjamaki 1149166bb9 [analyzer] Fix crash in CastToStruct when there is no record definition
This crash was reported in https://bugs.llvm.org//show_bug.cgi?id=31173

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

llvm-svn: 295545
2017-02-18 11:18:57 +00:00
Serge Pavlov 947719bed1 Process attributes 'ifunc' and 'alias' when checking for redefinition
These attributes effectively turn a non-defining declaration into a
definition, so the case when the declaration already has a body must
be diagnosed properly.

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

llvm-svn: 295541
2017-02-18 06:04:15 +00:00
Vedant Kumar 54e06823d2 [profiling] Make a test more explicit. NFC.
The cxx-structors.cpp test checks that some instrumentation doesn't
appear, but it should be more explicit about which instrumentation it
actually expects to appear.

llvm-svn: 295532
2017-02-18 02:02:55 +00:00
Vedant Kumar a32c08d304 [profiling] Tighten test cases which refer to "profn" vars. NFC.
The frontend can't see "__profn" profile name variables after IRGen
because llvm throws these away now. Tighten up some test cases which
checked for the non-existence of those variables.

llvm-svn: 295528
2017-02-18 01:50:14 +00:00
Richard Smith 057ec50830 Handle deduction guides better in -ast-print.
llvm-svn: 295521
2017-02-18 01:01:48 +00:00
Vedant Kumar 34b1fd6aaa Retry^2: [ubsan] Reduce null checking of C++ object pointers (PR27581)
This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '&this->x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang, check-ubsan, and a stage2 ubsan build.

I also compiled X86FastISel.cpp with -fsanitize=null using
patched/unpatched clangs based on r293572. Here are the number of null
checks emitted:

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            21767 |
  | patched, -O0   |            10758 |
  -------------------------------------

Changes since the initial commit:
- Don't introduce any unintentional object-size or alignment checks.
- Don't rely on IRGen of C labels in the test.

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

llvm-svn: 295515
2017-02-17 23:22:59 +00:00
Vedant Kumar 29ba8d9bfe Revert "Retry: [ubsan] Reduce null checking of C++ object pointers (PR27581)"
This reverts commit r295401. It breaks the ubsan self-host. It inserts
object size checks once per C++ method which fire when the structure is
empty.

llvm-svn: 295494
2017-02-17 20:59:40 +00:00
Charles Li 0ee7c63fd7 [Test] Make Lit tests C++11 compatible - misc
Updated 5 tests.

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

llvm-svn: 295484
2017-02-17 19:36:19 +00:00
Jonas Hahnfeld b07931f01d [OpenMP] Fix cancellation point in task with no cancel
With tasks, the cancel may happen in another task. This has a different
region info which means that we can't find it here.

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

llvm-svn: 295474
2017-02-17 18:32:58 +00:00
Jonas Hahnfeld 20fce72f1b [OpenMP] Remove barriers at cancel and cancellation point
This resolves a deadlock with the cancel directive when there is no explicit
cancellation point. In that case, the implicit barrier acts as cancellation
point. After removing the barrier after cancel, the now unmatched barrier for
the explicit cancellation point has to go as well.

This has probably worked before rL255992: With the calls for the explicit
barrier, it was sure that all threads passed a barrier before exiting.

Reported by Simon Convent and Joachim Protze!

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

llvm-svn: 295473
2017-02-17 18:32:51 +00:00
Richard Trieu dc4cb02470 Revert r295421, new ODR checker for modules, to fix build bot.
llvm-svn: 295427
2017-02-17 07:19:24 +00:00
Richard Trieu cb6b72628e Add better ODR checking for modules.
A slightly weaker form of ODR checking than previous attempts, but hopefully
won't break the modules build bot.  Future work will be needed to catch all
cases.

When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taken from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

llvm-svn: 295421
2017-02-17 05:54:30 +00:00
Argyrios Kyrtzidis 74790484b5 [index] Improvde how we handle synthesized ObjC properties and the associated ivars.
Related synthesized properties with the ivar they use with the 'accessor' relation, and make sure
we mark them 'implicit' when appropriate.

Patch by Nathan Hawes!
https://reviews.llvm.org/D30012

llvm-svn: 295416
2017-02-17 04:49:41 +00:00
Vedant Kumar 55875b9955 Retry: [ubsan] Reduce null checking of C++ object pointers (PR27581)
This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '&this->x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang and check-ubsan. I also compiled X86FastISel.cpp
with -fsanitize=null using patched/unpatched clangs based on r293572.
Here are the number of null checks emitted:

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            21767 |
  | patched, -O0   |            10758 |
  -------------------------------------

Changes since the initial commit: don't rely on IRGen of C labels in the
test.

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

llvm-svn: 295401
2017-02-17 02:03:51 +00:00
Vedant Kumar 4f94a94bea Revert "[ubsan] Reduce null checking of C++ object pointers (PR27581)"
This reverts commit r295391. It breaks this bot:

http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/1898

I need to not rely on labels in the IR test.

llvm-svn: 295396
2017-02-17 01:42:36 +00:00
Vedant Kumar 3e5a9a6be8 [ubsan] Reduce null checking of C++ object pointers (PR27581)
This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '&this->x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang and check-ubsan. I also compiled X86FastISel.cpp
with -fsanitize=null using patched/unpatched clangs based on r293572.
Here are the number of null checks emitted:

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            21767 |
  | patched, -O0   |            10758 |
  -------------------------------------

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

llvm-svn: 295391
2017-02-17 01:05:42 +00:00
Alex Lorenz 55aaa844cb Use correct fix-it location for -Wblock-capture-autoreleasing
The '__autoreleasing' keyword should be inserted after the Objective-C pointer
type.

rdar://30123548

llvm-svn: 295381
2017-02-16 23:15:36 +00:00
Richard Smith efa919ab07 Properly set up the DeclContext for parameters of implicit deduction guides;
this is needed for deferred instantiation of default arguments.

llvm-svn: 295379
2017-02-16 21:29:21 +00:00
Arpith Chacko Jacob fc711b1f47 [OpenMP] Teams reduction on the NVPTX device.
This patch implements codegen for the reduction clause on
any teams construct for elementary data types.  It builds
on parallel reductions on the GPU.  Subsequently,
the team master writes to a unique location in a global
memory scratchpad.  The last team to do so loads and
reduces this array to calculate the final result.

This patch emits two helper functions that are used by
the OpenMP runtime on the GPU to perform reductions across
teams.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29879

llvm-svn: 295335
2017-02-16 16:48:49 +00:00
Arpith Chacko Jacob 101e8fb1f3 [OpenMP] Parallel reduction on the NVPTX device.
This patch implements codegen for the reduction clause on
any parallel construct for elementary data types.  An efficient
implementation requires hierarchical reduction within a
warp and a threadblock.  It is complicated by the fact that
variables declared in the stack of a CUDA thread cannot be
shared with other threads.

The patch creates a struct to hold reduction variables and
a number of helper functions.  The OpenMP runtime on the GPU
implements reduction algorithms that uses these helper
functions to perform reductions within a team.  Variables are
shared between CUDA threads using shuffle intrinsics.

An implementation of reductions on the NVPTX device is
substantially different to that of CPUs.  However, this patch
is written so that there are minimal changes to the rest of
OpenMP codegen.

The implemented design allows the compiler and runtime to be
decoupled, i.e., the runtime does not need to know of the
reduction operation(s), the type of the reduction variable(s),
or the number of reductions.  The design also allows reuse of
host codegen, with appropriate specialization for the NVPTX
device.

While the patch does introduce a number of abstractions, the
expected use case calls for inlining of the GPU OpenMP runtime.
After inlining and optimizations in LLVM, these abstractions
are unwound and performance of OpenMP reductions is comparable
to CUDA-canonical code.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29758

llvm-svn: 295333
2017-02-16 16:20:16 +00:00
Arpith Chacko Jacob bd6344c0be Revert r295319 while investigating buildbot failure.
llvm-svn: 295323
2017-02-16 14:25:35 +00:00
Arpith Chacko Jacob 8e170fc857 [OpenMP] Parallel reduction on the NVPTX device.
This patch implements codegen for the reduction clause on
any parallel construct for elementary data types.  An efficient
implementation requires hierarchical reduction within a
warp and a threadblock.  It is complicated by the fact that
variables declared in the stack of a CUDA thread cannot be
shared with other threads.

The patch creates a struct to hold reduction variables and
a number of helper functions.  The OpenMP runtime on the GPU
implements reduction algorithms that uses these helper
functions to perform reductions within a team.  Variables are
shared between CUDA threads using shuffle intrinsics.

An implementation of reductions on the NVPTX device is
substantially different to that of CPUs.  However, this patch
is written so that there are minimal changes to the rest of
OpenMP codegen.

The implemented design allows the compiler and runtime to be
decoupled, i.e., the runtime does not need to know of the
reduction operation(s), the type of the reduction variable(s),
or the number of reductions.  The design also allows reuse of
host codegen, with appropriate specialization for the NVPTX
device.

While the patch does introduce a number of abstractions, the
expected use case calls for inlining of the GPU OpenMP runtime.
After inlining and optimizations in LLVM, these abstractions
are unwound and performance of OpenMP reductions is comparable
to CUDA-canonical code.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29758

llvm-svn: 295319
2017-02-16 14:03:36 +00:00
Anastasia Stulova 58984e7087 [OpenCL] Correct ndrange_t implementation
Removed ndrange_t as Clang builtin type and added
as a struct type in the OpenCL header.

Use type name to do the Sema checking in enqueue_kernel
and modify IR generation accordingly.

Review: D28058

Patch by Dmitry Borisenkov!  
 

llvm-svn: 295311
2017-02-16 12:27:47 +00:00
Anastasia Stulova 9d98a316c5 [OpenCL] Disallow blocks capture other blocks (v2.0, s6.12.5)
llvm-svn: 295307
2017-02-16 11:13:30 +00:00
Richard Trieu e55fb7f6f1 Revert r295284: Add better ODR checking for modules.
Fix modules build bot.

llvm-svn: 295293
2017-02-16 07:09:18 +00:00
Craig Topper f0d1147fae [AVX-512] Replace 512-bit masked packss/packus builtins and replace with new unmasked builtins.
These new unmasked builtins will enable us to easily support optimizing these builtins in InstCombine in the backend.

llvm-svn: 295291
2017-02-16 06:32:07 +00:00
Richard Trieu f351ac8987 Add better ODR checking for modules.
Recommit r293585 that was reverted in r293611 with new fixes.  The previous
issue was determined to be an overly aggressive AST visitor from forward
declared objects.  The visitor will now only deeply visit certain Decl's and
only do a shallow information extraction from all other Decl's.

When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taken from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

llvm-svn: 295284
2017-02-16 04:53:40 +00:00
Richard Smith f0393bf0a5 Revert r295277 to fix buildbot.
llvm-svn: 295281
2017-02-16 04:22:56 +00:00
Faisal Vali 051e3a2b7d [cxx1z-constexpr-lambda] Implement captures - thus completing implementation of constexpr lambdas.
Enable evaluation of captures within constexpr lambdas by using a strategy similar to that used in CodeGen:
  - when starting evaluation of a lambda's call operator, create a map from VarDecl's to a closure's FieldDecls
  - every time a VarDecl (or '*this) that represents a capture is encountered while evaluating the expression via the expression evaluator (specifically the LValueEvaluator) in ExprConstant.cpp - it is replaced by the corresponding FieldDecl LValue (an Lvalue-to-Rvalue conversion on this LValue representation then determines the right rvalue when needed).

Thanks to Richard Smith and Hubert Tong for their review and feedback!

https://reviews.llvm.org/D29748

llvm-svn: 295279
2017-02-16 04:12:21 +00:00
Richard Smith 86a1b135f0 Add missing "deduced A == A" check for function template partial ordering.
This appears to be the only template argument deduction context where we were
missing this check. Surprisingly, other implementations also appear to miss
the check in this case; it may turn out that important code is relying on
the widespread non-conformance here, in which case we'll need to reconsider.

llvm-svn: 295277
2017-02-16 03:49:44 +00:00
Evgeniy Stepanov 287b04b000 Add missing regexp quantifiers in a test.
llvm-svn: 295267
2017-02-16 01:35:23 +00:00
Vedant Kumar f4217f862a [Sema] Add lvalue-to-rvalue cast in direct-list-initialization of enum
After r264564, we allowed direct-list-initialization of an enum from an
integral value in C++1z mode, so long as that value can convert to the
enum's underlying type.

In this kind of initialization, we need a lvalue-to-rvalue conversion
for the initializer value if it is not a rvalue. This lets us accept the
following code:

  enum class A : unsigned {};
  A foo(unsigned x) { return A{x}; }

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

llvm-svn: 295266
2017-02-16 01:20:00 +00:00
Richard Smith 4e05eaa9e8 [c++1z] Diagnose non-deducible template parameters in deduction guide templates, per [temp.param]p11.
llvm-svn: 295264
2017-02-16 00:36:47 +00:00
Hans Wennborg cac8ce06dd [dllimport] Check for dtor references in functions
Destructor references are not modelled explicitly in the AST. This adds
checks for destructor calls due to variable definitions and temporaries.

If a dllimport function references a non-dllimport destructor, it must
not be emitted available_externally, as the referenced destructor might
live across the DLL boundary and isn't exported.

llvm-svn: 295258
2017-02-15 23:28:10 +00:00
Hans Wennborg 6c3d625fd9 [dllimport] Look through typedefs and arrays in HasNonDllImportDtor
The function is used to check whether a type is a class with
non-dllimport destructor. It needs to look through typedefs and array
types.

llvm-svn: 295257
2017-02-15 23:28:07 +00:00
George Burgess IV 9584508d5c [Modules] Consider enable_if attrs in isSameEntity.
Two functions that differ only in their enable_if attributes are
considered overloads, so we should check for those when we're trying to
figure out if two functions are mergeable.

We need to do the same thing for pass_object_size, as well. Looks like
that'll be a bit less trivial, since we sometimes do these merging
checks before we have pass_object_size attributes available (see the
merge checks in ASTDeclReader::VisitFunctionDecl that happen before we
read parameters, and merge checks in calls to ReadDeclAs<>()).

llvm-svn: 295252
2017-02-15 22:43:27 +00:00
Richard Smith 90e043dae0 PR24440: Do not silently discard a fold-expression appearing as the operand of a cast-expression.
llvm-svn: 295224
2017-02-15 19:57:10 +00:00
Argyrios Kyrtzidis 7d90ed0ac9 [index] USR generation: use getTemplateArgs() instead of getTemplateInstantiationArgs()
Otherwise we may end up creating a different USR for the definition of a function, vs its declaration.

llvm-svn: 295191
2017-02-15 16:16:27 +00:00
Sagar Thakur 9d0ed930ec [XRAY][MIPS] Add -fxray-instrument for mips/mipsel/mips64/mips64el
Summary: Adds xray instrument option for mips/mipsel/mips64/mips64el.

Reviewed by sdardis, dberris
Differential: D27698

llvm-svn: 295163
2017-02-15 10:41:38 +00:00
Eric Christopher 32ac5e41ef Add a definition for __STRUCT_PARM_ALIGN__ for elfv2 and 64-bit darwin platforms to match what other compilers produce.
llvm-svn: 295156
2017-02-15 07:50:11 +00:00
Akira Hatanaka 6697eff4b1 [Sema] Disallow returning a __block variable via a move.
r274291 made changes to prefer calling a move constructor to calling a
copy constructor when returning from a function. This caused programs to
crash when a __block variable in the heap was moved out and used later.

This commit fixes the bug by disallowing moving out of __block variables
implicitly.

rdar://problem/28181080

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

llvm-svn: 295150
2017-02-15 05:15:28 +00:00
Richard Smith 171e4b545d Fix assertion failure due to implicit special member lookup lacking a source location.
llvm-svn: 295149
2017-02-15 04:18:23 +00:00
Richard Smith 650e5b28d2 Speculatively revert r295118 to see if it's what's causing the modules selfhost buildbots to fail.
llvm-svn: 295146
2017-02-15 03:29:24 +00:00
Tim Shen def72aad0b [VLA] Fix the test failure on msvc by specifying the triple.
Differential Revision: https://reviews.llvm.org/D24333

llvm-svn: 295127
2017-02-15 00:01:12 +00:00
Tim Shen b34d0ef2ca [VLA] Handle VLA size expression in a full-expression context.
Summary: Previously the cleanups (e.g. dtor calls) are inserted into the
outer scope (e.g. function body scope), instead of it's own scope. After
the fix, the cleanups are inserted right after getting the size value.

This fixes pr30306.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 295123
2017-02-14 23:46:37 +00:00
Richard Smith 222b30b9d3 Stop asserting when a meaningless -std= flag is passed for a non-compilation
input kind; go back to silently ignoring the flag.

llvm-svn: 295122
2017-02-14 23:41:38 +00:00
Richard Smith 1d5f95f52f Do not implicitly instantiate the definition of a class template specialization
that has been explicitly specialized!

We assume in various places that we can tell the template specialization kind
of a class type by looking at the declaration produced by TagType::getDecl.
That was previously not quite true: for an explicit specialization, we could
have first seen a template-id denoting the specialization (with a use that does
not trigger an implicit instantiation of the defintiion) and then seen the
first explicit specialization declaration. TagType::getDecl would previously
return an arbitrary declaration when called on a not-yet-defined class; it
now consistently returns the most recent declaration in that case.

llvm-svn: 295118
2017-02-14 23:27:44 +00:00
Aaron Ballman 52d0aaac13 Improve diagnostic reporting when using __declspec without enabling __declspec as a keyword.
Fixes PR31936.

llvm-svn: 295114
2017-02-14 22:47:20 +00:00
Richard Smith c91daf1cf9 [Driver] Report available language standards on user error
In case user did not provide valid standard name for -std option, available
values (with short description) will be reported.

Patch by Paweł Żukowski!

llvm-svn: 295113
2017-02-14 22:44:20 +00:00
Reid Kleckner fb9f647e5f MS inline asm: Filter MXCSR out of the inferred clobber list
Since r295004, LLVM has started modelling this new register, but we
don't have GCC constraint inline asm spellings for it yet.

llvm-svn: 295107
2017-02-14 21:38:17 +00:00
Vedant Kumar 9503004089 [profiling] Update test cases to deal with name variable change (NFC)
This is a re-try of r295085: fix up some test cases that assume that
profile name variables are preserved by the instrprof pass.

This catches one additional case in test/CoverageMapping/unused_names.c.

llvm-svn: 295101
2017-02-14 20:03:56 +00:00
Vedant Kumar 0e052d89bd Revert "[profiling] Update test case to deal with name variable change (NFC)"
This reverts commit r295085, because the corresponding llvm change was
reverted.

llvm-svn: 295100
2017-02-14 20:03:53 +00:00
Vedant Kumar 4b5315f8ac [profiling] Update test case to deal with name variable change (NFC)
The 'profn' name variables shouldn't show up after we run the instrprof
pass, see https://reviews.llvm.org/D29921 for more details.

llvm-svn: 295085
2017-02-14 18:49:03 +00:00
Akira Hatanaka f1b3fc7356 [CodeGen][ObjC] Use the type of the captured field of the enclosing
block or lambda.

This is a follow-up to r281682, which fixed a bug in computeBlockInfo
where the captured VarDecl's type, rather than the captured field type
of the enclosing lambda or block, was used to compute the layout of a
block.

This commit makes similar changes to enterBlockScope. This is necessary
to correctly determine whether a block capture requires cleanup.

rdar://problem/30388124

llvm-svn: 295034
2017-02-14 06:46:55 +00:00
NAKAMURA Takumi eb7702e07d clang/test/Parser/cxx1z-class-template-argument-deduction.cpp: Tweak to ignore thiscall.
Line 38: multiple overloads of 'f' instantiate to the same signature 'void (int) __attribute__((thiscall))'

llvm-svn: 295020
2017-02-14 03:18:24 +00:00
Richard Smith c27b3d7623 Canonicalize implicit deduction guide parameter types when forming a deduction
guide from a constructor.

The purpose of this change is to avoid triggering instantiation of the class
when substituting back into the deduction guide if it uses a typedef member.
We will still instantiate the class if the constructor (explicitly or
implicitly, directly or indirectly) uses the current instantiation in a way
that we can't canonicalize out, but that seems unavoidable.

llvm-svn: 295016
2017-02-14 01:49:59 +00:00
Richard Smith cbe079321e [c++1z] Add some more tests for class template argument deduction, add
feature-test macro, and mark feature as done on status page.

llvm-svn: 295011
2017-02-14 00:55:25 +00:00
David Majnemer dc169759ca [MS ABI] Correctly mangling vbase destructors
They are a little bit of a special case in the mangling. They are always
mangled without taking into account their virtual-ness of the
destructor. They are also mangled to return void, unlike the actual
destructor.

This fixes PR31931.

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

llvm-svn: 295010
2017-02-14 00:54:11 +00:00
Richard Smith 3291877656 [c++1z] Synthesize implicit deduction guides from constructors on demand. Rank
such guides below explicit ones, and ensure that references to the class's
template parameters are not treated as forwarding references.

We make a few tweaks to the wording in the current standard:
1) The constructor parameter list is copied faithfully to the deduction guide,
   without losing default arguments or a varargs ellipsis (which the standard
   wording loses by omission).
2) If the class template declares no constructors, we add a T() -> T<...> guide
   (which will only ever work if T has default arguments for all non-pack
   template parameters).
3) If the class template declares nothing that looks like a copy or move
   constructor, we add a T(T<...>) -> T<...> guide.
#2 and #3 follow from the "pretend we had a class type with these constructors"
philosophy for deduction guides.

llvm-svn: 295007
2017-02-14 00:25:28 +00:00
Nick Lewycky 0752762180 When the new expr's array size is an ICE, emit it as a constant expression.
This bypasses integer sanitization checks which are redundant on the expression since it's been checked by Sema. Fixes a clang codegen assertion on "void test() { new int[0+1]{0}; }" when building with -fsanitize=signed-integer-overflow.

llvm-svn: 295006
2017-02-13 23:49:55 +00:00
Alex Lorenz 46eed9d625 [CodeCompletion] Code complete the '__auto_type' keyword
rdar://29219185

llvm-svn: 295003
2017-02-13 23:35:59 +00:00
Alex Lorenz 8f4d399c99 [CodeCompletion] Code complete the missing C++11 keywords
This commit adds context sensitive code completion support for the C++11
keywords that currently don't have completion results.

The following keywords are supported by this patch:

alignas
constexpr
static_assert
noexcept (as a function/method qualifier)
thread_local

The following special identifiers are also supported:

final (as a method qualifier or class qualifier)
override

rdar://29219185

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

llvm-svn: 295001
2017-02-13 23:19:40 +00:00
Charles Li e1958a083a [test] Make Lit tests C++11 Compatible - Objective-C++
Set 5 Objective-C++ tests to run at gnu++98

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

llvm-svn: 294997
2017-02-13 23:09:56 +00:00
Charles Li 2f84e43ce2 [Test] Make Lit tests C++11 compatible - printf format string
Different diagnostics when format string does not match 
actual arg type.

This commit contains the first 2 of 3 tests reviewed in D29685

llvm-svn: 294979
2017-02-13 18:57:06 +00:00
Reid Kleckner 9de921470d [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility
Fixes https://bugs.llvm.org/show_bug.cgi?id=31932

Based on a patch by Roland McGrath

Reviewed By: phosek

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

llvm-svn: 294978
2017-02-13 18:49:21 +00:00
Charles Li 58a221a4e2 [Test] Make Lit tests C++11 compatible - nounwind noexcept
C++11 destructors are nothrow by default.

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

llvm-svn: 294972
2017-02-13 17:56:30 +00:00
Benjamin Kramer 8484a326fb [ASTUnit] Clear out diagnostic state after creating the preamble.
If the preamble had diagnostic state this would leave behind invalid
state in the DiagnosticsEngine and crash later. The test case runs into
an assertion in DiagnosticsEngine::setSourceManager.

llvm-svn: 294963
2017-02-13 16:16:43 +00:00
Gor Nishanov bbe1c07387 [coroutines] NFC: Refactor Sema::CoroutineBodyStmt construction.
Summary:
Sema::CheckCompletedCoroutineBody was growing unwieldy with building all of the substatements. Also, constructors for CoroutineBodyStmt had way too many parameters.

Instead,  CoroutineBodyStmt now defines CtorArgs structure with all of the required construction parameters.
CheckCompleteCoroutineBody delegates construction of individual substatements to short functions one per each substatement.

Also, added a drive-by fix of initializing CoroutinePromise to nullptr in ScopeInfo.h.
And addressed the FIXME that wanted to tail allocate extra room at the end of the CoroutineBodyStmt to hold parameter move expressions. (The comment was longer that the code that implemented tail allocation).

Reviewers: rsmith, EricWF

Subscribers: mehdi_amini, cfe-commits

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

llvm-svn: 294933
2017-02-13 05:05:02 +00:00
Aaron Ballman e826cbf4f3 Revert r294910 and recommit r294861 and r294862 with a target triple to hopefully appease the bots.
llvm-svn: 294911
2017-02-12 19:24:47 +00:00
Renato Golin 510f37cc7d Revert "Attributes on K&R C functions should not cause incompatible..."
...function type with a redeclaration having the same attribute. Fixing this
introduced a secondary problem where we were assuming that K&R functions
could not be attributed types when reporting old-style function definitions
that are not preceded by a prototype."

Also Revert "Hopefully fixes a compile error introduced by r294861."

This reverts commit r294862, r294861, as they bork the ARM builds and
haven't fix it back.

Also, please, short commit titles, long commit decsriptions...

llvm-svn: 294910
2017-02-12 19:08:02 +00:00
Saleem Abdulrasool c30cec26ed CodeGen: annotate ObjC ARC functions with ABI constraints
Certain ARC runtime functions have an ABI contract of being forwarding.
Annotate the functions with the appropriate `returned` attribute on the
arguments.  This hoists some of the runtime ABI contract information
into the frontend rather than the backend transformations.

The test adjustments are to mark the returned function parameter as
such.  The minor change to the IR output is due to the fact that the
returned reference of the object causes it to extend the lifetime of the
object by returning an autoreleased return value.  The result is that
the explicit objc_autorelease call is no longer formed, as autorelease
elision is now possible on the return.

llvm-svn: 294872
2017-02-11 21:34:18 +00:00
Saleem Abdulrasool 96e24877a0 test: ignore some warnings in test code (NFC)
Silence some diagnostics which clang now generates.  This makes it
easier to see the failures in lit output.  NFC.

llvm-svn: 294871
2017-02-11 21:34:15 +00:00
Dylan McKay 315edb0216 [AVR] Fix __AVR_xxx macro definitions; authored by Peter Wu
Summary:
The -mmcu option for GCC sets macros like __AVR_ATmega328P__ (with the trailing
underscores), be sure to include these underscores for Clangs -mcpu option.

See "AVR Built-in Macros" in https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html

Reviewers: jroelofs, dylanmckay

Reviewed By: jroelofs, dylanmckay

Subscribers: efriedma, cfe-commits

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

llvm-svn: 294869
2017-02-11 21:06:07 +00:00
Aaron Ballman 3dcb85b01f Attributes on K&R C functions should not cause incompatible function type with a redeclaration having the same attribute. Fixing this introduced a secondary problem where we were assuming that K&R functions could not be attributed types when reporting old-style function definitions that are not preceded by a prototype.
This patch fixes PR31020.

llvm-svn: 294861
2017-02-11 17:49:53 +00:00
Benjamin Kramer a05bdf75c0 Update XFAIL line after r294781.
llvm-svn: 294820
2017-02-11 02:00:03 +00:00
Richard Trieu f11ab87ba3 Move test include file from include/ to Inputs/
The Inputs/ directory is the recommended location for extra files for test
cases.  No functional change.

llvm-svn: 294815
2017-02-11 00:52:01 +00:00
Richard Smith 541cf97fe0 [c++1z] Tests for class template argument deduction in dependent contexts.
llvm-svn: 294802
2017-02-10 23:10:17 +00:00
George Burgess IV f9013bf8f0 Don't let EvaluationModes dictate whether an invalid base is OK
What we want to actually control this behavior is something more local
than an EvalutationMode. Please see the linked revision for more
discussion on why/etc.

This fixes PR31843.

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

llvm-svn: 294800
2017-02-10 22:52:29 +00:00
Richard Smith bfbff07e73 [c++1z] Diagnose attempts to use variables with deduced class template
specialization types from within their own initializers.

llvm-svn: 294796
2017-02-10 22:35:37 +00:00
Richard Smith d69f4f5b05 [c++1z] Require an initializer for deduced class template specialization types.
It's actually meaningful and useful to allow such variables to have no
initializer, but we are strictly following the standard here until the C++
committee reaches consensus on allowing this.

llvm-svn: 294785
2017-02-10 21:40:29 +00:00
Richard Smith 278890f85b [c++1z] Enforce restriction that deduction guide is declared in the same scope as its template.
llvm-svn: 294778
2017-02-10 20:39:58 +00:00
Richard Smith 3817e4a40c [c++1z] Disallow deduction guides with deduced types that don't syntactically match the template being deduced.
llvm-svn: 294773
2017-02-10 19:49:50 +00:00
Joey Gouly 6ea21852af [libclang] [OpenCL] Expose half type.
Expose the half type (fp16) through libclang and the python bindings.

It seems CXType_LastBuiltin was not updated in b2ea6d9 ("Enable
support for __float128 in Clang", 2016-04-13), so update it now.

Add an Index test for OpenCL types; in the future we will add other
OpenCL types such as images to this test.

Patch by Sven van Haastregt.

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

llvm-svn: 294754
2017-02-10 15:51:11 +00:00
Eric Christopher f6ee1f3d69 Temporarily revert "For X86-64 linux and PPC64 linux align int128 to 16 bytes."
until we can get better TargetMachine::isCompatibleDataLayout to compare - otherwise
we can't code generate existing bitcode without a string equality data layout.

This reverts commit r294703.

llvm-svn: 294708
2017-02-10 04:35:21 +00:00
Eric Christopher 4855ba8f24 For X86-64 linux and PPC64 linux align int128 to 16 bytes.
For other platforms we should find out what they need and likely
make the same change, however, a smaller additional change is easier
for platforms we know have it specified in the ABI.

clang support for r294702

llvm-svn: 294703
2017-02-10 03:32:34 +00:00
Richard Smith a2c581f42f [c++1z] In class template argument deduction, all declarators must deduce the same type (just like with auto deduction).
llvm-svn: 294700
2017-02-10 03:27:13 +00:00
Hubert Tong 5a8ec4e287 [Concepts] Class template associated constraints
Summary:
This adds associated constraints as a property of class templates.
An error is produced if redeclarations are not similarly constrained.

Reviewers: rsmith, faisalv, aaron.ballman

Reviewed By: rsmith

Subscribers: cfe-commits, nwilson

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

llvm-svn: 294697
2017-02-10 02:46:19 +00:00
Richard Smith afe4aa8b2c [c++1z] P0512R0: support for 'explicit' specifier on deduction-guides.
llvm-svn: 294693
2017-02-10 02:19:05 +00:00
George Burgess IV fc9705679e Add support for armv7ve flag in clang (PR31358).
This is a followup change to add v7ve support to clang for gcc
compatibility. Please see r294661.

Patch by Manoj Gupta.

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

llvm-svn: 294662
2017-02-09 23:30:10 +00:00
Richard Smith 19a311a483 Disallow explicit instantiation and explicit specialization for deduction guides.
llvm-svn: 294641
2017-02-09 22:47:51 +00:00
Richard Smith 3af700977b Diagnose attempts to explicitly instantiate a template at class scope. Previously Clang would simply ignore the 'template' keyword in this case.
llvm-svn: 294639
2017-02-09 22:14:25 +00:00
Amjad Aboud 546bc1103b [DebugInfo] Added support to Clang FE for generating debug info for preprocessor macros.
Added "-fdebug-macro" flag (and "-fno-debug-macro" flag) to enable (and to disable) emitting macro debug info.
Added CC1 "-debug-info-macro" flag that enables emitting macro debug info.

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

llvm-svn: 294637
2017-02-09 22:07:24 +00:00
Richard Smith 60437620db [c++1z] P0091R3: Basic support for deducing class template arguments via deduction-guides.
llvm-svn: 294613
2017-02-09 19:17:44 +00:00
Marcos Pividori cc709cebc8 [windows] Fix test for cl driver.
cl-link.c test was failing after r294604 because of the change in the order of
parameters.

llvm-svn: 294609
2017-02-09 18:40:52 +00:00
Reid Kleckner 04f9f91da6 [MS] Implement the __fastfail intrinsic as a builtin
__fastfail terminates the process immediately with a special system
call. It does not run any process shutdown code or exception recovery
logic.

Fixes PR31854

llvm-svn: 294606
2017-02-09 18:31:06 +00:00
Craig Topper 41cb8ffcc1 [X86] Fix copy and paste bug in clzero test from r294559.
llvm-svn: 294560
2017-02-09 06:22:43 +00:00
Craig Topper 4574226c3f [X86] Clzero flag addition and inclusion under znver1
1. Adds the command line flag for clzero.
2. Includes the clzero flag under znver1.
3. Defines the macro for clzero.
4. Adds a new file which has the intrinsic definition for clzero instruction.

Patch by Ganesh Gopalasubramanian with some additional tests from me.

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

llvm-svn: 294559
2017-02-09 06:10:14 +00:00
Douglas Yung 60fc1dd532 Add check that "#define unix 1" is present for the PS4 target.
llvm-svn: 294534
2017-02-09 00:07:38 +00:00
David Blaikie ee12322372 Initialize builtins during modular codegen
llvm-svn: 294512
2017-02-08 20:51:11 +00:00
Richard Smith ef2cd8f8c3 More fixes for places where 'decltype(auto)' is permitted in the C++ grammar but makes no sense.
llvm-svn: 294509
2017-02-08 20:39:08 +00:00
Richard Smith 3f846bd9fe Don't crash on 'decltype(auto)::'. Rather than treating it as a meaningless
nested-name-specifier (as the standard appears to require), treat it as the
type specifier 'decltype(auto)' followed by a nested-name-specifier starting
with '::'.

llvm-svn: 294506
2017-02-08 19:58:48 +00:00
Charles Li 4f80074629 [Lit Test] Make tests C++11 compatible - Parse OpenMP
Differential Revision: https://reviews.llvm.org/D29725

llvm-svn: 294504
2017-02-08 19:46:15 +00:00
Reid Kleckner a858981c1d [MS] Fix C++ destructor thunk line info for a declaration
Sometimes the MS ABI needs to emit thunks for declarations that don't
have bodies. Destructor thunks make calls to inlinable functions, so
they need line info or LLVM will complain.

Fixes PR31893

llvm-svn: 294465
2017-02-08 16:09:32 +00:00
Craig Topper d2bf7b03e5 [X86] Add -mprefetchwt1/-mno-prefetchwt1 command line options and __PREFETCHWT1__ define to match gcc.
llvm-svn: 294424
2017-02-08 08:23:40 +00:00
Craig Topper 204ecffdb4 [X86] Add -msgx/-mno-sgx command line options and __SGX__ define to match gcc.
llvm-svn: 294423
2017-02-08 08:23:17 +00:00
Craig Topper b16cb82c93 [X86] Add -mmpx/-mno-mpx command line options and __MPX__ define to match gcc.
llvm-svn: 294419
2017-02-08 07:56:42 +00:00
Craig Topper 8c708cf6bc [X86] Add -mclwb/-mno-clwb command line arguments and __CLWB__ define to match gcc.
In the future, we should also add a clwb intrinsic to the backend, a frontend builtin, and an instrinsic header file.

llvm-svn: 294416
2017-02-08 07:36:58 +00:00
Craig Topper ef40aaf787 [X86] Add -mmovbe/-mno-movbe command line options to match gcc.
llvm-svn: 294413
2017-02-08 07:13:19 +00:00
Craig Topper 78b4787593 [X86] Add -mclflushopt/-mno-clflushopt command line support and __CLFLUSHOPT__ define to match gcc.
llvm-svn: 294411
2017-02-08 06:48:58 +00:00
Dylan McKay e8232d73f5 [AVR] Add support for the 'interrupt' and 'naked' attributes
Summary:
This teaches clang how to parse and lower the 'interrupt' and 'naked'
attributes.

This allows interrupt signal handlers to be written.

Reviewers: aaron.ballman

Subscribers: malcolm.parsons, cfe-commits

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

llvm-svn: 294402
2017-02-08 05:09:26 +00:00
Saleem Abdulrasool a6ae060db4 Sema: add warning for c++ member variable shadowing
Add a warning for shadowed variables across records.  Referencing a
shadow'ed variable may not give the desired variable.  Add an optional
warning for the shadowing.

Patch by James Sun!

llvm-svn: 294401
2017-02-08 03:30:13 +00:00
Richard Smith c88aa3f3a6 Diagnose an attempt to give a deduction-guide a function body.
llvm-svn: 294397
2017-02-08 01:27:29 +00:00
Richard Smith 8f8697f3e1 Fix constructor declarator detection for the case when the name is followed by
an attribute-specifier-seq. (Also fixes the same problem for deduction-guides.)

llvm-svn: 294396
2017-02-08 01:16:55 +00:00
Richard Smith f283fdcd50 P0091R3: Improved syntactic checking of deduction-guides.
llvm-svn: 294395
2017-02-08 00:35:25 +00:00
Bruno Cardoso Lopes 17da34d2bd [PCH] Fix a regression when PCH is used with -fmodules
Following up on r291465 after a regression in r276159. When we use
-fmodule-name=X while building a PCH, modular headers in X will be
textually included and the compiler knows that we are not building
module X, so don't serialize such headers in the PCH as being part of a
module, because at this point they are not.

This was causing subtle bugs and malformed AST crashes, for instance,
when using the PCH in subsequent compiler invocation with -fmodules, the
HFI for a modular header would map to the PCH, which would force a
module load of and unexistent module ID.

rdar://problem/30171164

llvm-svn: 294361
2017-02-07 21:54:57 +00:00
Saleem Abdulrasool 5602709b98 Revert "Basic: match GCC behaviour for SuS macro"
This reverts commit SVN r294148.  Seems that it was mistaken, and GCC
does still define `__unix` and `unix` when in GNU mode.

llvm-svn: 294332
2017-02-07 19:00:06 +00:00
Anastasia Stulova 32f0a4330a [OpenCL] Accept logical NOT for pointer types in CL1.1
Fix for bug 30217 - incorrect error given for logical
NOT operation with a pointer type: corrected sema check
and improved related tests.

Review: D29038
llvm-svn: 294313
2017-02-07 16:09:41 +00:00
Dylan McKay ecb6e7b83c Revert "Revert "[AVR] Allow specifying the CPU on the command line""
This reverts commit 7ac30e0f839fdab6d723ce2ef6a5b7a4cf03d150.

llvm-svn: 294282
2017-02-07 06:04:18 +00:00
Matt Arsenault 77ce553891 AMDGPU: Add a test checking alignments of emitted globals/allocas
Make sure the spec required type alignments are used in preparation
for a possible change which may break this.

llvm-svn: 294278
2017-02-07 04:28:02 +00:00
Peter Collingbourne 8e6a25feca Driver: Do not link safestack with --whole-archive.
This allows it to be used with the other sanitizers.

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

llvm-svn: 294274
2017-02-07 03:21:57 +00:00
Richard Smith 3584515018 P0091R3: Implement basic parsing support for C++17 deduction-guides.
We model deduction-guides as functions with a new kind of name that identifies
the template whose deduction they guide; the bulk of this patch is adding the
new name kind. This gives us a clean way to attach an extensible list of guides
to a class template in a way that doesn't require any special handling in AST
files etc (and we're going to need these functions we come to performing
deduction).

llvm-svn: 294266
2017-02-07 01:37:30 +00:00
Charles Li 11d0b8df5f [Lit Test] Make tests C++11 compatible - Microsoft diagnostics
Differential Revision: https://reviews.llvm.org/D29520

llvm-svn: 294225
2017-02-06 19:32:38 +00:00
Ulrich Weigand 82a86cb155 [SystemZ] Provide predefined __ARCH__ and __VX__ macros
GCC 7 will predefine two new macros on s390x:

- __ARCH__ indicates the ISA architecture level
- __VX__ indicates that the vector facility is available

This adds those macros to clang as well to ensure continued
compatibility with GCC.

llvm-svn: 294197
2017-02-06 17:04:22 +00:00
Carlo Bertolli d2192d1b63 [OpenMP] Remove fixme comment in regression test and related unnecessary statement
https://reviews.llvm.org/D29501

It looks like I forgot to remove a FIXME comment with the associated statement. The test does not need it and it gives the wrong impression of being an incomplete test.

llvm-svn: 294195
2017-02-06 16:03:41 +00:00
Diana Picus 37a2d6d699 Revert "[AVR] Allow specifying the CPU on the command line"
This reverts commit r294177. It seems to have broken some buildbots.

llvm-svn: 294180
2017-02-06 11:35:42 +00:00
Dylan McKay 8464c9b579 [AVR] Allow specifying the CPU on the command line
Summary:
This tells clang about all of the different AVR microcontrollers.

It also adds code to define the correct preprocessor macros for each
device.

Reviewers: jroelofs, asl

Reviewed By: asl

Subscribers: asl, cfe-commits

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

llvm-svn: 294177
2017-02-06 09:07:56 +00:00
Dylan McKay d31534cd3a [AVR] Add support for the full set of inline asm constraints
Summary:
Previously the method would simply return false, causing every single
inline assembly constraint to trigger a compile error.

This adds inline assembly constraint support for the AVR target.

This patch is derived from the code in
AVRISelLowering::getConstraintType.

More details can be found on the AVR-GCC reference wiki
http://www.nongnu.org/avr-libc/user-manual/inline_asm.html

Reviewers: jroelofs, asl

Reviewed By: asl

Subscribers: asl, ahatanak, saaadhu, cfe-commits

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

llvm-svn: 294176
2017-02-06 09:01:59 +00:00
Saleem Abdulrasool c5cddc9fa8 Basic: match GCC behaviour for SuS macro
GCC does not generate `__unix` nor `unix` macros.  The latter already
intrudes into the user's namespace and should be avoided.  Use the
canonical spelling of `__unix__` across all the targets.

llvm-svn: 294148
2017-02-05 22:18:15 +00:00
Coby Tayree c0fb36f442 [X86][MS]Adjacent comments within multi-line inline assembly statement
Allowing adjacent comments within MS inline assembly multi-line statement

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

llvm-svn: 294120
2017-02-05 10:23:06 +00:00
Richard Smith 33c33c3e86 PR31846: Don't replace 'auto' type with a template parameter type in a generic lambda
until after we've checked whether 'auto' is valid in the current language mode.

llvm-svn: 294078
2017-02-04 01:28:01 +00:00
Matthias Braun 9e838bd142 Driver: Do not warn about unused -pthread when linking on darwin
While there is nothing to do at link time to get pthreads support on
darwin, specifying the argument is fine and we should not warn about
unused arguments.

llvm-svn: 294065
2017-02-03 23:09:31 +00:00
Sanjay Patel 3bd28f85d5 [x86] fix tests with wrong dependency to pass because they broke with r294049
llvm-svn: 294058
2017-02-03 22:03:47 +00:00
Carlo Bertolli 7aa20a117d [OpenMP] Add missing regression test for pragma distribute, clause firstprivate
https://reviews.llvm.org/D28243

The regression test was missing from the previous already accepted patch.

llvm-svn: 294026
2017-02-03 19:09:16 +00:00
Charles Li bd1961d2bf [Lit Test] Make tests C++11 compatible - OpenMP constant expressions
C++11 introduced constexpr, hence the change in diagnostics.

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

llvm-svn: 294025
2017-02-03 18:58:34 +00:00
Alex Lorenz 776b417634 [Sema][ObjC++] Typo correction should handle ivars and properties
After r260016 and r260017 disabled typo correction for ivars and properties
clang didn't report errors about unresolved identifier in the base of ivar and
property ref expressions. This meant that clang invoked CodeGen on invalid AST
which then caused a crash.

This commit re-enables typo correction for ivars and properites, and fixes the
PR25113 & PR26486 (that were originally fixed in r260017 and r260016) in a
different manner by transforming the Objective-C ivar reference expression with
'IsFreeIvar' preserved.

rdar://30310772

llvm-svn: 294008
2017-02-03 14:22:33 +00:00
Warren Ristow 8d17b40500 Prevent ICE in dllexport class with _Atomic data member
Guard against a null pointer dereference that caused Clang to crash
when processing a class containing an _Atomic qualified data member,
and that is tagged with 'dllexport'.

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

llvm-svn: 293911
2017-02-02 17:53:34 +00:00
Gabor Horvath 3b008536f3 [analyzer] Fix an assertion fail in CStringSyntaxChecker.
Differential Revision: https://reviews.llvm.org/D29384

llvm-svn: 293874
2017-02-02 08:20:54 +00:00
Richard Smith 9ff61776df Fix attribute name in diagnostic message to match actual attribute name.
llvm-svn: 293853
2017-02-02 01:50:47 +00:00
Davide Italiano 8236b73dee [CodeGen] Update test after recent changes in llvm (r293846).
llvm-svn: 293848
2017-02-02 00:47:53 +00:00
Richard Smith 3411fbff0b Repoint 'missing typename' diagnostic to the location where 'typename' should be added.
llvm-svn: 293817
2017-02-01 21:41:18 +00:00
Richard Smith 62559bd7ce Fix hole in our enforcement of rule requiring 'typename' prior to a dependent
name. If the dependent name happened to end in a template-id (X<T>::Y<U>), we
would fail to notice that the 'typename' keyword is missing when resolving it
to a type.

It turns out that GCC has a similar bug. If this shows up in much real code, we
can easily downgrade this to an ExtWarn.

llvm-svn: 293815
2017-02-01 21:36:38 +00:00
Davide Italiano 0449607738 [CodeGen] Update test after recent changes in llvm (r293799).
llvm-svn: 293810
2017-02-01 20:43:28 +00:00
Akira Hatanaka 034c6337e5 [Sema][ObjC] Don't pass a DeclRefExpr that doesn't reference a VarDecl
to WeakObjectProfileTy's constructor.

This fixes an assertion failure in WeakObjectProfileTy's constructor.

rdar://problem/30112633

llvm-svn: 293808
2017-02-01 20:22:26 +00:00
Hans Wennborg 9d17df8b46 Drop 'dllimport' when redeclaring inline function template without the attribute (PR31695)
For non-template dllimport functions, MSVC allows providing an inline
definition without spelling out the attribute again. In the example below, f
remains a dllimport function.

  __declspec(dllimport) int f();
  inline int f() { return 42; }

  int useit() {
    return f();
  }

However, for a function template, not putting dllimport on the redeclaration
causes it to be dropped. In the example below, f is not dllimport.

  template <typename> __declspec(dllimport) int f();
  template <typename> inline int f() { return 42; }

  int useit() {
    return f<int>();
  }

This patch makes Clang match MSVC for the second example.

MSVC does not warn about the attribute being dropped in the example above, but
I think we should. (MSVC does warn if the inline keyword isn't used.)

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

llvm-svn: 293800
2017-02-01 18:52:53 +00:00
Alex Lorenz 86d3232daf [CodeGen][ObjC] Avoid asserting on block pointer types in
isPointerZeroInitializable

rdar://30111891

llvm-svn: 293787
2017-02-01 17:37:28 +00:00
Daniel Jasper acd40b563a Fix Index test after recent clang-format change.
llvm-svn: 293754
2017-02-01 10:00:10 +00:00
Hans Wennborg fd350a3b4f Follow-up to r293732: add a proper triple to the test
llvm-svn: 293735
2017-02-01 02:48:02 +00:00
Hans Wennborg 27dcc6c0e2 clang-cl: Evaluate arguments left-to-right in constructor call with initializer list (PR31831)
clang-cl would evaluate the arguments right-to-left (see PR), and for
non-Windows targets I suppose we only got it because we were already
emitting left-to-right in CodeGenFunction::EmitCallArgs.

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

llvm-svn: 293732
2017-02-01 02:21:07 +00:00
David Blaikie 4d92301075 Fix modules codegen to be compatible with modules-ts
The Module::WithCodegen flag was only being set when the module was
parsed from a ModuleMap. Instead set it late, in the ASTWriter to match
the layer where the MODULAR_CODEGEN_DECLs list is determined (the
WithCodegen flag essentially means "are this module's decls in
MODULAR_CODEGEN_DECLs").

When simultaneous emission of AST file and modular object is implemented
this may need to change - the Module::WithCodegen flag will need to be
set earlier, and ideally the MODULAR_CODEGEN_DECLs gathering will
consult this flag (that's not possible right now since Decls destined
for an AST File don't have a Module - only if they're /read/ from a
Module is that true - I expect that would need to change as well).

llvm-svn: 293692
2017-01-31 21:28:19 +00:00
Akira Hatanaka 59e3b43abc [Sema] Transform a templated name before looking it up in
FindInstantiatedDecl or passing it to RebuildMemberExpr.

This fixes PR30361.

rdar://problem/17341274

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

llvm-svn: 293678
2017-01-31 19:53:32 +00:00
Reid Kleckner 0b009e8269 Extend -Wcast-calling-convention to warn on declarations as well as definitions
My original warning was very conservative and I never revisited the
heuristics that were used.

This would have caught http://crbug.com/687251 at compile time.

llvm-svn: 293677
2017-01-31 19:37:45 +00:00
Marcos Pividori bd99882cf2 [windows] [asan] Fix tests failing after 293668.
llvm-svn: 293676
2017-01-31 19:05:05 +00:00
Nirav Dave 0c86ccf4b4 [X86] Teach Clang about -mfentry flag
Replace mcount calls with calls to fentry.

Reviewers: hfinkel, craig.topper

Subscribers: llvm-commits

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

llvm-svn: 293649
2017-01-31 17:00:35 +00:00
Sam McCall 61e29aafa7 Revert r293585 "Add better ODR checking for modules."
We're seeing what we believe are false positives. (It's hard to tell with the
available diagnostics, and I'm not sure how to reduce them yet).
I'll send Richard reproduction details offline.

djasper/chandlerc suggested this should be a warning for now, to make rolling it
out feasible.

llvm-svn: 293611
2017-01-31 08:24:40 +00:00
Maxim Ostapenko c5d0ed5f3a [lsan] Enable LSan for x86 Linux
This is a missed part of https://reviews.llvm.org/D28609.
Enable LSan for x86 Linux in clang driver.

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

llvm-svn: 293609
2017-01-31 07:00:23 +00:00
Sam McCall 93590e09d5 In VirtualCallChecker, handle indirect calls
Summary:
In VirtualCallChecker, handle indirect calls.

getDirectCallee() can be nullptr, and dyn_cast(nullptr) is UB

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 293604
2017-01-31 05:23:20 +00:00
Matt Arsenault a274b209f5 AMDGPU: Add builtin for fmed3 intrinsic
llvm-svn: 293600
2017-01-31 03:42:07 +00:00
Akira Hatanaka bc332648e8 Handle ObjCEncodeExpr in extractStringLiteralCharacter.
This fixes an assertion failure that occurs later in the function when
an ObjCEncodeExpr is cast to StringLiteral.

rdar://problem/30111207

llvm-svn: 293596
2017-01-31 02:31:39 +00:00
Richard Smith d6cc198d53 Improve fix for PR28739
Don't try to map an APSInt addend to an int64_t in pointer arithmetic before
bounds-checking it. This gives more consistent behavior (outside C++11, we
consistently use 2s complement semantics for both pointer and integer overflow
in constant expressions) and fixes some cases where in C++11 we would fail to
properly check for out-of-bounds pointer arithmetic (if the 2s complement
64-bit overflow landed us back in-bounds).

In passing, also fix some cases where we'd perform possibly-overflowing
arithmetic on CharUnits (which have a signed underlying type) during constant
expression evaluation.

llvm-svn: 293595
2017-01-31 02:23:02 +00:00
Richard Trieu fa3d93a148 Add better ODR checking for modules.
When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taked from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

llvm-svn: 293585
2017-01-31 01:44:15 +00:00
Vedant Kumar d3a601b06b Re-apply "[ubsan] Sanity-check shift amounts before truncation"
This re-applies r293343 (reverts commit r293475) with a fix for an
assertion failure caused by a missing integer cast. I tested this patch
by using the built compiler to compile X86FastISel.cpp.o with ubsan.

Original commit message:

Ubsan does not report UB shifts in some cases where the shift exponent
needs to be truncated to match the type of the shift base. We perform a
range check on the truncated shift amount, leading to false negatives.

Fix the issue (PR27271) by performing the range check on the original
shift amount.

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

llvm-svn: 293572
2017-01-30 23:38:54 +00:00
Richard Smith 642a2365fb PR28739: Check that integer values fit into 64 bits before extracting them as 64 bit values for pointer arithmetic.
This fixes various ways to tickle an assertion in constant expression
evaluation when using __int128. Longer term, we need to figure out what should
happen here: either any kind of overflow in offset calculation should result in
a non-constant value or we should truncate to 64 bits. In C++11 onwards, we're
effectively already checking for overflow because we strictly enforce array
bounds checks, but even there some forms of overflow can slip past undetected.

llvm-svn: 293568
2017-01-30 23:30:26 +00:00
Richard Smith ee57984c11 Towards P0091R3: parsing support for class template argument deduction in typename-specifiers.
This reinstates r293455, reverted in r293455, with a fix for cv-qualifier
handling on dependent typename-specifiers.

llvm-svn: 293544
2017-01-30 20:39:26 +00:00
Adam Nemet 820086a20b Adjust tests after folding inlining analysis into missed remarks
llvm-svn: 293493
2017-01-30 16:22:50 +00:00
Alex Lorenz 94c26be581 Revert "r293343 - [ubsan] Sanity-check shift amounts before truncation
(fixes PR27271)"

After r293343 clang fails to compile itself with -fsanitize=undefined (
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_build/).

rdar://30259929

llvm-svn: 293475
2017-01-30 11:37:18 +00:00
Sam McCall 4f53b51fe7 Revert r293455, which breaks v8 with a spurious error. Testcase added.
Summary: Revert r293455, which breaks v8 with a spurious error. Testcase added.

Reviewers: klimek

Subscribers: cfe-commits, rsmith

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

llvm-svn: 293473
2017-01-30 10:44:11 +00:00
David Blaikie b11c87324e Reapply "DebugInfo: Omit class definitions even in the presence of available_externally vtables"
Accounts for a case that caused an assertion failure by attempting to
query for the vtable linkage of a non-dynamic type.t

This reverts commit r292801.

llvm-svn: 293462
2017-01-30 06:36:08 +00:00
Argyrios Kyrtzidis a38cb204a3 [c-index-test] Provide capability to index module file imports and dump their input files.
This ensures the capability to index a module file using an existing ASTReader from a compiler instance or ASTUnit.

llvm-svn: 293461
2017-01-30 06:05:58 +00:00
David Blaikie 8abd2febfe Tidy up codegen modules test & make it x86 specific since it relies on Itanium name manglings
llvm-svn: 293457
2017-01-30 05:33:51 +00:00
David Blaikie 9ffe5a3525 Prototype of modules codegen
First pass at generating weak definitions of inline functions from module files
(& skipping (-O0) or emitting available_externally (optimizations)
definitions where those modules are used).

External functions defined in modules are emitted into the modular
object file as well (this may turn an existing ODR violation (if that
module were imported into multiple translations) into valid/linkable
code).

Internal symbols (static functions, for example) are not correctly
supported yet. The symbol will be produced, internal, in the modular
object - unreferenceable from the users.

Reviewers: rsmith

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

llvm-svn: 293456
2017-01-30 05:00:26 +00:00
Richard Smith c95726ea39 Towards P0091R3: parsing support for class template argument deduction in typename-specifiers.
llvm-svn: 293455
2017-01-30 04:38:28 +00:00
Arpith Chacko Jacob cdda3daa7f [OpenMP][NVPTX][CUDA] Adding support for printf for an NVPTX OpenMP device.
Support for CUDA printf is exploited to support printf for
an NVPTX OpenMP device.

To reflect the support of both programming models, the file
CGCUDABuiltin.cpp has been renamed to CGGPUBuiltin.cpp, and
the call EmitCUDADevicePrintfCallExpr has been renamed to
EmitGPUDevicePrintfCallExpr.

Reviewers: jlebar
Differential Revision: https://reviews.llvm.org/D17890

llvm-svn: 293444
2017-01-29 20:49:31 +00:00
Marcos Pividori b130469bc9 [windows] [asan] Add linker flag when including "asan_dynamic_runtime_thunk".
I modify clang driver for windows to include:
"-wholearchive:asan_dynamic_runtime_thunk", so all object files in the
static library: asan_dynamic_runtime_thunk are considered by the linker.
This is necessary, because some object files only include linker pragmas,
and doesn't resolve any symbol. If we don't include that flag, the
linker will ignore them, and won't read the linker pragmas.

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

llvm-svn: 293420
2017-01-29 06:03:05 +00:00
Argyrios Kyrtzidis 5fab854082 [c-index-test] Provide capability for 'c-index-test core' to dump symbol information from a PCH/module file.
llvm-svn: 293416
2017-01-29 04:50:35 +00:00
George Burgess IV 2b85475c91 Attempt to unbreak buildbots.
r293360 broke some ARM bots, because size_t on those targets is
apparently `unsigned int`, not `unsigned long`. `sizeof(whatever)`
should to give us a `size_t`, so we can just use the type of that
instead.

llvm-svn: 293369
2017-01-28 04:16:32 +00:00
George Burgess IV ce6284b179 Change how we handle diagnose_if attributes.
This patch changes how we handle argument-dependent `diagnose_if`
attributes. In particular, we now check them in the same place that we
check for things like passing NULL to Nonnull args, etc. This is
basically better in every way than how we were handling them before. :)

This fixes PR31638, PR31639, and PR31640.

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

llvm-svn: 293360
2017-01-28 02:19:40 +00:00
Richard Smith cfa5dc4a1d -Wunused-func-template: do not warn on non-template function declarations that
were nonetheless instantiated (particularly, non-template friends declared
within class templates).

llvm-svn: 293358
2017-01-28 01:50:33 +00:00
Richard Smith fc6fca1cab When converting a template argument representing &array to an expression for a
pointer typed template parameter, form &array rather than an array-to-pointer
decay on array.

llvm-svn: 293350
2017-01-28 00:38:35 +00:00
David Blaikie eb21001111 Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr
As Mehdi put it, entities should either be
available_externally+weak_odr, or linkonce_odr+linkonce_odr. While some
functions are emitted a_e/weak, their local variables were emitted
a_e/linkonce_odr.

While it might be nice to emit them a_e/weak, the Itanium ABI (& best
guess at MSVC's behavior as well) requires the local to be
linkonce/linkonce.

Reviewers: rsmith, mehdi_amini

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

llvm-svn: 293344
2017-01-27 23:11:10 +00:00
Vedant Kumar 3db9974b2d [ubsan] Sanity-check shift amounts before truncation (fixes PR27271)
Ubsan does not report UB shifts in some cases where the shift exponent
needs to be truncated to match the type of the shift base. We perform a
range check on the truncated shift amount, leading to false negatives.

Fix the issue (PR27271) by performing the range check on the original
shift amount.

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

llvm-svn: 293343
2017-01-27 23:02:44 +00:00
Richard Smith 78aacbe2f9 PR31783: Don't request the alignment of an invalid declaration.
Fixes an assertion failure on PS4 targets.

llvm-svn: 293333
2017-01-27 21:28:37 +00:00
Tim Northover 3b34a9b5d9 ARM-Darwin: re-enable -momit-leaf-frame-pointer.
In r279546 I disabled all frame pointer elimination at the front-end on
ARM-Darwin (and warned about it) because before that the backend had been
silently ignoring these options. It turns out we didn't ignore
-momit-leaf-frame-pointer though, just the more general -fomit-frame-pointer.

So this re-enables passing that down to CodeGen so that everything really does
continue working as before (with better diagnostics).

llvm-svn: 293311
2017-01-27 17:53:42 +00:00
Hans Wennborg 091f1b6ef3 clang-cl: Warn about /U flags that look like filenames (PR31662)
Both on Mac and Windows, it's common to have a 'Users' directory in the
root of the filesystem, so one might specify a filename as
'/Users/me/myfile.c'. clang-cl (as well as MSVC's cl.exe) will interpret
that as invoking the '/U' option, which is probably not what the user
wanted. Add a warning about this.

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

llvm-svn: 293305
2017-01-27 17:09:41 +00:00
Anastasia Stulova af0a7bbbe2 [OpenCL] Add missing address spaces in IR generation of blocks
Modify ObjC blocks impl wrt address spaces as follows:

- keep default private address space for blocks generated
as local variables (with captures);

- add global address space for global block literals (no captures);

- make the block invoke function and enqueue_kernel prototype with
the generic AS block pointer parameter to accommodate both 
private and global AS cases from above;

- add block handling into default AS because it's implemented as
a special pointer type (BlockPointer) in the frontend and therefore
it is used as a pointer everywhere. This is also needed to accommodate
both private and global AS blocks for the two cases above.

- removes ObjC RT specific symbols (NSConcreteStackBlock and
NSConcreteGlobalBlock) in the OpenCL mode.

Review: https://reviews.llvm.org/D28814
llvm-svn: 293286
2017-01-27 15:11:34 +00:00
Simon Dardis 9e962add70 [mips] Add support for static model on N64
The patch teaches the Clang driver how to handle the N64 static
relocation model properly. It enforces the correct target feature
(+noabicalls) when -fno-pic is used. This is required as non-pic
N64 code as the abi extension to call PIC code (CPIC) is unsupported.

Make PIC the default for mips64 and mips64el, this affects both N32
& N64 ABIs, to better match GCC.

As part of this effort, clean up the assembler invocation command
builder, so the correct flags are used.

This and r293279 in LLVM resolves PR/23485.

Thanks to Brooks Davis for reporting the issue!

Reviewers: slthakur, seanbruno

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

llvm-svn: 293285
2017-01-27 15:05:25 +00:00
Artem Dergachev 12caf8e1e6 [analyzer] Consider function call arguments while building CallGraph.
Function call can appear in the arguments of another function call, eg.:

  foo(bar());

This patch adds support for such cases.

Patch by Ivan Sidorenko!

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

llvm-svn: 293280
2017-01-27 12:14:56 +00:00
Peter Collingbourne b884716f6a Re-apply r292662, "IRGen: Start using the WriteThinLTOBitcode pass."
The internal build issue has been resolved.

llvm-svn: 293231
2017-01-26 23:51:50 +00:00
Richard Smith 76ea19641e [modules] Additional tests.
llvm-svn: 293223
2017-01-26 23:07:59 +00:00
Richard Smith 7ea2929d84 Add files forgotten in r293219.
llvm-svn: 293222
2017-01-26 23:06:10 +00:00
Richard Smith c0ca4c2c95 [modules] When reading / writing a typedef that is a name for linkage for
another declaration, ensure we actually serialize / deserialize that
declaration.

Before this patch, if another copy of the typedef were merged with the parsed
version, we would emit type information referring to the merged version and
consequently emit nothing about the parsed anonymous struct. This resulted in
us losing information, particularly the visible merged module set for the
parsed definition. Force that information to be emitted and to be loaded when
the typedef is used.

llvm-svn: 293219
2017-01-26 22:39:55 +00:00
Peter Collingbourne 7af93e31fe Add missing x86 requirement.
llvm-svn: 293210
2017-01-26 21:38:48 +00:00
Peter Collingbourne f5d1712189 IRGen: When loading the main module in the distributed ThinLTO backend, look for the module containing the summary.
Differential Revision: https://reviews.llvm.org/D29067

llvm-svn: 293209
2017-01-26 21:09:48 +00:00
Richard Smith 600b5261c4 PR0091R3: Implement parsing support for using templates as types.
This change adds a new type node, DeducedTemplateSpecializationType, to
represent a type template name that has been used as a type. This is modeled
around AutoType, and shares a common base class for representing a deduced
placeholder type.

We allow deduced class template types in a few more places than the standard
does: in conditions and for-range-declarators, and in new-type-ids. This is
consistent with GCC and with discussion on the core reflector. This patch
does not yet support deduced class template types being named in typename
specifiers.

llvm-svn: 293207
2017-01-26 20:40:47 +00:00
Akira Hatanaka c05c42567e Turn on -Wblock-capture-autoreleasing by default.
Turning on the warning by default helps the users as it's a common
mistake to capture out-parameters in a block without ensuring the object
assigned doesn't get released.

rdar://problem/30200058

llvm-svn: 293199
2017-01-26 18:51:10 +00:00
Akira Hatanaka 5d55a6c69d [Sema][ObjC] Make sure -Wblock-capture-autoreleasing issues a warning
even in the presence of nullability qualifiers.

This commit fixes bugs in r285031 where -Wblock-capture-autoreleasing
wouldn't issue warnings when the function parameters were annotated
with nullability qualifiers. Specifically, look through the sugar and
see if there is an AttributedType of kind attr_objc_ownership to
determine whether __autoreleasing was explicitly specified or implicitly
added by the compiler.

rdar://problem/30193488

llvm-svn: 293194
2017-01-26 18:13:06 +00:00
Arpith Chacko Jacob cca61a3a74 [OpenMP] Codegen support for 'target teams' on the NVPTX device.
This is a simple patch to teach OpenMP codegen to emit the construct
in Generic mode.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29143

llvm-svn: 293183
2017-01-26 15:43:27 +00:00
Adam Nemet 1a89f25b6e Further fixes to test from r293146
Require aarch64 and avoid filename in YAML since it may require quotation.

llvm-svn: 293149
2017-01-26 04:34:07 +00:00
Adam Nemet 3071266f6f Fix test from r293146
llvm-svn: 293147
2017-01-26 04:14:04 +00:00
Adam Nemet 7b796f825b Support MIR opt-remarks with -fsave-optimization-record
The handler that deals with IR passed/missed/analysis remarks is extended to
also handle the corresponding MIR remarks.

The more thorough testing in done via llc (rL293113, rL293121).  Here we just
make sure that the functionality is accessible through clang.

llvm-svn: 293146
2017-01-26 04:07:11 +00:00
Argyrios Kyrtzidis aee15fb204 [index] When indexing an ObjC method declaration use its base name for the location.
Instead of using the location of the beginning '-'/'+'.
This is consistent with location used for function decls and ObjC method calls where we use the base name as the location as well.

llvm-svn: 293134
2017-01-26 02:11:50 +00:00
Richard Smith d230de27f8 Remove and replace DiagStatePoint tracking and lookup data structure.
Rather than storing a single flat list of SourceLocations where the diagnostic
state changes (in source order), we now store a separate list for each FileID
in which there is a diagnostic state transition. (State for other files is
built and cached lazily, on demand.) This has two consequences:

1) We can now sensibly support modules, and properly track the diagnostic state
for modular headers (this matters when, for instance, triggering instantiation
of a template defined within a module triggers diagnostics).

2) It's much faster than the old approach, since we can now just do a binary
search on the offsets within the FileID rather than needing to call
isBeforeInTranslationUnit to determine source order (which is surprisingly
slow). For some pathological (but real world) files, this reduces total
compilation time by more than 10%.

For now, the diagnostic state points for modules are loaded eagerly. It seems
feasible to defer this until diagnostic state information for one of the
module's files is needed, but that's not part of this patch.

llvm-svn: 293123
2017-01-26 01:01:01 +00:00
Akira Hatanaka 151d339125 Fix test case committed in r293106 so that it passes on targets whose
pointers are 4-bytes instead of 8-bytes.

llvm-svn: 293111
2017-01-25 23:36:15 +00:00
Akira Hatanaka cb904604c9 Remove the return type from the check string in test case.
Bots were failing because some targets emit signext before i32.

llvm-svn: 293108
2017-01-25 23:16:32 +00:00
Akira Hatanaka fdcd18b4c9 [CodeGen] Suppress emission of lifetime markers if a label has been seen
in the current lexical scope.

clang currently emits the lifetime.start marker of a variable when the
variable comes into scope even though a variable's lifetime starts at
the entry of the block with which it is associated, according to the C
standard. This normally doesn't cause any problems, but in the rare case
where a goto jumps backwards past the variable declaration to an earlier
point in the block (see the test case added to lifetime2.c), it can
cause mis-compilation.

To prevent such mis-compiles, this commit conservatively disables
emitting lifetime variables when a label has been seen in the current
block.

This problem was discussed on cfe-dev here: 
http://lists.llvm.org/pipermail/cfe-dev/2016-July/050066.html

rdar://problem/30153946

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

llvm-svn: 293106
2017-01-25 22:55:13 +00:00
Justin Lebar b080b630b1 [CodeGen] [CUDA] Add the ability set default attrs on functions in linked modules.
Summary:
Now when you ask clang to link in a bitcode module, you can tell it to
set attributes on that module's functions to match what we would have
set if we'd emitted those functions ourselves.

This is particularly important for fast-math attributes in CUDA
compilations.

Each CUDA compilation links in libdevice, a bitcode library provided by
nvidia as part of the CUDA distribution.  Without this patch, if we have
a user-function F that is compiled with -ffast-math that calls a
function G from libdevice, F will have the unsafe-fp-math=true (etc.)
attributes, but G will have no attributes.

Since F calls G, the inliner will merge G's attributes into F's.  It
considers the lack of an unsafe-fp-math=true attribute on G to be
tantamount to unsafe-fp-math=false, so it "merges" these by setting
unsafe-fp-math=false on F.

This then continues up the call graph, until every function that
(transitively) calls something in libdevice gets unsafe-fp-math=false
set, thus disabling fastmath in almost all CUDA code.

Reviewers: echristo

Subscribers: hfinkel, llvm-commits, mehdi_amini

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

llvm-svn: 293097
2017-01-25 21:29:48 +00:00
Arpith Chacko Jacob 2cd6eeabfd [OpenMP] Support for the proc_bind-clause on 'target parallel' on the NVPTX device.
This patch adds support for the proc_bind clause on the Spmd construct
'target parallel' on the NVPTX device.  Since the parallel region is created
upon kernel launch, this clause can be safely ignored on the NVPTX device at
codegen time for level 0 parallelism.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29128

llvm-svn: 293069
2017-01-25 16:55:10 +00:00
Michal Gorny a56833b0e7 [test] Add HAVE_LIBZ to canonicalized booleans
Canonicalize HAVE_LIBZ as well to fix buildbot failures.

llvm-svn: 293053
2017-01-25 13:31:53 +00:00
Michal Gorny 638ac70a92 [test] Port clang tests to canonicalized booleans
Use the new llvm_canonicalize_cmake_booleans() function to canonicalize
booleans for lit tests. Replace the duplicate ENABLE_CLANG* variables
used to hold canonicalized values with in-place canonicalization. Use
implicit logic in Python code to avoid overrelying on exact 0/1 values.

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

llvm-svn: 293052
2017-01-25 13:11:45 +00:00
Martin Bohme ac93aa7022 [Driver] Prevent no-arc-exception-silence.m test from writing output.
Summary: This enables the test to run on systems where output cannot be written.

Reviewers: compnerd

Subscribers: cfe-commits

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

llvm-svn: 293051
2017-01-25 12:55:53 +00:00
Anastasia Stulova d1f390ef99 [OpenCL] Diagnose write_only image3d when extension is disabled
Prior to OpenCL 2.0, image3d_t can only be used with the write_only
access qualifier when the cl_khr_3d_image_writes extension is enabled,
see e.g. OpenCL 1.1 s6.8b.

Require the extension for write_only image3d_t types and guard uses of
write_only image3d_t in the OpenCL header.

Patch by Sven van Haastregt!

Review: https://reviews.llvm.org/D28860
llvm-svn: 293050
2017-01-25 12:18:50 +00:00
Arpith Chacko Jacob 7ecc0b7f3d [OpenMP] Support for thread_limit-clause on the 'target teams' directive.
The thread_limit-clause on the combined directive applies to the
'teams' region of this construct. We modify the ThreadLimitClause
class to capture the clause expression within the 'target' region.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29087

llvm-svn: 293049
2017-01-25 11:44:35 +00:00
Arpith Chacko Jacob bc126344e1 [OpenMP] Support for num_teams-clause on the 'target teams' directive.
The num_teams-clause on the combined directive applies to the
'teams' region of this construct. We modify the NumTeamsClause
class to capture the clause expression within the 'target' region.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29085

llvm-svn: 293048
2017-01-25 11:28:18 +00:00
Artem Dergachev 55705955ce [analyzer] Fix MacOSXAPIChecker fp with static locals seen from nested blocks.
This is an attempt to avoid new false positives caused by the reverted r292800,
however the scope of the fix is significantly reduced - some variables are still
in incorrect memory spaces.

Relevant test cases added.

rdar://problem/30105546
rdar://problem/30156693
Differential revision: https://reviews.llvm.org/D28946

llvm-svn: 293043
2017-01-25 10:21:45 +00:00
Diana Picus ac03b4b924 Revert "Use filename in linemarker when compiling preprocessed source"
This reverts commit r293004 because it broke the buildbots with "unknown CPU"
errors. I tried to fix it in r293026, but that broke on Green Dragon with this
kind of error:

error: expected string not found in input
// CHECK: l{{ +}}df{{ +}}*ABS*{{ +}}{{0+}}{{.+}}preprocessed-input.c{{$}}
          ^
<stdin>:2:1: note: scanning from here
/Users/buildslave/jenkins/sharedspace/incremental@2/clang-build/tools/clang/test/Frontend/Output/preprocessed-input.c.tmp.o: file format Mach-O 64-bit x86-64
^
<stdin>:2:67: note: possible intended match here
/Users/buildslave/jenkins/sharedspace/incremental@2/clang-build/tools/clang/test/Frontend/Output/preprocessed-input.c.tmp.o: file format Mach-O 64-bit x86-64

I suppose this means that llvm-objdump doesn't support Mach-O, so the test
should indeed check for linux (but not for x86). I'll leave it to someone that
knows better.

llvm-svn: 293032
2017-01-25 07:27:05 +00:00
Diana Picus 14aa59ac49 Try to fix test from r293004
This test broke on a lot of non-x86 buildbots with "unknowm CPU" errors. I don't
see anything platform-specific about this test, and it seems to work fine on ARM
if we just remove the -triple i686 flags from the run line.

llvm-svn: 293026
2017-01-25 06:23:50 +00:00
Saleem Abdulrasool bc6aaea336 Driver: ignore -fno-objc-arc-exception when -fno-objc-arc set
Sometime clang would be supplied -fobjc-arc -f(no)objc-arc-exceptions
and then later disable ARC with -fno-objc-arc, which only negate first
option, but not the latter, resulting usused argument warning.  Silence
this warning only when -fno-objc-arc option is present.

Patch by Onha Choe!

llvm-svn: 293014
2017-01-25 03:36:28 +00:00
Arpith Chacko Jacob 99a1e0eba5 [OpenMP] Codegen support for 'target teams' on the host.
This patch adds support for codegen of 'target teams' on the host.
This combined directive has two captured statements, one for the
'teams' region, and the other for the 'parallel'.

This target teams region is offloaded using the __tgt_target_teams()
call. The patch sets the number of teams as an argument to
this call.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29084

llvm-svn: 293005
2017-01-25 02:18:43 +00:00
David Callahan ae7e0da4f8 Use filename in linemarker when compiling preprocessed source
Summary:
Clang appears to always use name as specified on the command
line, whereas gcc uses the name as specified in the linemarker at the
first line when compiling a preprocessed source. This results mismatch
between two compilers in FILE symbol table entry. This patch makes clang
to resemble gcc's behavior in finding the original source file name and
use it as an input file name.

Even with this patch, values of FILE symbol table entry may still be
different because clang uses dirname+basename for the entry whlie gcc
uses basename only. I'll write a patch for that once this patch is
committed.

Reviewers: dblaikie, inglorion

Reviewed By: inglorion

Subscribers: inglorion, aprantl, bruno

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

llvm-svn: 293004
2017-01-25 01:55:28 +00:00
Arpith Chacko Jacob 86f9e46365 Reverting commit because an NVPTX patch sneaked in. Break up into two
patches.

llvm-svn: 293003
2017-01-25 01:45:59 +00:00
Arpith Chacko Jacob 4dbf368e14 [OpenMP] Codegen support for 'target teams' on the host.
This patch adds support for codegen of 'target teams' on the host.
This combined directive has two captured statements, one for the
'teams' region, and the other for the 'parallel'.

This target teams region is offloaded using the __tgt_target_teams()
call. The patch sets the number of teams as an argument to
this call.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29084

llvm-svn: 293001
2017-01-25 01:38:33 +00:00
Arpith Chacko Jacob e04da5dee2 [OpenMP] Support for the num_threads-clause on 'target parallel' on the NVPTX device.
This patch adds support for the Spmd construct 'target parallel' on the
NVPTX device. This involves ignoring the num_threads clause on the device
since the number of threads in this combined construct is already set on
the host through the call to __tgt_target_teams().

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29083

llvm-svn: 292999
2017-01-25 01:18:34 +00:00
Arpith Chacko Jacob 33c849a007 [OpenMP] Support for the num_threads-clause on 'target parallel'.
The num_threads-clause on the combined directive applies to the
'parallel' region of this construct. We modify the NumThreadsClause
class to capture the clause expression within the 'target' region.

The offload runtime call for 'target parallel' is changed to
__tgt_target_teams() with 1 team and the number of threads set by
this clause or a default if none.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29082

llvm-svn: 292997
2017-01-25 00:57:16 +00:00
Richard Smith 73edb6d0cc PR31742: Don't emit a bogus "zero size array" extwarn when initializing a
runtime-sized array from an empty list in an array new.

llvm-svn: 292991
2017-01-24 23:18:28 +00:00
Richard Smith 6536f6058d Strengthen test from r292632 to also check we get the mangling correct for this case.
llvm-svn: 292978
2017-01-24 21:03:48 +00:00
Mehdi Amini 3406bb6748 Fix test/Driver/embed-bitcode.c on non-Darwin host by setting the target explicitly
llvm-svn: 292964
2017-01-24 18:49:49 +00:00
Mehdi Amini 04e1a0a171 Forward -bitcode_process_mode to ld64 in marker-only mode
Reviewers: steven_wu

Subscribers: cfe-commits

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

llvm-svn: 292961
2017-01-24 18:15:21 +00:00
Alex Lorenz 638dbc3036 [CodeCompletion] Ensure that ObjC root class completes instance
methods from protocols and categories as well

Code completion results for class methods already include instance methods
from Objective-C root classes. This commit ensures that the results also include
instance methods from protocols that the root class implements and root class
categories as well.

rdar://28012953

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

llvm-svn: 292932
2017-01-24 14:15:08 +00:00
Greg Parker 77de38ed2e Revert "[test] Replace `REQUIRES-ANY: a, b, c` with `REQUIRES: a || b || c`."
The underlying `lit` change needs to be better-coordinated with libc++.

llvm-svn: 292898
2017-01-24 08:57:17 +00:00
Greg Parker 03e58ee734 [test] Replace `REQUIRES-ANY: a, b, c` with `REQUIRES: a || b || c`.
Requires the new `lit` boolean expressions in LLVM r292896.

llvm-svn: 292897
2017-01-24 08:47:25 +00:00
Devin Coughlin e1a5630213 Revert "[analyzer] Fix memory space of static locals seen from nested blocks."
This reverts commit r292800.

It is causing null pointer dereference false positives when a block that
captures a static local is evaluated at the top level.

llvm-svn: 292874
2017-01-24 02:10:59 +00:00
Hans Wennborg 251c204e57 Re-commit "Don't inline dllimport functions referencing non-imported methods"
This re-commits r292522 with the addition that it also handles calls
through pointer to member functions without crashing.

llvm-svn: 292856
2017-01-23 23:57:50 +00:00
Richard Smith 8d14835b2e PR31692: Don't mark a declaration as invalid if we haven't necessarily emitted a (user-visible) error.
llvm-svn: 292847
2017-01-23 23:14:23 +00:00
Tim Shen fd1e5aa8df [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)
Summary:
This patch changes the layout of DoubleAPFloat, and adjust all
operations to do either:
1) (IEEEdouble, IEEEdouble) -> (uint64_t, uint64_t) -> PPCDoubleDoubleImpl,
   then run the old algorithm.
2) Do the right thing directly.

1) includes multiply, divide, remainder, mod, fusedMultiplyAdd, roundToIntegral,
   convertFromString, next, convertToInteger, convertFromAPInt,
   convertFromSignExtendedInteger, convertFromZeroExtendedInteger,
   convertToHexString, toString, getExactInverse.
2) includes makeZero, makeLargest, makeSmallest, makeSmallestNormalized,
   compare, bitwiseIsEqual, bitcastToAPInt, isDenormal, isSmallest,
   isLargest, isInteger, ilogb, scalbn, frexp, hash_value, Profile.

I could split this into two patches, e.g. use
1) for all operatoins first, then incrementally change some of them to
2). I didn't do that, because 1) involves code that converts data between
PPCDoubleDoubleImpl and (IEEEdouble, IEEEdouble) back and forth, and may
pessimize the compiler. Instead, I find easy functions and use
approach 2) for them directly.

Next step is to implement move multiply and divide from 1) to 2). I don't
have plans for other functions in 1).

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

llvm-svn: 292839
2017-01-23 22:39:35 +00:00
Matt Arsenault 09cca093a3 AMDGPU: Update for changed subtarget feature name
llvm-svn: 292838
2017-01-23 22:31:14 +00:00
Paul Robinson a363d14538 Guard __gnuc_va_list typedef.
Differential Revision: http://reviews.llvm.org/D28620

llvm-svn: 292819
2017-01-23 19:09:21 +00:00
Alex Lorenz e7e8f80be1 [Sema] UsingShadowDecl shouldn't be hidden by the UsingDecl that owns it
rdar://23454249

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

llvm-svn: 292805
2017-01-23 17:23:23 +00:00
Anastasia Stulova 8ac3d0cb62 [OpenCL] Improved enqueue_kernel diagnostic message
- Removed duplicated word typo.
- Made coherent across multiple similar diagnostics.

llvm-svn: 292804
2017-01-23 17:12:36 +00:00
David Blaikie 8cf0c27404 Revert "DebugInfo: Omit class definitions even in the presence of available_externally vtables"
Patch crashing on a bootstrapping sanitizer bot:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/679

Reverting while I investigate.

This reverts commit r292768.

llvm-svn: 292801
2017-01-23 16:57:14 +00:00
Artem Dergachev 01728fbbc0 [analyzer] Fix memory space of static locals seen from nested blocks.
When a block within a function accesses a function's static local variable,
this local is captured by reference rather than copied to the heap.

Therefore this variable's memory space is known: StaticGlobalSpaceRegion.
Used to be UnknownSpaceRegion, same as for stack locals.

Fixes a false positive in MacOSXAPIChecker.

rdar://problem/30105546
Differential revision: https://reviews.llvm.org/D28946

llvm-svn: 292800
2017-01-23 16:57:11 +00:00
Arpith Chacko Jacob 1f46b70b5d [OpenMP] DSAChecker bug fix for combined directives.
The DSAChecker code in SemaOpenMP looks at the captured statement
associated with an OpenMP directive.  A combined directive such as
'target parallel' has nested capture statements, which have to be
fully traversed before executing the DSAChecker.  This is a patch
to perform the traversal for such combined directives.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29026

llvm-svn: 292794
2017-01-23 15:38:49 +00:00
Martin Bohme 5057766d87 Revert "IRGen: Start using the WriteThinLTOBitcode pass."
Summary:
This reverts commit r292662.

This change broke internal builds. Will provide a reproducer internally.

Subscribers: pcc, mehdi_amini, cfe-commits, mgorny

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

llvm-svn: 292791
2017-01-23 14:33:42 +00:00
Antonio Maiorano ae834047a4 clang-format: remove tests that assume no config file will be found as this is not always the case
These tests fail for developers who place their build directories under the
llvm root directory because llvm's own .clang-format file will be found.
Anyway these cases are covered by FormatStyle.GetStyleOfFile tests
(FormatTest.cpp).

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

llvm-svn: 292787
2017-01-23 13:20:23 +00:00
Aleksei Sidorin 079534760c ASTImporter: fix tests on Windows with removing slashed parts of paths
Differential Revision: https://reviews.llvm.org/D26753

llvm-svn: 292781
2017-01-23 10:39:45 +00:00
Aleksei Sidorin 9931f756c1 ASTImporter: quick test fix
Differential Revision: https://reviews.llvm.org/D26753

llvm-svn: 292779
2017-01-23 10:16:30 +00:00
Aleksei Sidorin daf82f675e ASTImporter: add forgotten tests for rL292776
llvm-svn: 292778
2017-01-23 09:45:29 +00:00
David Blaikie b06bcde1ab DebugInfo: Omit class definitions even in the presence of available_externally vtables
To ensure optimization level doesn't pessimize the -fstandalone-debug
vtable debug info optimization (where class definitions are only emitted
where the vtable is emitted - reducing redundant debug info) ensure the
debug info class definition is still omitted when an
available_externally vtable definition is emitted for optimization
purposes.

llvm-svn: 292768
2017-01-23 02:24:03 +00:00
Peter Collingbourne 6f16ac1473 IRGen: Start using the WriteThinLTOBitcode pass.
This is the final change necessary to support CFI with ThinLTO.

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

llvm-svn: 292662
2017-01-20 22:39:16 +00:00
Tim Shen 867be0d14c [Altivec] Change vec_sl to a << (b % (sizeof(a) * 8))
For a << b (as original vec_sl does), if b >= sizeof(a) * 8, the
behavior is undefined. However, Power instructions do define the
behavior, which is equivalent to a << (b % (sizeof(a) * 8)).

This patch changes altivec.h to use a << (b % (sizeof(a) * 8)), to
ensure the consistent semantic of the instructions. Then it combines
the generated multiple instructions back to a single shift.

This patch handles left shift only. Right shift, on the other hand, is
more complicated, considering arithematic/logical right shift.

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

llvm-svn: 292659
2017-01-20 22:05:33 +00:00
Reid Kleckner 25019ca828 Revert "Don't inline dllimport functions referencing non-imported methods"
This reverts commit r292522. It appears to be causing crashes in builds
using dllimport.

llvm-svn: 292643
2017-01-20 20:44:50 +00:00
Manman Ren dfcf1cb175 Revert r292508 given that we intend to remove driver options for cxx modules.
llvm-svn: 292639
2017-01-20 20:03:00 +00:00
Matt Arsenault 24b5ae4497 AMDGPU: Add builtin for getreg intrinsic
llvm-svn: 292636
2017-01-20 19:24:22 +00:00
Richard Smith 91fb1f4be7 Fix actually-reachable llvm_unreachable.
llvm-svn: 292632
2017-01-20 18:50:12 +00:00
Alex Lorenz 41d13152b1 [Frontend] The macro that describes the Objective-C bool type should
be defined for non Objective-C code as well

rdar://29794915

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

llvm-svn: 292617
2017-01-20 16:48:25 +00:00
Alex Lorenz 56fb6fef50 [Sema] Improve the error diagnostic for dot destructor calls on pointer objects
This commit improves the mismatched destructor type error by detecting when the
destructor call has used a '.' instead of a '->' on a pointer to the destructed
type. The diagnostic now suggests to use '->' instead of '.', and adds a fixit
where appropriate.

rdar://28766702

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

llvm-svn: 292615
2017-01-20 15:38:58 +00:00
Krasimir Georgiev 69cb6ce7fb [clang-format] Remove redundant test in style-on-command-line.cpp
Summary:
rL292562 added a fix to always format if the fallback style is set to "none".
In test/Format/style-on-command-line.cpp:19 is redundant, since -fallback-style
has a default value of LLVM set in ClangFormat.cpp:72.

@amaiorano: I believe that the rest of the test cases still cover your change in
case the fallback style is explicitly set to "none". Please, if this is not the
case, initiate a discussion.

Reviewers: ioeric, bkramer

Reviewed By: ioeric

Subscribers: cfe-commits, klimek, amaiorano

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

llvm-svn: 292604
2017-01-20 12:39:05 +00:00
Krasimir Georgiev 522d1f432f Remove 'RUN: false' from Driver/response-file.c
Summary:
It seems that rL292518 introduced a RUN: false, but the continuation rL292545
forgot to remove it back.

This has flown under the radar, because it's a long test and doesn't get
executed by default during sanity testing.

To test:
$ cd llvm_build
$ ./bin/llvm-lit --param run_long_tests=true tools/clang/test/Driver/response-file.c

@rsmith: have a look if this change is OK please.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, rsmith

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

llvm-svn: 292600
2017-01-20 11:06:58 +00:00
Alexey Bataev 880d8605e3 [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows
with SEH and openmp

In some cituations (during codegen for Windows SEH constructs)
CodeGenFunction instance may have CurFn equal to nullptr. OpenMP related
code does not expect such situation during cleanup.

llvm-svn: 292590
2017-01-20 08:57:28 +00:00
Jordan Rose ccca669ccd [AST Printer] Print attributes on enum constants
The AST printer was dropping attributes on enumerators (enum
constants). Now it's not.

llvm-svn: 292571
2017-01-20 03:33:42 +00:00
Greg Parker efa3185ee4 [test] Remove an unwanted match for `UNSUPPORTED:`.
llvm-svn: 292568
2017-01-20 02:12:22 +00:00
Antonio Maiorano 7eb7507aeb clang-format: fix fallback style set to "none" not always formatting
This fixes clang-format not formatting if fallback-style is explicitly set to
"none", and either a config file is found or YAML is passed in without a
"BasedOnStyle". With this change, passing "none" in these cases will have no
affect, and LLVM style will be used as the base style.

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

llvm-svn: 292562
2017-01-20 01:22:42 +00:00
Richard Smith 187ffb4a8e PR31701: Fix crash on invalid caused by parsing a dependent initializer when we
don't know we're in a dependent context.

llvm-svn: 292561
2017-01-20 01:19:46 +00:00
Richard Smith 5e29dd3fe0 P0426: Make the library implementation of constexpr char_traits a little easier
by providing a memchr builtin that returns char* instead of void*.

Also add a __has_feature flag to indicate the presence of constexpr forms of
the relevant <string> functions.

llvm-svn: 292555
2017-01-20 00:45:35 +00:00
Richard Smith fd3dae024f Finish implementation of C++ DR1310 (http://wg21.link/cwg1310).
Diagnose the case when a dependent template name instantiates to an
injected-class-name outside a nested-name-specifier.

llvm-svn: 292545
2017-01-20 00:20:39 +00:00
Hans Wennborg 7c650777b0 Don't inline dllimport functions referencing non-imported methods
This is another follow-up to r246338. I had assumed methods were already
handled by the AST visitor, but turns out they weren't.

llvm-svn: 292522
2017-01-19 21:33:13 +00:00
Richard Smith 74f02347ca PR13403 (+duplicates): implement C++ DR1310 (http://wg21.link/cwg1310).
Under this defect resolution, the injected-class-name of a class or class
template cannot be used except in very limited circumstances (when declaring a
constructor, in a nested-name-specifier, in a base-specifier, or in an
elaborated-type-specifier). This is apparently done to make parsing easier, but
it's a pain for us since we don't know whether a template-id using the
injected-class-name is valid at the point when we annotate it (we don't yet
know whether the template-id will become part of an elaborated-type-specifier).

As a tentative resolution to a perceived language defect, mem-initializer-ids
are added to the list of exceptions here (they generally follow the same rules
as base-specifiers).

When the reference to the injected-class-name uses the 'typename' or 'template'
keywords, we permit it to be used to name a type or template as an extension;
other compilers also accept some cases in this area. There are also a couple of
corner cases with dependent template names that we do not yet diagnose, but
which will also get this treatment.

llvm-svn: 292518
2017-01-19 21:00:13 +00:00
Manman Ren 4798302d87 Module: Improve diagnostic message when cxx modules are disabled and @import is used in Objective CXX.
rdar://problem/19399671

llvm-svn: 292508
2017-01-19 19:05:55 +00:00
Malcolm Parsons bece0cd512 [Sema] Reword unused lambda capture warning
Summary:
The warning doesn't know why the variable was looked up but not
odr-used, so reword it to not claim that it was used in an unevaluated
context.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 292498
2017-01-19 17:19:22 +00:00
Alex Lorenz 75391c7b3f [Sema] Fix PR28181 by avoiding calling BuildOverloadedBinOp in C mode
rdar://28532840

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

llvm-svn: 292497
2017-01-19 17:17:57 +00:00
Sumanth Gundapaneni 1952acf958 [Hexagon] Linux linker does not support .gnu-hash
Hexagon Linux dynamic loader does not use (in fact does not support)
.gnu-hash

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

llvm-svn: 292496
2017-01-19 16:54:04 +00:00
Dehao Chen b3a70de753 Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection
Summary:
SamplePGO uses profile with debug info to collect profile. Unlike the traditional debugging purpose, sample pgo needs more accurate debug info to represent the profile. We add -femit-accurate-debug-info for this purpose. It can be combined with all debugging modes (-g, -gmlt, etc). It makes sure that the following pieces of info is always emitted:

* start line of all subprograms
* linkage name of all subprograms
* standalone subprograms (functions that has neither inlined nor been inlined)

The impact on speccpu2006 binary size (size increase comparing with -g0 binary, also includes data for -g binary, which does not change with this patch):

               -gmlt(orig) -gmlt(patched) -g
433.milc       4.68%       5.40%          19.73%
444.namd       8.45%       8.93%          45.99%
447.dealII     97.43%      115.21%        374.89%
450.soplex     27.75%      31.88%         126.04%
453.povray     21.81%      26.16%         92.03%
470.lbm        0.60%       0.67%          1.96%
482.sphinx3    5.77%       6.47%          26.17%
400.perlbench  17.81%      19.43%         73.08%
401.bzip2      3.73%       3.92%          12.18%
403.gcc        31.75%      34.48%         122.75%
429.mcf        0.78%       0.88%          3.89%
445.gobmk      6.08%       7.92%          42.27%
456.hmmer      10.36%      11.25%         35.23%
458.sjeng      5.08%       5.42%          14.36%
462.libquantum 1.71%       1.96%          6.36%
464.h264ref    15.61%      16.56%         43.92%
471.omnetpp    11.93%      15.84%         60.09%
473.astar      3.11%       3.69%          14.18%
483.xalancbmk  56.29%      81.63%         353.22%
geomean        15.60%      18.30%         57.81%

Debug info size change for -gmlt binary with this patch:

433.milc       13.46%
444.namd       5.35%
447.dealII     18.21%
450.soplex     14.68%
453.povray     19.65%
470.lbm        6.03%
482.sphinx3    11.21%
400.perlbench  8.91%
401.bzip2      4.41%
403.gcc        8.56%
429.mcf        8.24%
445.gobmk      29.47%
456.hmmer      8.19%
458.sjeng      6.05%
462.libquantum 11.23%
464.h264ref    5.93%
471.omnetpp    31.89%
473.astar      16.20%
483.xalancbmk  44.62%
geomean        16.83%

Reviewers: davidxl, andreadb, rob.lougher, dblaikie, echristo

Reviewed By: dblaikie, echristo

Subscribers: hfinkel, rob.lougher, andreadb, gbedwell, cfe-commits, probinson, llvm-commits, mehdi_amini

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

llvm-svn: 292458
2017-01-19 00:44:21 +00:00
Peter Collingbourne 87cdfa7635 Add llvm-dis dependency to check-clang.
llvm-svn: 292450
2017-01-19 00:04:44 +00:00
Peter Collingbourne 1e1475ace5 Move vtable type metadata emission behind a cc1-level flag.
In ThinLTO mode, type metadata will require the module to be written as a
multi-module bitcode file, which is currently incompatible with the Darwin
linker. It is also useful to be able to enable or disable multi-module bitcode
for testing purposes. This introduces a cc1-level flag, -f{,no-}lto-unit,
which is used by the driver to enable multi-module bitcode on all but
Darwin+ThinLTO, and can also be used to enable/disable the feature manually.

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

llvm-svn: 292448
2017-01-18 23:55:27 +00:00
Arpith Chacko Jacob fe4890a68b [OpenMP] Support for the if-clause on the combined directive 'target parallel'.
The if-clause on the combined directive potentially applies to both the
'target' and the 'parallel' regions.  Codegen'ing the if-clause on the
combined directive requires additional support because the expression in
the clause must be captured by the 'target' capture statement but not
the 'parallel' capture statement.  Note that this situation arises for
other clauses such as num_threads.

The OMPIfClause class inherits OMPClauseWithPreInit to support capturing
of expressions in the clause.  A member CaptureRegion is added to
OMPClauseWithPreInit to indicate which captured statement (in this case
'target' but not 'parallel') captures these expressions.

To ensure correct codegen of captured expressions in the presence of
combined 'target' directives, OMPParallelScope was added to 'parallel'
codegen.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28781

llvm-svn: 292437
2017-01-18 20:40:48 +00:00
Graydon Hoare dc0405f74c [Modules] Correct test comment from obsolete earlier version of code. NFC
Summary:
Code committed in rL290219 went through a few iterations; test wound up with
stale comment.

Reviewers: doug.gregor, manmanren

Reviewed By: manmanren

Subscribers: cfe-commits

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

llvm-svn: 292435
2017-01-18 20:34:44 +00:00
Arpith Chacko Jacob 44a87c9f1b [OpenMP] Codegen for the 'target parallel' directive on the NVPTX device.
This patch adds codegen for the 'target parallel' directive on the NVPTX
device.  We term offload OpenMP directives such as 'target parallel' and
'target teams distribute parallel for' as SPMD constructs.  SPMD constructs,
in contrast to Generic ones like the plain 'target', can never contain
a serial region.

SPMD constructs can be handled more efficiently on the GPU and do not
require the Warp Loop of the Generic codegen scheme. This patch adds
SPMD codegen support for 'target parallel' on the NVPTX device and can
be reused for other SPMD constructs.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28755

llvm-svn: 292428
2017-01-18 19:35:00 +00:00
Richard Smith 11255ec765 PR9551: Implement DR1004 (http://wg21.link/cwg1004).
This rule permits the injected-class-name of a class template to be used as
both a template type argument and a template template argument, with no extra
syntax required to disambiguate.

llvm-svn: 292426
2017-01-18 19:19:22 +00:00
Arpith Chacko Jacob 19b911cb75 [OpenMP] Codegen support for 'target parallel' on the host.
This patch adds support for codegen of 'target parallel' on the host.
It is also the first combined directive that requires two or more
captured statements.  Support for this functionality is included in
the patch.

A combined directive such as 'target parallel' has two captured
statements, one for the 'target' and the other for the 'parallel'
region.  Two captured statements are required because each has
different implicit parameters (see SemaOpenMP.cpp).  For example,
the 'parallel' has 'global_tid' and 'bound_tid' while the 'target'
does not.  The patch adds support for handling multiple captured
statements based on the combined directive.

When codegen'ing the 'target parallel' directive, the 'target'
outlined function is created using the outer captured statement
and the 'parallel' outlined function is created using the inner
captured statement.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28753

llvm-svn: 292419
2017-01-18 18:18:53 +00:00
Arpith Chacko Jacob 42793e000a Revert r292374 to debug Windows buildbot failure.
llvm-svn: 292400
2017-01-18 15:36:05 +00:00
Jonathan Roelofs 8277c41a89 Warn when calling a non interrupt function from an interrupt on ARM
The idea for this originated from a really tricky bug: ISRs on ARM don't
automatically save off the VFP regs, so if say, memcpy gets interrupted and the
ISR itself calls memcpy, the regs are left clobbered when the ISR is done.

https://reviews.llvm.org/D28820

llvm-svn: 292375
2017-01-18 15:31:11 +00:00
Arpith Chacko Jacob 68019578a3 [OpenMP] Codegen support for 'target parallel' on the host.
This patch adds support for codegen of 'target parallel' on the host.
It is also the first combined directive that requires two or more
captured statements.  Support for this functionality is included in
the patch.

A combined directive such as 'target parallel' has two captured
statements, one for the 'target' and the other for the 'parallel'
region.  Two captured statements are required because each has
different implicit parameters (see SemaOpenMP.cpp).  For example,
the 'parallel' has 'global_tid' and 'bound_tid' while the 'target'
does not.  The patch adds support for handling multiple captured
statements based on the combined directive.

When codegen'ing the 'target parallel' directive, the 'target'
outlined function is created using the outer captured statement
and the 'parallel' outlined function is created using the inner
captured statement.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28753

llvm-svn: 292374
2017-01-18 15:14:52 +00:00
Craig Topper 367c86ddbe [AVX-512] Replace subvector broadcast builtins with shufflevectors and selects.
Verified that the backend codegens this equally well.

llvm-svn: 292329
2017-01-18 02:17:10 +00:00
Dan Gohman 0c5954195b [WebAssembly] Update grow_memory's return type.
The grow_memory instruction now returns the previous memory size. Add the
return type to the clang intrinsic.

llvm-svn: 292324
2017-01-18 01:03:35 +00:00
Akira Hatanaka 8eccb9bbb1 [Sema] Fix bug in handling of designated initializer.
CheckDesignatedInitializer wasn't taking into account the base classes
when computing the index for the field in the derived class, which
caused the test case to crash during IRGen because of a malformed AST.

rdar://problem/26795040

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

llvm-svn: 292245
2017-01-17 19:35:54 +00:00
David Majnemer 7291a3e7d2 [AST] AttributedType should derive type properties from the EquivalentType
Using the canonical type instead of the equivalent type can result in
insufficient template instantiations.

This fixes PR31656.

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

llvm-svn: 292194
2017-01-17 04:14:25 +00:00
Frederic Riss 1633f68fe1 Fix AArch64 global-merge backend option name.
-mglobal-merge is translated to the appropriate backend option in
the driver. r277322 changed the AArch64 option name in the backend,
but the driver was never updated.

llvm-svn: 292192
2017-01-17 03:38:45 +00:00
Richard Smith 957fbf1f9f Partial revert of r290511.
The rules around typechecking deduced template arguments during partial
ordering are not clear, and while the prior behavior does not seem to be
correct (it doesn't follow the general model of partial ordering where each
template parameter is replaced by a non-dependent but unique value), the new
behavior is also not clearly right and breaks some existing idioms.

The new behavior is retained for dealing with non-type template parameters
with 'auto' types, as without it even the most basic uses of that feature
don't work. We can revisit this once CWG has come to an agreement on how
partial ordering with 'auto' non-type template parameters is supposed to
work.

llvm-svn: 292183
2017-01-17 02:14:37 +00:00
Antonio Maiorano 3adfb6a3ee clang-format: Make GetStyle return Expected<FormatStyle> instead of FormatStyle
Change the contract of GetStyle so that it returns an error when an error occurs
(i.e. when it writes to stderr), and only returns the fallback style when it
can't find a configuration file.

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

llvm-svn: 292174
2017-01-17 00:12:27 +00:00
Joerg Sonnenberger 8450266425 Ensure that clang -pthread creates the right macro. -D_POSIX_THREADS
seems to have been a C&P error from old GCC specs for OpenBSD.

llvm-svn: 292119
2017-01-16 14:07:24 +00:00
Daniel Jasper 357f2f8827 Fix test failures after recent clang-format format change.
llvm-svn: 292116
2017-01-16 13:43:46 +00:00
Argyrios Kyrtzidis 0516803ca5 [code-completion] Fix crash when trying to do postfix completion of instance member inside a static function.
llvm-svn: 292052
2017-01-15 06:11:04 +00:00
Yaron Keren fa3674017a Fix PR31644 introduced by r287138 and add a regression test.
Thanks Dimitry Andric for the report and fix!

llvm-svn: 292032
2017-01-14 21:12:08 +00:00