Commit Graph

66020 Commits

Author SHA1 Message Date
Craig Topper eee7c0520c [AVX-512] Replace masked 128/256-bit byte, word, and dword min/max builtins with selects and the older unmasked builtins.
llvm-svn: 284954
2016-10-23 23:57:30 +00:00
Justin Lebar a45e6fde58 Remove LLVM_CONSTEXPR.
Summary: With MSVC 2013 and GCC < 4.8 gone, we can use the "constexpr" keyword.

Reviewers: bkramer, mehdi_amini

Subscribers: llvm-commits

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

llvm-svn: 284947
2016-10-23 19:39:16 +00:00
Craig Topper 0c5da26572 [AVX-512] Replace 512-bit pmovzx/sx builtins with native IR.
llvm-svn: 284936
2016-10-23 07:35:47 +00:00
Craig Topper 4ef879ac2c [AVX-512] Remove masked 128/256-bit packss/packus builtins and replace with selects and the older unmasked builtins.
llvm-svn: 284935
2016-10-23 07:35:39 +00:00
Ekaterina Romanova 06477bf035 Add more doxygen comments to emmintrin.h's intrinsics.
With this patch, all intrinsics in this file (with an exception of a handful of a recently added ones) will be documented. I will send out a patch for 4 missining intrisics later.

The doxygen comments are automatically generated based on Sony's intrinsics document.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream. This patch was internally reviewed by Yunzhong Gao.

llvm-svn: 284934
2016-10-23 07:30:50 +00:00
Richard Smith c7f576fc91 Fix mangling numbers for varargs lambdas; varargs and non-varargs lambdas get
different lambda-sigs, so they should have different counters.

llvm-svn: 284933
2016-10-23 04:53:03 +00:00
Mandeep Singh Grang 66215e97e3 [clang] Limit clang test to ARM and AArch64 only
Summary: Limit clang/test/Frontend/gnu-mcount.c to ARM and AArch64 only.

Reviewers: abdulras, honggyu.kim, rengolin

Subscribers: aemerson, rengolin, cfe-commits

Tags: #clang-c

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

llvm-svn: 284931
2016-10-23 00:53:03 +00:00
Craig Topper 4d63dfc286 [AVX-512] Replace masked 128/256-bit pavg builtins and replace with select and older unmasked builtins.
llvm-svn: 284929
2016-10-22 21:24:56 +00:00
Craig Topper 622c63614d [AVX-512] Replace masked 128/256-bit saturating add/sub builtins with select and older unmasked builtins.
llvm-svn: 284928
2016-10-22 21:24:52 +00:00
Craig Topper 11dda92405 [AVX-512] Replace masked 128/256-bit vpmovzx/vpmovsx builtins with native IR.
llvm-svn: 284927
2016-10-22 21:24:48 +00:00
Craig Topper f742445eb4 [AVX-512] Remove duplicate test cases from the avx512vlbw intrinsic test. These tests already exist in the avx512vl test and represent avx512vl instructions.
llvm-svn: 284926
2016-10-22 21:24:44 +00:00
Craig Topper eb1c0afa90 [AVX-512] Remove masked 128/256-bit pshufb builtins. Replace with a select and the older unmaksed builtins.
llvm-svn: 284925
2016-10-22 21:24:42 +00:00
Craig Topper 78a9c40326 [AVX-512] Remove builtins for 128/256-bit pabsb/pabsw. We can use a select and the older non-masked versions instead.
llvm-svn: 284924
2016-10-22 21:24:38 +00:00
Craig Topper c2c7e42bfe [AVX-512] Add typecasts to alignr intrinsics that were modified in r284920.
llvm-svn: 284923
2016-10-22 21:24:34 +00:00
Craig Topper f6373bc6fd [AVX-512] Remove masked 128/256-bit palignr builtins. We can just use a select in the header file with the older unmasked versions instead.
llvm-svn: 284920
2016-10-22 18:32:33 +00:00
Richard Smith 6294a768e5 Mark P0012R1 as "Partial" since it's now substantially complete.
llvm-svn: 284907
2016-10-22 01:35:34 +00:00
Richard Smith 58b4ab845a Add another testcase missed from r284905.
llvm-svn: 284906
2016-10-22 01:32:45 +00:00
Richard Smith 1be59c5106 [c++1z] P0012R1: Implement a few remaining pieces: downgrade diagnostic for
mismatched dynamic exception specifications in expressions from an error to a
warning, since this is no longer ill-formed in C++1z.

Allow reference binding of a reference-to-non-noexcept function to a noexcept
function lvalue. As defect resolutions, also allow a conditional between
noexcept and non-noexcept function lvalues to produce a non-noexcept function
lvalue (rather than decaying to a function pointer), and allow function
template argument deduction to deduce a reference to non-noexcept function when
binding to a noexcept function type.

llvm-svn: 284905
2016-10-22 01:32:19 +00:00
Manman Ren c8c9415644 Module: correctly set the module file kind when emitting file_modified.
rdar://28503343

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

llvm-svn: 284899
2016-10-21 23:35:03 +00:00
Manman Ren 70a7738f84 Module: improve the diagnostic message for include of non-modular header.
Emit the actual path to the non-modular include.

rdar://28897010

llvm-svn: 284897
2016-10-21 23:27:37 +00:00
Richard Smith ce76629905 Remove unnecessary distinction between Ref_Compatible and
Ref_Compatible_With_Added_Qualification. We always treated these two values the
same way.

llvm-svn: 284895
2016-10-21 23:01:55 +00:00
Richard Smith 5e9746f520 DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.
This has two significant effects:

1) Direct relational comparisons between null pointer constants (0 and nullopt)
   and pointers are now ill-formed. This was always the case for C, and it
   appears that C++ only ever permitted by accident. For instance, cases like
     nullptr < &a
   are now rejected.

2) Comparisons and conditional operators between differently-cv-qualified
   pointer types now work, and produce a composite type that both source
   pointer types can convert to (when possible). For instance, comparison
   between 'int **' and 'const int **' is now valid, and uses an intermediate
   type of 'const int *const *'.

Clang previously supported #2 as an extension.

