Commit Graph

71438 Commits

Author SHA1 Message Date
Hans Wennborg 989a65cd29 Fix some -Wunused-variable warnings
llvm-svn: 318578
2017-11-18 00:49:18 +00:00
Eugene Zelenko fd70e5de39 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318570
2017-11-17 23:43:46 +00:00
Anna Zaks 8ffd1932d0 Change code owner for Clang Static Analyzer to Devin Coughlin.
Differential Revision: https://reviews.llvm.org/D39964

llvm-svn: 318567
2017-11-17 23:19:04 +00:00
Michal Gorny ba996aba01 [cmake] Use llvm-lit directory when provided for stand-alone build
After the recent lit test changes, clang attempts to run its tests
via llvm-lit by default. However, the llvm-lit binary is not present
when performing stand-alone build resulting in a failure out of the box.

To solve that, add the llvm-lit directory to CMake when performing
a stand-alone build and LLVM sources are provided. This includes
the CMake rules generating the llvm-lit binary and effectively makes
it possible for clang to use it.

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

llvm-svn: 318562
2017-11-17 22:21:23 +00:00
Reid Kleckner 66f58909f8 Fix coverage test on Windows bot
llvm-svn: 318559
2017-11-17 21:55:23 +00:00
Reid Kleckner c0a81071d3 Loosen -Wempty-body warning
Do not show it when `if` or `else` come from macros.
E.g.,

    #define USED(A) if (A); else
    #define SOME_IF(A) if (A)

    void test() {
      // No warnings are shown in those cases now.
      USED(0);
      SOME_IF(0);
    }

Patch by Ilya Biryukov!

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

llvm-svn: 318556
2017-11-17 21:33:28 +00:00
Alex Lorenz 42a97a94ca [ObjC][ARC] Honor noescape attribute for -Warc-retain-cycles
rdar://35409566

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

llvm-svn: 318552
2017-11-17 20:44:25 +00:00
Ahmed Bougacha 5d0199a218 [CodeGen] Compute the objc EH vtable address point using inbounds GEP.
The object is provided by the objc runtime and is never visible in the
module itself, but even so, the address point we compute points into it,
and "+16" is guaranteed not to overflow.

This matches the c++ vtable IRGen.

Note that I'm not entirely convinced the 'i8*' type is correct here: at
the IR level, we're accessing memory that's outside the global object.
But we don't control the allocation, so it's not obviously wrong either.
But either way, this is only in a global initializer, so I don't think
it's going to be mucked with.  Filed PR35352 to discuss that.

llvm-svn: 318545
2017-11-17 19:46:47 +00:00
Eugene Zelenko ae304b0717 [AST] Partially revert r318341 to fix two broken tests on llvm-clang-x86_64-expensive-checks-win (NFC).
llvm-svn: 318538
2017-11-17 18:09:48 +00:00
Martin Probst a004b3f50f clang-format: remove trailing lines in lamdas and arrow functions.
Summary:
clang-format already removes empty lines at the beginning & end of
blocks:

    int x() {

      foo();  // lines before and after will be removed.

    }

However because lamdas and arrow functions are parsed as expressions,
the existing logic to remove empty lines in UnwrappedLineFormatter
doesn't handle them.

This change special cases arrow functions in ContinuationIndenter to
remove empty lines:

    x = []() {

      foo();  // lines before and after will now be removed.

    };

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 318537
2017-11-17 18:06:33 +00:00
Alexey Bataev f836537516 [OPENMP] Codegen for `target simd` construct.
Added codegen support for `target simd` directive.

llvm-svn: 318536
2017-11-17 17:57:25 +00:00
Stephan Bergmann 15b87c6de3 Indent code blocks so they are actually treated as such
llvm-svn: 318530
2017-11-17 16:34:36 +00:00
Dave Lee 984964a04f Fix skipping of flags in getClangStripDependencyFileAdjuster
Summary:
The ArgumentsAdjuster returned from `getClangStripDependencyFileAdjuster` will
skip dependency flags, and also their associated values for those flags that
take an argument. This change corrects the handling of the `-MD` and `-MMD`
flags, which do not take an argument.

Reviewers: saugustine, klimek, alexshap

Reviewed By: alexshap

Subscribers: cfe-commits

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

llvm-svn: 318529
2017-11-17 16:27:21 +00:00
Krasimir Georgiev 6649665d5a [clang-format] Add text proto filename detection
Summary: Adds text proto filename detection.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 318525
2017-11-17 15:10:49 +00:00
Manuel Klimek 7786614350 Implement more accurate penalty & trade-offs while breaking protruding tokens.
For each line that we break in a protruding token, compute whether the
penalty of breaking is actually larger than the penalty of the excess
characters. Only break if that is the case.

llvm-svn: 318515
2017-11-17 11:17:15 +00:00
Ilya Biryukov dd9ea751e1 Use llvm-config.h instead of config.h
To fix standalone builds broken by r318411 (config.h is private to llvm).

llvm-svn: 318514
2017-11-17 10:09:02 +00:00
Martin Storsjo ec82128971 [MinGW] Define __ARM_DWARF_EH__ for MinGW/ARM
Since SVN r318510, the MinGW/ARM configuration defaults to
dwarf exception handling.

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

llvm-svn: 318511
2017-11-17 08:06:49 +00:00
Bruno Cardoso Lopes b5b0c02249 Change path used in a test from r318503 to work on windows
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/13565

llvm-svn: 318507
2017-11-17 04:26:07 +00:00
Bruno Cardoso Lopes a66a325bbc [PCH+Modules] Improve diagnosticts to help out users pass an extra header search path
When mixing PCH and Implicit Modules, missing a header search path
can lead to the implicit built PCM to complaint about not finding its
matching module map.

Instead of adding more magic to implicit modules engine, add a note to
help the user add the appropriate path.

rdar://problem/33388847

llvm-svn: 318503
2017-11-17 03:24:11 +00:00
Justin Lebar 370c766e40 [CUDA] Remove implementations of nexttoward.
Summary:
__builtin_nexttoward lowers to a libcall, e.g. nexttowardf(), that CUDA
does not have.

Rather than try to implement it, we simply remove these functions --
nvcc doesn't support them either, and nextafter, which does work, does
essentially the same thing on GPUs, because GPUs don't have long double.

Reviewers: tra

Subscribers: cfe-commits, sanjoy

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

llvm-svn: 318494
2017-11-17 01:15:43 +00:00
David Blaikie 68d00b0b67 Update for layering fix in LLVM CodeGen<>Target
llvm-svn: 318491
2017-11-17 01:07:20 +00:00
Zachary Turner b5c237ec3d Re-revert "Refactor debuginfo-tests"
This is still broken because it causes certain tests to be
run twice with slightly different configurations, which is
wrong in some cases.

You can observe this by running:

  ninja -nv check-all | grep debuginfo-tests

And seeing that it passes clang/test and clang/test/debuginfo-tests
to lit, which causes it to run debuginfo-tests twice.  The fix is
going to involve either:

  a) figuring out that we're running in this "deprecated" configuration,
     and then deleting the clang/test/debuginfo-tests path, which should
     cause it to behave identically to before, or:
  b) make lit smart enough that it doesn't descend into a sub-suite if
     that sub-suite already has a lit.cfg file.

llvm-svn: 318486
2017-11-17 00:41:18 +00:00
Richard Smith e2467b7aed PR22763: if a defaulted (non-user-provided) special member function is
explicitly instantiated, still emit it with each use.

We don't emit a definition of the member with an explicit instantiation
definition (and indeed it appears that we're not allowed to, since an explicit
instantiation definition does not constitute an odr-use and only odr-use
permits definition for defaulted special members). So we still need to emit a
weak definition with each use.

This also makes defaulted-in-class declarations behave more like
implicitly-declared special members, which matches their design intent.
And it matches the way this problem was solved in GCC.

llvm-svn: 318474
2017-11-16 23:54:56 +00:00
Reid Kleckner adefb760a8 Issue -Wempty-body warnings for else blocks
This looks like it was just an oversight.

Fixes http://llvm.org/pr35319

llvm-svn: 318456
2017-11-16 21:26:18 +00:00
Ben Hamilton 7838101678 [VirtualFileSystem] Support creating directories then adding files inside
Summary:
In https://reviews.llvm.org/D39572 , I added support for specifying
`Type` when invoking `InMemoryFileSystem::addFile()`.

However, I didn't account for the fact that when `Type` is
`directory_file`, we need to construct an `InMemoryDirectory`, not an
`InMemoryFile`, or else clients cannot create files inside that
directory.

This diff fixes the bug and adds a test.

Test Plan: New test added. Ran test with:

  % make -j12 check-clang-tools

Reviewers: bkramer, hokein

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 318445
2017-11-16 19:34:08 +00:00
Reid Kleckner 06239e42c6 [MS] Apply adjustments after storing 'this'
Summary:
The MS ABI convention is that the 'this' pointer on entry is the address
of the vfptr that was used to make the virtual method call. In other
words, the pointer on entry always points to the base subobject that
introduced the virtual method. Consider this hierarchy:

  struct A { virtual void f() = 0; };
  struct B { virtual void g() = 0; };
  struct C : A, B {
    void f() override;
    void g() override;
  };

On entry to C::g, [ER]CX will contain the address of C's B subobject,
and C::g will have to subtract sizeof(A) to recover a pointer to C.

Before this change, we applied this adjustment in the prologue and
stored the new value into the "this" local variable alloca used for
debug info. However, MSVC does not do this, presumably because it is
often profitable to fold the adjustment into later field accesses. This
creates a problem, because the debugger expects the variable to be
unadjusted. Unfortunately, CodeView doesn't have anything like DWARF
expressions for computing variables that aren't in the program anymore,
so we have to declare 'this' to be the unadjusted value if we want the
debugger to see the right value.

This has the side benefit that, in optimized builds, the 'this' pointer
will usually be available on function entry because it doesn't require
any adjustment.

Reviewers: hans

Subscribers: aprantl, cfe-commits

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

llvm-svn: 318440
2017-11-16 19:09:36 +00:00
Zachary Turner 5e420717a1 Resubmit "Refactor debuginfo-tests"
This was reverted due to some failures on specific darwin buildbots,
the issue being that the new lit configuration was not setting the
SDKROOT environment variable.  We've tested a fix locally and confirmed
that it works, so this patch resubmits everything with the fix
applied.

llvm-svn: 318435
2017-11-16 18:26:20 +00:00
Alexey Bataev 2139ed638b [OPENMP] Add support for cancelling inside target parallel for
directive.

