Commit Graph

65880 Commits

Author SHA1 Message Date
Alex Lorenz 84ebbdaf40 NFC: CodeCompletionResult's constructor should take const NamedDecl
CodeCompletionResult's Declaration field is a const pointer to the
NamedDecl, and thus the constructor should take a const pointer as well.

llvm-svn: 284019
2016-10-12 15:33:35 +00:00
Javed Absar c7d16f4e05 [ARM] Fix - missing target-cpu in test
Fixes an incomplete test, wherein the target-cpu name (cortex-r52) was missing.

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

llvm-svn: 284009
2016-10-12 12:13:55 +00:00
Vassil Vassilev bb8fe3175a Reinstate r283887 and r283882.
Original message:
"[modules] PR28752: Do not instantiate variable declarations which are not visible.

https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!"

llvm-svn: 284008
2016-10-12 11:57:08 +00:00
Alex Lorenz 06cfa99268 [CodeCompletion] Show protocol properties that are accessed through qualified id
This commit improves code completion for properties that are declared in
Objective-C protocols by making sure that properties show up in completions
when they are accessed through a qualified id.

rdar://24426041

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

llvm-svn: 284007
2016-10-12 11:40:15 +00:00
Alex Lorenz 757a69b760 [Sema] Handle transparent_union attributes in C mode only
This commit marks the transparent_union attributes as C only because clang
doesn't support them in C++ mode. Prior to this commit, clang still tried to
verify these attributes in C++, leading to crashes when analyzing templated
transparent_union unions that have dependent field types. This commit ensures
that such crashes won't happen again.

As a result of this commit clang now displays a warning every time it encounters
a transparent_union attribute in C++ mode.

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

llvm-svn: 283995
2016-10-12 09:36:35 +00:00
Artem Belevich 89997ecd8f Added REQUIRED triples to the test that fails on some ARM buildbots.
llvm-svn: 283964
2016-10-12 02:08:08 +00:00
Justin Lebar 0254c46300 [CUDA] Make touching a kernel from a __host__ __device__ function a deferred error.
Previously, this was an immediate, don't pass go, don't collect $200
error.  But this precludes us from writing code like

  __host__ __device__ void launch_kernel() {
    kernel<<<...>>>();
  }

Such code isn't wrong, following our notions of right and wrong in CUDA,
unless it's codegen'ed.

llvm-svn: 283963
2016-10-12 01:30:08 +00:00
Mike Edwards f4bab7eb66 Revert - When optimizing for size, enable loop rerolling by default
This reverts r283685 as it is causing test failures on Green Dragon.

llvm-svn: 283950
2016-10-11 22:09:13 +00:00
Vedant Kumar f1ccf72d38 [Profile] Update testcase for r283948 (NFC)
Old: "__DATA,__llvm_prf_data"
New: "__DATA,__llvm_prf_data,regular,live_support"

This should fix the following bot failure:

  http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/55158

llvm-svn: 283949
2016-10-11 21:56:05 +00:00
Manman Ren a58f92f09d Module: for ObjectiveC, be consistent when checking hidden decls.
In MatchAllMethodDeclarations, when checking a hidden decl, be sure
to allow hidden when searching for methods.

rdar://28699972

llvm-svn: 283943
2016-10-11 21:18:20 +00:00
Arnold Schwaighofer 5bb08d8f5a Swift Calling Convention: Parameters are allowed after the
swift_error/swift_context parameter

We need to be able to decelare witness functions which append the self type and
the self witness tables at the end of the parameter list.

rdar://28720996

llvm-svn: 283933
2016-10-11 20:34:06 +00:00
Arnold Schwaighofer 5d2c510cf6 Pass the end of a component to SwiftAggLowering's enumerateComponents callback
This is usefull for determining whether components overlap.

llvm-svn: 283932
2016-10-11 20:34:03 +00:00
Mehdi Amini 7186a4323e Revert "Change Builtins name to be stored as StringRef instead of raw pointers (NFC)"
This reverts commit r283802. It introduces temporarily static
initializers, because StringRef ctor isn't (yet) constexpr for
string literals.
I plan to get there this week, but apparently GCC is so terrible
with these static initializer right now (10 min+ extra codegen
time was reported) that I'll hold on to this patch till the
constexpr one is ready, and land these at the same time.

llvm-svn: 283920
2016-10-11 19:04:24 +00:00
Bruno Cardoso Lopes c9fb1ff192 [Driver] Use -fsyntax-only in test/Driver/show-option-names.c
Make the test less expensive, follow up from r283915.

llvm-svn: 283917
2016-10-11 18:38:33 +00:00
Bruno Cardoso Lopes b81cf735c3 [Driver] Fix test from r283913 to unbreak bots
Followup from r283913 & r283827

http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/55135

llvm-svn: 283915
2016-10-11 18:31:45 +00:00
Bruno Cardoso Lopes 76952a76e5 Reapply [Driver][Diagnostics] Make 'show option names' default for driver warnings
Reapply r283827 by fixing the tests to not be target specific

Currently, driver level warnings do not show option names (e.g. warning:
complain about foo [-Woption-name]) in a diagnostic unless
-fdiagnostics-show-option is explictly specified. OTOH, the driver by
default turn this option on for CC1. Change the logic to show option
names by default in the driver as well.

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

rdar://problem/27300909

llvm-svn: 283913
2016-10-11 18:21:26 +00:00
Justin Lebar 49ec14692a [CUDA] Re-land support for <complex> (r283683 and r283680).
These were reverted in r283753 and r283747.

The first patch added a header to the root 'Headers' install directory,
instead of into 'Headers/cuda_wrappers'.  This was fixed in the second
patch, but by then the damage was done: The bad header stayed in the
'Headers' directory, continuing to break the build.

We reverted both patches in an attempt to fix things, but that still
didn't get rid of the header, so the Windows boostrap build remained
broken.

It's probably worth fixing up our cmake logic to remove things from the
install dirs, but in the meantime, re-land these patches, since we
believe they no longer have this bug.

llvm-svn: 283907
2016-10-11 17:36:03 +00:00
Reid Kleckner 25717350e5 Fix the build with MSVC 2013 after r283856
llvm-svn: 283906
2016-10-11 17:24:09 +00:00
Zachary Turner 3c8609278b Fix clang-offload-bundler test.
A recent change to llvm::cl slightly changed the format of
the help output, and it broke this test.  NFC

