Commit Graph

71138 Commits

Author SHA1 Message Date
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