Added missed support for cancelling of target parallel for construct.

llvm-svn: 318434
2017-11-16 18:20:21 +00:00
Yaxun Liu abf5b27f7a Update tests for llvm.invariant.group.barrier becoming mangled
Differential Revision: https://reviews.llvm.org/D40062

llvm-svn: 318414
2017-11-16 16:33:04 +00:00
Ilya Biryukov 417085ac37 Allow to store precompiled preambles in memory.
Summary:
These preambles are built by ASTUnit and clangd. Previously, preambles
were always stored on disk.

In-memory preambles are routed back to the compiler as virtual files in
a custom VFS.

Interface of ASTUnit does not allow to use in-memory preambles, as
ASTUnit::CodeComplete receives FileManager as a parameter, so we can't
change VFS used by the compiler inside the CodeComplete method.

A follow-up commit will update clangd in clang-tools-extra to use
in-memory preambles.

Reviewers: klimek, sammccall, bkramer

Reviewed By: klimek

Subscribers: ioeric, cfe-commits

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

llvm-svn: 318411
2017-11-16 16:25:01 +00:00
Eric Christopher f18016c640 Add NDEBUG checks around LLVM_DUMP_METHOD functions for Wunused-function warnings.
llvm-svn: 318371
2017-11-16 03:18:09 +00:00
Alex Lorenz dc616faa44 [DeclPrinter] Extract function PrintConstructorInitializers, NFC
Patch by Nikolai Kosjar!

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

llvm-svn: 318367
2017-11-16 01:31:27 +00:00
Alex Lorenz 35019dbe6b [DeclPrinter] Honor TerseOutput for constructors
Patch by Nikolai Kosjar!

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

llvm-svn: 318365
2017-11-16 01:28:25 +00:00
NAKAMURA Takumi 194d1a621d clang/module.modulemap: clang/Basic/X86Target.def may be textual header.
llvm-svn: 318347
2017-11-15 23:04:44 +00:00
Erich Keane bc4679880c Add X86Target.def that was forgotten in r30734
llvm-svn: 318345
2017-11-15 22:36:24 +00:00
Erich Keane 6da1108659 Split x86 "Processor" info into its own def file. [NFC]
A first step toward removing the repetition of
features/CPU info in the x86 target info, this
patch pulls all the processor information out into
its own .def file.

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