llvm-svn: 283895
2016-10-11 16:06:32 +00:00
Yaxun Liu a91da4ba47 [OpenCL] Allow partial initializer for array and struct
Currently Clang allows partial initializer for C99 but not for OpenCL, e.g.

float a[16][16] = {1.0f, 2.0f};

is allowed in C99 but not allowed in OpenCL.

This patch fixes that.

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

llvm-svn: 283891
2016-10-11 15:53:28 +00:00
Vassil Vassilev f6b491041f Revert r283887 and r283882, until the issue is understood and fixed.
llvm-svn: 283890
2016-10-11 15:51:06 +00:00
Mehdi Amini 1c9ff96668 Use StringRef instead of raw pointer in SourceManagerInternals LineTableInfo API (NFC)
llvm-svn: 283888
2016-10-11 15:15:32 +00:00
Vassil Vassilev a9903747e8 r283882 followup. Don't demote ParmVarDecls. This should fix our module builds.
llvm-svn: 283887
2016-10-11 15:09:26 +00:00
Vassil Vassilev 4b3e7388d1 [modules] PR28752: Do not instantiate variable declarations which are not visible.
https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!

llvm-svn: 283882
2016-10-11 13:57:36 +00:00
Renato Golin 93d683fc2e Revert "[Driver][Diagnostics] Make 'show option names' default for driver warnings"
This reverts commit r283827, as it's breaking all ARM/AARch64 bots.

llvm-svn: 283868
2016-10-11 10:26:33 +00:00
Manuel Klimek a5cf51f2dc Delete clang-completion-mode.el.
It has been unmaintained for a while (last change was more than four
years ago), and it appears not widely used.
By now there are multiple well-maintained alternatives (emacs-ycmd,
atuo-complete-clang), and if users try to make this work they'll likely
have a bad user experience.

Reasoning and problems pointed out by Philipp Stephani.

llvm-svn: 283864
2016-10-11 09:25:34 +00:00
Mehdi Amini 0df59d8c02 Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)
llvm-svn: 283856
2016-10-11 07:31:29 +00:00
Daniel Jasper 96bbd2394d Explicitly ignore return code in test for test systems that use pipefail
llvm-svn: 283853
2016-10-11 06:13:18 +00:00
Hal Finkel a898370c4d Fixup test/Driver/opt-record.c for nvptx pointer size
On some systems, it looks like nvptx is used instead of nvptx64.

llvm-svn: 283839
2016-10-11 01:05:45 +00:00
Hal Finkel 8f96e82cb8 Add an option to save the backend-produced YAML optimization record to a file
The backend now has the capability to save information from optimizations, the
same information that can be used to generate optimization diagnostics but in
machine-consumable form, into an output file. This can be enabled when using
opt (see r282539), and this change enables it when using clang. The idea is
that other tools will be able to consume these files, and perhaps in
combination with the original source code, produce various kinds of
optimization reports for users (and for compiler developers).

We now have at-least two tools that can consume these files:
  * tools/llvm-opt-report
  * utils/opt-viewer

Using the flag -fsave-optimization-record will cause the YAML file to be
generated; the file name will be based on the output file name (if we're using
-c or -S and have an output name), or the input file name. When we're using
CUDA, or some other offloading mechanism, separate files are generated for each
backend target. The output file name can be specified by the user using
-foptimization-record-file=filename.

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

llvm-svn: 283834
2016-10-11 00:26:09 +00:00
Justin Lebar 4043ca7394 [Sema] Add explicit move constructor for ExpressionEvaluationContextRecord.
This is needed to keep MSVC 2013 happy.

llvm-svn: 283833
2016-10-11 00:23:53 +00:00
Richard Smith f75dcbef20 Aligned allocation versus CUDA: make deallocation function preference order
match other CUDA preference orders, per discussion with jlebar. We now model
this in an attempt to match overload resolution as closely as possible:

- First, we throw out all non-callable (due to CUDA host/device mismatch)
  operator delete functions.
- Then we apply sizedness / alignedness preferences based on whether the type
  is overaligned and whether the deallocation function is a member.
- Finally, we use the CUDA callability preference as a tiebreaker.

llvm-svn: 283830
2016-10-11 00:21:10 +00:00
Bruno Cardoso Lopes 8838db8a9d [Driver][Diagnostics] Make 'show option names' default for driver warnings
Currently, driver level warnings do not show option names (e.g. warning:
complain about foo [-Woption-name]) in a diagnostic unless
-fdiagnostics-show-option is explictly specified. OTOH, the driver by
default turn this option on for CC1. Change the logic to show option
names by default in the driver as well.

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

rdar://problem/27300909

llvm-svn: 283827
2016-10-11 00:01:22 +00:00
Mehdi Amini 004b9c7aae Store FileEntry::Filename as a StringRef instead of raw pointer (NFC)
llvm-svn: 283815
2016-10-10 22:52:47 +00:00
Adrian Prantl e941fc1964 [Driver] Let -gline-tables-only win when it comes after -gmodules.
The -gmodules option is all about putting debug type info into clang
modules and for line tables the type information is irrelevant, so
combining these two options makes no sense.
This commmit fixes the behavior to match the one  documented on the
clang man page: the last -g... option wins.

<rdar://problem/27059770>

llvm-svn: 283810
2016-10-10 21:56:20 +00:00
Mehdi Amini b1bdc47309 Change Builtins name to be stored as StringRef instead of raw pointers (NFC)
llvm-svn: 283802
2016-10-10 21:34:29 +00:00
Vitaly Buka a77ac1b214 Add -fno-sanitize-address-use-after-scope flag
Reviewers: eugenis

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

llvm-svn: 283801
2016-10-10 21:31:50 +00:00
Nick Lewycky 6fdfaedd9d Make the LValue created in EmitValueForIvarAtOffset have the same Qualifiers in the LValue as the QualType in the LValue. No functionality change intended.
llvm-svn: 283795
2016-10-10 20:07:13 +00:00
Albert Gutowski fcea61c563 Implement MS read/write barriers and __faststorefence intrinsic
Reviewers: hans, rnk, majnemer

Subscribers: cfe-commits

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

llvm-svn: 283793
2016-10-10 19:40:51 +00:00
Justin Lebar 76d4defe41 [AST] Don't use make_pointee_iterator in VTableBuilder.
Our implementation of make_pointee_iterator seems to be causing MSVC
2015 to crash, so I'm going to remove it.

