Commit Graph

45289 Commits

Author SHA1 Message Date
Vassil Vassilev 916d8be252 Allocate after the early exit checks. NFC.
llvm-svn: 283448
2016-10-06 13:18:06 +00:00
Vassil Vassilev d1a88130c4 [modules] Allow VarDecls with initializers to use special var abbrev.
Update storage sizes to fit the (past) changes in the VarDecl's data model.
Update some comments.

Patch partially reviewed by Richard Smith as part of https://reviews.llvm.org/D24508

llvm-svn: 283444
2016-10-06 13:04:54 +00:00
Alex Lorenz 6f4bc4f68d [Sema] Fix PR30520: Handle incomplete field types in transparent_union unions
This commit fixes a crash that happens when clang is analyzing a
transparent_union attribute on a union which has a field with incomplete type.

rdar://28630028

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

llvm-svn: 283432
2016-10-06 09:47:29 +00:00
Alex Lorenz 7ba609a220 Fix PR30440: Initialize FunctionTypeDepth in CXXNameMangler
This commit fixes PR 30440 by initializing CXXNameMangler's FunctionTypeDepth
in the two constructors added in r274222 (The commit that caused this
regression).

rdar://28455269

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

llvm-svn: 283428
2016-10-06 09:37:15 +00:00
Petr Hosek 62e1d23986 [Driver] Add driver support for Fuchsia
Provide toolchain and tool support for Fuchsia operating system.
Fuchsia uses compiler-rt as the runtime library and libc++, libc++abi
and libunwind as the C++ standard library. lld is used as a default
linker.

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

llvm-svn: 283420
2016-10-06 06:08:09 +00:00
Mehdi Amini 1201117e60 Taking StringRef in Driver.h APIs instead of raw pointers (NFC)
llvm-svn: 283417
2016-10-06 05:11:48 +00:00
Mehdi Amini 2d487db031 Use llvm::raw_string_ostream instead of std::stringstream (NFC)
As a side effect, this avoid having to call .data() on the StringRef.

llvm-svn: 283416
2016-10-06 04:26:16 +00:00
Richard Smith 0511d23aeb PR22924, PR22845, some of CWG1464: When checking the initializer for an array
new expression, distinguish between the case of a constant and non-constant
initializer. In the former case, if the bound is erroneous (too many
initializer elements, bound is negative, or allocated size overflows), reject,
and take the bound into account when determining whether we need to
default-construct any elements. In the remanining cases, move the logic to
check for default-constructibility of trailing elements into the initialization
code rather than inventing a bogus array bound, to cope with cases where the
number of initialized elements is not the same as the number of initializer
list elements (this can happen due to string literal initialization or brace
elision).

This also fixes rejects-valid and crash-on-valid errors when initializing a
new'd array of character type from a braced string literal.

llvm-svn: 283406
2016-10-05 22:41:02 +00:00
Eric Liu 7956c4004d Make DeletedLines local variables in checkEmptyNamespace.
Summary: Patch by Sam McCall!

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 283332
2016-10-05 15:49:01 +00:00
Eric Liu 11a4237b23 [clang-format] append newline after code when inserting new headers at the end of the code which does not end with newline.
Summary:
append newline after code when inserting new headers at the end of the
code which does not end with newline.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 283330
2016-10-05 15:42:19 +00:00
Michael Zuckerman 9e43ccfe68 [Clang][AVX512][BuiltIn]Adding missing intrinsics move_{sd|ss} to clang
Differential Revision: http://reviews.llvm.org/D21021

llvm-svn: 283314
2016-10-05 12:56:06 +00:00
Alex Lorenz 014181e7f4 [Sema] Packed member warning: Use the typedef name for anonymous structures
This commit improves the packed member warning by showing the name of the
anonymous structure/union when it was defined within a typedef declaration.

rdar://28498901

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

llvm-svn: 283304
2016-10-05 09:27:48 +00:00
Artem Dergachev 602e625622 [analyzer] Squash a compile error in r283301.
The constexpr string literal trick isn't supported in MSVC2013.

llvm-svn: 283303
2016-10-05 08:47:31 +00:00
Artem Dergachev 9cb5614c29 [analyzer] Improve "Assuming..." diagnostic pieces for logical operators.
Logical short-circuit operators now act like other branch conditions.

If the symbolic value of the left-hand side is not known to be true or false
(based on the previous execution path), the "Assuming" event piece is added
in order to explain that the analyzer is adding a new assumption.

Additionally, when the assumption is made against the right-hand side of
the logical operator (i.e. when the operator itself acts as a condition
in another CFG terminator), the "Assuming..." piece is written out for the
right-hand side of the operator rather than for the whole operator.
This allows expression-specific diagnostic message text to be constructed.

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

