Commit Graph

30829 Commits

Author SHA1 Message Date
Nico Weber cc0573b03f clang-format: Don't leave behind temp files in -i mode on Windows, PR26125
Fix and analysis by Wei Mao <weimao1@gmail.com> (see bug), test by me.

llvm-svn: 296166
2017-02-24 20:49:00 +00:00
Alex Lorenz 24a1bedf76 [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma
in macro argument pre-expansion mode when skipping a function body

This commit fixes a token caching problem that currently occurs when clang is
skipping a function body (e.g. when looking for a code completion token) and at
the same time caching the tokens for _Pragma when lexing it in macro argument
pre-expansion mode.

When _Pragma is being lexed in macro argument pre-expansion mode, it caches the
tokens so that it can avoid interpreting the pragma immediately (as the macro
argument may not be used in the macro body), and then either backtracks over or
commits these tokens. The problem is that, when we're backtracking/committing in
such a scenario, there's already a previous backtracking position stored in
BacktrackPositions (as we're skipping the function body), and this leads to a
situation where the cached tokens from the pragma (like '(' 'string_literal'
and ')') will remain in the cached tokens array incorrectly even after they're
consumed (in the case of backtracking) or just ignored (in the case when they're
committed). Furthermore, what makes it even worse, is that because of a previous
backtracking position, the logic that deals with when should we call
ExitCachingLexMode in CachingLex no longer works for us in this situation, and
more tokens in the macro argument get cached, to the point where the EOF token
that corresponds to the macro argument EOF is cached. This problem leads to all
sorts of issues in code completion mode, where incorrect errors get presented
and code completion completely fails to produce completion results.

rdar://28523863

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

llvm-svn: 296140
2017-02-24 17:45:16 +00:00
Serge Pavlov 8ed8374057 Made test more target agnostic
Recommits r295975 (Added regression tests), reverted in r295975,
because it did not work on non-X86 targets.

llvm-svn: 296116
2017-02-24 13:15:08 +00:00
Roger Ferrer Ibanez d93add34b7 Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier
Fix an assertion that is hit when a redeclaration with differing types only
differs in the unaligned type-qualifier.

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

llvm-svn: 296099
2017-02-24 08:41:09 +00:00
Petr Hosek 162540ec1d [Driver] Enable SafeStack for Fuchsia targets
The runtime support is provided directly by the Fuchsia system C
library.

Patch by Roland McGrath

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

llvm-svn: 296082
2017-02-24 03:17:41 +00:00
Richard Trieu 8459ddf12a [ODRHash] Add handling of TypedefType and DeclarationName
Differential Revision: https://reviews.llvm.org/D21675

llvm-svn: 296078
2017-02-24 02:59:12 +00:00
George Burgess IV b7760210d3 Represent pass_object_size attrs in ExtParameterInfo
The goal of this is to fix a bug in modules where we'd merge
FunctionDecls that differed in their pass_object_size attributes. Since
we can overload on the presence of pass_object_size attributes, this
behavior is incorrect.

We don't represent `N` in `pass_object_size(N)` as part of
ExtParameterInfo, since it's an error to overload solely on the value of
N. This means that we have a bug if we have two modules that declare
functions that differ only in their pass_object_size attrs, like so:

// In module A, from a.h
void foo(char *__attribute__((pass_object_size(0))));

// In module B, from b.h
void foo(char *__attribute__((pass_object_size(1))));

// In module C, in main.c
#include "a.h"
#include "b.h"

At the moment, we'll merge the foo decls, when we should instead emit a
diagnostic about an invalid overload. We seem to have similar (silent)
behavior if we overload only on the return type of `foo` instead; I'll
try to find a good place to put a FIXME (or I'll just file a bug) soon.

This patch also fixes a bug where we'd not output the proper extended
parameter info for declarations with pass_object_size attrs.

llvm-svn: 296076
2017-02-24 02:49:47 +00:00
Douglas Yung 1db609f882 Recently a change was made to this test in r294639 which fails when the
compiler is run in a mode where the default C++ standard is newer than C++03.
The reason is because one of the warnings checked is only produced when the
compiler is using C++03 or lower.

This change fixes this problem as well as adds explicit run lines to run the
test in C++03 and C++11 modes.

llvm-svn: 296066
2017-02-24 01:25:02 +00:00
Hans Wennborg 260c6d4555 Revert r291477 "[Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin"
It caused PR31864. There is a patch in progress to fix that, but let's
revert in the meantime.

llvm-svn: 296063
2017-02-24 01:16:34 +00:00
Vedant Kumar 7f809b2fbd [profiling] PR31992: Don't skip interesting non-base constructors
Fix the fact that we don't assign profile counters to constructors in
classes with virtual bases, or constructors with variadic parameters.

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

llvm-svn: 296062
2017-02-24 01:15:19 +00:00
Alex Lorenz 95cb2fbd89 NFC, Add a test that ensures that we don't emit helper code in copy/dispose
routines for objects that are captured with the __unsafe_unretained
ownership qualifier

This is a preparation commit that improves code-coverage in code that emits
block copy/dispose routines.

llvm-svn: 296048
2017-02-24 00:09:30 +00:00
Alex Lorenz e3e8131460 NFC, Add a test that ensure that we don't emit helper code in copy/dispose
routines for variables that are const-captured

This is a preparation commit that improves code-coverage in code that emits
block copy/dispose routines.

llvm-svn: 296040
2017-02-23 23:41:50 +00:00
Richard Smith 382bc51fdd PR32044: Fix some cases where we would confuse a transparent init-list expression with an aggregate init.
llvm-svn: 296033
2017-02-23 22:41:47 +00:00
George Burgess IV 635a7369b7 Tighten up a regex in a test
...If we're trying to match "this function has only two arguments", `.*`
probably isn't the best thing to use. :)

llvm-svn: 296027
2017-02-23 22:14:55 +00:00
George Burgess IV d0a9e807f3 [CodeGen] Fix ExtParameterInfo bugs in C++ CodeGen code.
This patch makes use of the prefix/suffix ABI argument distinction that
was introduced in r295870, so that we now emit ExtParameterInfo at the
correct offset for member calls that have added ABI arguments. I don't
see a good way to test the generated param info, since we don't actually
seem to use it in CGFunctionInfo outside of Swift. Any
suggestions/thoughts for how to better test this are welcome. :)

This patch also fixes a small bug with inheriting constructors: if we
decide not to pass args into an base class ctor, we would still
generate ExtParameterInfo as though we did. The added test-case is for
that behavior.

llvm-svn: 296024
2017-02-23 22:07:35 +00:00
Richard Smith 1338122b25 Add context note to diagnostics that occur while declaring an implicit special member function.
llvm-svn: 296020
2017-02-23 21:43:43 +00:00
Erik Pilkington 9c42a8d43e [ObjC][CodeGen] CodeGen support for @available.
CodeGens uses of @available into calls to the compiler-rt function
__isOSVersionAtLeast.

This commit is part of a feature that I proposed here:
http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html

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

llvm-svn: 296015
2017-02-23 21:08:08 +00:00
Serge Pavlov 418e0fb9aa Reverted r295975
llvm-svn: 295982
2017-02-23 15:10:45 +00:00
Serge Pavlov 6485a994db Added regression tests
llvm-svn: 295975
2017-02-23 14:34:04 +00:00
George Burgess IV 0d6592a899 [CodeGen] Don't reemit expressions for pass_object_size params.
This fixes an assertion failure in cases where we had expression
statements that declared variables nested inside of pass_object_size
args. Since we were emitting the same ExprStmt twice (once for the arg,
once for the @llvm.objectsize call), we were getting issues with
redefining locals.

This also means that we can be more lax about when we emit
@llvm.objectsize for pass_object_size args: since we're reusing the
arg's value itself, we don't have to care so much about side-effects.

llvm-svn: 295935
2017-02-23 05:59:56 +00:00
Richard Trieu bcaaf96674 [ODRHash] Handle types in ODR hashing.
Fields will now have their types added to the hash, allowing for detection of
mismatched field types.  This detection allows the existing ODR checking to
produce the correct message.

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

llvm-svn: 295931
2017-02-23 03:25:57 +00:00
Richard Smith 73c3c21fae Fix tracking of whether the previous template instantiation stack matches the current one.
Rather than attempting to compare whether the previous and current top of
context stack are "equal" (which fails for a number of reasons, such as the
context stack entries containing pointers to objects on the stack, or reaching
the same "top of stack" entry through two different paths), track the depth of
context stack at which we last emitted a note and invalidate it when we pop the
context stack to less than that depth.

This causes us to emit some missing "in instantiation of" notes and to stop
emitting redundant "in instantiation of" stacks matching the previous stack in
rare cases.

llvm-svn: 295921
2017-02-23 02:09:03 +00:00
Richard Trieu d0786099b1 [ODRHash] Add IdentiferInfo and FieldDecl support.
IdentifierInfo is hashed based on the stored string.  FieldDecl versus other
Decl is now detected, as well as differently named fields.

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

llvm-svn: 295911
2017-02-23 00:23:01 +00:00
Alex Lorenz f9a28a287c [ObjC][Modules] Don't perform property lookup in hidden class extensions
rdar://30603803

llvm-svn: 295903
2017-02-22 23:18:49 +00:00
George Burgess IV 75b34a9610 [CodeGen] Add param info for ctors with ABI args.
This fixes a few assertion failures. Please see the added test case.

llvm-svn: 295894
2017-02-22 22:38:25 +00:00
Richard Trieu 639d7b68d6 [ODRHash] static_cast and Stmt hashing.
Add support for static_cast in classes.  Add pointer-independent profiling for
Stmt's, sharing most of the logic with Stmt::Profile.  This is the first of the
deep sub-Decl diffing for error messages.

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

llvm-svn: 295890
2017-02-22 22:22:42 +00:00
Richard Smith 64cb9ca456 PR32034: Evaluate _Atomic(T) in-place when T is a class or array type.
This is necessary in order for the evaluation of an _Atomic initializer for
those types to have an associated object, which an initializer for class or
array type needs.

llvm-svn: 295886
2017-02-22 22:09:50 +00:00
Matt Arsenault a0c6dca15b AMDGPU: Add fmed3 half builtin
llvm-svn: 295874
2017-02-22 20:55:59 +00:00
Bob Haarman 4f5a98570f stop using associative comdats for SEH filter functions
Summary: We implement structured exception handling (SEH) by generating filter functions for functions that use exceptions. Currently, we use associative comdats to ensure that the filter functions are preserved if and only if the functions we generated them for are preserved. This can lead to problems when generating COFF objects - LLVM may decide to inline a function that uses SEH and remove its body, at which point we will end up with a comdat that COFF cannot represent. To avoid running into that situation, this change makes us not use associative comdats for SEH filter functions. We can still get the benefits we used the associative comdats for: we will always preserve filter functions we use, and dead stripping can eliminate the ones we don't use.

Reviewers: rnk, pcc, ruiu

Reviewed By: rnk

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

llvm-svn: 295872
2017-02-22 20:29:39 +00:00
Richard Smith 4ae5ec8268 Improve support for 'decltype(auto)' in template template parameter matching.
A 'decltype(auto)' parameter can match any other kind of non-type template
parameter, so should be usable in place of any other parameter in a template
template argument. The standard is sadly extremely unclear on how this is
supposed to work, but this seems like the obviously-correct result.

It's less clear whether an 'auto' parameter should be able to match
'decltype(auto)', since the former cannot be used if the latter turns out to be
used for a reference type, but if we disallow that then consistency suggests we
should also disallow 'auto' matching 'T' for the same reason, defeating
intended use cases of the feature.

llvm-svn: 295866
2017-02-22 20:01:55 +00:00
Jan Vesely a6f369c727 [OpenCL] r600 needs OpenCL kernel calling convention
Differential Revision: https://reviews.llvm.org/D30236

llvm-svn: 295843
2017-02-22 15:01:42 +00:00
Jonas Hahnfeld 64a9e3c530 [OpenMP] Generate better diagnostics for cancel and cancellation point
checkNestingOfRegions uses CancelRegion to determine whether cancel and
cancellation point are valid in the given nesting. This leads to unuseful
diagnostics if CancelRegion is invalid. The given test case has produced:
  region cannot be closely nested inside 'parallel' region

As a solution, introduce checkCancelRegion and call it first to get the
expected error:
  one of 'for', 'parallel', 'sections' or 'taskgroup' is expected

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

llvm-svn: 295808
2017-02-22 06:49:10 +00:00
George Burgess IV 8856aa9a54 Call the correct @llvm.objectsize.
The following code would crash clang:

void foo(unsigned *const __attribute__((pass_object_size(0))));
void bar(unsigned *i) { foo(i); }

This is because we were always selecting the version of
`@llvm.objectsize` that takes an i8* in CodeGen. Passing an i32* as an
i8* makes LLVM very unhappy.

(Yes, I'm surprised that this remained uncaught for so long, too. :) )

As an added bonus, we'll now also use the appropriate address space when
emitting @llvm.objectsize calls.

llvm-svn: 295805
2017-02-22 02:35:51 +00:00
Richard Trieu e7f7ed2be7 Add more ODR checking.
Add the basics for the ODRHash class, which will only process Decl's from
a whitelist, which currently only has AccessSpecDecl.  Different access
specifiers in merged classes can now be detected.

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

llvm-svn: 295800
2017-02-22 01:11:25 +00:00
Richard Smith a0abc42911 Fix assertion failure when generating debug information for a variable
declaration declared using class template argument deduction.

Patch by Eric Fiselier (who is busy and asked me to commit this on his behalf)!

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

llvm-svn: 295794
2017-02-22 00:13:14 +00:00
Richard Smith b80bbca254 [c++1z] Mark constexpr lambdas as done on status page and start advertising
them via feature test macro __cpp_constexpr.

Thanks to Faisal for implementing this feature!

llvm-svn: 295791
2017-02-21 23:58:29 +00:00
Richard Smith 130cc445e4 Fix deduction of type of pack-expanded non-type template parameter.
We need to look through the PackExpansionType in the parameter type when
deducing, and we need to consider the possibility of deducing arguments for
packs that are not lexically mentioned in the pattern (but are nonetheless
deducible) when figuring out which packs are covered by a pack deduction scope.

llvm-svn: 295790
2017-02-21 23:49:18 +00:00
Brad Smith 9aa2bf209b Hook up OpenBSD AArch64 support
llvm-svn: 295786
2017-02-21 23:13:09 +00:00
Jacob Gravelle 40aefb5fe0 Declare lgamma library builtins as never being const
Summary:
POSIX requires lgamma writes to an external global variable, signgam.
This prevents annotating lgamma with readnone, which is incorrect on
targets that write to signgam.

Reviewers: efriedma, rsmith

Subscribers: cfe-commits

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

llvm-svn: 295781
2017-02-21 22:37:27 +00:00
Taewook Oh cc89bacabe Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters
Summary: This is a patch for PR31836. As the bug replaces the path separators in the included file name with the characters following them, the test script makes sure that there's no "Ccase-insensitive-include-pr31836.h" in the warning message.

Reviewers: rsmith, eric_niebler

Reviewed By: eric_niebler

Subscribers: karies, cfe-commits

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

llvm-svn: 295779
2017-02-21 22:30:55 +00:00
Tim Shen d4ba2f2336 [XRay] Merge xray clang flag tests, and add powerpc64le.
Summary: I'm not sure why they were in different files, but it's kind of harder to maintain. I create this patch partially for initiate a discussion.

Reviewers: dberris

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 295778
2017-02-21 22:30:00 +00:00
Dehao Chen 7810d4fbd0 Only enable AddDiscriminator pass when -fdebug-info-for-profiling is true
Summary: AddDiscriminator pass is only useful for sample pgo. This patch restricts AddDiscriminator to -fdebug-info-for-profiling so that it does not introduce unecessary debug size increases for non-sample-pgo builds.

Reviewers: dblaikie, aprantl

Reviewed By: dblaikie

Subscribers: cfe-commits

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

llvm-svn: 295764
2017-02-21 20:36:21 +00:00
Simon Dardis df827a7165 [mips] Define macros related to -mabicalls in the preprocessor
Summary:
Historically, NetBSD, FreeBSD and OpenBSD have defined the macro ABICALLS in
the preprocessor when -mabicalls is in effect.

Mainline GCC later defined __mips_abicalls when -mabicalls is in effect.

This patch teaches the preprocessor to define these macros when appropriate.

NetBSD does not require the ABICALLS macro.

This resolves PR/31694.

Thanks to Sean Bruno for highlighting this issue!

Reviewers: slthakur, seanbruno

Reviewed By: seanbruno

Subscribers: joerg, brad, emaste, seanbruno, cfe-commits

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

llvm-svn: 295728
2017-02-21 16:01:00 +00:00
Richard Smith 0cd9c0491e Fix lookup through injected-class-names in implicit deduction guides in the
case where the class template has a parameter pack.

Checking of the template arguments expects an "as-written" template argument
list, which in particular does not have any parameter packs. So flatten the
packs into separate arguments before passing them in.

llvm-svn: 295710
2017-02-21 08:42:39 +00:00
Richard Smith 7fa88bb844 When deducing an array bound from the length of an initializer list, don't
assume the bound has a non-dependent integral type.

llvm-svn: 295698
2017-02-21 07:22:31 +00:00
Richard Smith b4f9625a7b PR32010: Fix template argument depth mixup when forming implicit constructor
template deduction guides for class template argument deduction.

Ensure that we have a local instantiation scope for tracking the instantiated
parameters. Additionally, unusually, we're substituting at depth 1 and leaving
depth 0 alone; make sure that we don't reduce template parameter depth by 2 for
inner parameters in the process. (This is probably also broken for alias
templates in the case where they're expanded within a dependent context, but
this patch doesn't fix that.)

llvm-svn: 295696
2017-02-21 06:30:38 +00:00
Richard Smith 1832a028af Add template parameter depth and index to -ast-dump output.
llvm-svn: 295689
2017-02-21 02:04:03 +00:00
Saleem Abdulrasool b3a2d04edd Sema: use PropertyDecl for property selector
Using the constructed name for the class properties with dot syntax may
yield an inappropriate selector (i.e. if it is specified via property
attributes).  Prefer the declaration for the selector, falling back to
the constructed name otherwise.

Patch by David Herzka!

llvm-svn: 295683
2017-02-20 23:45:49 +00:00
Alex Lorenz 51c0128310 [Sema][ObjC] perform-selector ARC check should see @selector in parens
llvm-svn: 295674
2017-02-20 17:55:15 +00:00
Aleksei Sidorin 55a6350613 [ASTImporter] Support default argument initialization of ParmVarDecls
Patch by Peter Szecsi!

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

llvm-svn: 295654
2017-02-20 11:57:12 +00:00
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