llvm-svn: 318343
2017-11-15 22:25:39 +00:00
Eugene Zelenko 11a7ef8559 [AST, Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318341
2017-11-15 22:00:04 +00:00
Hans Wennborg 0abe0cacc4 Try to fix test/SemaCXX/deleted-operator.cpp after r318309
The number of 'built-in candidate' notes now varies since __float128 may
or may not be a candidate depending on the target.

llvm-svn: 318314
2017-11-15 17:47:58 +00:00
Hans Wennborg 8237141be1 BuiltinOperatorOverloadBuilder: Don't consider types that are unavailable on the target (PR35174)
In the PR, Clang ended up in a situation where it tried to mangle the
__float128 type, which isn't supported when targetingt MSVC, because
Clang instantiated a variable template with that type when searching for
a conversion to use in an arithmetic expression.

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

llvm-svn: 318309
2017-11-15 17:11:53 +00:00
David Blaikie ac7e3d6451 ASTMatchers.h: Fix ODR violations by avoiding internal linkage variables in headers
Internal linkage variables ODR referenced from inline functions create
ODR violations (the same inline function ends up having different
definitions in each TU, since it references different variables - rather
than one definition).

This also happens to break modular code generation - so this is the last
fix to allow clang to compile with modular code generation.

llvm-svn: 318304
2017-11-15 16:52:12 +00:00
Benjamin Kramer 99f9759d96 [libclang] Fix cursors for in-class initializer of field declarations
Fixes PR33745.

Patch by Nikolai Kosjar!

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

llvm-svn: 318292
2017-11-15 12:20:41 +00:00
Alexey Bader bed400957b [OpenCL] Fix code generation of function-scope constant samplers.
Summary:
Constant samplers are handled as static variables and clang's code generation
library, which leads to llvm::unreachable. We bypass emitting sampler variable
as static since it's translated to a function call later.

Reviewers: yaxunl, Anastasia

Reviewed By: yaxunl, Anastasia

Subscribers: cfe-commits

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

llvm-svn: 318290
2017-11-15 11:38:17 +00:00
Sam McCall 1102a861f5 [clang] Expose orderedString from CodeCompletionResult. NFC
llvm-svn: 318286
2017-11-15 09:15:06 +00:00
NAKAMURA Takumi 14d7cf66a1 ASTMatchers.h: Avoid warnings due to "@throw". [-Wdocumentation]
llvm-svn: 318274
2017-11-15 06:53:45 +00:00
Richard Smith efdb50375f PR35214: don't crash if we see an array of unknown bound added to an empty but invalid designator.
llvm-svn: 318258
2017-11-15 03:03:56 +00:00
Richard Smith 85567ddaba [modules] Fix crash in complex class merging scenario.
When we merge together class definitions, we can end up with the canonical
declaration of a field not being the one that was lexically within the
canonical definition of the class. Additionally, when we merge class
definitions via update records (eg, for a template specialization whose
declaration is instantiated in one module and whose definition is instantiated
in multiple others), we can end up with the list of lexical contents for the
class not including a particular declaration of a field whose lexical parent is
that class definition. In the worst case, we have a field whose canonical
declaration's lexical parent has no fields, and in that case this attempt to
number the fields by walking the fields in the declaration of the class that
contained one of the canonical fields will fail.

Instead, when numbering fields in a class, do the obvious thing: walk the
fields in the definition.

I'm still trying to reduce a testcase; the setup that leads to the above
scenario seems to be quite fragile.

llvm-svn: 318245
2017-11-15 01:33:46 +00:00
Erich Keane 8202521cf5 Simplify CpuIs code to use include from LLVM
LLVM exposes a file in the backend (X86TargetParser.def) that
contains information about the correct list of CpuIs values.

This patch removes 2 of the copied and pasted versions of this
list from clang and instead includes the data from the .def file.

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

llvm-svn: 318234
2017-11-15 00:11:24 +00:00
Vedant Kumar 6186971a4a [PGO] Detect more structural changes with the stable hash
Lifting from Bob Wilson's notes: The hash value that we compute and
store in PGO profile data to detect out-of-date profiles does not
include enough information. This means that many significant changes to
the source will not cause compiler warnings about the profile being out
of date, and worse, we may continue to use the outdated profile data to
make bad optimization decisions.  There is some tension here because
some source changes won't affect PGO and we don't want to invalidate the
profile unnecessarily.

This patch adds a new hashing scheme which is more sensitive to loop
nesting, conditions, and out-of-order control flow. Here are examples
which show snippets which get the same hash under the current scheme,
and different hashes under the new scheme:

Loop Nesting Example
--------------------

  // Snippet 1
  while (foo()) {
    while (bar()) {}
  }

  // Snippet 2
  while (foo()) {}
  while (bar()) {}

Condition Example
-----------------

  // Snippet 1
  if (foo())
    bar();
  baz();

  // Snippet 2
  if (foo())
    bar();
  else
    baz();

Out-of-order Control Flow Example
---------------------------------

  // Snippet 1
  while (foo()) {
    if (bar()) {}
    baz();
  }

  // Snippet 2
  while (foo()) {
    if (bar())
      continue;
    baz();
  }

In each of these cases, it's useful to differentiate between the
snippets because swapping their profiles gives bad optimization hints.

The new hashing scheme considers some logical operators in an effort to
detect more changes in conditions. This isn't a perfect scheme. E.g, it
does not produce the same hash for these equivalent snippets:

  // Snippet 1
  bool c = !a || b;
  if (d && e) {}

  // Snippet 2
  bool f = d && e;
  bool c = !a || b;
  if (f) {}

This would require an expensive data flow analysis. Short of that, the
new hashing scheme looks reasonably complete, based on a scan over the
statements we place counters on.

Profiles which use the old version of the PGO hash remain valid and can
be used without issue (there are tests in tree which check this).

rdar://17068282

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

llvm-svn: 318229
2017-11-14 23:56:53 +00:00
Eugene Zelenko 1eab6c12f7 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318221
2017-11-14 23:35:42 +00:00
Eugene Zelenko 4a5354fd36 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318216
2017-11-14 23:13:32 +00:00
Alex Lorenz 8337f81f68 [refactor][selection] canonicalize decl ref callee to the call expr
We would like to extract the full call when just the callee function is
selected

llvm-svn: 318215
2017-11-14 23:10:50 +00:00
Hans Wennborg 57dd59d472 Try to fix the instrument-functions tests
On e.g. PPC the return value and argument were marked 'signext'. This
makes the test expectations a bit more flexible.

Follow-up to r318199.

llvm-svn: 318214
2017-11-14 23:10:04 +00:00
Alex Lorenz f64d0a4d00 [refactor][selection] canonicalize member expr callee to the full
member call expression

We would like to extract the full call when just the callee is selected.

llvm-svn: 318205
2017-11-14 22:06:55 +00:00
Hans Wennborg 76c26c1dca Switch -mcount and -finstrument-functions to emit EnterExitInstrumenter attributes
This updates -mcount to use the new attribute names (LLVM r318195), and
switches over -finstrument-functions to also use these attributes rather
than inserting instrumentation in the frontend.

It also adds a new flag, -finstrument-functions-after-inlining, which
makes the cygprofile instrumentation get inserted after inlining rather
than before.

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

llvm-svn: 318199
2017-11-14 21:13:27 +00:00
Alexey Bataev 817d7f36e9 [OPENMP] Fix DSA analysis for threadprivates after deserialization.
If threadprivate vaible is deserialized, it is not marked as
threadprivate in DSAStack.

llvm-svn: 318194
2017-11-14 21:01:01 +00:00
Alex Lorenz cc55754a79 [refactor][extract] avoid extracting expressions from types in functions
llvm-svn: 318169
2017-11-14 18:59:01 +00:00
Sam McCall ed1b3f71ff [tooling] Make compile_flags.txt negative test more hermetic
llvm-svn: 318154
2017-11-14 15:22:34 +00:00
Dave Lee be39868bfc Make isDefinition matcher support ObjCMethodDecl
Summary:
Allow the `isDefinition()` matcher to apply to `ObjCMethodDecl` nodes, in
addition to those it already supports. For whatever reason, `ObjCMethodDecl`
does not inherit from `FunctionDecl` and so this is specialization is necessary.

Reviewers: aaron.ballman, malcolm.parsons, alexshap

Reviewed By: aaron.ballman

Subscribers: cfe-commits, klimek

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

llvm-svn: 318152
2017-11-14 14:17:26 +00:00
Gabor Horvath 328d3afc3b Make DiagnosticIDs::getAllDiagnostics static. NFC.
Patch by: Andras Leitereg!

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

llvm-svn: 318150
2017-11-14 12:14:49 +00:00
Gabor Horvath 7a91c08414 [ASTImporter] TypeAliasTemplate and PackExpansion importing capability
Patch by: Zoltan Gera!

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

llvm-svn: 318147
2017-11-14 11:30:38 +00:00
Erik Verbruggen 3cc3911cc0 [libclang] Allow crash recovery with LIBCLANG_NOTHREADS
Enabled crash recovery for some libclang operations on a calling thread even
when LIBCLANG_NOTHREAD is specified.

Previously it would only run under crash recovery if LIBCLANG_NOTHREAD is not
set. Moved handling of LIBCLANG_NOTHREAD env variable into RunSafely from its
call sites.

llvm-svn: 318142
2017-11-14 09:34:39 +00:00
Manuel Klimek 45ab559ee7 Refactor ContinuationIndenter's breakProtrudingToken logic.
Create more orthogonal pieces. The restructuring made it easy to try out
several alternatives to D33589, and while none of the alternatives
turned out to be the right solution, the underlying simplification of
the structure is helpful.

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

llvm-svn: 318141
2017-11-14 09:19:53 +00:00
Craig Topper 926b95c4dd [NewPassManager] Pass the -fdebug-pass-manager flag setting into the Analysis managers to match what we do in opt
Summary: Currently the -fdebug-pass-manager flag for clang doesn't enable the debug logging in the analysis managers. This is different than what the switch does when passed to opt.

Reviewers: chandlerc

Reviewed By: chandlerc

Subscribers: cfe-commits

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

llvm-svn: 318140
2017-11-14 08:48:28 +00:00
Chandler Carruth 77c8bb19db [PM] Require a registered x86 target for this test which uses the x86
triple.

llvm-svn: 318137
2017-11-14 05:20:03 +00:00
Chandler Carruth a8bd4e3816 [PM] Wire up support for the bounds checking sanitizer with the new PM.
Not much interesting here. Mostly wiring things together.

One thing worth noting is that the approach is substantially different
from the old PM. Here, the -O0 case works fundamentally differently in
that we just directly build the pipeline without any callbacks or other
cruft. In some ways, this is nice and clean. However, I don't like that
it causes the sanitizers to be enabled with different changes at
different times. =/ Suggestions for a better way to do this are welcome.

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

llvm-svn: 318131
2017-11-14 01:59:18 +00:00
Chandler Carruth afce44949a [PM] Add a missing header that I had in the next commit but was needed
in r318128. Should fix the build.

llvm-svn: 318130
2017-11-14 01:47:24 +00:00
Alex Lorenz f3df1f7bf1 [completion] complete ObjC interface names in an expression
Objective-C interfaces can be used in a class property expression.

rdar://26982192

llvm-svn: 318129
2017-11-14 01:46:24 +00:00
Chandler Carruth 00a301d568 [PM] Port BoundsChecking to the new PM.
Registers it and everything, updates all the references, etc.

Next patch will add support to Clang's `-fexperimental-new-pass-manager`
path to actually enable BoundsChecking correctly.

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

llvm-svn: 318128
2017-11-14 01:30:04 +00:00
Mandeep Singh Grang e66d232c05 [Sema] Stable sort OverloadCandidates to remove non-deterministic ordering
Summary: This fixes failure in Misc/diag-template-diffing.cpp uncovered by D39245.

Reviewers: rjmccall, rsmith

Reviewed By: rjmccall

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 318121
2017-11-14 00:22:24 +00:00
Zachary Turner faf04a09f6 Revert "Update test_debuginfo.pl script to point to new tree location."
This reverts the aforementioned patch and 2 subsequent follow-ups,
as some buildbots are still failing 2 tests because of it.
Investigation is ongoing into the cause of the failures.

llvm-svn: 318112
2017-11-13 23:33:29 +00:00
Hans Wennborg 656c8629e2 Update link to protobuf
llvm-svn: 318110
2017-11-13 23:27:55 +00:00
Hans Wennborg 5fd1f17370 Update a link to the old code.google.com bug tracker
llvm-svn: 318109
2017-11-13 23:27:54 +00:00
Hans Wennborg 6ad65fcd70 Update link to the Chromium Clang page
llvm-svn: 318108
2017-11-13 23:27:53 +00:00
Eugene Zelenko de0215ccf3 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318101
2017-11-13 23:01:27 +00:00
Matt Arsenault a5888a730d OpenCL: Assume inline asm is convergent
Already done for CUDA.

llvm-svn: 318098
2017-11-13 22:40:55 +00:00
Sanjay Patel 33f83995a8 [CodeGen] fix const-ness of cbrt and fma
cbrt() is always constant because it can't overflow or underflow. Therefore, it can't set errno.

fma() is not always constant because it can overflow or underflow. Therefore, it can set errno.
But we know that it never sets errno on GNU / MSVC, so make it constant in those environments.

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

llvm-svn: 318093
2017-11-13 22:11:49 +00:00
Mandeep Singh Grang 789b19a6b6 [clang] Remove redundant return [NFC]
Reviewers: rsmith, sfantao, mcrosier

Reviewed By: mcrosier

Subscribers: jholewinski, cfe-commits

Tags: #clang

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

llvm-svn: 318074
2017-11-13 19:29:31 +00:00
Devin Coughlin 5df6b94381 [analyzer] ObjCGenerics: Don't warn on cast conversions involving explicit cast
The ObjCGenerics checker warns on a cast when there is no subtyping relationship
between the tracked type of the value and the destination type of the cast. It
does this even if the cast was explicitly written. This means the user can't
write an explicit cast to silence the diagnostic.

This commit treats explicit casts involving generic types as an indication from
the programmer that the Objective-C type system is not rich enough to express
the needed invariant. On explicit casts, the checker now removes any existing
information inferred about the type arguments. Further, it no longer assumes
the casted-to specialized type because the invariant the programmer specifies
in the cast may only hold at a particular program point and not later ones. This
prevents a suppressing cast from requiring a cascade of casts down the
line.

rdar://problem/33603303

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

llvm-svn: 318054
2017-11-13 17:35:29 +00:00
Teresa Johnson 4cd016ab7c [ThinLTO] Handle -fdebug-pass-manager for backend invocations via clang
Recommit of r317951 and r317951 along with what I believe should fix
the remaining buildbot failures - the target triple should be specified
for both the ThinLTO pre-thinlink compile and backend (post-thinlink)
compile to ensure it is consistent.

Original description:
The LTO Config field wasn't being set when invoking a ThinLTO backend
via clang (i.e. for distributed builds).

llvm-svn: 318042
2017-11-13 15:38:33 +00:00
Uriel Korach 5b2b71d909 [X86] test/testn intrinsics lowering to IR. clang side
Change Header files of the intrinsics for lowering test and testn intrinsics to IR code.
Removed test and testn builtins from clang

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

llvm-svn: 318035
2017-11-13 12:50:52 +00:00
Jina Nahias aecd4f5f9d Change
// CHECK: shufflevector <8 x double> %0, <8 x double> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 8, i32 9>
To
// CHECK: shufflevector <8 x double> %{{.*}}, <8 x double> %{{.*}}, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 8, i32 9>
for fixing 318025 commit warning

Change-Id: Id48a1fe1f247fe6a0b84e7189f18d2e637678e79
llvm-svn: 318031
2017-11-13 11:41:41 +00:00
Gabor Horvath 5cfada60b4 [analyzer] Document the issue hash debugging facility
Differential Revision: https://reviews.llvm.org/D39543

llvm-svn: 318030
2017-11-13 11:13:02 +00:00
Jina Nahias dca979194d [x86][AVX512] Lowering shuffle i/f intrinsics to LLVM IR
This patch, together with a matching llvm patch (https://reviews.llvm.org/D38671), implements the lowering of X86 shuffle i/f intrinsics to IR.

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

Change-Id: I9b3c2f2b34323bd9ccb21d0c1832f848b88ec047
llvm-svn: 318025
2017-11-13 09:15:31 +00:00
Dave Lee bfb990b783 Fix AST matcher documentation typo
llvm-svn: 317993
2017-11-11 23:53:27 +00:00
Dave Lee 0934fdc3a5 Add ObjC exception statement AST matchers
Summary: Add AST matchers for Objective-C @throw, @try, @catch and @finally.

Reviewers: aaron.ballman, malcolm.parsons, alexshap, compnerd

Reviewed By: aaron.ballman

Subscribers: cfe-commits, klimek

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

llvm-svn: 317992
2017-11-11 22:46:15 +00:00
Michal Gorny 3495440e45 [python] [tests] Fix test_linkage for unique external linkage
Starting with r314037, anonymous namespaces no longer give
unique-external linkage to variables. However, this linkage can still be
achieved by using a type which is not exterally visible,
e.g. through being declared in an anonymous namespace but used outside
it. Fix the test to take advantage of that.

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

llvm-svn: 317986
2017-11-11 20:01:41 +00:00
Faisal Vali 1f3a2af902 Adjust r316292 - remove the anonymous union for sharing a bitfield in FunctionDecl.
The anonymous union did NOT save us storage, but instead behaved as if we added an additional integer data member to FunctionDecl.  

For additional context, the anonymous union renders the bit fields as non-adjacent and prevents them from sharing the same 'memory location' (i.e. bit-storage) by requiring the anonymous union object to be appropriately aligned.

This was confirmed through discussion with Richard Smith in Albuquerque (ISO C++ Meeting)

https://reviews.llvm.org/rL316292

llvm-svn: 317984
2017-11-11 18:02:29 +00:00
Richard Smith be49c048c1 [cxx_status] Add resolution of CWG issue 1581, since it's an important, visible change.
llvm-svn: 317983
2017-11-11 18:00:16 +00:00
Richard Smith 137f657031 [cxx_status] Update for moved Albuquerque papers.
llvm-svn: 317982
2017-11-11 17:54:46 +00:00
Gor Nishanov 04491bd8f3 [coroutines] Promote cleanup.dest.slot allocas to registers to avoid storing it in the coroutine frame
Summary:
We don't want to store cleanup dest slot saved into the coroutine frame (as some of the cleanup code may
access them after coroutine frame destroyed).

This is an alternative to https://reviews.llvm.org/D37093

It is possible to do this for all functions, but, cursory check showed that in -O0, we get slightly longer function (by 1-3 instructions), thus, we are only limiting cleanup.dest.slot elimination to coroutines.

Reviewers: rjmccall, hfinkel, eric_niebler

Reviewed By: eric_niebler

Subscribers: EricWF, cfe-commits

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

llvm-svn: 317981
2017-11-11 17:00:43 +00:00
Justin Lebar 7c56dfe441 [CUDA] Fix std::min on device side to return the min, not the max.
Summary:
How embarrassing.

This is tested in the test-suite -- fix to come there in a separate
patch.

Reviewers: tra

Subscribers: sanjoy, cfe-commits

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

llvm-svn: 317961
2017-11-11 01:25:44 +00:00
Jake Ehrlich c451cf240b Add CLANG_DEFAULT_OBJCOPY to allow Clang to use llvm-objcopy for dwarf fission
llvm-objcopy is getting to where it can be used in non-trivial ways
(such as for dwarf fission in clang). It now supports dwarf fission but
this feature hasn't been thoroughly tested yet. This change allows
people to optionally build clang to use llvm-objcopy rather than GNU
objcopy. By default GNU objcopy is still used so nothing should change.

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

llvm-svn: 317960
2017-11-11 01:15:41 +00:00
Teresa Johnson 93838a5bd1 Revert "[ThinLTO] Handle -fdebug-pass-manager for backend invocations via clang"
This reverts commit r317951 and r317952. The new test is aborting on
some bots and I'll need to investigate later.

llvm-svn: 317959
2017-11-11 01:06:41 +00:00
Richard Trieu 931638ecb6 Handle lambda captures of variable length arrays in profiling and printing.
From http://reviews.llvm.org/D4368 these cases were thought to not be reachable
and the checks removed before the rest of the code was committed in r216649.
However, these cases are reachable and the checks are added back.

llvm-svn: 317957
2017-11-11 00:54:25 +00:00
Eugene Zelenko b7d89107cd [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317953
2017-11-11 00:08:50 +00:00
Teresa Johnson 56def791bc Add x86-registered-target to REQUIRES for new test
Should fix test added in r317951.

llvm-svn: 317952
2017-11-11 00:05:39 +00:00
Teresa Johnson 140c1a0966 [ThinLTO] Handle -fdebug-pass-manager for backend invocations via clang
Summary:
The LTO Config field wasn't being set when invoking a ThinLTO backend
via clang (i.e. for distributed builds).

Reviewers: danielcdh

Subscribers: mehdi_amini, inglorion, eraman, cfe-commits

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

llvm-svn: 317951
2017-11-10 23:37:39 +00:00
Hans Wennborg 7bf8201009 Remove declaration of EmitMCountInstrumentation(). NFC
The definition was removed in r280355.

llvm-svn: 317944
2017-11-10 22:34:23 +00:00
Zachary Turner 4abbbcc199 Fix for skipped CMake configuration on debuginfo-tests.
This should have been part of the change to debuginfo-tests, but
it was left out.  This should get the buildbots green.

llvm-svn: 317931
2017-11-10 22:12:04 +00:00
Zachary Turner 0f2ce11df7 [debuginfo-tests] Make debuginfo-tests work in a standard configuration.
Previously, debuginfo-tests was expected to be checked out into
clang/test and then the tests would automatically run as part of
check-clang.  This is not a standard workflow for handling
external projects, and it brings with it some serious drawbacks
such as the inability to depend on things other than clang, which
we will need going forward.

The goal of this patch is to migrate towards a more standard
workflow.  To ease the transition for build bot maintainers,
this patch tries not to break the existing workflow, but instead
simply deprecate it to give maintainers a chance to update
the build infrastructure.

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

llvm-svn: 317925
2017-11-10 20:57:57 +00:00
Konstantin Zhuravlyov bfd6c1c016 AMDGPU: Add -mxnack/-mno-xnack options that set +/-xnack feature
Differential Revision: https://reviews.llvm.org/D39878

llvm-svn: 317917
2017-11-10 19:28:25 +00:00
Konstantin Zhuravlyov 8914a6d50e AMDGPU/NFC: Move getAMDGPUTargetFeatures to AMDGPU toolchain
Differential Revision: https://reviews.llvm.org/D39877

llvm-svn: 317909
2017-11-10 19:09:57 +00:00
Daniel Jasper 028d815e28 [clang-format] Handle leading comments in using declaration
This fixes clang-format internal assertion for the following code:

  /* override */ using std::string;

Patch by Igor Sugak. Thank you.

llvm-svn: 317901
2017-11-10 17:11:18 +00:00
Carlo Bertolli 8760acb8e3 [NFC] Pacify bbot for OpenMP 'teams distribute parallel for'
llvm-svn: 317898
2017-11-10 16:49:09 +00:00
Michal Gorny 084e43bfbf [python] [tests] Rewrite to use standard unittest module
Rewrite the tests from using plain 'assert' mixed with some nosetests
methods to the standard unittest module layout. Improve the code
to use the most canonical assertion methods whenever possible.

This has a few major advantages:

- the code uses standard methods now, resulting in a reduced number
of WTFs whenever someone with basic Python knowledge gets to read it,

- completely unnecessary dependency on nosetests is removed since
the standard library supplies all that is necessary for the tests
to run,

- the tests can be run via any test runner, including the one built-in
in Python,

- the failure output for most of the tests is improved from 'assertion
x == y failed' to actually telling the values.

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

llvm-svn: 317897
2017-11-10 16:44:12 +00:00
Carlo Bertolli 3808ff743e [OpenMP] Parse+Sema for copyin clause of 'teams distribute parallel for'
https://reviews.llvm.org/D39902

Simply leverage existing implementation and verify correct functioning with two regression tests.

llvm-svn: 317893
2017-11-10 16:05:00 +00:00
Alexey Bataev 77aed73c2d [OpenMP] diagnose assign to firstprivate const, patch by Joel E. Denny
Summary:
[OpenMP] diagnose assign to firstprivate const

Clang does not diagnose assignments to const variables declared
firstprivate.  Furthermore, codegen is broken such that, at run time,
such assignments simply have no effect.  For example, the following
prints 0 not 1:

int main() {
  const int i = 0;
  #pragma omp parallel firstprivate(i)
  { i=1; printf("%d\n", i); }
  return 0;
}

This commit makes these assignments a compile error, which is
consistent with other OpenMP compilers I've tried (pgcc 17.4-0, gcc
6.3.0).

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: cfe-commits

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

llvm-svn: 317891
2017-11-10 15:39:50 +00:00
Krasimir Georgiev 410ed245f6 [clang-format] Support python-style comments in text protos
Summary: This patch adds support for python-style comments in text protos.

Reviewers: djasper

Reviewed By: djasper

Subscribers: bkramer, cfe-commits, klimek

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

llvm-svn: 317886
2017-11-10 12:50:09 +00:00
Dean Michael Berris 46d0cd3413 Revert "[XRay][darwin] Initial XRay in Darwin Support"
This reverts r317875.

llvm-svn: 317877
2017-11-10 07:00:55 +00:00
Dean Michael Berris bfd111bca5 [XRay][darwin] Initial XRay in Darwin Support
Summary:
This change implements the changes required in both clang and
compiler-rt to allow building XRay-instrumented binaries in Darwin. For
now we limit this to x86_64. We also start building the XRay runtime
library in compiler-rt for osx.

A caveat to this is that we don't have the tests set up and running
yet, which we'll do in a set of follow-on changes.

This patch uses the monorepo layout for the coordinated change across
multiple projects.

Reviewers: kubamracek

Subscribers: mgorny, cfe-commits, llvm-commits

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

llvm-svn: 317875
2017-11-10 05:50:13 +00:00
Craig Topper b3d447356f [X86] Reduce the number of FMA builtins needed by the frontend by adding negates to operands of the fmadd and fmaddsub builtins.
The backend should be able to combine the negates to create fmsub, fnmadd, and fnmsub. faddsub converting to fsubadd still needs work I think, but should be very doable.

This matches what we already do for the masked builtins.

This only covers the packed builtins. Scalar builtins will be done after FMA4 is fixed.

llvm-svn: 317873
2017-11-10 05:20:32 +00:00
Steven Wu 9278019eb3 [Driver] Make clang/cc conforms to UNIX standard
Summary:
This is basically reverting r261774 with a tweak for clang-cl. UNIX
standard states:
When c99 encounters a compilation error that causes an object file not
to be created, it shall write a diagnostic to standard error and
continue to compile other source code operands, but it shall not perform
the link phase and it shall return a non-zero exit status

The same goes for c89 or cc. And they are all alias or shims pointing to
clang on Darwin.

The original commit was intended for CUDA so the error message doesn't
get emit twice for both host and device. It seems that the clang driver
has been changed to model the CUDA dependency differently. Now the
driver behaves the same without this commit.

rdar://problem/32223263

Reviewers: thakis, dexonsmith, tra

Reviewed By: tra

Subscribers: jlebar, cfe-commits

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

llvm-svn: 317860
2017-11-10 01:32:47 +00:00
Eugene Zelenko 8998f10e55 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317854
2017-11-10 00:59:22 +00:00
George Karpenkov 8ee82ed81b [analyzer] [NFC] Minor ExprEngineC refactoring
Move a repeated block of code into a function.

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

llvm-svn: 317849
2017-11-09 23:33:37 +00:00
George Karpenkov d860e7a6b8 [analyzer] do not crash when trying to convert an APSInt to an unexpected type
This is the issue breaking the postgresql bot, purely by chance exposed
through taint checker, somehow appearing after
https://reviews.llvm.org/D38358 got committed.

The backstory is that the taint checker requests SVal for the value of
the pointer, and analyzer has a "fast path" in the getter to return a
constant when we know that the value is constant.
Unfortunately, the getter requires a cast to get signedness correctly,
and for the pointer `void *` the cast crashes.

This is more of a band-aid patch, as I am not sure what could be done
here "correctly", but it should be applied in any case to avoid the
crash.

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

llvm-svn: 317839
2017-11-09 21:49:38 +00:00
Alex Lorenz 41856684c1 [index] tag declarations should use the decl role instead of ref
The 'decl' role is more canonical than the 'ref'. This helps us establish the
'specialization-of' relation just by looking at decls or defs.

rdar://31884960

llvm-svn: 317832
2017-11-09 20:50:59 +00:00
Michal Gorny fe5ae8e471 [python] [tests] Update priority values in code completion test
The priority for destructors and operators was reduced in r314019.
Adjust the values used in the test appropriately to fix the test
failure.

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

llvm-svn: 317828
2017-11-09 20:17:41 +00:00
George Karpenkov bbb66ad7b2 [analyzer] assume bitwise arithmetic axioms
Patches the solver to assume that bitwise OR of an unsigned value with a
constant always produces a value larger-or-equal than the constant, and
bitwise AND with a constant always produces a value less-or-equal than
the constant.

This patch is especially useful in the context of using bitwise
arithmetic for error code encoding: the analyzer would be able to state
that the error code produced using a bitwise OR is non-zero.

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

llvm-svn: 317820
2017-11-09 19:06:22 +00:00
Alexey Bataev 5d7edca316 [OPENMP] Codegen for `#pragma omp target parallel for simd`.
Added codegen for `#pragma omp target parallel for simd` and clauses.

llvm-svn: 317813
2017-11-09 17:32:15 +00:00
Alexey Bataev 9a5e64f56a [OPENMP] Treat '#pragma omp target parallel for simd' as simd directive.
`#pragma omp target parallel for simd` mistakenly was not treated as a
simd directive, fixed this problem.

llvm-svn: 317811
2017-11-09 17:01:35 +00:00
Ben Hamilton e5af5bde71 [VirtualFileSystem] InMemoryFileSystem::addFile(): Type and Perms
Summary:
This implements a FIXME in InMemoryFileSystem::addFile(), allowing
clients to specify User, Group, Type, and/or Perms when creating a
file in an in-memory filesystem.

New tests included. Ran tests with:

% ninja BasicTests && ./tools/clang/unittests/Basic/BasicTests

Fixes PR#35172 (https://bugs.llvm.org/show_bug.cgi?id=35172)

Reviewers: bkramer, hokein

Reviewed By: bkramer, hokein

Subscribers: alexfh

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

llvm-svn: 317800
2017-11-09 16:01:16 +00:00
Krasimir Georgiev d4102df9ad [clang-format] Keep Sphinx happy after r317794
llvm-svn: 317799
2017-11-09 15:54:59 +00:00
Krasimir Georgiev 818da9bb29 [clang-format] Sort using declarations by splitting on '::'
Summary: This patch improves using declarations sorting.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

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

llvm-svn: 317794
2017-11-09 15:41:23 +00:00
Krasimir Georgiev 1696bb6523 [clang-format] Apply a clang-tidy suggestion, NFC
llvm-svn: 317793
2017-11-09 15:12:17 +00:00
Krasimir Georgiev 112c2e96c8 [clang-format] Fix a clang-tidy finding, NFC
llvm-svn: 317784
2017-11-09 13:22:03 +00:00
Krasimir Georgiev 0fcb580bb1 [clang-format] Fix argument name comment, NFC
llvm-svn: 317783
2017-11-09 13:19:14 +00:00
Sam McCall 60d74e4588 [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.
Summary:
This is an alternative to JSONCompilationDatabase for simple projects that
don't use a build system such as CMake.
(You can also drop one in ~, to make your tools use e.g. C++11 by default)

There's no facility for varying flags per-source-file or per-machine.
Possibly this could be accommodated backwards-compatibly using cpp, but even if
not the simplicity seems worthwhile for the cases that are addressed.

Tested with clangd, works great! (requires clangd restart)

Reviewers: klimek

Subscribers: ilya-biryukov, cfe-commits

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

llvm-svn: 317777
2017-11-09 10:37:39 +00:00
John McCall 26d55e0346 Fix a bug with the use of __builtin_bzero in a conditional expression.
Patch by Bharathi Seshadri!

llvm-svn: 317776
2017-11-09 09:32:32 +00:00
Craig Topper e5b84ec2a1 [X86] Rename the VEX scalar fma builtins to end with a '3' to match gcc
I think we need to use different builtins for the FMA4 instructions since those instructions zero the upper bits and FMA3 instructions pass the bits through.

So this moves the existing builtins to be the FMA3 versions. New versions will be added for FMA4.

llvm-svn: 317766
2017-11-09 04:10:46 +00:00
Vedant Kumar f9a0d44eea [Coverage] Emit deferred regions in headers
There are some limitations with emitting regions in macro expansions
because we don't gather file IDs within the expansions. Fix the check
that prevents us from emitting deferred regions in expansions to make an
exception for headers, which is something we can handle.

rdar://35373009

llvm-svn: 317760
2017-11-09 02:33:40 +00:00
Vedant Kumar 8046d22a36 [Coverage] Complete top-level deferred regions before labels
The area immediately after a terminated region in the function top-level
should have the same count as the label it precedes.

This solves another problem with wrapped segments. Consider:

  1| a:
  2|   return 0;
  3| b:
  4|   return 1;

Without a gap area starting after the first return, the wrapped segment
from line 2 would make it look like line 3 is executed, when it's not.

rdar://35373009

llvm-svn: 317759
2017-11-09 02:33:39 +00:00
Vedant Kumar 2e8c875905 [Coverage] Emit a gap area after if conditions
The area immediately after the closing right-paren of an if condition
should have a count equal to the 'then' block's count. Use a gap region
to set this count, so that region highlighting for the 'then' block
remains precise.

This solves a problem we have with wrapped segments. Consider:

  1| if (false)
  2|   foo();

Without a gap area starting after the condition, the wrapped segment
from line 1 would make it look like line 2 is executed, when it's not.

rdar://35373009

llvm-svn: 317758
2017-11-09 02:33:38 +00:00
Alex Lorenz 343982316f Remove redundant copy-pasted comment in test file from r317736
llvm-svn: 317737
2017-11-08 22:47:15 +00:00
Alex Lorenz 1ee711633d [ObjC] Fix function signature handling for blocks literals with attributes
Block literals can have a type with attributes in its signature, e.g.
ns_returns_retained. The code that inspected the type loc of the block when
declaring its parameters didn't account for this fact, and only looked through
paren type loc. This commit ensures that getAsAdjusted is used instead of
IgnoreParens to find the block's FunctionProtoTypeLoc. This ensures that
block parameters are declared correctly in the block and avoids the
'undeclared identifier' error.

rdar://35416160

llvm-svn: 317736
2017-11-08 22:44:34 +00:00
Alex Lorenz 49370ac7e2 [ObjC] Boxed strings should use the nullability from stringWithUTF8String's return type
Objective-C NSString has a class method stringWithUTF8String that creates a new
NSString from a C string. Objective-C box expression @(...) can be used to
create an NSString instead of invoking the stringWithUTF8String method directly
(The compiler lowers it down to the invocation though). This commit ensures that
the type of @(string-value) gets the same nullability attributes as the return
type of stringWithUTF8String to ensure that the diagnostics are consistent
between the two.

rdar://33847186

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

llvm-svn: 317727
2017-11-08 21:33:15 +00:00
Alexey Bataev fb0ebecf0e [OPENMP] Codegen for `#pragma omp target parallel for`.
llvm-svn: 317719
2017-11-08 20:16:14 +00:00
David L. Jones db9d254c1a Add a missing "REQUIRES: system-windows" to a Windows-only test.
This un-breaks builds on other platforms. Otherwise, they fail due to warnings like:

warning: unable to find a Visual Studio installation; try running Clang from a developer command prompt [-Wmsvc-not-found]
llvm-svn: 317716
2017-11-08 20:03:11 +00:00
Marco Castelluccio a3efbb0836 Add CoreOption flag to "-coverage" option to make it available for clang-cl
Summary:
The -coverage option is not a CoreOption, so it is not available to clang-cl.
This patch adds the CoreOption flag to "-coverage" to allow it to be used with clang-cl.

Reviewers: rnk

Reviewed By: rnk

Subscribers: cfe-commits

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

llvm-svn: 317709
2017-11-08 19:21:54 +00:00
Masud Rahman cff22e5081 [bindings] fix TLS test failure
Since cfe commit r237337, '__declspec(thread)' and 'thread_local' have
been the same since MSVC 2015.  i.e. they are both considered to supply
a dynamic TLS kind, not a static TLS kind.

This test originally did not specify which version of MS compatibility
to assume.  As a result, the test was brittle, since changing the
default compatibility version could break the test.

This commit adds a specific version when building up the flags used to
parse the translation unit, and tests both versions.

llvm-svn: 317706
2017-11-08 19:17:27 +00:00
Artem Dergachev 5904fba8c9 [analyzer] Fix a crash on logical operators with vectors.
Do not crash when trying to compute x && y or x || y where x and y are
of a vector type.

For now we do not seem to properly model operations with vectors. In particular,
operations && and || on a pair of vectors are not short-circuit, unlike regular
logical operators, so even our CFG is incorrect.

Avoid the crash, add respective FIXME tests for later.

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

rdar://problem/34317663

llvm-svn: 317700
2017-11-08 17:27:58 +00:00
Haojian Wu f6c0678db7 [clang-refactor] Get rid of OccurrencesFinder in RenamingAction, NFC
Summary:
The OccurrencesFinder is only used in RenameOccurrences to find symbol
occurrences, there is no need to inherit RefactoringRule.

Replace it with a single utility function to avoid code misleading.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

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

llvm-svn: 317696
2017-11-08 14:53:08 +00:00
Ilya Biryukov 5df0d12733 Workaround reverse-iteration buildbot breakages. Filed PR35244.
Clang's completion output is non-deterministic, causing test failures
with turned on LLVM_REVERSE_ITERATION.
The workaround is to use CHECK-DAGs for now, will remove them when
PR35244 gets fixed.

llvm-svn: 317687
2017-11-08 13:05:52 +00:00
Ilya Biryukov b5da91c875 Avoid printing some redundant name qualifiers in completion
Summary:
Adjusted PrintingPolicy inside code completion to avoid printing some
redundant name qualifiers.

Before this change, typedefs that were written unqualified in source
code were printed with qualifiers in completion. For example, in the
following code

    struct foo {
        typedef int type;
        type method();
    };

completion item for `method` had return type of `foo::type`, even
though the original code used `type` without qualifiers.
After this change, the completion item has return type `type`, as
originally written in the source code.

Note that this change does not suppress qualifiers written by the
user. For example, in the following code

    typedef int type;
    struct foo {
        typedef int type;
        ::type method(foo::type);
    };

completion item for `method` has return type of `::type` and
parameter type of `foo::type`, as originally written in the source
code.

Reviewers: arphaman, bkramer, klimek

Reviewed By: arphaman

Subscribers: mgorny, eraman, cfe-commits

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

llvm-svn: 317677
2017-11-08 10:39:09 +00:00
Ilya Biryukov cc3cf58cd2 Moved QualTypeNames.h from Tooling to AST.
Summary:
For code reuse in SemaCodeComplete.
Note that the tests for QualTypeNames are still in Tooling as they use
Tooling's common testing code.

Reviewers: rsmith, saugustine, rnk, klimek, bkramer

Reviewed By: rnk

Subscribers: cfe-commits, mgorny

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

llvm-svn: 317676
2017-11-08 10:39:03 +00:00
Haojian Wu 200458f342 [clang-refactor] Introduce a new rename rule for qualified symbols
Summary: Prototype of a new rename rule for renaming qualified symbol.

Reviewers: arphaman, ioeric, sammccall

Reviewed By: arphaman, sammccall

Subscribers: jklaehn, cfe-commits, klimek

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

llvm-svn: 317672
2017-11-08 08:56:56 +00:00
Craig Topper 23a302256a [X86] Add masked vcvtps2ph builtins to CheckX86BuiltinFunctionCall.
This ensures that only immediates that fit in 8-bits are used. This matches what we do for the unmasked versions.

llvm-svn: 317664
2017-11-08 04:54:26 +00:00
Eugene Zelenko b8c9e2aae5 [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317648
2017-11-08 01:03:16 +00:00
Eugene Zelenko 0d00c89995 [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317644
2017-11-08 00:39:18 +00:00
Sriraman Tallam fe34d6d8cd Change noplt.c to work for non-x86 targets.
Differential Revision: https://reviews.llvm.org/D39759

llvm-svn: 317627
2017-11-07 22:34:55 +00:00
Justin Lebar da9e0bd3a2 [NVPTX] Implement __nvvm_atom_add_gen_d builtin.
Summary:
This just seems to have been an oversight.  We already supported the f64
atomic add with an explicit scope (e.g. "cta"), but not the scopeless
version.

Reviewers: tra

Subscribers: jholewinski, sanjoy, cfe-commits, llvm-commits, hiraditya

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

llvm-svn: 317623
2017-11-07 22:10:54 +00:00
Alex Lorenz bbe51d86ec [ObjC++] Don't warn about pessimizing move for __block variables
rdar://33316951

llvm-svn: 317620
2017-11-07 21:40:11 +00:00
Mitch Phillips 512fa40b3e Update SanitizerSpecialCaseList to use renamed functions in base class.
Note: This change has a cyclical dependency on D39485. Both these changes must be submitted at the same time to avoid a build breakage.

Reviewers: vlad.tsyrklevich

Subscribers: llvm-commits

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

llvm-svn: 317616
2017-11-07 21:16:37 +00:00
Sriraman Tallam 5c65148565 New clang option -fno-plt which avoids the PLT and lazy binding while making external calls.
Differential Revision: https://reviews.llvm.org/D39079

llvm-svn: 317605
2017-11-07 19:37:51 +00:00
Alex Lorenz f4bf4227b7 [refactor] rename field references in __builtin_offsetof
rdar://33875453

llvm-svn: 317599
2017-11-07 18:30:23 +00:00
George Rokos 065755d23d Clang/libomptarget map interface flag renaming - NFC patch
This patch renames some of the flag names of the clang/libomptarget map interface. The old names are slightly misleading, whereas the new ones describe in a better way what each flag is about.

Only the macros within the enumeration are renamed, there is no change in functionality therefore there are no updated regression tests.

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

llvm-svn: 317598
2017-11-07 18:27:04 +00:00
Alex Lorenz 1c628e3c3e [index] __builtin_offset's field reference is located at the end location
The starting location is the location of the '.'

llvm-svn: 317596
2017-11-07 18:25:36 +00:00
Alex Lorenz 7b760095cb [index] index field references in __builtin_offset
rdar://35109556

llvm-svn: 317593
2017-11-07 17:29:11 +00:00
Arnold Schwaighofer 612d693c64 SystemZ Swift TargetInfo: swifterror support in the backend is broken
Return false for swifterror support until the backend is fixed.

llvm-svn: 317589
2017-11-07 16:40:51 +00:00
Sanjay Patel 040fbe3027 [CodeGen] split math and complex tests into separate files; NFCI
The files are already large, and we may need to add even more RUNs to 
distinguish differences based on OS, environment, or other platform things.

llvm-svn: 317583
2017-11-07 15:13:22 +00:00
Eric Liu c47fd014ae [clang-refactor] Use ClangTool more explicitly by making refaroing actions AST frontend actions.
Summary: This is a refactoring change. NFC

Reviewers: arphaman, hokein

Reviewed By: arphaman, hokein

Subscribers: cfe-commits

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

llvm-svn: 317577
2017-11-07 14:35:03 +00:00
Artem Dergachev 0b5b1f14fd [analyzer] pr34779: CStringChecker: Accept non-standard headers.
Do not crash when trying to define and call a non-standard
strcpy(unsigned char *, unsigned char *) during analysis.

At the same time, do not try to actually evaluate the call.

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

llvm-svn: 317565
2017-11-07 10:51:15 +00:00
Sjoerd Meijer 167f2e34d5 [docs] Add section 'Half-Precision Floating Point'
This documents the differences/interactions between _Float16 and __fp16
and is a companion change for the _Float16 type implementation (r312794).

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

llvm-svn: 317558
2017-11-07 10:09:45 +00:00
George Karpenkov 166548c0dc [analyzer] [NFC] Remove unused typedef from SVals.h
Differential Revision: https://reviews.llvm.org/D39620

llvm-svn: 317537
2017-11-07 02:02:10 +00:00
Alex Lorenz 4e30b96834 Clarify the error message for unsupported aliases on Darwin
rdar://35109556

llvm-svn: 317532
2017-11-07 00:31:19 +00:00
Devin Coughlin 046833e5fb [analyzer] Model correct dispatch_once() 'done' value in BodyFarm
The analyzer's BodyFarm models dispatch_once() by comparing the passed-in
predicate against a known 'done' value. If the predicate does not have that
value, the model updates the predicate to have that value and executes the
passed in block.

Unfortunately, the current model uses the wrong 'done' value: 1 instead of ~0.
This interferes with libdispatch's static inline function _dispatch_once(),
which enables a fast path if the block has already been executed. That function
uses __builtin_assume() to tell the compiler that the done flag is set to ~0 on
exit. When r302880 added modeling of __builtin_assume(), this caused the
analyzer to assume 1 == ~0. This in turn caused the analyzer to never explore any code after a call to dispatch_once().

This patch regains the missing coverage by updating BodyFarm to use the correct
'done' value.

rdar://problem/34413048

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

llvm-svn: 317516
2017-11-06 22:12:19 +00:00
Dave Lee f96bedfce3 Vary Windows toolchain selection by -fuse-ld
Summary:
This change allows binutils to be used for linking with MSVC. Currently, when
using an MSVC target and `-fuse-ld=bfd`, the driver produces an invalid linker
invocation.

Reviewers: rnk, compnerd

Reviewed By: compnerd

Subscribers: smeenai, cfe-commits

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

llvm-svn: 317511
2017-11-06 21:18:05 +00:00
Craig Topper 57f96ac6dc [X86] Replace the mask cmpeq/cmple/cmplt/cmpgt/cmpge/cmpneq intrinsics with macros that just pass the right comparison predicate value to the regular cmp intrinsic. Remove mask cmpeq/cmpgt builtins that are now unused.
This shortens the intrinsic headers a little and allows us to get rid of the cmpeq and cmpgt handling from CGBuiltin.cpp.

llvm-svn: 317506
2017-11-06 21:00:49 +00:00
Martin Storsjo b438ea3f1c [X86] Add 3dnow and 3dnowa to the list of valid target features
These were missed in SVN r316783, which broke compiling mingw-w64 CRT.

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

llvm-svn: 317504
2017-11-06 20:33:13 +00:00
Jan Korous 06aa2aff7b [Parser] Fix TryParseLambdaIntroducer() error handling
rdar://35066196

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

llvm-svn: 317493
2017-11-06 17:42:17 +00:00
Sanjay Patel 401aaee300 [CodeGen] match new fast-math-flag method: isFast()
This corresponds to LLVM commiti r317488:

If that commit is reverted, this commit will also need to be reverted.

llvm-svn: 317489
2017-11-06 16:27:36 +00:00
Daniel Jasper bbf5f4ecbc [clang-format] Handle unary operator overload with arguments and specifiers
Before:
  int operator++(int)noexcept;

After:
  int operator++(int) noexcept;

Patch by Igor Sugak. Thank you!

llvm-svn: 317473
2017-11-06 12:11:51 +00:00
Eric Liu 190afe955c [Tooling] Test internal::createExecutorFromCommandLineArgsImpl instead of the wrapper.
llvm-svn: 317466
2017-11-06 09:29:09 +00:00
Jina Nahias 48e298b8c4 lowering broadcastm
Change-Id: I0661abea3e3742860e0a03ff9e4fcdc367eff7db
llvm-svn: 317456
2017-11-06 07:04:12 +00:00
Adrian Prantl 131ab94008 Remove \brief from doxygen comments in PrettyPrinter.h
Patch by @xsga!

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

llvm-svn: 317443
2017-11-05 21:52:36 +00:00
Johannes Altmanninger a584beb9d7 [clang-diff] NFC: format
llvm-svn: 317434
2017-11-05 11:53:18 +00:00
Roman Lebedev d9af8e1f98 [Sema] Document+test the -Wsign-conversion change for enums in C code [NFC]
Basically a regression after r316268.
However the diagnostic is correct, but the test coverage is bad.

So just like rL316500, introduce yet more tests,
and adjust the release notes.

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

llvm-svn: 317421
2017-11-04 20:27:47 +00:00
Aaron Ballman 3f8bad8626 Move the clang-tblgen-targets project into the Misc folder on IDEs like Visual Studio rather than leave it in the root directory. NFC.
llvm-svn: 317419
2017-11-04 20:06:49 +00:00
Aaron Ballman e89760cb29 Move the clang-tblgen project into the Clang tablegenning folder on IDEs like Visual Studio rather than leave it in the root directory. NFC.
llvm-svn: 317418
2017-11-04 20:06:22 +00:00
Aaron Ballman e7db01f0e0 Move the libclang-headers project into the Misc folder on IDEs like Visual Studio rather than leave it in the root directory. NFC.
llvm-svn: 317417
2017-11-04 20:00:21 +00:00
Sanjay Patel c919758075 [CodeGen] add remquo to list of recognized library calls
This is just an oversight because we already do recognize __builtin_remquo()
with the same signature.

http://en.cppreference.com/w/c/numeric/math/remquo
http://pubs.opengroup.org/onlinepubs/9699919799/functions/remquo.html

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

llvm-svn: 317407
2017-11-04 15:03:11 +00:00
Martell Malone b22e600484 CodeGenCXX: no default dllimport storage for mingw
GNU frontends don't have options like /MT, /MD
This fixes a few link error regressions with libc++ and libc++abi

Reviewers: rnk, mstorsjo, compnerd

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

llvm-svn: 317398
2017-11-04 02:15:49 +00:00
Martell Malone db5b34ce30 [Driver] MinGW: Remove custom linker detection
This is a re-apply of rL313082 which was reverted in rL313088

In rL289668 the ability to specify the default linker at compile time
was added but because the MinGW driver used custom detection we could
not take advantage of this new CMAKE flag CLANG_DEFAULT_LINKER.

rL289668 added no test cases and the mingw driver was either overlooked
or purposefully skipped because it has some custom linker tests
Removing them here because they are covered by the generic case.

Reviewers: rnk

Differntial Revision: https://reviews.llvm.org/D37727

llvm-svn: 317397
2017-11-04 02:07:59 +00:00
Richard Trieu 73cf924104 Update ODR hashing tests
Add a mix of postive and negative tests to check that wrong Decls won't be
flagged in the diagnostic.  Split the check everything test and moved the
pieces closer to where the related tests are.

llvm-svn: 317394
2017-11-04 01:20:50 +00:00
Eugene Zelenko 918e0ca77a [Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317381
2017-11-03 22:35:27 +00:00
Alex Lorenz 3cee7cfb30 Add -fcxx-exceptions for ExtractionSemicolonPolicy.cpp to appease PS4 bots
llvm-svn: 317372
2017-11-03 21:31:10 +00:00
Aaron Ballman 72f6563bb3 Replace a use of std::for_each() with llvm::for_each(); NFC.
llvm-svn: 317359
2017-11-03 20:09:17 +00:00
Alex Lorenz 3aae328318 Move Extract.cpp that wasn't moved in r317343
llvm-svn: 317344
2017-11-03 18:21:06 +00:00
Alex Lorenz ebbbb81266 [refactor][extract] insert semicolons into extracted/inserted code
when needed

This commit implements the semicolon insertion logic into the extract
refactoring. The following rules are used:

- extracting expression: add terminating ';' to the extracted function.
- extracting statements that don't require terminating ';' (e.g. switch): add
  terminating ';' to the callee.
- extracting statements with ';':  move (if possible) the original ';' from the
  callee and add terminating ';'.
- otherwise, add ';' to both places.

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

llvm-svn: 317343
2017-11-03 18:11:22 +00:00
Kostya Kortchinsky 8acdc98271 [Driver] Add Scudo as a possible -fsanitize= option
Summary:
This change adds Scudo as a possible Sanitizer option via -fsanitize=.
This allows for easier static & shared linking of the Scudo library, it allows
us to enforce PIE (otherwise the security of the allocator is moot), and check
for incompatible Sanitizers combo.

In its current form, Scudo is not compatible with any other Sanitizer, but the
plan is to make it work in conjunction with UBsan (-fsanitize=scudo,undefined),
which will require additional work outside of the scope of this change.

Reviewers: eugenis, kcc, alekseyshl

Reviewed By: eugenis, alekseyshl

Subscribers: llvm-commits, srhines

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

llvm-svn: 317337
2017-11-03 17:04:13 +00:00
Sanjay Patel 594d217502 [CodeGen] add libcall attr tests to show errno-related diffs; NFC
See rL317220 for the builtin siblings.

llvm-svn: 317336
2017-11-03 16:27:27 +00:00
Eric Liu 152ad05050 [Tooling] Fix linking of StandaloneToolExecutorPlugin.
llvm-svn: 317332
2017-11-03 15:57:27 +00:00
Eric Liu 6e6228477b [Tooling] Put createExecutorFromCommandLineArgs implementation in a wrapper. NFC
llvm-svn: 317328
2017-11-03 15:20:57 +00:00
Krasimir Georgiev c47fc31da1 [clang-format] Sort using-declarations case sensitively with a special case for '_'
Summary:
This makes clang-format sort using declarations case-sensitive with the
exception that '_' comes just before 'A'. This is better than the current case
insensitive version, because it groups uppercase names in the same namespace
together.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

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

llvm-svn: 317325
2017-11-03 14:38:07 +00:00
Erik Verbruggen 4d1eb2d5cb [preamble] Also record the "skipping" state of the preprocessor
When a preamble ends in a conditional preprocessor block that is being
skipped, the preprocessor needs to continue skipping that block when
the preamble is used.

This fixes PR34570.

llvm-svn: 317308
2017-11-03 09:40:07 +00:00
Justin Lebar 648f4cad52 [CUDA] Mark CUDA as a no-errno platform.
Summary:
CUDA doesn't support errno at all, so this is the right thing -- or at
least, in the right direction.

But also, this unbreaks the CUDA test-suite math tests [0] after D39481.
__cuda_cmath.h forwards nexttoward() to __builtin_nexttoward, which,
after that patch, was lowering to a libcall that doesn't exist in NVPTX.

[0] http://lab.llvm.org:8011/builders/clang-cuda-build/builds/14999

Reviewers: tra

Subscribers: sanjoy, cfe-commits

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

llvm-svn: 317297
2017-11-03 02:30:00 +00:00
Richard Smith e124612eda [c++17] Visit class template explicit specializations just like all other class definitions in codegen.
If an explicit specialization has a static data member, it may be a definition and we may need to register it for emission.

llvm-svn: 317296
2017-11-03 01:26:01 +00:00
George Karpenkov 85a34aa21e [analyzer] [NFC] very minor ExprEngineC refactoring
Differential Revision: https://reviews.llvm.org/D39577

llvm-svn: 317294
2017-11-03 00:41:29 +00:00
George Karpenkov 0354483013 [analyzer] do not crash on libcxx03 call_once implementation
Addresses https://bugs.llvm.org/show_bug.cgi?id=35075, rdar://35230961

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

llvm-svn: 317293
2017-11-03 00:36:03 +00:00
David Blaikie 1524e67feb Modular Codegen: Don't home always_inline functions
Since they'll likely (not always - if the address is taken, etc) be
inlined away, even at -O0, separately provided weak definitions are
likely to be unused so skip all of that.

llvm-svn: 317279
2017-11-02 22:28:50 +00:00
David Blaikie 0826729793 Modular Codegen: Don't home/modularize static functions in headers
Consistent with various workarounds in the backwards compatible modules
that allow static functions in headers to exist, be deduplicated to some
degree, and not generally fail right out of the gate... do the same with
modular codegen as there are enough cases (including in libstdc++ and in
LLVM itself - though I cleaned up the easy ones) that it's worth
supporting as a migration/backcompat step.

Simply create a separate, internal linkage function in each object that
needs it. If an available_externally/modularized function references a
static function, but the modularized function is eventually dropped and
not inlined, the static function will be dropped as unreferenced.

llvm-svn: 317274
2017-11-02 21:55:40 +00:00
Eugene Zelenko 4b3289e84f [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317273
2017-11-02 21:45:30 +00:00
Erich Keane a957ffbce3 Add default calling convention support for regcall.
Added support for regcall as default calling convention. Also added code to
exclude main when applying default calling conventions.

Patch-By: eandrews

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

llvm-svn: 317268
2017-11-02 21:08:00 +00:00
Sanjay Patel c5c8207eae [CodeGen] fix const-ness of builtin equivalents of <math.h> and <complex.h> functions that might set errno
This just makes const-ness of the builtins match const-ness of their lib function siblings. 
We're deferring fixing some of these that are obviously wrong to follow-up patches. 
Hopefully, the bugs are visible in the new test file (added at rL317220).

As the description in Builtins.def says: "e = const, but only when -fmath-errno=0".

This is step 2 of N to fix builtins and math calls as discussed in D39204.

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

llvm-svn: 317265
2017-11-02 20:39:26 +00:00
Alex Lorenz d44fdc2b66 revert r317228: remove unused function from ObjCRuntime.h, NFC
This function is actually used in LLDB

llvm-svn: 317231
2017-11-02 19:42:40 +00:00
Alex Lorenz a15c4deb7b remove unused function from ObjCRuntime.h, NFC
llvm-svn: 317228
2017-11-02 19:01:34 +00:00
Alexey Bataev 5d2c9a46fc [OPENMP] Fix PR35152: Do not use getInvokeDest() function for EH checks.
The compiler may crash under some conditions if the getInvokeDest() is
used, but later it is not used. Fixed this problem in OpenMP.

llvm-svn: 317227
2017-11-02 18:55:05 +00:00
Alex Lorenz 547e5ad0af [refactor][selection] canonicalize selected string literal to objc
string literal when possible

llvm-svn: 317224
2017-11-02 18:05:48 +00:00
Sanjay Patel 241b8f8fb0 [CodeGen] add builtin attr tests to show errno-related diffs; NFC
llvm-svn: 317220
2017-11-02 17:06:05 +00:00
Jan Korous c217b1b124 Fix comment typo
llvm-svn: 317216
2017-11-02 16:37:00 +00:00
Alexey Bataev 0e1b45897e [OPENMP] Fix PR35156: Get correct thread id with windows exceptions.
If the thread id is requested in windows mode within funclets, we may
generate incorrect function call that could lead to broken codegen.

llvm-svn: 317208
2017-11-02 14:25:34 +00:00
Jonas Hahnfeld 96087f3825 [OpenMP] Extend "Avoid VLAs for reduction" optimization to VLAs as base
We can generate constant sized arrays whenever the array section has constant
length, even if the base expression itself is a VLA.

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

llvm-svn: 317207
2017-11-02 13:30:42 +00:00
Eric Liu 35cbbdd9f4 Fix clang-format CLion integration bug.
CLion's Sax parser threw this error:

Failed to parse clang-format XML replacements. Input: <?xml version='1.0'?>
<replacements xml:space='preserve' incomplete_format='true' line=89>
[...]
[org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 66; Open quote is expected for attribute "line" associated with an  element type  "replacements".]

Patch by Justine Tunney (jart@google.com)!

llvm-svn: 317205
2017-11-02 12:48:48 +00:00
Jan Korous 205bcd0d54 Fix typo in class annotation
llvm-svn: 317200
2017-11-02 12:15:51 +00:00
Shoaib Meenai c37c747b2c [libclang] Add dummy libclang-headers target
`LLVM_DISTRIBUTION_COMPONENTS` assumes that each component has both
`component` and `install-component` targets. Add a dummy no-op target
for `libclang-headers` to placate this check.

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

llvm-svn: 317188
2017-11-02 05:04:00 +00:00
Shoaib Meenai 30e182d454 [clang-rename] Use add_clang_tool
`add_clang_tool` includes a call to `add_clang_executable`, but it also
sets up the install rule, and adds an `install-*` target. The latter is
required for using `LLVM_DISTRIBUTION_COMPONENTS`.

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

llvm-svn: 317150
2017-11-02 01:11:40 +00:00
Richard Smith f501759a85 PR33746: Store the 'inline'ness of a static data member with the update record
for instantiating its definition.

We model the 'inline'ness as being instantiated with the static data member in
order to track whether the declaration has become a definition yet.

llvm-svn: 317147
2017-11-02 01:06:00 +00:00
Saleem Abdulrasool 8f6d944721 CodeGen: simplify EH personality selection (NFC)
Fix a typo in the comment, reorder to ensure that the ordering matches
across the ObjC/ObjC++ cases.  NFCI.

llvm-svn: 317146
2017-11-02 00:25:40 +00:00
Richard Smith 4d629b8023 Fix missing -Wregister warning when 'register' is applied to a function parameter.
llvm-svn: 317140
2017-11-01 23:38:37 +00:00
Eugene Zelenko 06becf8f99 [ASTMatchers] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317137
2017-11-01 23:09:49 +00:00
Krasimir Georgiev 87b42549ee [clang-format] Make parseUnaryOperator non-recursive, NFCI
Summary:
This patch makes the implementation of parseUnaryOperator non-recursive. We had
a problem with a file starting with tens of thousands of +'es and -'es which
caused clang-format to stack overflow.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

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

llvm-svn: 317113
2017-11-01 18:20:41 +00:00
NAKAMURA Takumi 1657f2ad99 Fix warnings discovered by rL317076. [-Wunused-private-field]
llvm-svn: 317091
2017-11-01 13:47:55 +00:00
NAKAMURA Takumi c206e449cc Reformat.
llvm-svn: 317089
2017-11-01 13:47:48 +00:00
Richard Smith a31174efe0 Fix -Wunused-private-field to fire regardless of which implicit special members have been implicitly declared.
llvm-svn: 317076
2017-11-01 04:52:12 +00:00
NAKAMURA Takumi 057a942d9e clang/lib/Format/Format.cpp: Fix warnings introduced in rL316903. [-Wpedantic]
llvm-svn: 317075
2017-11-01 04:43:22 +00:00
Richard Trieu 7f932dd063 Change assertion to quick exit from checking function.
Remove the assertion that could be triggered by invalid code.  Replace it with
an early exit from the checking function.

llvm-svn: 317073
2017-11-01 03:57:27 +00:00
George Karpenkov 050b53b311 [analyzer] Removing unused stored field.
llvm-svn: 317070
2017-11-01 02:29:04 +00:00
Craig Topper a2b907a469 [X86] Define i586 and pentium preprocessor defines for -march=lakemont to match GCC
llvm-svn: 317069
2017-11-01 02:18:49 +00:00
Richard Smith 5173136a96 [c++17] Refine resolution of constructor / conversion function disambiguation.
Given a choice between a constructor call and a conversion function in C++17,
we prefer the constructor for direct-initialization and the conversion function
for copy-initialization, matching the behavior in C++14 and before. The
guaranteed copy elision rules were not intended to change the meaning of such
code (other than by removing unnecessary copy constructor calls).

This tweak will be raised with CWG.

llvm-svn: 317066
2017-11-01 01:37:11 +00:00
George Karpenkov ed017b634c [Analyzer] Use value storage for BodyFarm
Differential Revision: https://reviews.llvm.org/D39428

llvm-svn: 317065
2017-11-01 01:36:01 +00:00
Alex Lorenz 61f2c3f58c [refactor][extract] code extracted from inline method should be placed
in a function defined before the outer class

llvm-svn: 317062
2017-11-01 01:12:56 +00:00
Alex Lorenz 1e416fe23d [refactor][extract] prohibit extraction of ObjC property setters
llvm-svn: 317056
2017-11-01 00:20:55 +00:00
Alex Lorenz 7cd48cd8a9 [refactor][selection] code ranges can be selected in objc methods
llvm-svn: 317054
2017-11-01 00:07:12 +00:00
Wolfgang Pieb 173b47ca05 Making a couple of tests a bit more flexible wrt thunk mangling. Fixes checkin for r317047.
llvm-svn: 317053
2017-11-01 00:01:20 +00:00
Benjamin Kramer 0e71fd1957 Make helper function static. NFC.
llvm-svn: 317052
2017-10-31 23:23:36 +00:00
Wolfgang Pieb a347c47f5d Fix for PR33930. Short-circuit metadata mapping when cloning a varargs thunk.
The cloning happens before all metadata nodes are resolved. Prevent the value
mapper from running into unresolved or temporary MD nodes.

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

llvm-svn: 317047
2017-10-31 22:49:48 +00:00
Vlad Tsyrklevich 634c601fe3 [CFI] Add CFI-icall pointer type generalization
Summary:
This change allows generalizing pointers in type signatures used for
cfi-icall by enabling the -fsanitize-cfi-icall-generalize-pointers flag.
This works by 1) emitting an additional generalized type signature
metadata node for functions and 2) llvm.type.test()ing for the
generalized type for translation units with the flag specified.

This flag is incompatible with -fsanitize-cfi-cross-dso because it would
require emitting twice as many type hashes which would increase artifact
size.

Reviewers: pcc, eugenis

Reviewed By: pcc

Subscribers: kcc

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

llvm-svn: 317044
2017-10-31 22:39:44 +00:00
Vitaly Buka 1efe7740ce [clang-fuzzer] Fix incremental builds of the fuzzer
Summary:
Don't use BUILD_IN_SOURCE keep git checkout clean
Don't forward CMAKE_GENERATOR as ExternalProject_Add should do it already
Reset UPDATE_COMMAND to avoid git checkout updates on each build

Reviewers: kcc, morehouse

Subscribers: cfe-commits, mgorny

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

llvm-svn: 317035
2017-10-31 20:49:57 +00:00
Richard Smith fd62945d36 Fix usage of right shift operator in fold expressions
The right shift operator was not seen as a valid operator in a fold expression, which is PR32563.

Patch by Nicolas Lesser ("Blitz Rakete")!

llvm-svn: 317032
2017-10-31 20:29:22 +00:00
Sanjay Patel 7cb25a888c [CodeGen] map sqrt libcalls to llvm.sqrt when errno is not set
The LLVM sqrt intrinsic definition changed with:
D28797
...so we don't have to use any relaxed FP settings other than errno handling.

This patch sidesteps a question raised in PR27435:
https://bugs.llvm.org/show_bug.cgi?id=27435

Is a programmer using __builtin_sqrt() invoking the compiler's intrinsic definition of sqrt or the mathlib definition of sqrt?

But we have an answer now: the builtin should match the behavior of the libm function including errno handling.

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

llvm-svn: 317031
2017-10-31 20:19:39 +00:00
Ivan A. Kosarev b9c59f36fc [CodeGen] Propagate may-alias'ness of lvalues with TBAA info
This patch fixes various places in clang to propagate may-alias
TBAA access descriptors during construction of lvalues, thus
eliminating the need for the LValueBaseInfo::MayAlias flag.

This is part of D38126 reworked to be a separate patch to
simplify review.

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

llvm-svn: 316988
2017-10-31 11:05:34 +00:00
Alex Lorenz b87b6bf73a [refactor] select the entire DeclStmt if one ifs decls is selected
llvm-svn: 316971
2017-10-31 01:28:17 +00:00
Alex Lorenz c38ba6697f Typo correct the condition of 'do-while' before exiting its scope
rdar://35172419

llvm-svn: 316966
2017-10-30 22:55:11 +00:00
Richard Smith a544c51e94 [modules] Retain multiple using-directives in the same scope even if they name the same namespace.
They might have different visibility, and thus discarding all but one of them
can result in rejecting valid code. Also fix name lookup to cope with multiple
using-directives being found that denote the same namespace, where some are not
visible -- don't cache an "already visited" state for a using-directive that we
didn't visit because it was hidden.

llvm-svn: 316965
2017-10-30 22:38:20 +00:00
George Karpenkov 0c3a7c2015 [analyzer] Use the same filename for the header and the implementation of BugReporterVisitor
Differential Revision: https://reviews.llvm.org/D37935

llvm-svn: 316963
2017-10-30 22:31:57 +00:00
George Karpenkov 3c128cb1e6 [analyzer] [tests] Remove empty folders in reference results, do not store diffs.txt
Storing diffs.txt is now redundant, as we simply dump the CmpRuns output
to stdout (it is saved in CI and tends to be small).
Not generating those files enables us to remove empty folders, which
confuse git, as it would not add them with reference results.

llvm-svn: 316948
2017-10-30 19:40:33 +00:00
Richard Smith 849e7da8b7 Undo accidental language mode change in this test.
llvm-svn: 316936
2017-10-30 18:06:18 +00:00
Richard Smith 70a81b1e8b Add a test to make sure that -Wdeprecated doesn't warn on use of 'throw()' in system headers (deprecated in C++17).
llvm-svn: 316935
2017-10-30 18:05:10 +00:00
Gabor Horvath 4581f7497b [analyzer] Left shifting a negative value is undefined
The analyzer did not return an UndefVal in case a negative value was left
shifted. I also altered the UndefResultChecker to emit a clear warning in this
case.

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

llvm-svn: 316924
2017-10-30 17:06:42 +00:00
Krasimir Georgiev 7f64fa8022 [clang-format] Handle CRLF correctly when formatting escaped newlines
Subscribers: klimek

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

Contributed by @peterbudai!

llvm-svn: 316910
2017-10-30 14:41:34 +00:00
Yaxun Liu 561ac06ff2 CodeGen: Fix insertion position of addrspace cast for alloca
For non-zero alloca addr space, alloca is usually casted to default addr
space immediately.

For non-vla, alloca is inserted at AllocaInsertPt, therefore the addr
space cast should also be insterted at AllocaInsertPt. However,
for vla, alloca is inserted at the current insertion point of IRBuilder,
therefore the addr space cast should also inserted at the current
insertion point of IRBuilder.

Currently clang always insert addr space cast at AllocaInsertPt, which
causes invalid IR.

This patch fixes that.

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

llvm-svn: 316909
2017-10-30 14:38:30 +00:00