We do not accept the cases in #1 as an extension. I've tested a fair amount of
code to check that this doesn't break it, but if it turns out that someone is
relying on this, we can easily add it back as an extension.

This is a re-commit of r284800.

llvm-svn: 284890
2016-10-21 22:00:42 +00:00
Justin Lebar 5e83dfedb8 Switch SmallSetVector to use DenseSet when it overflows its inline space.
Summary:
SetVector already used DenseSet, but SmallSetVector used std::set.  This
leads to surprising performance differences.  Moreover, it means that
the set of key types accepted by SetVector and SmallSetVector are
quite different!

In order to make this change, we had to convert some callsites that used
SmallSetVector<std::string, N> to use SmallSetVector<CachedHashString, N>
instead.

Reviewers: timshen

Subscribers: llvm-commits

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

llvm-svn: 284887
2016-10-21 21:45:01 +00:00
Malcolm Parsons 57c09c8e23 [Sema] Store a SourceRange for multi-token builtin types
Summary:
clang-tidy's modernize-use-auto check uses the SourceRange of a
TypeLoc when replacing the type with auto.
This was producing the wrong result for multi-token builtin types
like long long:

-long long *ll = new long long();
+auto long *ll = new long long();

Reviewers: alexfh, hokein, rsmith, Prazek, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 284885
2016-10-21 21:13:56 +00:00
Justin Lebar 4d38a5cf74 [CUDA] Simplify some repeated diagnostic expectations in CUDA tests.
Instead of repeating the diagnostic, use "expected-note N".

Test-only change.

llvm-svn: 284882
2016-10-21 20:50:47 +00:00
Artem Belevich 07db5cf6c8 Declare H and H new/delete.
llvm-svn: 284879
2016-10-21 20:34:05 +00:00
Vassil Vassilev f054b8c378 Remove accidentally checked in assert.
Thanks to Manman for spotting this.

llvm-svn: 284877
2016-10-21 20:30:30 +00:00
Justin Lebar 6f72737c3b [CUDA] Use FunctionDeclAndLoc for the Sema::LocsWithCUDACallDiags hashtable.
Summary: NFC

Reviewers: rnk

Subscribers: cfe-commits

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

llvm-svn: 284869
2016-10-21 20:08:52 +00:00
Benjamin Kramer 33e9760376 Remove move constructors that are identical to the generated default move ctor.
llvm-svn: 284856
2016-10-21 18:55:07 +00:00
Artem Belevich 9fb40e3bbd Removed unused function argument. NFC.
Differential Revision: https://reviews.llvm.org/D25839

llvm-svn: 284843
2016-10-21 17:15:46 +00:00
Reid Kleckner 7a2037151c Remove unnecessary x86 backend requirements from OpenMP tests
Clang can generate LLVM IR for x86 without a registered x86 backend.

llvm-svn: 284836
2016-10-21 16:09:20 +00:00
Benjamin Kramer ae8de9bc75 Remove non-existing file from modulemap.
This picked up a builtin header if it happened to be available.

llvm-svn: 284815
2016-10-21 10:19:37 +00:00
Renato Golin 41189656ed Revert "DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules."
This reverts commit r284800, as it failed all ARM/AArch64 bots.

llvm-svn: 284811
2016-10-21 08:03:49 +00:00
Martin Probst 717f6dcddc clang-format: [JS] Fix template string ASI.
Summary:
Previously, automatic semicolon insertion would add an unwrapped line
when a template string contained a line break.

    var x = `foo${
        bar}`;

Would be formatted with `bar...` on a separate line and no indent.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 284807
2016-10-21 05:11:38 +00:00
Richard Smith fdf0888b69 Don't try to use !Previous.empty() as a proxy for "Is this a redeclaration?" --
we don't collapse that down to a single entry if it's not a redeclaration.
Instead, set the Redeclaration bit on the Declarator to indicate whether a
function is a redeclaration (which may not have been linked into the
redeclaration chain if it's a dependent context friend).

Fixes a rejects-valid; see testcase.

llvm-svn: 284802
2016-10-21 03:15:03 +00:00
Richard Smith 0c1c53e3fa DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.
This has two significant effects:

1) Direct relational comparisons between null pointer constants (0 and nullopt)
   and pointers are now ill-formed. This was always the case for C, and it
   appears that C++ only ever permitted by accident. For instance, cases like
     nullptr < &a
   are now rejected.

2) Comparisons and conditional operators between differently-cv-qualified
   pointer types now work, and produce a composite type that both source
   pointer types can convert to (when possible). For instance, comparison
   between 'int **' and 'const int **' is now valid, and uses an intermediate
   type of 'const int *const *'.

Clang previously supported #2 as an extension.

We do not accept the cases in #1 as an extension. I've tested a fair amount of
code to check that this doesn't break it, but if it turns out that someone is
relying on this, we can easily add it back as an extension.

llvm-svn: 284800
2016-10-21 02:36:37 +00:00
Bruno Cardoso Lopes de9cab942b [Driver][Darwin] Pass -no_deduplicate to ld64
Recent versions of ld64 run a deduplicate pass, which is on by default.
Disable the pass by using -no_deduplicate in certain condition and
enhance total compile time.

rdar://problem/25455336

llvm-svn: 284798
2016-10-21 01:49:14 +00:00
Bruno Cardoso Lopes ed84df008f [Modules] Add 'no_undeclared_includes' module map attribute
The 'no_undeclared_includes' attribute should be used in a module to
tell that only non-modular headers and headers from used modules are
accepted.

The main motivation behind this is to prevent dep cycles between system
libraries (such as darwin) and libc++.

Patch by Richard Smith!

llvm-svn: 284797
2016-10-21 01:41:56 +00:00
Reid Kleckner 5f8878fa5e Revert 9 changes from r284793, they still fail on some bots
llvm-svn: 284794
2016-10-20 23:30:39 +00:00
Reid Kleckner 2e1538f282 Remove 24 instances of 'REQUIRES: shell'
Tests fall into one of the following categories:

- The requirement was unnecessary