llvm-svn: 283302
2016-10-05 08:28:25 +00:00
Artem Dergachev 0c33406aaa [analyzer] Add "Assuming..." diagnostic pieces for unsupported conditions.
In the analyzer's path-sensitive reports, when a report goes through a branch
and the branch condition cannot be decided to be definitely true or false
(based on the previous execution path), an event piece is added that tells the
user that a new assumption is added upon the symbolic value of the branch
condition. For example, "Assuming 'a' is equal to 3".

The text of the assumption is hand-crafted in various manners depending on
the AST expression. If the AST expression is too complex and the text of
the assumption fails to be constructed, the event piece is omitted.
This causes loss of information and misunderstanding of the report.

Do not omit the event piece even if the expression is too complex;
add a piece with a generic text instead.

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

llvm-svn: 283301
2016-10-05 08:19:49 +00:00
Justin Lebar 3e6449b4f4 [CUDA] Mark device functions as nounwind.
Summary:
This prevents clang from emitting 'invoke's and catch statements.

Things previously mostly worked thanks to TryToMarkNoThrow() in
CodeGenFunction.  But this is not a proper IPO, and it doesn't properly
handle cases like mutual recursion.

Fixes bug 30593.

Reviewers: tra

Subscribers: cfe-commits

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

llvm-svn: 283272
2016-10-04 23:41:49 +00:00
Justin Lebar 49e7614efb [CUDA] Destroy deferred diagnostics before destroying the ASTContext's PartialDiagnostic allocator.
Summary:
This will let us (in a separate patch) allocate deferred diagnostics in
the ASTContext's PartialDiagnostic arena.

Reviewers: rnk

Subscribers: cfe-commits

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

llvm-svn: 283271
2016-10-04 23:41:45 +00:00
Albert Gutowski f3a0bce155 Separate builtins for x84-64 and i386; implement __mulh and __umulh
Summary: We need x86-64-specific builtins if we want to implement some of the MS intrinsics - winnt.h contains definitions of some functions for i386, but not for x86-64 (for example _InterlockedOr64), which means that we cannot treat them as builtins for both i386 and x86-64, because then we have definitions of builtin functions in winnt.h on i386.

Reviewers: thakis, majnemer, hans, rnk

Subscribers: cfe-commits

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

llvm-svn: 283264
2016-10-04 22:29:49 +00:00
Hans Wennborg 625fba8840 clang-cl: Make /Fo apply also when using -flto
llvm-svn: 283258
2016-10-04 21:01:04 +00:00
Hans Wennborg 26228e3010 clang-cl: Use the .obj file extension also in LTO mode
llvm-svn: 283257
2016-10-04 21:01:02 +00:00
Anna Zaks fb859a934a [analyzer] Add PostStmt callback for ArraySubscriptExpr
A patch by Jan Smets!

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

llvm-svn: 283253
2016-10-04 20:49:31 +00:00
Sanjay Patel 0bb72c1424 [clang] make reciprocal estimate codegen a function attribute
The motivation for the change is that we can't have pseudo-global settings
for codegen living in TargetOptions because that doesn't work with LTO.

Ideally, these reciprocal attributes will be moved to the instruction-level
via FMF, metadata, or something else. But making them function attributes is
at least an improvement over the current state.

I'm committing this patch ahead of the related LLVM patch to avoid bot failures,
but if that patch needs to be reverted, then this should be reverted too.

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

llvm-svn: 283251
2016-10-04 20:44:05 +00:00
Vedant Kumar e356f1a50c [ubsan] Disable bounds-check for flexible array ivars
This eliminates a class of false positives for -fsanitize=array-bounds
on instrumented ObjC projects.

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

