Commit Graph

53131 Commits

Author SHA1 Message Date
Kristof Umann 9d6c4402c6 [analyzer] ConversionChecker: handle floating point
Extend the alpha.core.Conversion checker to handle implicit converions
where a too large integer value is converted to a floating point type. Each
floating point type has a range where it can exactly represent all integers; we
emit a warning when the integer value is above this range. Although it is
possible to exactly represent some integers which are outside of this range
(those that are divisible by a large enough power of 2); we still report cast
involving those, because their usage may lead to bugs. (For example, if 1<<24
is stored in a float variable x, then x==x+1 holds.)

Patch by: Donát Nagy!

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

llvm-svn: 347006
2018-11-16 01:00:55 +00:00
Erich Keane a6e4a3987c Fix parens warning in assert in ASTMatchFinder
Change-Id: Ie34f9c6846b98fba87449e73299519fc2346bac1
llvm-svn: 346996
2018-11-15 21:35:35 +00:00
Bruno Ricci b94ad1e1d3 [AST] Store the string data in StringLiteral in a trailing array of chars
Use the newly available space in the bit-fields of Stmt and store the
string data in a trailing array of chars after the trailing array
of SourceLocation. This cuts the size of StringLiteral by 2 pointers.

Also refactor slightly StringLiteral::Create and StringLiteral::CreateEmpty
so that StringLiteral::Create is just responsible for the allocation, and the
constructor is responsible for doing all the initialization. This match what
is done for the other classes in general.

This patch should have no other functional changes apart from this.

A concern was raised during review about the interaction between
this patch and serialization abbreviations. I believe however that
there is currently no abbreviation defined for StringLiteral.
The only statements/expressions which have abbreviations are currently
DeclRefExpr, IntegerLiteral, CharacterLiteral and ImplicitCastExpr.

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

Reviewed By: dblaikie, rjmccall

llvm-svn: 346969
2018-11-15 17:31:16 +00:00
Bruno Ricci af214885cd [AST][NFC] Various NFCs in StringLiteral
Factored out of D54166
([AST] Store the string data in StringLiteral in a trailing array of chars):

* For-range loops in containsNonAscii and containsNonAsciiOrNull.
* Comments and style fixes.
* int -> unsigned in mapCharByteWidth since TargetInfo::getCharWidth
  and friends return an unsigned, and StringLiteral manipulates and
  stores CharByteWidth as an unsigned.

llvm-svn: 346967
2018-11-15 16:42:14 +00:00
Bruno Ricci 4c74253a4f [AST] Pack MemberExpr
Use the newly available space in the bit-fields of Stmt
to store some data from MemberExpr. This saves
one pointer per MemberExpr.

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

Reviewed By: dblaikie

llvm-svn: 346953
2018-11-15 13:56:22 +00:00
Mikael Holmen ee84676a1e Fix warning about unused variable [NFC]
llvm-svn: 346950
2018-11-15 13:01:54 +00:00
David Blaikie e0cfc04419 NFC cleanup: Prefer make_unique over reset(new T())
llvm-svn: 346929
2018-11-15 03:04:23 +00:00
David Blaikie 1013fe7451 Fix combining pragma __debug dump & parser_crash with -E
Previously these would be transformed into annotation tokens and the
preprocessor would then assume they were real tokens with source
locations and assert/UB.

Other pragmas that produce annotation tokens aren't a problem because
they aren't handled if the parser isn't hooked up - ParsePragma.cpp
registers those handlers & isn't run for pure preprocessing. So they're
treated as unknown pragmas & printed verbatim by the preprocessor.

Perhaps these pragmas should be treated the same way? But they got mixed
in with other __debug pragmas that do need to be handled during
preprocessing.

The third __debug pragma that produces an annotation token is 'captured'
- which had its own fix for this issue - by not inserting the annotation
token in the first place if it detected that it was in preprocessing
mode. I've removed that fix (from Lex/Pragma.cpp) in favor of the more
general one in Frontend/PrintPreprocessedOutput.cpp.

llvm-svn: 346928
2018-11-15 03:04:21 +00:00
David Blaikie a99b8e4c35 Rewrite-imports on crash: Simplify handling
-frewrite-imports already implies -frewrite-includes (it piggy-backs
on/extends the implementation) so there's no need to conditionally pass
-frewrite-includes when already using -frewrite-imports (& especially I
don't think these would want to be different between crash reporting and
not crash reporting)

llvm-svn: 346927
2018-11-15 03:04:19 +00:00
JF Bastien 3a881e6bbc CGDecl::emitStoresForConstant fix synthesized constant's name
Summary: The name of the synthesized constants for constant initialization was using mangling for statics, which isn't generally correct and (in a yet-uncommitted patch) causes the mangler to assert out because the static ends up trying to mangle function parameters and this makes no sense. Instead, mangle to `"__const." + FunctionName + "." + DeclName`.

Reviewers: rjmccall

Subscribers: dexonsmith, cfe-commits

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

llvm-svn: 346915
2018-11-15 00:19:18 +00:00
Reid Kleckner 7b7b1140e3 [codeview] Make "clang -g" emit codeview by default when targetting MSVC
Summary:
If you're using the Microsoft ABI, chances are that you want PDBs and
codeview debug info. Currently, everyone has to remember to specific
-gcodeview by default, when it would be nice if the standard -g option
did the right thing by default.

Also, do some related cleanup of -cc1 options. When targetting the MS
C++ ABI, we probably shouldn't pass -debugger-tuning=gdb. We were also
passing -gcodeview twice, which is silly.

Reviewers: smeenai, zturner

Subscribers: aprantl, JDevlieghere, llvm-commits

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

llvm-svn: 346907
2018-11-14 22:59:27 +00:00
Richard Smith 28ddb91dec [c++20] Implement P0482R6: enable -fchar8_t by default in C++20 mode.
This unfortunately results in a substantial breaking change when
switching to C++20, but it's not yet clear what / how much we should
do about that. We may want to add a compatibility conversion from
u8 string literals to const char*, similar to how C++98 provided a
compatibility conversion from string literals to non-const char*,
but that's not handled by this patch.

The feature can be disabled in C++20 mode with -fno-char8_t.

llvm-svn: 346892
2018-11-14 21:04:34 +00:00
Shoaib Meenai d84cf13690 [AST] Fix typo in MicrosoftMangle
Correct the spelling from Artifical to Artificial.

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

llvm-svn: 346882
2018-11-14 19:16:22 +00:00
David Bolvansky 3cc2ef80d1 Reverted D52835 to fix review comments
llvm-svn: 346866
2018-11-14 14:27:51 +00:00
David Bolvansky a208bbd576 [Diagnostics] Check integer to floating point number implicit conversions
Summary:
GCC already catches these situations so we should handle it too.

GCC warns in C++ mode only (does anybody know why?). I think it is useful in C mode too.

Reviewers: rsmith, erichkeane, aaron.ballman, efriedma, xbolva00

Reviewed By: xbolva00

Subscribers: efriedma, craig.topper, scanon, cfe-commits

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

llvm-svn: 346865
2018-11-14 14:24:33 +00:00
Sam McCall 814e7974c6 [AST] Allow limiting the scope of common AST traversals (getParents, RAV).
Summary:
The goal is to allow analyses such as clang-tidy checks to run on a
subset of the AST, e.g. "only on main-file decls" for interactive tools.

Today, these become "problematically global" by running RecursiveASTVisitors
rooted at the TUDecl, or by navigating up via ASTContext::getParent().

The scope is restricted using a set of top-level-decls that RecursiveASTVisitors
should be rooted at. This also applies to the visitor that populates the
parent map, and so the top-level-decls are considered to have no parents.

This patch makes the traversal scope a mutable property of ASTContext.
The more obvious way to do this is to pass the top-level decls to
relevant functions directly, but this has some problems:
 - it's error-prone: accidentally mixing restricted and unrestricted
   scopes is a performance trap. Interleaving multiple analyses is
   common (many clang-tidy checks run matchers or RAVs from matcher callbacks)
 - it doesn't map well to the actual use cases, where we really do want
   *all* traversals to be restricted.
 - it involves a lot of plumbing in parts of the code that don't care
   about traversals.
This approach was tried out in D54259 and D54261, I wanted to like it
but it feels pretty awful in practice.

Caveats: to get scope-limiting behavior of RecursiveASTVisitors, callers
have to call the new TraverseAST(Ctx) function instead of TraverseDecl(TU).
I think this is an improvement to the API regardless.

Reviewers: klimek, ioeric

Subscribers: mgorny, cfe-commits

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

llvm-svn: 346847
2018-11-14 10:33:30 +00:00
Alexey Sotkin 692f12b389 [OpenCL] Fix invalid address space generation for clk_event_t
Summary:
Addrspace(32) was generated when putting 0 in clk_event_t * event_ret
parameter for enqueue_kernel function.