- Additional quoting was required for backslashes in paths (see "sed -e
  's/\\/\\\\/g'") in the sanitizer tests.

- OpenMP used 'REQUIRES: shell' as a proxy for the test failing on
  Windows. Those tests fail there reliably, so use XFAIL instead.

I tried not to remove shell requirements that were added to suppress
flaky test failures, but if I screwed up, we can add it back as needed.

llvm-svn: 284793
2016-10-20 23:11:45 +00:00
Richard Smith eb7ef2e1ca Re-commit r284753, reverted in r284778, with a fix for PR30749.
Original commit message:

[c++1z] Teach composite pointer type computation how to compute the composite
pointer type of two function pointers with different noexcept specifications.
While I'm here, also teach it how to merge dynamic exception specifications.

llvm-svn: 284785
2016-10-20 21:53:09 +00:00
Alexander Shaposhnikov 476cbf901b [clang] Remove FileEntry copy-constructor
Code cleanup: address FIXME in the file
include/clang/Basic/FileManager.h and remove 
copy-constructor of the class FileEntry.

Test plan: make check-clang

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

llvm-svn: 284782
2016-10-20 21:20:35 +00:00
Reid Kleckner afd7b69658 Revert "Disable swiftcall test on windows: More brutal way to appease windows bots"
This reverts commit r284174. The tests pass for me locally. It must have
been a 2015 only crash.

Fixes PR30699

llvm-svn: 284781
2016-10-20 21:17:28 +00:00
Hans Wennborg 2b81f42a76 Revert r284753 "[c++1z] Teach composite pointer type computation how to compute the composite"
It caused PR30749.

llvm-svn: 284778
2016-10-20 20:54:32 +00:00
Reid Kleckner ae818501b7 Fix off-by-one error in PPCaching.cpp token annotation assertion
This assert is intended to defend against backtracking into the middle
of a sequence of tokens that is being replaced with an annotation, but
it's OK if we backtrack to the exact position of the start of the
annotation sequence. Use a <= comparison instead of <.

Fixes PR25946

llvm-svn: 284777
2016-10-20 20:53:20 +00:00
Michal Gorny 16f37c30a3 [Driver] Refactor DetectDistro() parameters to take VFS ref only. NFC
Refactor the DetectDistro() function to take a single vfs::FileSystem
reference only, instead of Driver and llvm::Triple::ArchType.
The ArchType parameter was not used anyway, and Driver was only used to
obtain the VFS.

Aside to making the API simpler and more transparent, it makes it
easier to add unit tests for the function in the future -- since
the tests would need only to provide an appropriate VFS.

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

llvm-svn: 284774
2016-10-20 20:45:40 +00:00
Michal Gorny 0a2cd96e05 [Driver] Parse Debian version as integer when possible. NFC
Replace the string matching for /etc/debian_version with split
integer/string matching algorithm. When the file contains 'major.minor'
version number, parse the major version as integer and use a switch
clause to match it. Otherwise, attempt 'codename/sid' matching using
a StringSwitch.

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

llvm-svn: 284770
2016-10-20 20:13:35 +00:00
Vedant Kumar 2d38ae6c41 [CodeGen] Devirtualize calls to methods marked final in a derived class
If we see a virtual method call to Base::foo() but can infer that the
object is an instance of Derived, and that 'foo' is marked 'final' in
Derived, we can devirtualize the call to Derived::foo().

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

llvm-svn: 284766
2016-10-20 18:44:14 +00:00
Richard Smith f70a906a11 [c++1z] Fix assertion failure when using the wrong number of bindings for a
struct with unnamed bitfields.

llvm-svn: 284761
2016-10-20 18:29:25 +00:00
Ekaterina Romanova 493091fdef Add more doxygen comments to emmintrin.h's intrinsics.
With this patch, 75% of the intrinsics in this file will be documented now. The patches for the rest of the intrisics in this file will be send out later.

The doxygen comments are automatically generated based on Sony's intrinsics document.

I got an OK from Eric Christopher to commit doxygen comments without prior code review upstream. This patch was internally reviewed by Yunzhong Gao.

llvm-svn: 284754
2016-10-20 17:59:15 +00:00
Richard Smith 9c37e66c31 [c++1z] Teach composite pointer type computation how to compute the composite
pointer type of two function pointers with different noexcept specifications.
While I'm here, also teach it how to merge dynamic exception specifications.

llvm-svn: 284753
2016-10-20 17:57:33 +00:00
Renato Golin f46be19104 [clang-cl] Fix test that shouldn't be running on non-x86
The clang-cl test required x86-registered-target but it defaulted to the
host's triple and AArch64 still doesn't support COFF, so the test failed.

The triple was "aarch64-pc-windows-msvc18.0.0" with ObjectFormat equals
llvm::Triple::COFF, failing assertion:

Assertion `(TT.isOSBinFormatELF() || TT.isOSBinFormatMachO()) &&
          "Only expect Darwin and ELF targets"

in AArch64MCTargetDesc.cpp:78.

Making the test only run on Windows hosts obviously fixes the problem.

llvm-svn: 284749
2016-10-20 17:41:08 +00:00
Malcolm Parsons 5d8cdb83db [Format] Cleanup after replacing constructor body with = default
Summary:
Remove colon and commas after replacing constructor body with = default.
Fix annotation of TT_CtorInitializerColon when preceded by a comment.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 284732
2016-10-20 14:58:45 +00:00
Benjamin Kramer c3f89253ae Retire llvm::alignOf in favor of C++11 alignof.
No functionality change intended.

llvm-svn: 284730
2016-10-20 14:27:22 +00:00
Benjamin Kramer e9f132d3f4 Clean up alignment hacks now that MSVC 2013 and GCC 4.7 are gone.
llvm-svn: 284729
2016-10-20 13:52:26 +00:00
Richard Smith e38da03f58 Work around MSVC rejects-valid. Apparenty (some versions of) MSVC will check
that a member is default-initializable even if it's initialized by a default
member initializer.

llvm-svn: 284701
2016-10-20 07:53:17 +00:00
Erik Pilkington 53937db801 Replace uses of LLVM_FUNCTION_NAME with __func__, this was macro was removed from llvm/Support in r284681
llvm-svn: 284690
2016-10-20 02:46:22 +00:00
Richard Smith 6ffdb1f3ed Refactor and simplify Sema::FindCompositePointerType. No functionality change intended.
llvm-svn: 284685
2016-10-20 01:20:00 +00:00
Richard Smith 6609443f2f PR26276: Fix detection of non-cast-expressions as operands of fold-expressions.
llvm-svn: 284684
2016-10-20 00:55:15 +00:00
Victor Leschuk 11eabd4cde Upgrade debug-info-vla test: we do not pass default alignment now
llvm-svn: 284683
2016-10-20 00:37:07 +00:00
Victor Leschuk a7ece03b32 DebugInfo: pass alignment value only if it was forced
Preparation to implement DW_AT_alignment support:
 - We pass non-zero align value to DIBuilder only when alignment was forced
 - Modify tests to match this change

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

llvm-svn: 284679
2016-10-20 00:13:19 +00:00
Richard Smith 6f42740707 Fix crash on noreturn conversion in unprototyped function type. Thanks to Keith
Walker for spotting the bug.

llvm-svn: 284673
2016-10-20 00:01:36 +00:00
Richard Smith 628954652f Extend hack to work around bad exception specifications for 'swap' members to
also cover libstdc++'s std::__debug::array and std::__profile::array.

llvm-svn: 284669
2016-10-19 23:47:37 +00:00
Reid Kleckner 6432d45f7b Use noexcept instead of LLVM_NOEXCEPT now that all compilers support it
llvm-svn: 284667
2016-10-19 23:39:55 +00:00
Michael Gottesman 66cc2d5210 [cmake] Follow LLVM's lead in creating exported tool targets for clang tools.
This is needed by downstream projects such as swift to get proper cmake
dependency information for LLVM/Clang targets.

A few months ago I added support for exporting this information for Clang
libraries. In order to be incremental, I did not add support for exporting clang
tools as well at that time. Now such support is needed, so I am committing this
incremental code.

llvm-svn: 284658
2016-10-19 22:46:06 +00:00
Richard Smith c5452ed941 Add optimization to sizeof...(X) handling: if none of parameter pack X's
corresponding arguments are unexpanded pack expansions, we can compute the
result without substituting them. This significantly improves the memory usage
and performance of make_integer_sequence implementations that do this kind of
thing:

  using result = integer_sequence<T, Ns ..., sizeof...(Ns) + Ns ...>;

... but note that such an implementation will still perform O(sizeof...(Ns)^2)
work while building the second pack expansion (we just have a somewhat lower
constant now).

In principle we could get this down to linear time by caching whether the
number of expansions of a pack is constant, or checking whether we're within an
alias template before scanning the pack for pack expansions (since that's the
only case in which we do substitutions within a dependent context at the
moment), but this patch doesn't attempt that.

llvm-svn: 284653
2016-10-19 22:18:42 +00:00
Eli Friedman 01d6b963d2 Don't crash generating debug info for VLA in function prototype.
Fixes regression from r279445.

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

llvm-svn: 284652
2016-10-19 22:16:32 +00:00
Victor Leschuk 802e4a58a6 DebugInfo: use uint32_t for alignment variables.
LLVM now uses uint32_t for DebugInfo alignment for space efficiency,
in this patch we change frontend DebugInfo-related variables to uint32_t too.

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

llvm-svn: 284651
2016-10-19 22:11:07 +00:00
Chris Bieneman 76a2e60e59 [CMake] Add clang-bootstrap-deps target
Having this target allows other parts of the build system to add to the bootstrap dependencies without needing to be defined before the bootstrap targets are created.

This will specifically be used connect the builtins build from the LLVM runtimes directory as a dependency of the next build stage.

llvm-svn: 284648
2016-10-19 21:18:48 +00:00
Justin Lebar 6c86e9160d [CUDA] When we emit an error that might have been deferred, also print a callstack.
Summary:
Previously, when you did something not allowed in a host+device function
and then caused it to be codegen'ed, we would print out an error telling
you that you did something bad, but we wouldn't tell you how we decided
that the function needed to be codegen'ed.

This change causes us to print out a callstack when emitting deferred
errors.  This is immensely helpful when debugging highly-templated code,
where it's often unclear how a function became known-emitted.

We only print the callstack once per function, after we print the all
deferred errors.

This patch also switches all of our hashtables to using canonical
FunctionDecls instead of regular FunctionDecls.  This prevents a number
of bugs, some of which are caught by tests added here, in which we
assume that two FDs for the same function have the same pointer value.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

llvm-svn: 284647
2016-10-19 21:15:01 +00:00
Chris Bieneman ebe8b83fbc [CMake] Support thin LTO in PGO CMake cache
This allows you to set PGO_INSTRUMENT_LTO=Thin and have it work correctly.

llvm-svn: 284646
2016-10-19 21:12:04 +00:00
Justin Lebar 2271ba2c52 [AST] Add CanonicalDeclPtr<T>.
Summary:
CanonicalDeclPtr<T> is just like a T*, except it calls
T::getCanonicalDecl() on construction.

This is useful as the key in a "set of canonical Decls" -- it's much
less error-prone than calling getCanonicalDecl() every time you touch
the set.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

llvm-svn: 284644
2016-10-19 21:03:42 +00:00
Justin Lebar 9730ae943f [CUDA] Emit errors for wrong-side calls made on the same line as non-wrong-side calls.
Summary:
This fixes two related bugs:

1) Previously, if you had a non-wrong side call at some source code
location L, we wouldn't emit errors for wrong-side calls that appeared
at L.

2) We'd only emit one wrong-side error per source code location, when we
actually want to emit it twice if we hit this line more than once due to
e.g. template instantiation.

Reviewers: tra

Subscribers: rnk, cfe-commits

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

llvm-svn: 284643
2016-10-19 21:03:38 +00:00
Vedant Kumar cdd6da83a6 [ubsan] Drop dependency on a 64-bit arch in a test (NFC)
This should fix:

    http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/46184

llvm-svn: 284642
2016-10-19 20:53:16 +00:00
Vedant Kumar da25927188 [ubsan] Re-work check lines to try to appease a bot (NFC)
This bot does not produce the IR I expect -- it's missing some
'handler.dynamic_type_cache_miss:' labels. We don't need to rely on
those labels, so get rid of them in hopes of making the bot happy.

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

llvm-svn: 284639
2016-10-19 20:28:35 +00:00
Sriraman Tallam 165a8845f8 New clang option -mpie-copy-relocations to use copy relocations for PIE builds.
Differential Revision: https://reviews.llvm.org/D19996

llvm-svn: 284638
2016-10-19 20:24:06 +00:00
Vedant Kumar 018f266bbc [ubsan] Use the object pointer's type info for devirtualized calls
ubsan reports a false positive 'invalid member call' diagnostic on the
following example (PR30478):

  struct Base1 {
    virtual int f1() { return 1; }
  };

  struct Base2 {
    virtual int f1() { return 2; }
  };

  struct Derived2 final : Base1, Base2 {
    int f1() override { return 3; }
  };

  int t1() {
    Derived2 d;
    return static_cast<Base2 *>(&d)->f1();
  }

Adding the "final" attribute to a most-derived class allows clang to
devirtualize member calls into an instance of that class. We should pass
along the type info of the object pointer to avoid the FP. In this case,
that means passing along the type info for 'Derived2' instead of 'Base2'
when checking the dynamic type of static_cast<Base2 *>(&d2).

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

llvm-svn: 284636
2016-10-19 20:21:16 +00:00
Hans Wennborg 0a79a1203a MS ABI: Fix assert when generating virtual function call with virtual bases and -flto (PR30731)
getClassAtVTableLocation() was calling
ASTRecordLayout::getBaseClassOffset() on a virtual base, causing an
assert.

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

llvm-svn: 284624
2016-10-19 18:04:27 +00:00
Simon Dardis 1f90f2d33f [mips][msa] Range check MSA intrinsics with immediates
This patch teaches clang to range check immediates for MIPS MSA instrinsics.
This checking is done strictly in comparison to some existing GCC
implementations. E.g. msa_andvi_b(var, 257) does not result in andvi $wX, 1.
Similarily msa_ldi_b takes a range of -128 to 127.

As part of this effort, correct the existing MSA test as it has both illegal
types and immediates.

Reviewers: vkalintiris

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

llvm-svn: 284620
2016-10-19 17:50:52 +00:00
Douglas Katzman 69d7cf0d41 [Myriad] Find libc++ headers next to clang binary
llvm-svn: 284617
2016-10-19 17:30:40 +00:00
Benjamin Kramer f1fce6e966 Remove unused diagnostics. NFC.
llvm-svn: 284595
2016-10-19 14:22:38 +00:00
Benjamin Kramer 089a39e859 Don't copy replacements in for-range loop. NFC.
llvm-svn: 284589
2016-10-19 13:50:17 +00:00
Michal Gorny 0ed2f4e98b [cmake] Use LLVM_CMAKE_PATH for GetSVN script
Use the LLVM_CMAKE_PATH variable to locate the GetSVN.cmake script.
The variable was already available in stand-alone builds, and is also
set by LLVM since r284581.

llvm-svn: 284582
2016-10-19 12:21:39 +00:00
Andrey Bokhanko 9941ca8af6 [Sema] Gcc compatibility of vector shift
Gcc prints error if elements of left and right parts of a shift have different
sizes. This patch is provided the GCC compatibility.

Patch by Vladimir Yakovlev.

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

llvm-svn: 284579
2016-10-19 12:06:10 +00:00
Vassil Vassilev c774a23bd9 [modules] Do not report missing definitions of demoted constexpr variable templates.
This is a followup to regression introduced in r284284.

This should fix our libstdc++ modules builds.

https://reviews.llvm.org/D25678

Reviewed by Richard Smith!

llvm-svn: 284577
2016-10-19 11:19:30 +00:00
Eric Liu 99eeab7ff3 [clang-format] Add comment manipulation header
Summary:
Introduces a separate target for comment manipulation.
Currently, comment manipulation is in BreakableComment.cpp.
Towards implementing comment reflowing, we want to factor out the
comment-related functionality, so it can be reused.
Start simple by just moving out getLineCommentIndentPrefix.

Patch by Krasimir Georgiev!

Reviewers: djasper

Subscribers: klimek, beanz, mgorny, modocache

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

llvm-svn: 284573
2016-10-19 08:19:46 +00:00
Richard Smith 5f4b388442 Resolve exception specifications when selecting an overloaded operator.
llvm-svn: 284556
2016-10-19 00:14:23 +00:00
Justin Lebar d3fd70dedd [CUDA] Rework tests now that we emit deferred diagnostics during sema. Test-only change.
Summary:
Previously we had to split out a lot of our tests into a test that
checked only immediate errors and a test that checked only deferred
errors.  This was because, if you emitted any immediate errors, we
wouldn't run codegen, where the deferred errors were emitted.

We've fixed this, and now emit deferred errors during sema.  This lets
us merge a bunch of tests, and lets us convert some other tests to
-fsyntax-only.

Reviewers: tra

Subscribers: cfe-commits

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

llvm-svn: 284553
2016-10-19 00:06:49 +00:00
Richard Smith 84a0b6dba1 DR1330: instantiate exception-specifications when "needed". We previously did
not instantiate exception specifications of functions if they were only used in
unevaluated contexts (other than 'noexcept' expressions).

In C++17 onwards, this becomes essential since the exception specification is
now part of the function's type.

Note that this means that constructs like the following no longer work:

  struct A {
    static T f() noexcept(...);
    decltype(f()) *p;
  };

... because the decltype expression now needs the exception specification of
'f', which has not yet been parsed.

llvm-svn: 284549
2016-10-18 23:39:12 +00:00
Richard Smith fccb5128b2 Add missing warning for use of C++1z init-statements in C++14 and before.
llvm-svn: 284530
2016-10-18 20:27:16 +00:00
Richard Smith 304b124a11 [c++1z] Fix corner case where we could create a function type whose canonical type is not actually canonical.
llvm-svn: 284528
2016-10-18 20:13:25 +00:00
Richard Smith 2a2cda58f8 When two function types have equivalent (but distinct) noexcept specifications, create separate type sugar nodes. This is necessary so that substitution into the exception specification will substitute into the correct expression.
llvm-svn: 284519
2016-10-18 19:29:18 +00:00
Mandeep Singh Grang a5065216d0 Fix clang tests
Summary:
Add REQUIRES for target specific tests.

Patch by Azharuddin Mohammed.

Reviewers: apazos, weimingz, rsmith, ddunbar, spop, mgrang

Subscribers: sebpop, llvm-commits

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

llvm-svn: 284517
2016-10-18 19:22:20 +00:00
Akira Hatanaka 642f799b0d [CodeGen][ObjC] Do not call objc_storeStrong when initializing a
constexpr variable.

When compiling a constexpr NSString initialized with an objective-c
string literal, CodeGen emits objc_storeStrong on an uninitialized
alloca, which causes a crash.

This patch folds the code in EmitScalarInit into EmitStoreThroughLValue
and fixes the crash by calling objc_retain on the string instead of
using objc_storeStrong.

rdar://problem/28562009

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

llvm-svn: 284516
2016-10-18 19:05:41 +00:00
Vedant Kumar ecc3144031 Drop a redundant ".get()" call (NFC)
Pointed out by Malcolm Parsons.

llvm-svn: 284510
2016-10-18 18:19:02 +00:00
Michal Gorny da6d2b8315 [cmake] Update lit search to match the one in LLVM
Update the lit search logic to support all names supported in LLVM
(since r283029). The search order (i.e. PATHS vs HINTS) does no really
matter since the established path is not used, except for determining
whether lit is available.

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

llvm-svn: 284496
2016-10-18 17:07:30 +00:00
Erik Pilkington d080746c19 Revert r284265 "[Sema] Refactor context checking for availability diagnostics"
This has a bug in it, pointed out by Bob Wilson!

llvm-svn: 284486
2016-10-18 15:26:43 +00:00
Daniel Marjamaki fa1bf447d9 alpha.core.UnreachableCode - don't warn about unreachable code inside macro
In macros, 'do {...} while (0)' is often used. Don't warn about the condition 0 when it is unreachable.

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

llvm-svn: 284477
2016-10-18 13:16:53 +00:00
Artem Dergachev 940c770d27 [analyzer] Add NumberObjectConversion checker.
When dealing with objects that represent numbers, such as Objective-C NSNumber,
the language provides little protection from accidentally interpreting
the value of a pointer to such object as the value of the number represented
by the object. Results of such mis-interpretation may be unexpected.

The checker attempts to fill this gap in cases when the code is obviously
incorrect.

With "Pedantic" option enabled, this checker enforces a coding style to
completely prevent errors of this kind (off by default).

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

llvm-svn: 284473
2016-10-18 11:06:28 +00:00
Alex Lorenz f0b4e5db16 [CodeCompletion] Add a block property setter completion result
This commit changes code completion results for Objective-C block properties:
clang now suggests an additional completion result that displays the block
property together with '=' and the block literal placeholder for the appropriate
readwrite block properties.

This commit uses a simple heuristic to determine when it's appropriate to
suggest a setter completion for block properties: the additional block setter
completion is provided iff the member access that's being completed is a
standalone statement.

rdar://28481726

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

llvm-svn: 284472
2016-10-18 10:55:01 +00:00
Alex Lorenz 920ae14388 [CodeCompletion][NFC] Extract a function that formats block placeholders.
This commit extracts a new function named `formatBlockPlaceholder` from
the function `FormatFunctionParameter` so that it can be reused in follow-up
commits that improve code completion for block property setters.

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

llvm-svn: 284468
2016-10-18 10:38:58 +00:00
Alex Lorenz a1951202c2 [CodeCompletion][NFC] Extract a function that looks for block decl type locs.
This commit extracts a new function named `findTypeLocationForBlockDecl` from
the function `FormatFunctionParameter` so that it can be reused in follow-up
commits that improve code completion for block property setters.

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

llvm-svn: 284467
2016-10-18 10:35:27 +00:00
Igor Kudrin 692f4e95cf [libclang] Add missing cursor kinds to python bindings.
Differential Revision: https://reviews.llvm.org/D25673

llvm-svn: 284464
2016-10-18 09:42:03 +00:00
Igor Kudrin a6ea95ad64 [libclang] Fix a failure in a test for python bindings on CursorKind.OVERLOAD_CANDIDATE.
The test fails because the value does not lay in any existing group.

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

llvm-svn: 284463
2016-10-18 09:30:33 +00:00
Richard Smith 391fb8662a [c++1z] Include "noexcept" in builtin function types where appropriate. Fixes
an assertion failure looking up a matching ::operator delete for
__builtin_operator_delete.

llvm-svn: 284458
2016-10-18 07:13:55 +00:00
Richard Smith 99677afd54 [c++1z] Use canonical expression equivalence to determine whether two different
dependent noexcept specifications result in the same canonical function type.

We still use non-canonical hashing when deduplicating type sugar so that
diagnostics will point to the right place.

llvm-svn: 284457
2016-10-18 06:47:03 +00:00
Dominic Chen a1ab61cd8b [analyzer] Update alpha and potential checker documentation, esp. alpha.valist
Summary:
Move alpha.valist from potential to alpha since it was implemented in D15227

Cleanup some HTML comments, add a missing link

Reviewers: jordan_rose, zaks.anna

Subscribers: cfe-commits, xazax.hun

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

llvm-svn: 284445
2016-10-18 01:15:19 +00:00
Chris Bieneman b137053189 [CMake] Add a few default passthrough variables for bootstrap builds
This just passes through a few missing CMake variables for multi-stage builds.

llvm-svn: 284443
2016-10-18 00:50:20 +00:00
Vedant Kumar d2c6a6d134 [Basic] unique_ptr-ify SourceManager::MacroArgsCacheMap (NFC)
Differential Revision: https://reviews.llvm.org/D25711

llvm-svn: 284442
2016-10-18 00:23:27 +00:00
Petr Hosek b406388e5f [Driver] Use stem rather than filename for executable name
When comparing the linker name in Fuchsia driver, use stem rather
than filename to get the name of the linker becase on Windows, the
filename will have an extension.

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

llvm-svn: 284430
2016-10-17 22:02:53 +00:00
Adrian Prantl fac32f3f6a Explicitly pass an isysroot to avoid the SDKROOT overriding the deployment target.
This fixes the green dragon builders after r284416.

llvm-svn: 284423
2016-10-17 20:37:56 +00:00
Adrian Prantl 3e23c04f0a Improve the CHECK lines in debug-options.c by separating out the check
for debug info kind and dwarf version.

llvm-svn: 284420
2016-10-17 20:14:23 +00:00
Davide Italiano 877428dee1 [Coverage] Update test after r284418.
We now strip coverage metadata if debug info are not present.

llvm-svn: 284419
2016-10-17 20:06:32 +00:00
Adrian Prantl 119a998ae3 Update testcase for r284416.
llvm-svn: 284417
2016-10-17 19:46:26 +00:00
Adrian Prantl d50d56c774 Driver/Darwin: Set the DWARF version based on the deployment target.
System utilities such as atos only support DWARF 4 on OS X 10.11+ and
iOS 9+. We thus want to enable DWARF 4 only if the deployment target
has a recent enough operating system version and use DWARF 2 for older
systems.

<rdar://problem/28766743>

llvm-svn: 284416
2016-10-17 19:36:18 +00:00
Michal Gorny 9e1b6e108e [Driver] Use VFS to perform all distribution checks
Use the VFS provided by D.getVFS() for all distribution checks,
including those performing read of the release file. Requested
by @bruno on D24954.

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

llvm-svn: 284403
2016-10-17 18:07:15 +00:00
Krzysztof Parzyszek ff5ee6a36a Add a dummy file in each subdirectory in test/Driver/Inputs/hexagon_tree
Git does not store empty subdirectories (while SVN does). Git clone of
the clang repository did not create the fake Hexagon installation tree
used for testing the driver. This only became evident after a change
in the Hexagon toolchain that started checking for existence of certain
directories.

llvm-svn: 284402
2016-10-17 18:04:05 +00:00
Tim Northover a43458bfe4 Hexagon: add dummy files to test dir so git keeps them.
Should fix hexagon-elf-toolchain.c tests on Git.

llvm-svn: 284401
2016-10-17 18:00:27 +00:00
Adrian Prantl c5751a8378 Fix a typo.
llvm-svn: 284400
2016-10-17 17:41:51 +00:00
Krzysztof Parzyszek 50fd615f54 Reapply r284383. The test failures were due to a missing dir in test/
llvm-svn: 284392
2016-10-17 15:30:10 +00:00
Krzysztof Parzyszek d45a60449b Revert r284383, while I figure out how to reproduce the failures locally
llvm-svn: 284389
2016-10-17 14:47:29 +00:00
Krzysztof Parzyszek cdcd403bc2 Return correct path from HexagonToolChain::getHexagonTargetDir
This problem was exposed by r284129, causing clang-hexagon-elf to fail
clang tests.

llvm-svn: 284383
2016-10-17 13:23:41 +00:00
Benjamin Kramer a72a70aeb9 Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"
This reverts commit r284176. It still marks some modules as invisible
that should be visible. Will follow up with the author with a test case.

llvm-svn: 284382
2016-10-17 13:00:44 +00:00
Vassil Vassilev 45bf62fc5e Do not reset TUScope when we are in incremental processing mode.
Patch by Axel Naumann!

Reviewed by Richard Smith and me.

llvm-svn: 284372
2016-10-17 10:15:25 +00:00
Justin Bogner fe183d7e96 AST: Prefer LLVM_NODISCARD to LLVM_ATTRIBUTE_UNUSED_RESULT
llvm-svn: 284366
2016-10-17 06:46:35 +00:00
Justin Lebar d692dfb65e [CUDA] Fix false-positive in known-emitted handling.
Previously: When compiling for host, our constructed call graph went
*through* kernel calls.  This meant that if we had

  host calls kernel calls HD

we would incorrectly mark the HD function as known-emitted on the host
side, and thus perform host-side checks on it.

Fixing this exposed another issue, wherein when marking a function as
known-emitted, we also need to traverse the callgraph of its template,
because non-dependent calls are attached to a function's template, not
its instantiation.

llvm-svn: 284355
2016-10-17 02:25:55 +00:00
NAKAMURA Takumi e04c253a94 clang/test/CXX/conv/conv.fctptr/p1.cpp: Appease for targeting i686-win32.
error: 'error' diagnostics seen but not expected:
    File clang\test\CXX\conv\conv.fctptr\p1.cpp Line 16: assigning to 'void (S::*)() __attribute__((thiscall)) noexcept' from incompatible type 'void (S::*)() __attribute__((thiscall))': different exception specifications

llvm-svn: 284352
2016-10-16 23:00:18 +00:00
Devin Coughlin 684d19d879 Revert "Revert "[analyzer] Make MallocChecker more robust against custom redeclarations""
This reverts commit r284340 to reapply r284335. The bot breakage was due to
an unrelated change in the polybench test suite.

llvm-svn: 284351
2016-10-16 22:19:03 +00:00
Justin Bogner 14994133bb AST: Improve a couple of comments and cast unused values to void
Make these comments a bit more explicit that they're initializing the
RawText member, and explicitly cast the unused result of getRawText to
void for clarity.

llvm-svn: 284341
2016-10-16 20:12:42 +00:00
Devin Coughlin eeb8d20db4 Revert "[analyzer] Make MallocChecker more robust against custom redeclarations"
This reverts commit r284335.

It appears to be causing test-suite compile-time and execution-time
performance measurements to take longer than expected on several bots.
This is surprising, because r284335 is a static-analyzer-only change.

llvm-svn: 284340
2016-10-16 19:26:07 +00:00
Richard Smith 3c4f8d2e96 P0012R1: Make exception specifications be part of the type system. This
implements the bulk of the change (modifying the type system to include
exception specifications), but not all the details just yet.

llvm-svn: 284337
2016-10-16 17:54:23 +00:00
Devin Coughlin 62ce463a35 [analyzer] Make MallocChecker more robust against custom redeclarations
Add additional checking to MallocChecker to avoid crashing when memory
routines have unexpected numbers of arguments. You wouldn't expect to see much
of this in normal code (-Wincompatible-library-redeclaration warns on this),
but, for example, CMake tests can generate these.

This is PR30616.

rdar://problem/28631974

llvm-svn: 284335
2016-10-16 17:26:06 +00:00
Richard Smith ebb006e875 Extend this test and make it a bit clearer which cases Clang is getting wrong.
llvm-svn: 284331
2016-10-16 06:23:29 +00:00
Devin Coughlin 4fba10c394 Revert "[analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker""
Revert:
r283662: [analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker"
r283660: [analyzer] Fix build error after r283660 - remove constexpr strings.

It was causing an internal build bot to fail. It looks like in some cases
adding an extra note can cause scan-build plist output to drop a diagnostic
altogether.

llvm-svn: 284317
2016-10-16 00:30:08 +00:00
Richard Smith 49db68d59b Disable a silly GCC diagnostic for combining a scanf length specifier with the
'*' specifier. Apparently the GNU folks want to discourage self-documenting
code.

llvm-svn: 284300
2016-10-15 01:59:52 +00:00
Vedant Kumar 9d2a16b9b1 [Coverage] Support for C++17 if initializers
Differential Revision: https://reviews.llvm.org/D25572

llvm-svn: 284293
2016-10-14 23:38:16 +00:00
Vedant Kumar f2a6ec5521 [Coverage] Support for C++17 switch initializers
Differential Revision: https://reviews.llvm.org/D25539

llvm-svn: 284292
2016-10-14 23:38:13 +00:00
Saleem Abdulrasool 8bbc3158c3 Sema: honour dllexport in itanium more faithfully
Although the itanium environment uses the itanium layout for C++, treat the
dllexport semantics more similarly to the MSVC specification.  This preserves
the existing behaviour for the use of the itanium ABI on non-windows-itanium
environments.  Export the inline definitions too.

llvm-svn: 284288
2016-10-14 22:25:46 +00:00
Arnold Schwaighofer b715eb4504 Add more swift calling convention tests
llvm-svn: 284285
2016-10-14 21:55:56 +00:00
Richard Smith edbc6e93e1 Reinstate r284008 reverted in r284081, with two fixes:
1) Merge and demote variable definitions when we find a redefinition in
MergeVarDecls, not only when we find one in AddInitializerToDecl (we only reach
the second case if it's the addition of the initializer itself that converts an
existing declaration into a definition). 

2) When rebuilding a redeclaration chain for a variable, if we merge two
definitions together, mark the definitions as merged so the retained definition
is made visible whenever the demoted definition would have been.

Original commit message (from r283882):

[modules] PR28752: Do not instantiate variable declarations which are not visible.

Original patch by Vassil Vassilev! Changes listed above are mine.

llvm-svn: 284284
2016-10-14 21:41:24 +00:00
David L Kreitzer d397ea4d6f Define Contiki OS toolchain
Patch by Michael LeMay

Differential revision: http://reviews.llvm.org/D19854

llvm-svn: 284278
2016-10-14 20:44:33 +00:00
David Sheinkman c37a49896a __builtin_fpclassify missing one int parameter
Patch by Tania Albarghouthi.

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

llvm-svn: 284277
2016-10-14 20:43:37 +00:00
Douglas Katzman 3ed0f643fc Implement no_sanitize_address for global vars
llvm-svn: 284272
2016-10-14 19:55:09 +00:00
Richard Smith f80a27e3c6 [linux] When pre-reserving stack pages to work around broken address space
layout for PIE binaries, ask the OS how much stack space is already in use to
avoid stack overflow if we are run with more than 512K of combined command line
arguments + environment variables.

llvm-svn: 284271
2016-10-14 19:51:36 +00:00
Erik Pilkington 88eff2575e [Sema] Refactor context checking for availability diagnostics
This commit combines a couple of redundant functions that do availability
attribute context checking into a more correct/simpler one.

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

llvm-svn: 284265
2016-10-14 19:08:01 +00:00
Manman Ren 3b5dbf23a4 Module: emit initializers in submodules when importing the parent module.
When importing the parent module, module initializers in submodules should
be emitted.

rdar://28740482

llvm-svn: 284263
2016-10-14 18:55:44 +00:00
Ed Maste 55633f7682 Revert r284256 due to test failure
llvm-svn: 284259
2016-10-14 18:20:12 +00:00
Ed Maste aaa44fe5cd Link static PIE programs against rcrt0.o on OpenBSD
Patch by Stefan Kempf.

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

llvm-svn: 284256
2016-10-14 17:59:53 +00:00
Albert Gutowski 1deab38717 Implement __stosb intrinsic as a volatile memset
Summary: We need `__stosb` to be an intrinsic, because SecureZeroMemory function uses it without including intrin.h. Implementing it as a volatile memset is not consistent with MSDN specification, but it gives us target-independent IR while keeping the most important properties of `__stosb`.

Reviewers: rnk, hans, thakis, majnemer

Subscribers: cfe-commits

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

llvm-svn: 284253
2016-10-14 17:33:05 +00:00
Alexey Bataev bef6aa6ea9 Fix for PR30632: Name mangling issue.
There was a bug in the implementation of captured statements. If it has
a lambda expression in it and the same lambda expression is used outside
the captured region, clang produced an error:
```
error: definition with same mangled name as another definition
```
Here is an example:
```
struct A {
 template <typename L>
 void g(const L&) { }
};

template<typename T>
void f() {
  {
    A().g([](){});
  }
  A().g([](){});
}

int main() {
  f<void>();
}
```

Error report:
```
main.cpp:3:10: error: definition with same mangled name as another
definition
    void g(const L&) { }
             ^
main.cpp:3:10: note: previous definition is here
```
Patch fixes this bug.

llvm-svn: 284229
2016-10-14 12:43:59 +00:00