llvm-svn: 283790
2016-10-10 19:26:22 +00:00
Richard Smith b2f0f05742 Re-commit r283722, reverted in r283750, with a fix for a CUDA-specific use of
past-the-end iterator.

Original commit message:

P0035R4: Semantic analysis and code generation for C++17 overaligned
allocation.

llvm-svn: 283789
2016-10-10 18:54:32 +00:00
Albert Gutowski 7216f17653 Implement __emul, __emulu, _mul128 and _umul128 MS intrinsics
Reviewers: rnk, thakis, majnemer, hans

Subscribers: cfe-commits

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

llvm-svn: 283785
2016-10-10 18:09:27 +00:00
Justin Lebar b89d85fec0 [Examples] Fix use of sema.LateParsedTemplateMap in clang/examples.
llvm-svn: 283778
2016-10-10 16:41:00 +00:00
Mehdi Amini ce2da5e143 Use StringRef in LangOptions::isNoBuiltinFunc API (NFC)
llvm-svn: 283776
2016-10-10 16:34:07 +00:00
Justin Lebar 5f3d1dc44c [Analysis] Use unique_ptr for CallGraph::FunctionMap.
Reviewers: timshen

Subscribers: cfe-commits

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

llvm-svn: 283775
2016-10-10 16:26:48 +00:00
Justin Lebar 5cb35e1676 [Analysis] Use unique_ptr in AnalyaisDeclContextManager's ContextMap.
Reviewers: timshen

Subscribers: cfe-commits

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

llvm-svn: 283774
2016-10-10 16:26:44 +00:00
Justin Lebar 82380d8eb4 [AST] Convert Marshallers to use unique_ptr.
Reviewers: timshen

Subscribers: cfe-commits, klimek

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

llvm-svn: 283773
2016-10-10 16:26:40 +00:00
Justin Lebar 03b0620192 Use unique_ptr for VTableBuilder::VBaseInfo map.
Reviewers: timshen

Subscribers: cfe-commits

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

llvm-svn: 283772
2016-10-10 16:26:36 +00:00
Justin Lebar e920cfadf0 Use unique_ptr for VTableBuilder::VFTableLayouts map.
Reviewers: timshen

Subscribers: cfe-commits

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

llvm-svn: 283771
2016-10-10 16:26:33 +00:00
Justin Lebar 562914e505 Use unique_ptr for VPtrLocationsMap and VPtrInfoVector.
Reviewers: timshen

Subscribers: cfe-commits

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

llvm-svn: 283770
2016-10-10 16:26:29 +00:00
Justin Lebar 072f9ba99a [AST] Use unique_ptr for VTableLayout.
Reviewers: timshen

Subscribers: cfe-commits

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

llvm-svn: 283769
2016-10-10 16:26:24 +00:00
Justin Lebar 20ebffc99a [AST] Convert MangleNumberingContext to a unique_ptr.
Summary: It doesn't need to be refcounted anymore, either.

Reviewers: timshen

Subscribers: cfe-commits

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

llvm-svn: 283768
2016-10-10 16:26:19 +00:00
Justin Lebar 28f09c50e2 [Sema] Use unique_ptr instead of raw pointers in the late-parsed templates map.
Summary:
This is possible now that MapVector supports move-only values.

Depends on D25404.

Reviewers: timshen

Subscribers: cfe-commits

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

llvm-svn: 283766
2016-10-10 16:26:08 +00:00
Eric Fiselier 7ae80c6396 [Sema] Prevent using member declaration diagnostic if the base class is invalid.
Summary:
Once a base class has been made invalid (by a static_assert for example) all using-member declarations in the derived classes will result in a "not a base class" diagnostic. This diagnostic is very misleading and should not be emitted.

This change is needed to help libc++ produce reasonable diagnostics in `std::optional` and `std::variant`.  

Reviewers: rsmith, majnemer, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 283755
2016-10-10 14:26:40 +00:00
Nico Weber 21b9c7a6dc Revert r283683 because r283680 got reverted.
llvm-svn: 283753
2016-10-10 14:20:35 +00:00
Daniel Jasper e9abe64816 Revert "P0035R4: Semantic analysis and code generation for C++17 overaligned allocation."
This reverts commit r283722. Breaks:
  Clang.SemaCUDA.device-var-init.cu
  Clang.CodeGenCUDA.device-var-init.cu

http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/884/

llvm-svn: 283750
2016-10-10 14:13:55 +00:00
Nico Weber 67dd74ef89 Revert r283680.
Breaks bootstrap builds on (at least) Windows:
In file included from D:\buildslave\clang-x64-ninja-win7\llvm\lib\Support\Allocator.cpp:14:
In file included from D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/Support/Allocator.h:24:
In file included from D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/SmallVector.h:20:
In file included from D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/Support/MathExtras.h:19:
D:\buildslave\clang-x64-ninja-win7\stage1.install\bin\..\lib\clang\4.0.0\include\algorithm(63,8) :
    error: unknown type name '__device__'
    inline __device__ const __T &

llvm-svn: 283747
2016-10-10 14:10:00 +00:00
Michal Gorny 7cfe480122 [Driver] Make -print-libgcc-file-name print compiler-rt lib when used
Make the -print-libgcc-file-name option print an appropriate compiler
runtime library, that is libgcc.a if gcc runtime is used
and an appropriate compiler-rt library if that runtime is used.

The main use for this is to allow linking executables built with
-nodefaultlibs (e.g. to avoid linking to the standard C++ library) to
the compiler runtime library, e.g. using:

  clang++ ... -nodefaultlibs $(clang++ ... -print-libgcc-file-name)

in which case currently a program built like this linked to the gcc
runtime unconditionally. The patch fixes it to use compiler-rt libraries
instead when compiler-rt is the active runtime.

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

llvm-svn: 283746
2016-10-10 12:23:40 +00:00
Daniel Jasper 1eb779b5ae Revert "[x86][inline-asm][clang] accept 'v' constraint"
This reverts commit r283716.

Breaks buildbot:
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/9155/testReport/junit/Clang/CodeGen/x86_inline_asm_v_constraint_c/

llvm-svn: 283743
2016-10-10 11:40:28 +00:00
Daniel Marjamaki ed0cca244d Fix style issue. Spaces in argument list.
llvm-svn: 283725
2016-10-10 07:39:39 +00:00
Richard Smith f5d8a75efa Mark aligned allocation as done.
llvm-svn: 283724
2016-10-10 06:55:42 +00:00
Richard Smith 189e52fcdf P0035R4: Semantic analysis and code generation for C++17 overaligned
allocation.