Patch by Viktoria Maksimova

Reviewers: Anastasia, yaxunl, AlexeySotkin

Reviewed By:  Anastasia, AlexeySotkin

Subscribers: cfe-commits

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

llvm-svn: 346838
2018-11-14 09:40:05 +00:00
George Rimar 91829eef65 [Clang] - Add '-gsplit-dwarf[=split,=single]' version for '-gsplit-dwarf' option.
The DWARF5 specification says(Appendix F.1):

"The sections that do not require relocation, however, can be
written to the relocatable object (.o) file but ignored by the
linker or they can be written to a separate DWARF object (.dwo)
file that need not be accessed by the linker."

The first part describes a single file split DWARF feature and there
is no way to trigger this behavior atm. 
Fortunately, no many changes are required to keep *.dwo sections
in a .o, the patch does that.

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

llvm-svn: 346837
2018-11-14 09:22:16 +00:00
Yaxun Liu 2bcc9517c5 [HIP] Fix device only compilation
Fix a bug causing host code being compiled when --cude-device-only is set.

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

llvm-svn: 346828
2018-11-14 04:47:31 +00:00
Alex Lorenz 7d76ef9b3d [HeaderSearch] loadSubdirectoryModuleMaps should respect -working-directory
Include search paths can be relative paths. The loadSubdirectoryModuleMaps function
should account for that and respect the -working-directory parameter given to Clang.

rdar://46045849

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

llvm-svn: 346822
2018-11-14 01:08:03 +00:00
Matt Arsenault e19dc6137f OpenCL: Don't warn on v printf modifier
This avoids spurious warnings, but could use
a lot of work. For example the number of vector
elements is not verified, and the passed
value type is not checked.

Fixes bug 39486

llvm-svn: 346806
2018-11-13 22:30:35 +00:00
David Greene c03328a7c0 [Driver] Support g++ headers in include/g++
ray's gcc installation puts C++ headers in PREFIX/include/g++ without
indicating a gcc version at all. Typically this is because the version
is encoded somewhere in PREFIX.

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

llvm-svn: 346802
2018-11-13 21:38:45 +00:00
Bruno Ricci 3dfcb848e3 [AST] Revert r346793 and r346781
This somehow breaks the msan bots. Revert while I figure it out.