llvm-svn: 283249
2016-10-04 20:36:04 +00:00
Daniel Jasper 85d1f0b610 clang-format: Fix bad multi-variable for-loop formatting.
Before:
  for (int*p, *q; p != q; p = p->next) {

After:
  for (int *p, *q; p != q; p = p->next) {

llvm-svn: 283246
2016-10-04 20:18:25 +00:00
Reid Kleckner d2c0c25be4 [MS] Move hex long long sign compat hack to -fms-compatibility
Treating large 0x*LL literals as signed instead of unsigned is not a
conforming language extension, so move it out of -fms-extensions.

Came up in PR30605

llvm-svn: 283227
2016-10-04 15:57:49 +00:00
David Sheinkman 92589990ba [OpenMP] fix segfault when a variable referenced in reduction clause is a reference parameter\nDifferential Revision: http://reviews.llvm.org/D24524
llvm-svn: 283223
2016-10-04 14:41:36 +00:00
Serge Pavlov 06b7a87298 Do not find friend function definitions inside non-instantiated class.
Previously if a file-level function was defined inside befriending
template class, it always was treated as defined. For instance, the code like:
```
  int func(int x);
  template<typename T> class C1 {
    friend int func(int x) { return x; }
  };
  template<typename T> class C2 {
    friend int func(int x) { return x; }
  };
```
could not be compiled due to function redefinition, although not of the templates
is instantiated. Moreover, the body of friend function can contain use of template
parameters, attempt to get definition of such function outside any instantiation
causes compiler abnormal termination.

Other compilers (gcc, icc) follow viewpoint that the body of the function defined
in friend declaration becomes available when corresponding class is instantiated.
This patch implements this viewpoint in clang.

Definitions introduced by friend declarations in template classes are not added
to the redeclaration chain of corresponding function. Only when the template is
instantiated, instantiation of the function definition is placed to the chain.

The fix was made in collaboration with Richard Smith.

This change fixes PR8035, PR17923, PR22307 and PR25848.

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

llvm-svn: 283207
2016-10-04 10:11:43 +00:00
Dean Michael Berris 4541bb7fd0 Revert "[XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed"
This reverts 283193 -- broke the build.

llvm-svn: 283199
2016-10-04 08:54:51 +00:00
NAKAMURA Takumi 90893f0eab Revert r283106, "Wdocumentation fix"
It should depend on r283094 and r283182.

llvm-svn: 283195
2016-10-04 08:32:33 +00:00
Dean Michael Berris 5db9121b31 [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed
Added the code which explicitly emits an error in Clang in case
`-fxray-instrument` is passed, but XRay is not supported for the
selected target.

Author: rSerge

Reviewers: dberris, rsmith, aaron.ballman, rnk

Subscribers: cfe-commits, iid_iunknown

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

llvm-svn: 283193
2016-10-04 08:22:47 +00:00
Vitaly Buka 1a8d52d1ae Revert "[analyzer] Improve CloneChecker diagnostics" as its depends on reverted r283092
This reverts commit r283094.

llvm-svn: 283182
2016-10-04 02:40:35 +00:00
Vitaly Buka b3814f6f38 Revert "[analyzer] Add extra notes to ObjCDeallocChecker" as its depends on reverted r283092
This reverts commit r283093.

llvm-svn: 283181
2016-10-04 02:36:58 +00:00
Vitaly Buka 20efb97ff3 Revert "[analyzer] Extend bug reports with extra notes" to fix Windows bot.
This reverts commit r283092.

llvm-svn: 283180
2016-10-04 02:19:17 +00:00
Gor Nishanov 3e048bb140 [coroutines] Switch to using std::experimental namespace per P0057R5
Summary:
Look for coroutine_traits and friends in std::experimental namespace.
Patch (mostly) by EricWF.

Reviewers: cfe-commits, EricWF, rsmith

Subscribers: majnemer, mehdi_amini

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

llvm-svn: 283170
2016-10-04 00:31:16 +00:00
Gor Nishanov 97e3b6d895 [coroutines] Adding builtins for coroutine intrinsics and backendutil support.
Summary:
With this commit simple coroutines can be created in plain C using coroutine builtins.

Reviewers: rnk, EricWF, rsmith

Subscribers: modocache, mgorny, mehdi_amini, beanz, cfe-commits

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

llvm-svn: 283155
2016-10-03 22:44:48 +00:00
Manman Ren a0042c4922 ObjectiveC: fix a seg fault when deserialing redeclaration of ObjCMethodDecl.
The deserialization of redeclartion can cause seg fault since getCanonicalDecl
of the redeclaration returns the lookup result on the ObjCContainerDecl,
which can be null if FindExternalVisibleDeclsByName is not done updating
the lookup results.

The fix is to return the redeclaration itself as the canonical decl. Note that
the handling for redeclaration of ObjCMethodDecl is not in line with other
redeclarables.

rdar://28488466

llvm-svn: 283145
2016-10-03 21:26:46 +00:00
Reid Kleckner f33bfcb0e0 Factor out a diagnostic kind enum for use in two %select expressions
NFC

llvm-svn: 283131
2016-10-03 18:34:23 +00:00
Justin Lebar 53b000afc2 [CUDA] Clean up some comments in Sema::IsOverload. NFC
llvm-svn: 283121
2016-10-03 16:48:27 +00:00
Justin Lebar e060feb7b1 [CUDA] Disallow overloading destructors.
Summary:
We'd attempted to allow this, but turns out we were doing a very bad
job.  :)

Making this work properly would be a giant change in clang.  For
example, we'd need to make CXXRecordDecl::getDestructor()
context-sensitive, because the destructor you end up with depends on
where you're calling it from.

For now (and hopefully for ever), just disallow overloading of
destructors in CUDA.

Reviewers: rsmith

Subscribers: cfe-commits, tra

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

llvm-svn: 283120
2016-10-03 16:48:23 +00:00
Vedant Kumar 30914f3d1c [ARC] Ignore qualifiers in copy-restore expressions
When ARC is enabled, an ObjCIndirectCopyRestoreExpr models the passing
of a function argument s.t:

  * The argument is copied into a temporary,
  * The temporary is passed into the function, and
  * After the function call completes, the temporary is move-assigned
    back to the original location of the argument.

The argument type and the parameter type must agree "except possibly in
qualification". This commit weakens an assertion in EmitCallArg() to
actually reflect that.

llvm-svn: 283116
2016-10-03 15:29:22 +00:00
Yaxun Liu ea6b796e0e [OpenCL] Fix bug in __builtin_astype causing invalid LLVM cast instructions
__builtin_astype is used to cast OpenCL opaque types to other types, as such, it needs to be able to handle casting from and to pointer types correctly.

Current it cannot handle 1) casting between pointers of different addr spaces 2) casting between pointer type and non-pointer types.