llvm-svn: 283722
2016-10-10 06:42:31 +00:00
Michael Zuckerman fe2b9b4fbf [x86][inline-asm][clang] accept 'v' constraint
Commit in the name of: Coby Tayree 

1.'v' constraint for (x86) non-avx arch imitates the already implemented 'x' constraint, i.e. allows XMM{0-15} & YMM{0-15} depending on the apparent arch & mode (32/64).
2.for the avx512 arch it allows [X,Y,Z]MM{0-31} (mode dependent)

This patch applies the needed changes to clang
 LLVM patch: https://reviews.llvm.org/D25005

Differential Revision: D25004 

llvm-svn: 283716
2016-10-10 05:45:54 +00:00
Hal Finkel 60ebf61274 When optimizing for size, enable loop rerolling by default
We have a loop-rerolling optimization which can be enabled by using
-freroll-loops. While sometimes loops are hand-unrolled for performance
reasons, when optimizing for size, we should always undo this manual
optimization to produce smaller code (our optimizer's unroller will still
unroll the rerolled loops if it thinks that is a good idea).

llvm-svn: 283685
2016-10-09 03:06:31 +00:00
Justin Lebar 3b593f56fc [CUDA] Don't install cuda_wrappers/{algorithm,complex} into the main include dir.
This is obviously wrong -- if we do this, then all compiles will pick up
these wrappers, which is not what we want.

llvm-svn: 283683
2016-10-09 00:27:39 +00:00
Justin Lebar d3c5d2a4de [CUDA] Support <complex> and std::min/max on the device.
Summary:
We do this by wrapping <complex> and <algorithm>.

Tests are in the test-suite.

Reviewers: tra

Subscribers: jhen, beanz, cfe-commits, mgorny

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

llvm-svn: 283680
2016-10-08 22:16:12 +00:00
Justin Lebar 2dfbe9a3b4 [CUDA] Rename cuda_builtin_vars.h to __clang_cuda_builtin_vars.h.
Summary: This matches the idiom we use for our other CUDA wrapper headers.

Reviewers: tra

Subscribers: beanz, mgorny, cfe-commits

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

llvm-svn: 283679
2016-10-08 22:16:08 +00:00
Justin Lebar e9eb792a0f [CUDA] Declare our __device__ math functions in the same inline namespace as our standard library.
Summary:
Currently we declare our inline __device__ math functions in namespace
std.  But libstdc++ and libc++ declare these functions in an inline
namespace inside namespace std.  We need to match this because, in a
later patch, we want to get e.g. <complex> to use our device overloads,
and it only will if those overloads are in the right inline namespace.

Reviewers: tra

Subscribers: cfe-commits, jhen

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

llvm-svn: 283678
2016-10-08 22:16:03 +00:00
Justin Lebar 67a78a6cc0 [CUDA] Add #pragma clang force_cuda_host_device_{begin,end} pragmas.
Summary:
These cause us to consider all functions in-between to be __host__
__device__.

You can nest these pragmas; you just can't have more 'end's than
'begin's.

Reviewers: rsmith

Subscribers: tra, jhen, cfe-commits

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

llvm-svn: 283677
2016-10-08 22:15:58 +00:00
Mehdi Amini 732afdd09a Turn cl::values() (for enum) from a vararg function to using C++ variadic template
The core of the change is supposed to be NFC, however it also fixes
what I believe was an undefined behavior when calling:

 va_start(ValueArgs, Desc);

with Desc being a StringRef.

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

llvm-svn: 283671
2016-10-08 19:41:06 +00:00
Artem Dergachev 83ebea4cb6 [analyzer] Fix build error after r283660 - remove constexpr strings.
llvm-svn: 283662
2016-10-08 11:07:21 +00:00
Artem Dergachev 4eca0de7b7 [analyzer] Re-apply r283094 "Improve CloneChecker diagnostics"
The parent commit (r283092) was reverted before and now finally landed.