llvm-svn: 346801
2018-11-13 21:33:22 +00:00
David Blaikie 27692de9cf DebugInfo: Add a driver flag for DWARF debug_ranges base address specifier use.
Summary:
This saves a lot of relocations in optimized object files (at the cost
of some cost/increase in linked executable bytes), but gold's 32 bit
gdb-index support has a bug (
https://sourceware.org/bugzilla/show_bug.cgi?id=21894 ) so we can't
switch to this unconditionally. (& even if it weren't for that bug, one
might argue that some users would want to optimize in one direction or
the other - prioritizing object size or linked executable size)

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

llvm-svn: 346789
2018-11-13 20:08:13 +00:00
Bruno Ricci 69396af194 [AST][NFC] Style fixes for UnaryOperator
In preparation for the patch which will move some data to the bit-fields
of Stmt. In particular, rename the private variable "Val" -> "Operand"
since the substatement is the operand of the unary operator.
Run clang-format on UnaryOperator. NFC otherwise.

llvm-svn: 346781
2018-11-13 19:27:39 +00:00
Bruno Ricci a795e8012e [AST][NFC] Pack DeclRefExpr
Move the SourceLocation to the bit-fields of Stmt + clang-format.
This saves one pointer per DeclRefExpr but otherwise NFC.

llvm-svn: 346770
2018-11-13 17:56:44 +00:00
Erich Keane de6480a38c [NFC] Move storage of dispatch-version to GlobalDecl
As suggested by Richard Smith, and initially put up for review here:
https://reviews.llvm.org/D53341, this patch removes a hack that was used
to ensure that proper target-feature lists were used when emitting
cpu-dispatch (and eventually, target-clones) implementations. As a part
of this, the GlobalDecl object is proliferated to a bunch more
locations.

Originally, this was put up for review (see above) to get acceptance on
the approach, though discussion with Richard in San Diego showed he
approved of the approach taken here.  Thus, I believe this is acceptable
for Review-After-commit

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

Change-Id: I0a0bd673340d334d93feac789d653e03d9f6b1d5
llvm-svn: 346757
2018-11-13 15:48:08 +00:00
Krasimir Georgiev 28e2dbb14d [clang-format] Do not treat the asm clobber [ as ObjCExpr
Summary:
The opening square of an inline asm clobber was being annotated as an ObjCExpr.
This caused, amongst other things, the ObjCGuesser to guess header files
containing that pattern as ObjC files.

Reviewers: benhamilton

Reviewed By: benhamilton

Subscribers: cfe-commits

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

llvm-svn: 346756
2018-11-13 15:38:12 +00:00
Takuto Ikuta 245d94776f [clang-cl] Do not allow using both /Zc:dllexportInlines- and /fallback flag
Summary: /Zc:dllexportInlines with /fallback may cause unexpected linker error. It is better to disallow compile rather than warn for this combination.

Reviewers: hans, thakis

Reviewed By: hans

Subscribers: cfe-commits, llvm-commits

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

llvm-svn: 346733
2018-11-13 04:14:09 +00:00
Aaron Ballman a85ba92cb0 Convert a condition into an assertion per post-review feedback; NFC intended.
llvm-svn: 346714
2018-11-12 22:32:38 +00:00
Erik Pilkington ba88e21f8c [Sema] Make sure we substitute an instantiation-dependent default template argument
Fixes llvm.org/PR39623

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

llvm-svn: 346709
2018-11-12 21:31:06 +00:00
Erich Keane a946acd585 Fix the 'fixit' for inline namespace replacement.
I'd neglected to add to the fixit for r346677.  Richard Smith mentioned
this in a review-after-commit, so fixing it here.

Change-Id: I77e612be978d4eedda8d5bbd60b812b88f875cda
llvm-svn: 346705
2018-11-12 21:08:41 +00:00
Richard Smith bd844e0de7 PR39628 Treat all non-zero values as 'true' in bool compound-assignment
in constant evaluation, not just odd values.

llvm-svn: 346699
2018-11-12 20:11:57 +00:00
Jordan Rupprecht 054dc28afa [clang-format] Support breaking consecutive string literals for TableGen
Summary:
clang-format can get confused by string literals in TableGen: it knows that strings can be broken up, but doesn't seem to understand how that can be indented across line breaks, and arranges them in a weird triangular pattern. Take this output example from `clang-format tools/llvm-objcopy/ObjcopyOpts.td` (which has now been formatted in rL345896 with this patch applied):

```
defm keep_global_symbols
: Eq<
      "keep-global-symbols", "Reads a list of symbols from <filename> and "
                             "runs as if " "--keep-global-symbol=<symbol> "
                                           "is set for each one. "
                                           "<filename> " "contains one "
                                                         "symbol per line "
                                                         "and may contain "
                                                         "comments "
                                                         "beginning " "with"
                                                                      " '#'"
                                                                      ". "
                                                                      "Lead"
                                                                      "ing "
```

Reviewers: alexshap, MaskRay, djasper

Reviewed By: MaskRay

Subscribers: krasimir, mgorny, cfe-commits

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

llvm-svn: 346687
2018-11-12 18:15:04 +00:00
Kristof Umann 35fc356fec [analyzer] Drastically simplify the tblgen files used for checkers
Interestingly, only about the quarter of the emitter file is used, the DescFile
entry hasn't ever been touched [1], and the entire concept of groups is a
mystery, so I removed them.

[1] http://lists.llvm.org/pipermail/cfe-dev/2018-October/059664.html

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

llvm-svn: 346680
2018-11-12 17:49:51 +00:00
Erich Keane 53f391dcb3 Implement P1094R2 (nested inline namespaces)
As approved for the Working Paper in San Diego, support annotating
inline namespaces with 'inline'.

Change-Id: I51a654e11ffb475bf27cccb2458768151619e384
llvm-svn: 346677
2018-11-12 17:19:48 +00:00
Jonas Devlieghere 3854e7864e Revert "Make clang-based tools find libc++ on MacOS"
This breaks the LLDB bots.

llvm-svn: 346675
2018-11-12 16:59:50 +00:00
Calixte Denizet 186d5bd874 Revert rL346644, rL346642: the added test test/CodeGen/code-coverage-filter.c is failing under windows
llvm-svn: 346659
2018-11-12 14:57:17 +00:00
Ilya Biryukov d8ebe7951d Make clang-based tools find libc++ on MacOS
Summary:
When they read compiler args from compile_commands.json.
This change allows to run clang-based tools, like clang-tidy or clangd,
built from head using the compile_commands.json file produced for XCode
toolchains.

On MacOS clang can find the C++ standard library relative to the
compiler installation dir.

The logic to do this was based on resource dir as an approximation of
where the compiler is installed. This broke the tools that read
'compile_commands.json' and don't ship with the compiler, as they
typically change resource dir.

To workaround this, we now use compiler install dir detected by the driver
to better mimic the behavior of the original compiler when replaying the
compilations using other tools.

Reviewers: sammccall, arphaman, EricWF

Reviewed By: sammccall

Subscribers: ioeric, christof, kadircet, cfe-commits

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

llvm-svn: 346652
2018-11-12 13:55:55 +00:00
Calixte Denizet cedcc73d93 [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov
Summary:
These options are taking regex separated by colons to filter files.
- if both are empty then all files are instrumented
- if -fprofile-filter-files is empty then all the filenames matching any of the regex from exclude are not instrumented
- if -fprofile-exclude-files is empty then all the filenames matching any of the regex from filter are instrumented
- if both aren't empty then all the filenames which match any of the regex in filter and which don't match all the regex in filter are instrumented
- this patch is a follow-up of https://reviews.llvm.org/D52033

Reviewers: marco-c, vsk

Reviewed By: marco-c, vsk

Subscribers: cfe-commits, sylvestre.ledru

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

llvm-svn: 346642
2018-11-12 09:12:27 +00:00
Jan Kratochvil ca71cc9c5a Fix compatibility with z3-4.8.1
With z3-4.8.1:
../tools/clang/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:49:40: error:
'Z3_get_error_msg_ex' was not declared in this scope
../tools/clang/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:49:40: note:
suggested alternative: 'Z3_get_error_msg'

Formerly used Z3_get_error_msg_ex() as one could find in z3-4.7.1 states:
	"Retained function name for backwards compatibility within v4.1"
And it is implemented only as a forwarding call:
	return Z3_get_error_msg(c, err);

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

llvm-svn: 346635
2018-11-12 06:48:02 +00:00
Michael Wu 260e962402 Support Swift in platform availability attribute
Summary: This adds support for Swift platform availability attributes. It's largely a port of the changes made to https://github.com/apple/swift-clang/ for Swift availability attributes. Specifically, 84b5a21c31 and e5b87f265a . The implementation of attribute_availability_swift is a little different and additional tests in test/Index/availability.c were added.

Reviewers: manmanren, friss, doug.gregor, arphaman, jfb, erik.pilkington, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: aaron.ballman, ColinKinloch, jrmuizel, cfe-commits

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

llvm-svn: 346633
2018-11-12 02:44:33 +00:00
Kristina Brooks 7349d90b74 [CodeGen][CXX]: Fix no_destroy CG bug under specific circumstances
Summary:

Class with no user-defined destructor that has an inherited member that has a
non-trivial destructor and a non-default constructor will attempt to emit a
destructor despite being marked as __attribute((no_destroy)) in which case it
would trigger an assertion due to an incorrect assumption. 

In addition this adds missing test coverage for IR generation for no_destroy.

(Note that here use of no_destroy is synonymous with its global flag 
counterpart `-fno-c++-static-destructors` being enabled)

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

llvm-svn: 346628
2018-11-12 01:19:16 +00:00
Jonas Devlieghere 64a2630825 Pass the function type instead of the return type to FunctionDecl::Create
Fix places where the return type of a FunctionDecl was being used in
place of the function type

FunctionDecl::Create() takes as its T parameter the type of function
that should be created, not the return type. Passing in the return type
looks to have been copypasta'd around a bit, but the number of correct
usages outweighs the incorrect ones so I've opted for keeping what T is
the same and fixing up the call sites instead.

This fixes a crash in Clang when attempting to compile the following
snippet of code with -fblocks -fsanitize=function -x objective-c++ (my
original repro case):

  void g(void(^)());
  void f()
  {
      __block int a = 0;
        g(^(){ a++; });
  }

as well as the following which only requires -fsanitize=function -x c++:

  void f(char * buf)
  {
      __builtin_os_log_format(buf, "");
  }

Patch by: Ben (bobsayshilol)

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

llvm-svn: 346601
2018-11-11 00:56:15 +00:00
Kristina Brooks 825f9d3e26 [clang]: Fix misapplied patch in 346582.
llvm-svn: 346583
2018-11-10 08:04:38 +00:00
Kristina Brooks 1333b57f37 Correct naming conventions and 80 col rule violation in CGDeclCXX.cpp. NFC.
Differential Revision: https://reviews.llvm.org/D54373

llvm-svn: 346582
2018-11-10 07:53:47 +00:00
Yan Zhang e2d56dcc03 Fix ClangFormat issue of recognizing ObjC subscript as C++ attributes when message target is a result of a C-style method.
Summary:
The issue is that for array subscript like:

```
arr[[Foo() bar]];
```
ClangFormat will recognize it as C++11 attribute syntax and put a space between 'arr' and first '[', like:

```
arr [[Foo() bar]];
```

Now it is fixed. Tested with:
```
ninja FormatTests
```

Reviewers: benhamilton

Reviewed By: benhamilton

Subscribers: cfe-commits

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

llvm-svn: 346566
2018-11-09 23:19:14 +00:00
Adrian Prantl 42ab39f1e8 Revert "Revert rL346454: Fix a use-after-free introduced by r344915."
This un-reverts commit 346454 with a relaxed CHECK for Windows.

llvm-svn: 346556
2018-11-09 21:17:38 +00:00
Jonas Toth 295aa09dd2 [ASTMatchers] overload ignoringParens for Expr
Summary: This patch allows fixing PR39583.

Reviewers: aaron.ballman, sbenza, klimek

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 346554
2018-11-09 20:54:06 +00:00
Alexey Bataev 8bcc69c054 [OPENMP][NVPTX]Extend number of constructs executed in SPMD mode.
If the statements between target|teams|distribute directives does not
require execution in master thread, like constant expressions, null
statements, simple declarations, etc., such construct can be xecuted in
SPMD mode.

llvm-svn: 346551
2018-11-09 20:03:19 +00:00
Simon Pilgrim b1e694b87e Revert rL346454: Fix a use-after-free introduced by r344915.
r344915 added a call to ApplyDebugLocation to the sanitizer check
function emitter. Some of the sanitizers are emitted in the function
epilogue though and the LexicalScopeStack is emptied out before. By
detecting this situation and early-exiting from ApplyDebugLocation the
fallback location is used, which is equivalent to the return location.

rdar://problem/45859802
........
Causes EXPENSIVE_CHECKS build bot failures: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win

llvm-svn: 346549
2018-11-09 19:42:53 +00:00
Dylan McKay 02bbe41f54 Use the correct address space when bitcasting func pointer to int pointer
When we cast a function pointer to an int pointer, at some pointer later
it gets bitcasted back to a function and called.

In backends that have a nonzero program memory address space specified
in the data layout, the old code would lose the address space data. When
LLVM later attempted to generate the bitcast from i8* to i8(..)*
addrspace(1), it would fail because the pointers are not in the same
address space.

With this patch, the address space of the function will carry on to the
address space of the i8* pointer. This is because all function pointers
in Harvard architectures need to be assigned to the correct address
space.

This has no effect to any in-tree backends except AVR.

llvm-svn: 346548
2018-11-09 19:42:05 +00:00
Aaron Ballman ac77dcd764 Allow a double-underscore spelling of Clang attributes using double square bracket syntax.
This matches a similar behavior with GCC accepting [[gnu::__attr__]] as a alias for [[gnu::attr]] in that clang attributes can now be spelled with two leading and trailing underscores.

I had always intended for this to work, but missed the critical bit. We already had an existing test in test/Preprocessor/has_attribute.cpp for [[clang::__fallthrough__]] but using that spelling would still give an "unknown attribute" diagnostic.

llvm-svn: 346547
2018-11-09 19:37:18 +00:00
Adrian Prantl a40cce80a7 Fix a nondeterminism in the debug info for VLA size expressions.
The artificial variable describing the array size is supposed to be
called "__vla_expr", but this was implemented by retrieving the name
of the associated alloca, which isn't a reliable source for the name,
since nonassert compilers may drop names from LLVM IR.

rdar://problem/45924808

llvm-svn: 346542
2018-11-09 19:17:56 +00:00
Yaxun Liu 92a04835e4 [HIP] Remove useless sections in linked files
clang-offload-bundler creates __CLANG_OFFLOAD_BUNDLE__* sections in the bundles,
which get into the linked files. These sections are useless after linking. They waste disk
space and cause confusion for clang when directly linked with other object files, therefore
should be removed.

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

llvm-svn: 346536
2018-11-09 18:52:05 +00:00
Peter Collingbourne c97638556b Driver: Make -fsanitize=shadow-call-stack compatible with -fsanitize-minimal-runtime.
Differential Revision: https://reviews.llvm.org/D54330

llvm-svn: 346526
2018-11-09 17:54:49 +00:00
Aaron Ballman c44c174246 Introduce the _Clang scoped attribute token.
Currently, we only accept clang as the scoped attribute identifier for double square bracket attributes provided by Clang, but this has the potential to conflict with user-defined macros. To help alleviate these concerns, this introduces the _Clang scoped attribute identifier as an alias for clang. It also introduces a warning with a fixit on the off chance someone attempts to use __clang__ as the scoped attribute (which is a predefined compiler identification macro).

llvm-svn: 346521
2018-11-09 17:19:45 +00:00
Dylan McKay 21e7f5e24e Use the correct address space when emitting the ctor function list
This patch modifies clang so that, if compiling for a target that
explicitly specifies a nonzero program memory address space, the
constructor list global will have the same address space as the
functions it contains.

AVR is the only in-tree backend which has a nonzero program memory
address space.

Without this, the IR verifier would always fail if a constructor
was used on a Harvard architecture backend.

This has no functional change to any in-tree backends except AVR.

llvm-svn: 346520
2018-11-09 17:15:06 +00:00
Alexey Bataev 09c9eea78f [OPENMP][NVPTX]Allow to use shared memory for the
target|teams|distribute variables.

If the total size of the variables, declared in target|teams|distribute
regions, is less than the maximal size of shared memory available, the
buffer is allocated in the shared memory.

llvm-svn: 346507
2018-11-09 16:18:04 +00:00
Takuto Ikuta 7bd78fc196 [clang-cl] Add warning for /Zc:dllexportInlines- when the flag is used with /fallback
Summary:
This is followup of
https://reviews.llvm.org/D51340

Reviewers: hans, thakis

Reviewed By: hans

Subscribers: cfe-commits, llvm-commits

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

llvm-svn: 346491
2018-11-09 13:25:45 +00:00
Sam McCall 5f5bc99340 [Tooling] Avoid diagnosing missing input files in an edge-case where it's incorrect.
llvm-svn: 346485
2018-11-09 11:49:22 +00:00
Zi Xuan Wu 71c35e13c3 [PowerPC] [Clang] [AltiVec] The second parameter of vec_sr function should be modulo the number of bits in the element
The second parameter of vec_sr function is representing shift bits and it should be modulo the number of bits in the element like what vec_sl does now. 
This is actually required by the ABI:

Each element of the result vector is the result of logically right shifting the corresponding
element of ARG1 by the number of bits specified by the value of the corresponding
element of ARG2, modulo the number of bits in the element. The bits that are shifted out
are replaced by zeros.

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

llvm-svn: 346471
2018-11-09 03:35:32 +00:00
Bill Wendling 8003edc9aa Compound literals, enums, et al require const expr
Summary:
Compound literals,  enums, file-scoped arrays, etc. require their
initializers and size specifiers to be constant. Wrap the initializer
expressions in a ConstantExpr so that we can easily check for this later
on.

Reviewers: rsmith, shafik

Reviewed By: rsmith

Subscribers: cfe-commits, jyknight, nickdesaulniers

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

llvm-svn: 346455
2018-11-09 00:41:36 +00:00
Adrian Prantl 009cc9b7ca Fix a use-after-free introduced by r344915.
r344915 added a call to ApplyDebugLocation to the sanitizer check
function emitter. Some of the sanitizers are emitted in the function
epilogue though and the LexicalScopeStack is emptied out before. By
detecting this situation and early-exiting from ApplyDebugLocation the
fallback location is used, which is equivalent to the return location.

rdar://problem/45859802

llvm-svn: 346454
2018-11-09 00:26:15 +00:00
David Blaikie 436f7b6d8a [Frontend/Modules] Show diagnostics on prebuilt module configuration mismatch too
The current version only emits  the below error for a module (attempted to be loaded) from the `prebuilt-module-path`:

```
error: module file blabla.pcm cannot be loaded due to a configuration mismatch with the current compilation [-Wmodule-file-config-mismatch]
```

With this change, if the prebuilt module is used, we allow the proper diagnostic behind the configuration mismatch to be shown.

```
error: POSIX thread support was disabled in PCH file but is currently enabled
error: module file blabla.pcm cannot be loaded due to a configuration mismatch with the current compilation [-Wmodule-file-config-mismatch]
```

(A few lines later an error is emitted anyways, so there is no reason not to complain for configuration mismatches if a config mismatch is found and kills the build.)

Reviewed By: dblaikie

Tags: #clang

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

llvm-svn: 346439
2018-11-08 20:47:30 +00:00
Sam McCall 2c78247041 [Tooling] Produce diagnostics for missing input files.
Summary:
This was disabled way back in 2011, in the dark times before Driver was VFS-aware.

Also, make driver more VFS-aware :-)

This breaks one ClangTidy test (we improved the error message), will fix when
submitting.

Reviewers: ioeric

Subscribers: cfe-commits, alexfh

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

llvm-svn: 346414
2018-11-08 16:57:01 +00:00
Yaxun Liu 4bbdebc49a Fix bitcast to address space cast for coerced load/stores
Coerced load/stores through memory do not take into account potential
address space differences when it creates its bitcasts.

Patch by David Salinas.

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

llvm-svn: 346413
2018-11-08 16:55:46 +00:00
Alexey Bataev 969dbc02c2 [OPENMP]Make lambda mapping follow reqs for PTR_AND_OBJ mapping.
The base pointer for the lambda mapping must point to the lambda capture
placement and pointer must point to the captured variable itself. Patch
fixes this problem.

llvm-svn: 346408
2018-11-08 15:47:39 +00:00
Hans Wennborg 797004d2ea clang-cl: Add "/clang:" pass-through arg support.
The clang-cl driver disables access to command line options outside of the
"Core" and "CLOption" sets of command line arguments. This filtering makes it
impossible to pass arguments that are interpreted by the clang driver and not
by either 'cc1' (the frontend) or one of the other tools invoked by the driver.

An example driver-level flag is the '-fno-slp-vectorize' flag, which is
processed by the driver in Clang::ConstructJob and used to set the cc1 flag
"-vectorize-slp". There is no negative cc1 flag or -mllvm flag, so it is not
currently possible to disable the SLP vectorizer from the clang-cl driver.

This change introduces the "/clang:" argument that is available when the
driver mode is set to CL compatibility. This option works similarly to the
"-Xclang" option, except that the option values are processed by the clang
driver rather than by 'cc1'. An example usage is:

  clang-cl /clang:-fno-slp-vectorize /O2 test.c

Another example shows how "/clang:" can be used to pass a flag where there is
a conflict between a clang-cl compat option and an overlapping clang driver
option:

  clang-cl /MD /clang:-MD /clang:-MF /clang:test_dep_file.dep test.c

In the previous example, the unprefixed /MD selects the DLL version of the msvc
CRT, while the prefixed -MD flag and the -MF flags are used to create a make
dependency file for included headers.

One note about flag ordering: the /clang: flags are concatenated to the end of
the argument list, so in cases where the last flag wins, the /clang: flags
will be chosen regardless of their order relative to other flags on the driver
command line.

Patch by Neeraj K. Singh!

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

llvm-svn: 346393
2018-11-08 11:27:04 +00:00
Andrew Savonichev 3fee351867 [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension
Summary:
Documentation can be found at https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_device_side_avc_motion_estimation.txt

Patch by Kristina Bessonova


Reviewers: Anastasia, yaxunl, shafik

Reviewed By: Anastasia

Subscribers: arphaman, sidorovd, AlexeySotkin, krisb, bader, asavonic, cfe-commits

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

llvm-svn: 346392
2018-11-08 11:25:41 +00:00
Alexey Bataev 2a6f3f5fa2 [OPENMP]Fix handling of the globals during compilation for the device.
Fixed lookup for the target regions in unused virtual functions + fixed
processing of the global variables not marked as declare target but
emitted during debug info emission.

llvm-svn: 346343
2018-11-07 19:11:14 +00:00
Andrew Savonichev 3b12b7e702 Revert r346326 [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation
This patch breaks Index/opencl-types.cl LIT test:

Script:
--
: 'RUN: at line 1';   stage1/bin/c-index-test -test-print-type llvm/tools/clang/test/Index/opencl-types.cl -cl-std=CL2.0 | stage1/bin/FileCheck llvm/tools/clang/test/Index/opencl-types.cl
--
Command Output (stderr):
--
llvm/tools/clang/test/Index/opencl-types.cl:3:26: warning: unsupported OpenCL extension 'cl_khr_fp16' - ignoring [-Wignored-pragmas]
llvm/tools/clang/test/Index/opencl-types.cl:4:26: warning: unsupported OpenCL extension 'cl_khr_fp64' - ignoring [-Wignored-pragmas]
llvm/tools/clang/test/Index/opencl-types.cl:8:9: error: use of type 'double' requires cl_khr_fp64 extension to be enabled
llvm/tools/clang/test/Index/opencl-types.cl:11:8: error: declaring variable of type 'half' is not allowed
llvm/tools/clang/test/Index/opencl-types.cl:15:3: error: use of type 'double' requires cl_khr_fp64 extension to be enabled
llvm/tools/clang/test/Index/opencl-types.cl:16:3: error: use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 extension to be enabled
llvm/tools/clang/test/Index/opencl-types.cl:26:26: warning: unsupported OpenCL extension 'cl_khr_gl_msaa_sharing' - ignoring [-Wignored-pragmas]
llvm/tools/clang/test/Index/opencl-types.cl:35:44: error: use of type '__read_only image2d_msaa_t' requires cl_khr_gl_msaa_sharing extension to be enabled
llvm/tools/clang/test/Index/opencl-types.cl:36:49: error: use of type '__read_only image2d_array_msaa_t' requires cl_khr_gl_msaa_sharing extension to be enabled
llvm/tools/clang/test/Index/opencl-types.cl:37:49: error: use of type '__read_only image2d_msaa_depth_t' requires cl_khr_gl_msaa_sharing extension to be enabled
llvm/tools/clang/test/Index/opencl-types.cl:38:54: error: use of type '__read_only image2d_array_msaa_depth_t' requires cl_khr_gl_msaa_sharing extension to be enabled

llvm-svn: 346338
2018-11-07 18:34:19 +00:00
Andrew Savonichev 35dfce723c [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension
Summary:
Documentation can be found at https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_device_side_avc_motion_estimation.txt

Patch by Kristina Bessonova


Reviewers: Anastasia, yaxunl, shafik

Reviewed By: Anastasia

Subscribers: arphaman, sidorovd, AlexeySotkin, krisb, bader, asavonic, cfe-commits

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

llvm-svn: 346326
2018-11-07 15:44:01 +00:00
Aleksandar Beserminji e59211638c [mips][msa] Fix msa_[st/ld] offset check
This patch fixes a minimum divider for offset in intrinsics
msa_[st/ld]_[b/h/w/d], when value is known in compile time.

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

llvm-svn: 346302
2018-11-07 11:37:05 +00:00
Ilya Biryukov ebf0a6d75d [CodeComplete] Do not complete self-initializations
Summary:
Removes references to initialized variable from the following completions:

    int x = ^;

Handles only the trivial cases where the variable name is completed
immediately at the start of initializer or assignment, more complicated
cases aren't covered, e.g. these completions still contain 'x':

    // More complicated expressions.
    int x = foo(^);
    int x = 10 + ^;
    // Other kinds of initialization.
    int x{^};
    int x(^);
    // Constructor initializers.
    struct Foo {
      Foo() : x(^) {}
      int x;
    };

We should address those in the future, but they are outside of the scope of
this initial change.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: arphaman, cfe-commits

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

llvm-svn: 346301
2018-11-07 10:02:31 +00:00
Vedant Kumar 9e41b5eb6e [Darwin] Export new weak external symbols when compiling with coverage
Some weak external symbols were added to the profile runtime in D49953,
and on Darwin, these need to be exported for tapi verification purposes.

I've tightened the test so that future breakages can be caught earlier.

rdar://45831054

llvm-svn: 346276
2018-11-06 22:25:00 +00:00
Aaron Ballman f3869cd14d Don't use std::next() on an input iterator; NFC.
Instead, advance the old-fashioned way, as std::next() cannot be used on an input iterator until C++17.

llvm-svn: 346266
2018-11-06 21:12:44 +00:00
Reid Kleckner 902fa41188 [MS] Zero out ECX in __cpuid in intrin.h
Summary:
Some CPUID leafs depend on the value of ECX as well as EAX, but we left
it uninitialized.

Originally reported as https://crbug.com/901547

Reviewers: craig.topper, hans

Subscribers: cfe-commits

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

llvm-svn: 346265
2018-11-06 20:45:26 +00:00
Kadir Cetinkaya b1501462e2 T was unused on assertion disabled builds.
llvm-svn: 346216
2018-11-06 08:59:25 +00:00
Akira Hatanaka 908aabb783 Cast to uint64_t instead of to unsigned.
This is a follow-up to r346211.

llvm-svn: 346212
2018-11-06 07:12:28 +00:00
Akira Hatanaka d572cf496d os_log: Allow specifying mask type in format string.
A mask type is a 1 to 8-byte string that follows the "mask." annotation
in the format string. This enables obfuscating data in the event the
provided privacy level isn't enabled.

rdar://problem/36756282

llvm-svn: 346211
2018-11-06 07:05:14 +00:00
Akira Hatanaka fb1e4465f1 os_log: Add a new privacy annotation "sensitive".
This is a stricter privacy annotation than "private", which will be used
for data that shouldn’t be logged to disk. For backward compatibility,
the "private" bit is set too.

rdar://problem/36755912

llvm-svn: 346210
2018-11-06 06:26:17 +00:00
Akira Hatanaka b17ebff627 os_log: Minor code cleanups. NFC.
Also, add a new test case and fix an incorrect comment.

llvm-svn: 346209
2018-11-06 05:41:33 +00:00
Mandeep Singh Grang 574caddc0d [COFF, ARM64] Implement InterlockedDecrement*_* builtins
This is eight in a series of patches to move intrinsic definitions out of intrin.h.

Differential: https://reviews.llvm.org/D54068
llvm-svn: 346208
2018-11-06 05:07:43 +00:00
Mandeep Singh Grang fdf74d9751 [COFF, ARM64] Implement InterlockedIncrement*_* builtins
This is seventh in a series of patches to move intrinsic definitions out of intrin.h.

Differential: https://reviews.llvm.org/D54067
llvm-svn: 346207
2018-11-06 05:05:32 +00:00
Mandeep Singh Grang c89157b5c1 [COFF, ARM64] Implement InterlockedAnd*_* builtins
This is sixth in a series of patches to move intrinsic definitions out of intrin.h.

Differential: https://reviews.llvm.org/D54066
llvm-svn: 346206
2018-11-06 05:03:13 +00:00
Mandeep Singh Grang 806f10701b [COFF, ARM64] Implement InterlockedXor*_* builtins
This is fifth in a series of patches to move intrinsic definitions out of intrin.h.

Note: This was reviewed and approved in D54065 but somehow that diff was messed
up. Committing this again with the proper diff.

llvm-svn: 346205
2018-11-06 04:55:20 +00:00
Mandeep Singh Grang d9f70b1495 Revert "[COFF, ARM64] Implement InterlockedXor*_* builtins"
This reverts commit cc3d3cd0fbeb88412d332354c261ff139c4ede6b.

llvm-svn: 346192
2018-11-06 01:14:24 +00:00
Mandeep Singh Grang d8a4455d97 [COFF, ARM64] Implement InterlockedXor*_* builtins
Summary: This is fifth in a series of patches to move intrinsic definitions out of intrin.h.

Reviewers: rnk, efriedma, mstorsjo, TomTan

Reviewed By: efriedma

Subscribers: javed.absar, kristof.beyls, chrib, jfb, kristina, cfe-commits

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

llvm-svn: 346191
2018-11-06 01:12:29 +00:00
Mandeep Singh Grang ec62b31e2c [COFF, ARM64] Implement InterlockedOr*_* builtins
This is fourth in a series of patches to move intrinsic definitions out of intrin.h.

llvm-svn: 346190
2018-11-06 01:11:25 +00:00
Mandeep Singh Grang 6b880689f0 [COFF, ARM64] Implement InterlockedCompareExchange*_* builtins
Summary: This is third in a series of patches to move intrinsic definitions out of intrin.h.

Reviewers: rnk, efriedma, mstorsjo, TomTan

Reviewed By: efriedma

Subscribers: javed.absar, kristof.beyls, chrib, jfb, kristina, cfe-commits

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

llvm-svn: 346189
2018-11-06 00:36:48 +00:00
Dan Albert b2c5cab133 [Driver] Reland again again: Default Android toolchains to libc++.
Landed more fixes to the compiler-rt Android tests.

Original review was https://reviews.llvm.org/D53109.

llvm-svn: 346167
2018-11-05 20:57:46 +00:00
Ben Hamilton 0675e87ec8 [Format] Add debugging to ObjC language guesser
Summary:
To handle diagnosing bugs where ObjCHeaderStyleGuesser guesses
wrong, this diff adds a bit more debug logging to the Objective-C
language guesser.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits

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

llvm-svn: 346144
2018-11-05 16:59:33 +00:00
Haojian Wu 63ecf07311 [Tooling] Correct the total number of files being processed when `filter` is provided.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 346135
2018-11-05 15:08:00 +00:00
Haojian Wu cd5e59f552 [Tooling] Add "-filter" option to AllTUsExecution
Summary: We can run the tools on a subset files of compilation database.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 346131
2018-11-05 13:42:05 +00:00
Benjamin Kramer 5904c41ed2 Reapply "Fix regression in behavior of clang -x c++-header -fmodule-name=XXX"
This reverts commit r345963. We have a path forward now.

Original commit message:
The driver accidentally stopped passing the input filenames on to -cc1
in this mode due to confusion over what action was being requested.

This change also fixes a couple of crashes I encountered when passing
multiple files to such a -cc1 invocation.

llvm-svn: 346130
2018-11-05 12:46:02 +00:00
Kristof Umann 0a1f91c80c [analyzer] Restrict AnalyzerOptions' interface so that non-checker objects have to be registered
One of the reasons why AnalyzerOptions is so chaotic is that options can be
retrieved from the command line whenever and wherever. This allowed for some
options to be forgotten for a looooooong time. Have you ever heard of
"region-store-small-struct-limit"? In order to prevent this in the future, I'm
proposing to restrict AnalyzerOptions' interface so that only checker options
can be retrieved without special getters. I would like to make every option be
accessible only through a getter, but checkers from plugins are a thing, so I'll
have to figure something out for that.

This also forces developers who'd like to add a new option to register it
properly in the .def file.

This is done by

* making the third checker pointer parameter non-optional, and checked by an
  assert to be non-null.
* I added new, but private non-checkers option initializers, meant only for
  internal use,
* Renamed these methods accordingly (mind the consistent name for once with
  getBooleanOption!):
  - getOptionAsString -> getCheckerStringOption,
  - getOptionAsInteger -> getCheckerIntegerOption
* The 3 functions meant for initializing data members (with the not very
  descriptive getBooleanOption, getOptionAsString and getOptionAsUInt names)
  were renamed to be overloads of the getAndInitOption function name.
* All options were in some way retrieved via getCheckerOption. I removed it, and
  moved the logic to getStringOption and getCheckerStringOption. This did cause
  some code duplication, but that's the only way I could do it, now that checker
  and non-checker options are separated. Note that the non-checker version
  inserts the new option to the ConfigTable with the default value, but the
  checker version only attempts to find already existing entries. This is how
  it always worked, but this is clunky and I might end reworking that too, so we
  can eventually get a ConfigTable that contains the entire configuration of the
  analyzer.

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

llvm-svn: 346113
2018-11-05 03:50:37 +00:00
Kristof Umann cb88cc674c Ensure the correct order of evaluation in part 2. of PlistMacroExpansion
Windows buildbots break with the previous commit '[analyzer][PlistMacroExpansion]
Part 2.: Retrieving the macro name and primitive expansion'. This patch attempts
to solve this issue.

llvm-svn: 346112
2018-11-05 02:37:29 +00:00
Kristof Umann 3800257fba Reland '[analyzer][PlistMacroExpansion] Part 2.: Retrieving the macro name and primitive expansion'
llvm-svn: 346111
2018-11-05 02:14:36 +00:00
Petr Hosek 6c652b7f11 [Driver] Use -Bstatic/dynamic for libc++ on Fuchsia
-static relies on lld's behavior, but -Bstatic/dynamic is supported
across all linkers.

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

llvm-svn: 346107
2018-11-04 22:38:47 +00:00
Sylvestre Ledru 99682d0af7 Add support of the next Ubuntu (Ubuntu 19.04 - Disco Dingo)
llvm-svn: 346103
2018-11-04 17:41:41 +00:00
Kristof Umann d96bdd2402 Revert '[analyzer][PlistMacroExpansion] Part 2.: Retrieving the macro name and primitive expansion'
llvm-svn: 346096
2018-11-04 14:18:37 +00:00
Kristof Umann 7430213d8e [analyzer][PlistMacroExpansion] Part 2.: Retrieving the macro name and primitive expansion
This patch adds a couple new functions to acquire the macro's name, and also
expands it, although it doesn't expand the arguments, as seen from the test files

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

llvm-svn: 346095
2018-11-04 13:59:44 +00:00
Brian Gesiak a87ecf6c7f [coroutines] Fix fallthrough warning on try/catch
Summary:
The test case added in this diff would incorrectly warn that control
flow may fall through without returning. Here's a standalone example:
https://godbolt.org/z/dCwXEi

The same program, but using `return` instead of `co_return`, does not
produce a warning: https://godbolt.org/z/mVldqQ

The issue was in how Clang analysis would structure its representation
of the control-flow graph. Specifically, when constructing the CFG,
`CFGBuilder::Visit` had special handling of a `ReturnStmt`, in which it
would place object destructors in the same CFG block as a `return` statement,
immediately after it. Doing so would allow the logic in
`lib/Sema/AnalysisBasedWarning.cpp` `CheckFallThrough` to work properly in the
program that used `return`, correctly determining that no "plain edges" preceded
the exit block of the function.

Because a `co_return` statement would not enjoy the same treatment when
it was being built into the control-flow graph, object destructors
would not be placed in the same CFG block as the `co_return`, thus
resulting in a "plain edge" preceding the exit block of the function,
and so the warning logic would be triggered.

Add special casing for `co_return` to Clang analysis, thereby
remedying the mistaken warning.

Test Plan: `check-clang`

Reviewers: GorNishanov, tks2103, rsmith

Reviewed By: GorNishanov

Subscribers: EricWF, lewissbaker, cfe-commits

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

llvm-svn: 346074
2018-11-03 22:35:17 +00:00
Takuto Ikuta 302c643531 Add /Zc:DllexportInlines option to clang-cl
Summary:
This CL adds /Zc:DllexportInlines flag to clang-cl.
When Zc:DllexportInlines- is specified, inline class member function is not exported if the function does not have local static variables.

By not exporting inline function, code for those functions are not generated and that reduces both compile time and obj size. Also this flag does not import inline functions from dllimported class if the function does not have local static variables.

On my 24C48T windows10 machine, build performance of chrome target in chromium repository is like below.
These stats are come with 'target_cpu="x86" enable_nacl = false is_component_build=true dcheck_always_on=true` build config and applied
* https://chromium-review.googlesource.com/c/chromium/src/+/1212379
* https://chromium-review.googlesource.com/c/v8/v8/+/1186017

Below stats were taken with this patch applied on a05115cd4c

| config                          | build time | speedup | build dir size |
| with patch, PCH on, debug       | 1h10m0s    | x1.13   | 35.6GB         |
| without patch, PCH on, debug    | 1h19m17s   |         | 49.0GB         |
| with patch, PCH off, debug      | 1h15m45s   | x1.16   | 33.7GB         |
| without patch, PCH off, debug   | 1h28m10s   |         | 52.3GB         |
| with patch, PCH on, release     | 1h13m13s   | x1.22   | 26.2GB         |
| without patch, PCH on, release  | 1h29m57s   |         | 37.5GB         |
| with patch, PCH off, release    | 1h23m38s   | x1.32   | 23.7GB         |
| without patch, PCH off, release | 1h50m50s   |         | 38.7GB         |

This patch reduced obj size and the number of exported symbols largely, that improved link time too.
e.g. link time stats of blink_core.dll become like below
|                              | cold disk cache | warm disk cache |
| with patch, PCH on, debug    | 71s             | 30s             |
| without patch, PCH on, debug | 111s            | 48s             |

This patch's implementation is based on Nico Weber's patch. I modified to support static local variable, added tests and took stats.

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

Reviewers: hans, thakis, rnk, javed.absar

Reviewed By: hans

Subscribers: kristof.beyls, smeenai, dschuff, probinson, cfe-commits, eraman

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

llvm-svn: 346069
2018-11-03 06:45:00 +00:00
Richard Smith 3501895863 Revert r345562: "PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of type"
This exposes a (known) CodeGen bug: it can't cope with emitting lvalue
expressions that denote non-odr-used but usable-in-constant-expression
variables. See PR39528 for a testcase.

Reverted for now until that issue can be fixed.

llvm-svn: 346065
2018-11-03 02:23:33 +00:00
Petr Hosek c39b97f211 [Driver] Use -push-/-pop-state and -as-needed for libc++ on Fuchsia
This avoids introducing unnecessary DT_NEEDED entries when using
C++ driver for linking C code or C++ code that doesn't use C++
standard library.

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

llvm-svn: 346064
2018-11-03 01:43:25 +00:00
Mandeep Singh Grang 7fa07e554d [COFF, ARM64] Implement InterlockedExchange*_* builtins
Summary: Windows SDK needs these intrinsics to be proper builtins.  This is second in a series of patches to move intrinsic defintions out of intrin.h.

Reviewers: rnk, mstorsjo, efriedma, TomTan

Reviewed By: rnk, efriedma

Subscribers: javed.absar, kristof.beyls, chrib, jfb, kristina, cfe-commits

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

llvm-svn: 346044
2018-11-02 21:18:23 +00:00
Aaron Ballman b55cd69a67 Diagnose parameter names that shadow the names of inherited fields under -Wshadow-field.
This addresses PR34120. Note, unlike GCC, we take into account the accessibility of the field when deciding whether to warn or not.

llvm-svn: 346041
2018-11-02 21:04:44 +00:00
Kristof Umann 37829b56a1 Attempt to fix 'logical operation on address of string constant'
Caused a lot of warnings for Windows:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/21178/steps/build/logs/warnings%20%2867%29

llvm-svn: 346033
2018-11-02 19:48:56 +00:00
Mandeep Singh Grang 6cef4e5c87 [COFF, ARM64] Change setjmp for AArch64 Windows to use Intrinsic.sponentry
Summary: ARM64 setjmp expects sp on entry instead of framepointer.

Patch by: Yin Ma (yinma@codeaurora.org)

Reviewers: mgrang, eli.friedman, ssijaric, mstorsjo, rnk, compnerd

Reviewed By: mgrang

Subscribers: efriedma, javed.absar, kristof.beyls, chrib, cfe-commits

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

llvm-svn: 346024
2018-11-02 18:10:07 +00:00
Erik Pilkington e3b7144e6a [CodeGen] Fix a crash when updating a designated initializer
We need to handle the ConstantAggregateZero case here too.

rdar://45691981

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

llvm-svn: 346004
2018-11-02 17:36:58 +00:00
Filipe Cabecinhas 0eb5008352 Change -fsanitize-address-poison-class-member-array-new-cookie to -fsanitize-address-poison-custom-array-cookie
Handle it in the driver and propagate it to cc1

Reviewers: rjmccall, kcc, rsmith

Subscribers: cfe-commits

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

llvm-svn: 346001
2018-11-02 17:29:04 +00:00
Alexey Bataev 1fc1f8e819 [OPENMP][NVPTX]Use __kmpc_data_sharing_coalesced_push_stack function.
Coalesced memory access requires use of the new function
`__kmpc_data_sharing_coalesced_push_stack` instead of the
`__kmpc_data_sharing_push_stack`.

llvm-svn: 345991
2018-11-02 16:08:31 +00:00
Kristof Umann 391b19c78a [analyzer] Put llvm.Conventions back in alpha
Interestingly, this many year old (when I last looked I remember 2010ish)
checker was committed without any tests, so I thought I'd implement them, but I
was shocked to see how I barely managed to get it working. The code is severely
outdated, I'm not even sure it has ever been used, so I'd propose to move it
back into alpha, and possibly even remove it.

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

llvm-svn: 345990
2018-11-02 16:02:10 +00:00
Kristof Umann f1f351c985 [analyzer] New flag to print all -analyzer-config options
A new -cc1 flag is avaible for the said purpose: -analyzer-config-help

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

llvm-svn: 345989
2018-11-02 15:59:37 +00:00
Kristof Umann e390633d46 [analyzer][NFC] Collect all -analyzer-config options in a .def file
I'm in the process of refactoring AnalyzerOptions. The main motivation behind
here is to emit warnings if an invalid -analyzer-config option is given from the
command line, and be able to list them all.

In this patch, I'm moving all analyzer options to a def file, and move 2 enums
to global namespace.

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

llvm-svn: 345986
2018-11-02 15:50:44 +00:00
Kristof Umann c83b0dda49 [analyzer][NFC] Fix some incorrect uses of -analyzer-config options
I'm in the process of refactoring AnalyzerOptions. The main motivation behind
here is to emit warnings if an invalid -analyzer-config option is given from
the command line, and be able to list them all.

In this patch, I found some flags that should've been used as checker options,
or have absolutely no mention of in AnalyzerOptions, or are nonexistent.

- NonLocalizedStringChecker now uses its "AggressiveReport" flag as a checker
    option
- lib/StaticAnalyzer/Frontend/ModelInjector.cpp now accesses the "model-path"
    option through a getter in AnalyzerOptions
- -analyzer-config path-diagnostics-alternate=false is not a thing, I removed it,
- lib/StaticAnalyzer/Checkers/AllocationDiagnostics.cpp and
    lib/StaticAnalyzer/Checkers/AllocationDiagnostics.h are weird, they actually
    only contain an option getter. I deleted them, and fixed RetainCountChecker
    to get it's "leak-diagnostics-reference-allocation" option as a checker option,
- "region-store-small-struct-limit" has a proper getter now.

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

llvm-svn: 345985
2018-11-02 15:48:10 +00:00
Alexey Bataev 2dc07d0cf3 [OPENMP]Change the mapping type for lambda captures.
The previously used combination `PTR_AND_OBJ | PRIVATE` could be used for mapping of some data in Fortran. Changed it to `PTR_AND_OBJ | LITERAL`.

llvm-svn: 345982
2018-11-02 15:25:06 +00:00
Alexey Bataev e40901806f [OPENMP][NVPTX]Improve emission of the globalized variables for
target/teams/distribute regions.

Target/teams/distribute regions exist for all the time the kernel is
executed. Thus, if the variable is declared in their context and then
escape it, we can allocate global memory statically instead of
allocating it dynamically.
Patch captures all the globalized variables in target/teams/distribute
contexts, merges them into the records, one per each target region.
Those records are then joined into the union, one per compilation unit
(to save the global memory). Those units are organized into
2 x dimensional arrays, where the first dimension is
the number of blocks per SM and the second one is the number of SMs.
Runtime functions manage this global memory space between the executing
teams.

llvm-svn: 345978
2018-11-02 14:54:07 +00:00
Tim Northover 314fbfa1c4 Reapply Logging: make os_log buffer size an integer constant expression.
The size of an os_log buffer is known at any stage of compilation, so making it
a constant expression means that the common idiom of declaring a buffer for it
won't result in a VLA. That allows the compiler to skip saving and restoring
the stack pointer around such buffers.

This also moves the OSLog and other FormatString helpers from
libclangAnalysis to libclangAST to avoid a circular dependency.

llvm-svn: 345971
2018-11-02 13:14:11 +00:00
Patrick Lyster 7a2a27c4a4 Add support for 'atomic_default_mem_order' clause on 'requires' directive. Also renamed test files relating to 'requires'. Differntial review: https://reviews.llvm.org/D53513
llvm-svn: 345967
2018-11-02 12:18:11 +00:00
Ilya Biryukov dfc56b43fa Revert "Fix regression in behavior of clang -x c++-header -fmodule-name=XXX"
This reverts commit r345803 and r345915 (a follow-up fix to r345803).

Reason: r345803 blocks our internal integrate because of the new
warnings showing up in too many places. The fix is actually correct,
we will reland it after figuring out how to integrate properly.

llvm-svn: 345963
2018-11-02 10:50:26 +00:00
Fangrui Song fbd5039b7e Fix -Wimplicit-fallthrough warning in LLVM_ENABLE_ASSERTIONS=Off builds
llvm-svn: 345950
2018-11-02 04:09:08 +00:00
Richard Smith 9914c3a2ba When building a header module, treat inputs as headers rather than
source files.

This suppresses certain warnings (eg, '#include_next in main source
file').

llvm-svn: 345915
2018-11-02 00:24:40 +00:00
Volodymyr Sapsai 8b286f99d4 [CodeGen] Fix assertion on referencing constexpr Obj-C object with ARC.
Failed assertion is
> Assertion failed: ((ND->isUsed(false) || !isa<VarDecl>(ND) || !E->getLocation().isValid()) && "Should not use decl without marking it used!"), function EmitDeclRefLValue, file llvm-project/clang/lib/CodeGen/CGExpr.cpp, line 2437.

`EmitDeclRefLValue` mentions
> // A DeclRefExpr for a reference initialized by a constant expression can
> // appear without being odr-used. Directly emit the constant initializer.

The fix is to use the similar approach for non-references as for references. It
is achieved by trying to emit a constant before we attempt to load non-odr-used
variable as LValue.

rdar://problem/40650504

Reviewers: ahatanak, rjmccall

Reviewed By: rjmccall

Subscribers: dexonsmith, erik.pilkington, cfe-commits

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

llvm-svn: 345903
2018-11-01 22:50:08 +00:00
Volodymyr Sapsai ef1899b01d [CodeGen] Move `emitConstant` from ScalarExprEmitter to CodeGenFunction. NFC.
The goal is to use `emitConstant` in more places. Didn't move
`ComplexExprEmitter::emitConstant` because it returns a different type.

Reviewers: rjmccall, ahatanak

Reviewed By: rjmccall

Subscribers: dexonsmith, erik.pilkington, cfe-commits

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

llvm-svn: 345897
2018-11-01 21:57:05 +00:00
Reid Kleckner 4dc0b1ac60 Fix clang -Wimplicit-fallthrough warnings across llvm, NFC
This patch should not introduce any behavior changes. It consists of
mostly one of two changes:
1. Replacing fall through comments with the LLVM_FALLTHROUGH macro
2. Inserting 'break' before falling through into a case block consisting
   of only 'break'.

We were already using this warning with GCC, but its warning behaves
slightly differently. In this patch, the following differences are
relevant:
1. GCC recognizes comments that say "fall through" as annotations, clang
   doesn't
2. GCC doesn't warn on "case N: foo(); default: break;", clang does
3. GCC doesn't warn when the case contains a switch, but falls through
   the outer case.

I will enable the warning separately in a follow-up patch so that it can
be cleanly reverted if necessary.

Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu

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

llvm-svn: 345882
2018-11-01 19:54:45 +00:00
Aaron Ballman 2c0febe3e6 Output "rule" information in SARIF exports.
SARIF allows you to export descriptions about rules that are present in the SARIF log. Expose the help text table generated into Checkers.inc as the rule's "full description" and export all of the rules present in the analysis output. This information is useful for analysis result viewers like CodeSonar.

llvm-svn: 345874
2018-11-01 18:57:38 +00:00
Reid Kleckner 14518f1d9b Add LLVM_FALLTHROUGH annotation after switch
This silences a -Wimplicit-fallthrough warning from clang. GCC does not
appear to warn when the case body ends in a switch.

This is a somewhat surprising but intended fallthrough that I pulled out
from my mechanical patch. The code intends to handle 'Yi' and related
constraints as the 'x' constraint.

llvm-svn: 345873
2018-11-01 18:53:02 +00:00
Mandeep Singh Grang 5c39b6ab7f Revert "[COFF, ARM64] Change setjmp for AArch64 Windows to use Intrinsic.sponentry"
This reverts commit 619111f5ccf349b635e4987ec02d15777c571495.

llvm-svn: 345872
2018-11-01 18:38:26 +00:00
Tim Northover eedc0f0f1a Revert "Reapply Logging: make os_log buffer size an integer constant expression."
Still more dependency hell.

llvm-svn: 345871
2018-11-01 18:37:42 +00:00
Tim Northover c1ac697ab7 Reapply Logging: make os_log buffer size an integer constant expression.
The size of an os_log buffer is known at any stage of compilation, so making it
a constant expression means that the common idiom of declaring a buffer for it
won't result in a VLA. That allows the compiler to skip saving and restoring
the stack pointer around such buffers.

This also moves the OSLog helpers from libclangAnalysis to libclangAST
to avoid a circular dependency.

llvm-svn: 345866
2018-11-01 18:04:49 +00:00
Reid Kleckner e540d97b10 Replace two fallthrough annotations after covered switch with unreachable
Both preceding switches handle all possible enumerators, so the
fallthrough is actually unreachable. This strengthens that to an
assertion.

The first instance had a comment from 2010 indicating that fallthrough
was possible, but that was back when we had a unary operator for
offsetof. Now it is its own expression kind, so the annotation was
stale.

llvm-svn: 345862
2018-11-01 17:51:48 +00:00
David Bolvansky b8dc05260c [Diagnostics] Implement -Wsizeof-pointer-div
Summary:
void test(int *arr) {
    int arr_len = sizeof(arr) / sizeof(*arr);  // warn, incorrect way to compute number of array elements
}

Enabled under -Wall (same behaviour as GCC)

Reviewers: rsmith, MTC, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: MTC, thakis, jfb, cfe-commits

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

llvm-svn: 345847
2018-11-01 16:26:10 +00:00
Tim Northover d686dbbc7c Revert "Logging: make os_log buffer size an integer constant expression.
This also reverts a couple of follow-up commits trying to fix the
dependency issues. Latest revision added a cyclic dependency that can't
just be patched up in 5 minutes.

llvm-svn: 345846
2018-11-01 16:15:24 +00:00
Kadir Cetinkaya fabaaaaadb [clang] Improve ctor initializer completions.
Summary:
Instead of providing generic "args" for member and base class
initializers, tries to fetch relevant constructors and show their signatures.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ZaMaZaN4iK, eraman, arphaman, cfe-commits

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

llvm-svn: 345844
2018-11-01 15:54:18 +00:00
Erich Keane f1005012c2 Multiversioning- Ensure all MV functions are emitted.
Multiverson function versions are always used (by the resolver), so ensure that
they are always emitted.

Change-Id: I5d2e0841fddf0d18918b3fb92ae76814add7ee96
llvm-svn: 345839
2018-11-01 15:11:43 +00:00
Erich Keane 9e94c18abe CPU-Dispatch- Fix type of a member function, prevent deferrals
The member type creation for a cpu-dispatch function was not correctly
including the 'this' parameter, so ensure that the type is properly
determined. Also, disable defer in the cases of emitting the functoins,
as it can end up resulting in the wrong version being emitted.

Change-Id: I0b8fc5e0b0d1ae1a9d98fd54f35f27f6e5d5d083
llvm-svn: 345838
2018-11-01 15:11:41 +00:00
Tim Northover 2ef8096a5c Logging: put link against libclangAnalysis rather than libLLVMAnalysis for os_log
llvm-svn: 345835
2018-11-01 14:43:35 +00:00
Tim Northover 32aabc5585 Logging: add CMake dependency so libAST can use OSLog analysis.
Should fix bots on platforms with slightly different symbol resolution
semantics.

llvm-svn: 345833
2018-11-01 14:22:20 +00:00
Tim Northover a94ecc619b Logging: make os_log buffer size an integer constant expression.
The size of an os_log buffer is known at any stage of compilation, so making it
a constant expression means that the common idiom of declaring a buffer for it
won't result in a VLA. That allows the compiler to skip saving and restoring
the stack pointer around such buffers.

llvm-svn: 345828
2018-11-01 13:49:54 +00:00
Erich Keane 44731c5300 CPU-Dispatch-- Fix conflict between 'generic' and 'pentium'
When a dispatch function was being emitted that had both a generic and a
pentium configuration listed, we would assert.  This is because neither
configuration has any 'features' associated with it so they were both
considered the 'default' version.  'pentium' lacks any features because
we implement it in terms of __builtin_cpu_supports (instead of Intel
proprietary checks), which is unable to decern between the two.

The fix for this is to omit the 'generic' version from the dispatcher if
both are present. This permits existing code to compile, and still will
choose the 'best' version available (since 'pentium' is technically
better than 'generic').

Change-Id: I4b69f3e0344e74cbdbb04497845d5895dd05fda0
llvm-svn: 345826
2018-11-01 12:50:37 +00:00
Sven van Haastregt 4fbf1ab165 Allow clk_event_t comparisons
Also rename `invalid-clk-events-cl2.0.cl` to `clk_event_t.cl` and
repurpose it to include both positive and negative clk_event_t tests.

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

llvm-svn: 345825
2018-11-01 12:43:00 +00:00
Aaron Ballman fa28f335b8 Update to the 10-10 SARIF spec.
This removes the Step property (which can be calculated by consumers trivially), and updates the schema and version numbers accordingly.

llvm-svn: 345823
2018-11-01 11:52:07 +00:00
Roman Lebedev 1bb9aea56b [clang][CodeGen] ImplicitIntegerSignChangeSanitizer: actually ignore NOP casts.
I fully expected for that to be handled by the canonical type check,
but it clearly wasn't. Sadly, somehow it hide until now.

Reported by Eli Friedman.

llvm-svn: 345816
2018-11-01 08:56:51 +00:00
Li Jia He bbaedf2ba1 [Clang][PowerPC] Support constraint 'wi' in asm
From the gcc manual, we can see that the specific limit of wi inline asm is “FP or VSX register to hold 64-bit integers for VSX insns or NO_REGS”. The link is https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/Machine-Constraints.html#Machine-Constraints. We should accept this constraint.

Reviewed By: jsji

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

llvm-svn: 345809
2018-11-01 02:32:49 +00:00
Mandeep Singh Grang be0e78e017 [COFF, ARM64] Implement llvm.addressofreturnaddress intrinsic
llvm-svn: 345808
2018-11-01 01:35:34 +00:00
Richard Smith 2902989774 Fix typo in comment.
llvm-svn: 345805
2018-11-01 01:05:00 +00:00
Thomas Lively 6940328d02 [WebAssembly] Fix type names in truncation builtins
Summary: Use the same convention as all the other WebAssembly builtin names.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, kristina, cfe-commits

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

llvm-svn: 345804
2018-11-01 01:03:17 +00:00