This patch fixes that.

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

llvm-svn: 283114
2016-10-03 14:41:50 +00:00
Simon Pilgrim efd4006080 Wdocumentation fix
llvm-svn: 283106
2016-10-03 12:37:08 +00:00
Alex Lorenz ea9b59a33d Fix PR 28885: Fix AST Printer output for the inherited constructor using
declarations.

This commit ensures that the correct record type is printed out for the
using declarations that represent C++ inherited constructors.
It fixes a regression introduced in r274049 which changed the name that's
stored in the using declarations that correspond to inherited constructors.

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

llvm-svn: 283105
2016-10-03 12:22:17 +00:00
Alex Lorenz 4ff920bf1b Revert r283102 (Typo in the phabricator link)
llvm-svn: 283104
2016-10-03 12:17:56 +00:00
Alex Lorenz 2bc02892be Fix PR 28885: Fix AST Printer output for the inherited constructor using
declarations.

This commit ensures that the correct record type is printed out for the
using declarations that represent C++ inherited constructors.
It fixes a regression introduced in r274049 which changed the name that's
stored in the using declarations that correspond to inherited constructors.

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

llvm-svn: 283102
2016-10-03 12:12:03 +00:00
Daniel Marjamaki 042a3c5a2d [StaticAnalyzer] Fix UnreachableCode false positives.
When there is 'do { } while (0);' in the code the ExplodedGraph and UnoptimizedCFG did not match.

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

llvm-svn: 283095
2016-10-03 08:28:51 +00:00
Artem Dergachev c87d2a613e [analyzer] Improve CloneChecker diagnostics
Highlight code clones referenced by the warning message with the help of
the extra notes feature recently introduced in r283092.

Change warning text to more clang-ish. Remove suggestions from the copy-paste
error checker diagnostics, because currently our suggestions are strictly 50%
wrong (we do not know which of the two code clones contains the error), and
for that reason we should not sound as if we're actually suggesting this.
Hopefully a better solution would bring them back.

Make sure the suspicious clone pair structure always mentions
the correct variable for the second clone.

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

llvm-svn: 283094
2016-10-03 08:11:50 +00:00
Artem Dergachev 918602df8d [analyzer] Add extra notes to ObjCDeallocChecker
The report is now highlighting instance variables and properties
referenced by the warning message with the help of the
extra notes feature recently introduced in r283092.

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

llvm-svn: 283093
2016-10-03 08:03:51 +00:00
Artem Dergachev 9dceb11b2f [analyzer] Extend bug reports with extra notes
These diagnostics are separate from the path-sensitive engine's path notes,
and can be added manually on top of path-sensitive or path-insensitive reports.

The new note diagnostics would appear as note:-diagnostic on console and
as blue bubbles in scan-build. In plist files they currently do not appear,
because format needs to be discussed with plist file users.

The analyzer option "-analyzer-config notes-as-events=true" would convert
notes to normal path notes, and put them at the beginning of the path.
This is a temporary hack to show the new notes in plist files.

A few checkers would be updated in subsequent commits,
including tests for this new feature.

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

llvm-svn: 283092
2016-10-03 07:58:26 +00:00
Craig Topper c4a8228bcc [AVX-512] Use native IR for masked 512-bit add/sub/mul/div ps/pd intrinsics when rounding mode isn't used.
llvm-svn: 283073
2016-10-02 17:43:00 +00:00