llvm-svn: 283661
2016-10-08 10:54:30 +00:00
Artem Dergachev 46209e1dd0 [analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker"
The parent commit (r283092) was reverted before and now finally landed.

llvm-svn: 283660
2016-10-08 10:53:00 +00:00
Yaron Keren e0bcdd4d25 Un-tabify source files, NFC.
llvm-svn: 283657
2016-10-08 06:45:10 +00:00
Mehdi Amini 5bf825b764 Use StringRef in Command::printArg() instead of raw pointer (NFC)
llvm-svn: 283645
2016-10-08 01:38:43 +00:00
Justin Lebar 9fdb46e71c [CUDA] Do a better job at detecting wrong-side calls.
Summary:
Move CheckCUDACall from ActOnCallExpr and BuildDeclRefExpr to
DiagnoseUseOfDecl.  This lets us catch some edge cases we were missing,
specifically around class operators.

This necessitates a few other changes:

 - Avoid emitting duplicate deferred diags in CheckCUDACall.

   Previously we'd carefully placed our call to CheckCUDACall such that
   it would only ever run once for a particular callsite.  But now this
   isn't the case.

 - Emit deferred diagnostics from a template
   specialization/instantiation's primary template, in addition to from
   the specialization/instantiation itself.  DiagnoseUseOfDecl ends up
   putting the deferred diagnostics on the template, rather than the
   specialization, so we need to check both.

Reviewers: rsmith

Subscribers: cfe-commits, tra

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

llvm-svn: 283637
2016-10-08 01:07:11 +00:00
Mehdi Amini 087f1fbb53 Rename variable to not use C++ reserved name (leading underscore + capital) (NFC)
llvm-svn: 283616
2016-10-07 22:03:03 +00:00
Mehdi Amini 44f0eda077 Fix MSVC build: requires namespace in front of StringRef (NFC)
llvm-svn: 283615
2016-10-07 22:02:59 +00:00
Mehdi Amini 6fcd4eb9fc Driver: use StringRef instead of raw pointer in lookupTypeForExtension() (NFC)
llvm-svn: 283611
2016-10-07 21:41:00 +00:00
Mehdi Amini c50b1a263b Turn ArchName/BoundArch in Driver from raw pointer to StringRef (NFC)
llvm-svn: 283605
2016-10-07 21:27:26 +00:00
Douglas Katzman 4f25bf6ac9 Visually align table def with respective enum. NFC
'warn_attribute_wrong_decl_type' has to stay in sync with
'enum AttributeDeclKind' which is much easier when they line up.

llvm-svn: 283601
2016-10-07 21:02:38 +00:00
Michal Gorny 822629db5d Revert r283572 - [Driver] Make -print-libgcc-file-name print compiler-rt lib when used
Revert the -print-libgcc-file-name change as the new test fails
on Darwin. It needs to be updated to run the libgcc part only on systems
supporting that rtlib.

llvm-svn: 283586
2016-10-07 20:04:00 +00:00
Artem Dergachev b1991c5fa7 [analyzer] Re-apply r283092, attempt no.4, chunk no.4 (last)
The problem that caused the msvc crash has been indentified and fixed
in the previous commit. This patch contains the rest of r283092.

llvm-svn: 283584
2016-10-07 19:25:10 +00:00
Nirav Dave 2620d22b2b Silence Warning. NFC.
llvm-svn: 283583
2016-10-07 19:11:33 +00:00
Artem Dergachev 9913583e06 [analyzer] Re-apply r283092, attempt no.4, chunk no.3, fixup 1.
Remove the brace default initializer to see if this is what's causing
the msvc crash.

llvm-svn: 283574
2016-10-07 17:24:06 +00:00
Artem Dergachev a458828fe7 [analyzer] Re-apply r283092, attempt no.4, chunk no.3.
This is the primary suspect for causing the msvc crash, now that vector of
smart pointers was proven to be safe. Probably the default {}-initializer
is the problem.

llvm-svn: 283573
2016-10-07 17:12:05 +00:00
Michal Gorny 81684a0676 [Driver] Make -print-libgcc-file-name print compiler-rt lib when used
Make the -print-libgcc-file-name option print an appropriate compiler
runtime library, that is libgcc.a if gcc runtime is used
and an appropriate compiler-rt library if that runtime is used.

The main use for this is to allow linking executables built with
-nodefaultlibs (e.g. to avoid linking to the standard C++ library) to
the compiler runtime library, e.g. using:

  clang++ ... -nodefaultlibs $(clang++ ... -print-libgcc-file-name)

in which case currently a program built like this linked to the gcc
runtime unconditionally. The patch fixes it to use compiler-rt libraries
instead when compiler-rt is the active runtime.

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

llvm-svn: 283572
2016-10-07 17:08:06 +00:00
Artem Dergachev ae22c0752d [analyzer] Re-apply r283092, attempt no.4, chunk no.2.
Define the list of pieces in BugReport class. This is half of the changes
in the BugReport class code, which is pointed to by the msvc crash message.

llvm-svn: 283568
2016-10-07 15:55:18 +00:00
Artem Dergachev 8b70c4e529 [analyzer] Re-apply r283092, attempt no.4, a small chunk.
Define PathDiagnosticNotePiece. The next commit would be able to address the
BugReport class code that is pointed to by the msvc crash message.

llvm-svn: 283566
2016-10-07 15:23:02 +00:00
Dehao Chen e239e95160 Update clang test to accomendate discriminator change in https://reviews.llvm.org/D25132
Summary: https://reviews.llvm.org/D25132 added discriminator even add -g0. This leads to test fail which is addressed in thie patch.

Reviewers: davidxl, dnovillo

Subscribers: llvm-commits

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

llvm-svn: 283564
2016-10-07 15:21:29 +00:00
Daniel Marjamaki d99ebc03f4 [analyzer] Don't merge different return nodes in ExplodedGraph
Returns when calling an inline function should not be merged in the ExplodedGraph unless they are same.

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

llvm-svn: 283554
2016-10-07 14:21:08 +00:00
Simon Pilgrim 12d6baf5e4 Wdocumentation fix
llvm-svn: 283549
2016-10-07 13:25:41 +00:00
Javed Absar 00b7444dc1 [ARM]: Add Cortex-R52 target
This patch adds Cortex-R52, the new ARM real-time processor.
Cortex-R52 implements the ARMv8-R architecture.

llvm-svn: 283543
2016-10-07 12:08:41 +00:00
Artem Dergachev f03039fb4d Revert "[analyzer] Re-apply r283092, attempt no.3, in small chunks this time."
llvm-svn: 283541
2016-10-07 11:29:32 +00:00
Artem Dergachev 7258ca3ab7 [analyzer] Re-apply r283092, attempt no.3, in small chunks this time.
llvm-svn: 283540
2016-10-07 11:26:15 +00:00
Artem Dergachev 5d9278ef00 Revert "[analyzer] Try to re-apply r283092 "Extend bug reports with extra notes"
Vector of smart pointers wasn't the thing that caused msvc crash.

llvm-svn: 283537
2016-10-07 10:56:44 +00:00
Artem Dergachev fc36b586fb [analyzer] Try to re-apply r283092 "Extend bug reports with extra notes"
Replace SmallVector<IntrusiveRefCntPtr> with a vector of plain pointers.
Would insignificantly increase memory usage.

llvm-svn: 283536
2016-10-07 10:44:09 +00:00
Mehdi Amini a0016ec95f Use StringReg in TargetParser APIs (NFC)
llvm-svn: 283527
2016-10-07 08:37:29 +00:00
Richard Smith e15a370084 PR25890: Fix incoherent error handling in PerformImplicitConversion and
CheckSingleAssignmentConstraints. These no longer produce ExprError() when they
have not emitted an error, and reliably inform the caller when they *have*
emitted an error.

This fixes some serious issues where we would fail to emit any diagnostic for
invalid code and then attempt to emit code for an invalid AST, and conversely
some issues where we would emit two diagnostics for the same problem.

llvm-svn: 283508
2016-10-06 23:12:58 +00:00
Anton Yartsev 0509d047f4 [analyzer] Add explanation why analyzer report is not generated (fix for PR12421).
Currently if the path diagnostic consumer (e.g HTMLDiagnostics and PlistDiagnostics) do not support cross file diagnostics then the path diagnostic report is silently omitted in the case of cross file diagnostics. The patch adds a little verbosity to Clang in this case.
The patch also adds help entry for the "--analyzer-output" driver option.

llvm-svn: 283499
2016-10-06 21:42:21 +00:00
Richard Smith 254a45ee65 Add another .def file to module map to fix modules buildbot's displeasure.
llvm-svn: 283498
2016-10-06 21:31:04 +00:00
Eric Fiselier 9813131936 [coroutines] Fix co_return statement for initializer list arguments
Summary:
Previously the statement `co_return {42}` would be transformed into `P.return_void()`, since the type of `{42}` is represented as `void` by Clang.

This patch fixes the bug by checking for `InitListExpr` arguments and transforming them accordingly.

Reviewers: majnemer, GorNishanov, rsmith

Subscribers: mehdi_amini, cfe-commits

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

llvm-svn: 283495
2016-10-06 21:23:38 +00:00
Richard Smith c26d97401c [modules] Be sure to emit local specializations of imported templates, even if
the resulting specialization is not referenced by the rest of the AST. This
both avoids performing unnecessary reinstantiations in downstream users of the
AST file and fixes a bug (breaking modules self-host right now) where we would
sometimes fail to emit a definition of a class template specialization if we
imported just a declaration of it from elsewhere (see new testcase for reduced
example).

llvm-svn: 283489
2016-10-06 20:30:51 +00:00
Justin Lebar 14299363af [Sema] Replace smart quote with "'" in comment.
Looks like the smart quote was copy/pasted from the C++ standard.

The smart quote was not encoded as valid UTF-8 (?), even though vim was
detecting the file as UTF-8.  This broke the clang-format Python script,
which tried to read the file using the same encoding as vim detected.

llvm-svn: 283487
2016-10-06 19:47:56 +00:00
David Sheinkman d03c85c02e [OpenMP] Check if the template specialization is mappable instead of specialized template Differential Revision: https://reviews.llvm.org/D25252
llvm-svn: 283460
2016-10-06 15:47:36 +00:00
Vassil Vassilev 916d8be252 Allocate after the early exit checks. NFC.
llvm-svn: 283448
2016-10-06 13:18:06 +00:00
Vassil Vassilev d1a88130c4 [modules] Allow VarDecls with initializers to use special var abbrev.
Update storage sizes to fit the (past) changes in the VarDecl's data model.
Update some comments.

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

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

rdar://28630028

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

llvm-svn: 283432
2016-10-06 09:47:29 +00:00
Benjamin Kramer 6aa14cbce7 Add missing -no-canonical-prefixes.
llvm-svn: 283430
2016-10-06 09:40:37 +00:00
Alex Lorenz 7ba609a220 Fix PR30440: Initialize FunctionTypeDepth in CXXNameMangler
This commit fixes PR 30440 by initializing CXXNameMangler's FunctionTypeDepth
in the two constructors added in r274222 (The commit that caused this
regression).

rdar://28455269

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

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

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

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

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

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

llvm-svn: 283406
2016-10-05 22:41:02 +00:00
Nemanja Ivanovic 06d550b85a Removing optimization from the RUN lines and adjusting the checks
to not rely on optimization.

llvm-svn: 283363
2016-10-05 19:11:36 +00:00
Eric Liu 7956c4004d Make DeletedLines local variables in checkEmptyNamespace.
Summary: Patch by Sam McCall!

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

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

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

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

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

rdar://28498901

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

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

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

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

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

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

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

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

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

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

llvm-svn: 283301
2016-10-05 08:19:49 +00:00
Justin Lebar 4a759ff44c [CUDA] Add missing ':' to noexcept.cu test.
llvm-svn: 283280
2016-10-05 00:27:38 +00:00
Justin Lebar 3e6449b4f4 [CUDA] Mark device functions as nounwind.
Summary:
This prevents clang from emitting 'invoke's and catch statements.

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

Fixes bug 30593.

Reviewers: tra

Subscribers: cfe-commits

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

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

Reviewers: rnk

Subscribers: cfe-commits

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

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

Reviewers: thakis, majnemer, hans, rnk

Subscribers: cfe-commits

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

llvm-svn: 283264
2016-10-04 22:29:49 +00:00
Hans Wennborg 625fba8840 clang-cl: Make /Fo apply also when using -flto
llvm-svn: 283258
2016-10-04 21:01:04 +00:00
Hans Wennborg 26228e3010 clang-cl: Use the .obj file extension also in LTO mode
llvm-svn: 283257
2016-10-04 21:01:02 +00:00
Hans Wennborg 2b0eea4a3b clang-cl: expose the -fuse-ld option
llvm-svn: 283256
2016-10-04 21:01:00 +00:00
Hans Wennborg 02d03befb9 clang-cl: Expose the -flto option
We could hook up /GL as an alias for -flto, but that might be
confusing, as clang-cl in that mode would not be drop-in compatible
with cl.exe /GL, as it requires the linker to be lld.

Exposing -flto seems like a less confusing way to expose this
functionality.

llvm-svn: 283255
2016-10-04 21:00:57 +00:00
Anna Zaks fb859a934a [analyzer] Add PostStmt callback for ArraySubscriptExpr
A patch by Jan Smets!

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

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

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

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

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

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

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

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

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

llvm-svn: 283246
2016-10-04 20:18:25 +00:00
Mike Aizatsky a271d1a531 [sancov] documentation update after r283241
llvm-svn: 283242
2016-10-04 19:19:16 +00:00
Reid Kleckner 56f4535634 Test what happens when tag lookup and redeclaration lookup disagree
Clang has a diagnostic for the what happens when an elaborated type
implicitly creates a tag declaration and the initial tag lookup fails,
but the redeclaration lookup succeeds and finds a non-tag type. However,
it wasn't tested, and looked like dead code. After much staring, we
discovered how to exercise it, and are now committing the test for
posterity.

In this example, the tag lookup will not find A, but then when we go to
insert a declaration of A at global scope, we discover the template
friend, which is not a tag type.

  struct C {
    template <typename> friend struct A;
  };
  struct B {
    struct A *p;
  };

llvm-svn: 283235
2016-10-04 18:10:23 +00:00
Alex Lorenz 9e5afc4a2c [Sema] Format a comment line so that it fits 80 columns. NFC
llvm-svn: 283228
2016-10-04 16:06:37 +00:00
Reid Kleckner d2c0c25be4 [MS] Move hex long long sign compat hack to -fms-compatibility
Treating large 0x*LL literals as signed instead of unsigned is not a
conforming language extension, so move it out of -fms-extensions.

Came up in PR30605

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

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

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

The fix was made in collaboration with Richard Smith.

This change fixes PR8035, PR17923, PR22307 and PR25848.

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

llvm-svn: 283207
2016-10-04 10:11:43 +00:00
Manuel Klimek 8a70450590 Minor cleanups in clang-format.el.
- Enable lexical binding
- Formatting
- Enable file name completion for the clang-format-executable variable
- Add a missing docstring
- When available, use bufferpos-to-filepos and filepos-to-bufferpos. These functions given more precise mapping than byte-to-position and position-bytes.
- Rename arguments of clang-format-region to match the docstring
- Instead of binding local variables to nil and then assigning them, bind them directly to their values
- Make use of the fact that insert-file-contents returns the number of characters it inserted
- Use cl-destructuring-bind to make the code a bit shorter
- Use standard iteration (dolist) instead of mapc with a lambda, which is more common and shorter
- Remove a message that was most likely only present for debugging purposes

Patch by Philipp Stephani.

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

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

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

Author: rSerge

Reviewers: dberris, rsmith, aaron.ballman, rnk

Subscribers: cfe-commits, iid_iunknown

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

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

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

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

llvm-svn: 283180
2016-10-04 02:19:17 +00:00
Vitaly Buka bba7416978 Revert "[analyzer] A blind attempt to fix a buildbot" as it does not help.
This reverts commit r283141.

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

Reviewers: cfe-commits, EricWF, rsmith

Subscribers: majnemer, mehdi_amini

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

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

Reviewers: rnk, EricWF, rsmith

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

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

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

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

rdar://28488466

llvm-svn: 283145
2016-10-03 21:26:46 +00:00
Artem Dergachev 844ba8879e [analyzer] A blind attempt to fix a buildbot after r283092.
The msvc compiler seems to crash compiling the BugReport class.

llvm-svn: 283141
2016-10-03 20:12:12 +00:00
Eric Liu 385f10152c Added more comments to tooling::Replacements.
Summary: Also test phabricator commit processing.

Subscribers: klimek, cfe-commits

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

llvm-svn: 283135
2016-10-03 19:14:30 +00:00
Reid Kleckner f33bfcb0e0 Factor out a diagnostic kind enum for use in two %select expressions
NFC

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

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

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

Reviewers: rsmith

Subscribers: cfe-commits, tra

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

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

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

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

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

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

This patch fixes that.

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

llvm-svn: 283114
2016-10-03 14:41:50 +00:00
Sjoerd Meijer d98493414b This adds a separate file for the fp denormal regression tests. NFC.
I forgot to svn add the new file in my previous commit.

llvm-svn: 283110
2016-10-03 13:13:50 +00:00
Sjoerd Meijer a5d3fd4780 This adds a separate file for the fp denormal regression tests. NFC.
Differential Revision: https://reviews.llvm.org/D24907

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

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

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

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

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

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

llvm-svn: 283102
2016-10-03 12:12:03 +00:00
Daniel Marjamaki fd1b3814b3 [StaticAnalyser] Add test case to ensure that unreachable code is found.
https://reviews.llvm.org/D24905

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

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

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

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

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

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

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

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

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

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

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

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

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

llvm-svn: 283092
2016-10-03 07:58:26 +00:00
Aditya Kumar b906230bcb Keep the test only for Itanium abi
llvm-svn: 283085
2016-10-03 02:36:33 +00:00
Michal Gorny 9fbdfd1785 [cmake] Install 'clang-cpp' symlink
Install the 'clang-cpp' symlink used to spawn the preprocessor. The code
handling this suffix is already included in Driver. FreeBSD is already
creating such a symlink in ports, and a similar one was requested
by Gentoo/FreeBSD team. The goal is to handle software that takes a C
preprocessor via a variable but does not handle passing options
correctly (i.e. 'clang -E' does not work).

Bug: https://bugs.gentoo.org/478810

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

llvm-svn: 283075
2016-10-02 19:28:57 +00:00
Craig Topper c4a8228bcc [AVX-512] Use native IR for masked 512-bit add/sub/mul/div ps/pd intrinsics when rounding mode isn't used.
llvm-svn: 283073
2016-10-02 17:43:00 +00:00
Justin Lebar 281ce2af17 [CUDA] Allow extern __shared__ on empty-length arrays.
"extern __shared__ int x[]" is OK.

llvm-svn: 283068
2016-10-02 15:24:50 +00:00
Gor Nishanov 4ffb434ca8 [coroutines] Rename driver flag -fcoroutines to -fcoroutines-ts
Summary:
Also makes -fcoroutines_ts to be both a Driver and CC1 flag.

Patch mostly by EricWF.

Reviewers: rnk, cfe-commits, rsmith, EricWF

Subscribers: mehdi_amini

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

llvm-svn: 283064
2016-10-02 03:31:58 +00:00
Aditya Kumar e84372b039 Alias must point to a definition
Reapplying the patch after modifying the test case.

Inlining the destructor caused the compiler to generate bad IR which failed the Verifier in the backend.
https://llvm.org/bugs/show_bug.cgi?id=30341

This patch disables alias to available_externally definitions.

Reviewers: eugenis, rsmith

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

llvm-svn: 283063
2016-10-02 03:06:36 +00:00
Hal Finkel 415c2a38f2 [PowerPC] Enable soft-float for PPC64, and +soft-float -> -hard-float
Enable soft-float support on PPC64, as the backend now supports it. Also, the
backend now uses -hard-float instead of +soft-float, so set the target features
accordingly.

Fixes PR26970.

llvm-svn: 283061
2016-10-02 02:10:45 +00:00
Craig Topper 7609f1c269 [AVX-512] Check rounding mode for builtins that take one. Rounding mode should be either _MM_FROUND_CUR_DIRECTION or a 2-bit rounding mode ORed with _MM_FROUND_NO_EXC.
llvm-svn: 283054
2016-10-01 21:03:50 +00:00
Craig Topper 4910755107 [AVX-512] Add _MM_FROUND_NO_EXC to test cases that pass a rounding mode intrinsics. This is preparation for a follow up commit that will check validity of rounding mode argument.
llvm-svn: 283053
2016-10-01 21:03:46 +00:00
Mehdi Amini 99d1b29503 Use StringRef for MemoryBuffer identifier API (NFC)
llvm-svn: 283043
2016-10-01 16:38:28 +00:00
Mehdi Amini 7410717a62 Use StringRef in Registry API (NFC)
llvm-svn: 283039
2016-10-01 15:44:54 +00:00
Mehdi Amini 117296c0a0 Use StringRef in Pass/PassManager APIs (NFC)
llvm-svn: 283004
2016-10-01 02:56:57 +00:00
Mehdi Amini b7fb124512 Use StringRef in Triple API (NFC)
llvm-svn: 282996
2016-10-01 01:16:22 +00:00
Richard Trieu c2265be186 Fix crash when emitting error.
With templated classes, is possible to not be able to determine is a member
function is a special member function before the class is instantiated.  Only
these special member functions can be defaulted.  In some cases, knowing
whether a function is a special member function can't be determined until
instantiation, so an uninstantiated function could possibly be defaulted too.
Add a case to the error diagnostic when the function marked with a default is
not known to be a special member function.

llvm-svn: 282989
2016-10-01 00:15:24 +00:00
Justin Lebar 9d4ed262ef [CUDA] Harmonize asserts in SemaCUDA, NFC.
llvm-svn: 282987
2016-09-30 23:57:38 +00:00
Justin Lebar e71b2fa4c9 [CUDA] Disallow __constant__ local variables.
Reviewers: tra, rnk

Subscribers: cfe-commits

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

llvm-svn: 282986
2016-09-30 23:57:34 +00:00
Justin Lebar 1041101953 [CUDA] Disallow 'extern __shared__' variables.
Also add a test that we disallow

  __constant__ __shared__ int x;

because it's possible to break this without breaking

  __shared__ __constant__ int x;

Reviewers: rnk

Subscribers: cfe-commits, tra

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

llvm-svn: 282985
2016-09-30 23:57:30 +00:00
Richard Smith 360cb2570e Fix bogus "inline namespace cannot be reopened as non-inline" diagnostic to
just warn that the second declaration is missing the 'inline' keyword. This is
valid, and we shouldn't be suggesting otherwise.

llvm-svn: 282981
2016-09-30 23:16:08 +00:00
Saleem Abdulrasool 8dbaf5cb4d CodeGen: inherit DLLExport attribute in Windows Itanium
When emitting the fundamental type information constants, inherit the
DLLExportAttr from `__fundamental_type_info`.  We would previously not
honor the `__declspec(dllexport)` on the type information.

llvm-svn: 282980
2016-09-30 23:11:05 +00:00
Richard Smith 591390284f P0035R4: add predefined __STDCPP_DEFAULT_NEW_ALIGNMENT__ macro. By default, we
assume that ::operator new provides no more alignment than is necessary for any
primitive type, except when we're on a GNU OS, where glibc's malloc guarantees
to provide 64-bit alignment on 32-bit systems and 128-bit alignment on 64-bit
systems. This can be controlled by the command-line -fnew-alignment flag.

llvm-svn: 282974
2016-09-30 22:41:36 +00:00
Eric Fiselier 7d5773e610 [coroutines] Diagnose when 'main' is declared as a coroutine.
Summary: The title says it all.

Reviewers: rsmith, GorNishanov

Subscribers: mehdi_amini, cfe-commits

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

llvm-svn: 282973
2016-09-30 22:38:31 +00:00
Bruno Cardoso Lopes c08cd4e20b [Sema] Support lax conversions for compound assignments
Support lax convertions on compound assignment expressions like:

  typedef __attribute__((vector_size(8))) double float64x1_t;
  typedef __attribute__((vector_size(16))) double float64x2_t;
  float64x1_t vget_low_f64(float64x2_t __p0);

  double c = 3.0;
  float64x2_t v = {0.0, 1.0};
  c += vget_low_f64(v);

This restores one more valid behavior pre r266366, and is a incremental
follow up from work committed in r274646.

While here, make the check more strict, add FIXMEs, clean up variable
names to match what they can actually be and update testcases to reflect
that. We now reject:

  typedef float float2 __attribute__ ((vector_size (8)));
  double d;
  f2 += d;

which doesn't fit as a direct bitcast anyway.

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

rdar://problem/28033929

llvm-svn: 282968
2016-09-30 22:19:38 +00:00
Kostya Serebryany f74169c9d6 [sanitizer-coverage] fix docs
llvm-svn: 282962
2016-09-30 21:57:10 +00:00
Alexander Shaposhnikov 6237a21d8c Add missing std::move in Replacements::add
This diff adds std::move to avoid copying of 
the Replacement NewR in the method Replacements::add.

Test plan: make -j8 check-all

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

llvm-svn: 282949
2016-09-30 21:05:45 +00:00
Mike Aizatsky a675e0e03c [sancov] -symbolize documentation update
llvm-svn: 282948
2016-09-30 21:02:56 +00:00
Justin Lebar 20614e0d9c [CUDA] Fix implicit-device-lambda.cu after r282911.
This commit added a warning that we're (correctly) hitting in this test.
Just ignore it.

llvm-svn: 282927
2016-09-30 20:17:37 +00:00
Justin Lebar 7a406e78b3 [CUDA] Remove incorrect comment in CUDASetLambdaAttrs.
I'd said that nvcc doesn't allow you to add __host__ or __device__
attributes on lambdas in all circumstances, but I believe this was user
error on my part.  I can't reproduce these warnings/errors if I pass
--expt-extended-lambda to nvcc.

llvm-svn: 282912
2016-09-30 19:55:59 +00:00
Justin Lebar e46ea72d97 [CUDA] Emit a warning if a CUDA host/device/global attribute is placed after '(...)'.
Summary:
This is probably the sane place for the attribute to go, but nvcc
specifically rejects it.  Other GNU-style attributes are allowed in this
position (although judging from the warning it emits for
host/device/global, those attributes are applied to the lambda's
anonymous struct, not to the function itself).

It would be nice to have a FixIt message here, but doing so, or even
just getting the correct range for the attribute, including its '((' and
'))'s, is apparently Hard.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

llvm-svn: 282911
2016-09-30 19:55:55 +00:00
Justin Lebar 0139a5dcac [CUDA] Fix up MaybeParseGNUAttributes call used for out-of-place attributes on CUDA lambdas.
Summary: There's an overload that we can use to make this a bit cleaner.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

llvm-svn: 282910
2016-09-30 19:55:48 +00:00
Martin Storsjo ed95a08ea4 [MS] Implement __iso_volatile loads/stores as builtins
These are supposed to produce the same as normal volatile
pointer loads/stores. When -volatile:ms is specified,
normal volatile pointers are forced to have atomic semantics
(as is the default on x86 in MSVC mode). In that case,
these builtins should still produce non-atomic volatile
loads/stores without acquire/release semantics, which
the new test verifies.

These are only available on ARM (and on AArch64,
although clang doesn't support AArch64/Windows yet).

This implements what is missing for PR30394, making it possible
to compile C++ for ARM in MSVC mode with MSVC headers.

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

llvm-svn: 282900
2016-09-30 19:13:46 +00:00