]> granicus.if.org Git - clang/log
clang
6 years ago[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested...
Simon Marchi [Mon, 6 Aug 2018 21:48:20 +0000 (21:48 +0000)]
[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name

Summary:
InMemoryFileSystem::status behaves differently than
RealFileSystem::status.  The Name contained in the Status returned by
RealFileSystem::status will be the path as requested by the caller,
whereas InMemoryFileSystem::status returns the normalized path.

For example, when requested the status for "../src/first.h",
RealFileSystem returns a Status with "../src/first.h" as the Name.
InMemoryFileSystem returns "/absolute/path/to/src/first.h".

The reason for this change is that I want to make a unit test in the
clangd testsuite (where we use an InMemoryFileSystem) to reproduce a
bug I get with the clangd program (where a RealFileSystem is used).
This difference in behavior "hides" the bug in the unit test version.

An indirect impact of this change is that a -Wnonportable-include-path
warning is now emitted in test PCH/case-insensitive-include.c.  This is
because the real path of the included file (with the wrong case) was not
available previously, whereas it is now.

Reviewers: malaperle, ilya-biryukov, bkramer

Reviewed By: ilya-biryukov

Subscribers: eric_niebler, malaperle, omtcyfz, hokein, bkramer, ilya-biryukov, ioeric, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339063 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[MinGW] Predefine UNICODE if -municode is specified during compilation
Martin Storsjo [Mon, 6 Aug 2018 19:48:44 +0000 (19:48 +0000)]
[MinGW] Predefine UNICODE if -municode is specified during compilation

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339048 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix for broken build on clang-hexagon-elf for ambiguous call to
Leonard Chan [Mon, 6 Aug 2018 19:31:00 +0000 (19:31 +0000)]
Fix for broken build on clang-hexagon-elf for ambiguous call to
std::abs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339044 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Remove TODO comment that no longer applies (ParsedAttr)
Erich Keane [Mon, 6 Aug 2018 18:11:48 +0000 (18:11 +0000)]
[NFC] Remove TODO comment that no longer applies (ParsedAttr)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339039 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemoved the OverflowConversionsToFract tests for now. Will add them back
Leonard Chan [Mon, 6 Aug 2018 18:02:16 +0000 (18:02 +0000)]
Removed the OverflowConversionsToFract tests for now. Will add them back
in once I figure out why this doesn't work on windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339038 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix for failing test from sanitizer-x86_64-linux-fast where there was a
Leonard Chan [Mon, 6 Aug 2018 17:55:38 +0000 (17:55 +0000)]
Fix for failing test from sanitizer-x86_64-linux-fast where there was a
left shift on a negative value.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339037 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoForce test/Driver/fuchsia.c(pp) to use lld
David Greene [Mon, 6 Aug 2018 17:35:44 +0000 (17:35 +0000)]
Force test/Driver/fuchsia.c(pp) to use lld

The Fuchsia driver relies on lld so invoke clang with
-fuse-ld=lld. This gets the test passing when the clang default linker
is something other than lld.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339036 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Fixed Point Arithmetic] Remove unused include.
Benjamin Kramer [Mon, 6 Aug 2018 16:53:21 +0000 (16:53 +0000)]
[Fixed Point Arithmetic] Remove unused include.

lib/Basic cannot depend on lib/AST.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339031 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Remove unnecessary indirections in DeclarationNameTable
Bruno Ricci [Mon, 6 Aug 2018 16:47:31 +0000 (16:47 +0000)]
[AST] Remove unnecessary indirections in DeclarationNameTable

DeclarationNameTable currently hold 3 "void *" to
FoldingSet<CXXSpecialName>, FoldingSet<CXXLiteralOperatorIdName>
and FoldingSet<CXXDeductionGuideNameExtra>.

CXXSpecialName, CXXLiteralOperatorIdName and
CXXDeductionGuideNameExtra are private classes holding extra
information about a "special" declaration name and are in
AST/DeclarationName.cpp. The original intent seems to have
been to keep these classes private and only expose
DeclarationNameExtra and DeclarationName (the code dates from
2008 and has not been significantly changed since).

However this make the code less straightforward than necessary
because of the need to have "void *" in DeclarationNameTable
(with 1 of 3 comments wrong) and to manually allocate/deallocate
the FoldingSets.

Moreover removing the extra indirections reduce the run-time of
an fsyntax-only on all of Boost by 2.3% which is not totally
unexpected given how frequently this data structure is used
(especially for C++).

A concern raised by erichkeane during the review was that
including Type.h would increase the compile time unreasonably.
However test builds (both clean and incremental) showed that
this patch did not result in any compile time increase.

Reviewed By: erichkeane

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339030 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Fixed Point Arithmetic] Fixed Point Constant
Leonard Chan [Mon, 6 Aug 2018 16:42:37 +0000 (16:42 +0000)]
[Fixed Point Arithmetic] Fixed Point Constant

This patch proposes an abstract type that represents fixed point numbers, similar to APInt or APSInt that was discussed in https://reviews.llvm.org/D48456#inline-425585. This type holds a value, scale, and saturation and is meant to perform intermediate calculations on constant fixed point values.

Currently this class is used as a way for handling the conversions between fixed point numbers with different sizes and radixes. For example, if I'm casting from a signed _Accum to a saturated unsigned short _Accum, I will need to check the value of the signed _Accum to see if it fits into the short _Accum which involves getting and comparing against the max/min values of the short _Accum. The FixedPointNumber class currently handles the radix shifting and extension when converting to a signed _Accum.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339028 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Fixed Point Arithmetic] Fix for FixedPointValueToString
Leonard Chan [Mon, 6 Aug 2018 16:05:08 +0000 (16:05 +0000)]
[Fixed Point Arithmetic] Fix for FixedPointValueToString

- Print negative numbers correctly
- Handle APInts of different sizes
- Add formal unit tests for FixedPointValueToString
- Add tests for checking correct printing when padding is set
- Restrict to printing in radix 10 since that's all we need for now

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339026 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Add individual size info for Types in -print-stats
Bruno Ricci [Mon, 6 Aug 2018 15:17:32 +0000 (15:17 +0000)]
[AST] Add individual size info for Types in -print-stats

This mirrors what is done for Decls and Stmts in the -print-stats
output, ie instead of printing "57426 LValueReference types"
we print "57426 LValueReference types, 40 each (2297040 bytes)".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339024 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ASTmporter] SourceRange-free function parameter checking for declarations
Gabor Marton [Mon, 6 Aug 2018 14:38:37 +0000 (14:38 +0000)]
[ASTmporter] SourceRange-free function parameter checking for declarations

Summary: The previous code which avoided infinite recursion (because of reparsing declarations in function parameter lists) contained SourceRange dependent code which had some problems when parameter types were coming from macros. The new solution is not using macros and therefore much safer. A couple of importer problems are fixed in redis and tmux by this fix. Various unittests are included.

Reviewers: a.sidorin, r.stahl, a_sidorin

Reviewed By: a_sidorin

Subscribers: cfe-commits, dkrupp, balazske, martong

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

Patch by Zoltan Gera!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339018 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Move the enum in ObjCMethodDeclBitfields
Bruno Ricci [Mon, 6 Aug 2018 14:33:45 +0000 (14:33 +0000)]
[AST] Move the enum in ObjCMethodDeclBitfields

Move the enum { ObjCMethodFamilyBitWidth = 4 } to the top of
the class. For some dark reason having the enum between the
bitfields breaks the packing with gcc version 7.3-win32 20180312.

Reported by: Abramo Bagnara (by email)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339017 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang] Fix broken include_next in float.h
Louis Dionne [Mon, 6 Aug 2018 14:29:47 +0000 (14:29 +0000)]
[clang] Fix broken include_next in float.h

Summary:
The code defines __FLOAT_H and then includes the next <float.h>, which is
guarded on __FLOAT_H so it gets skipped entirely. This commit uses the header
guard __CLANG_FLOAT_H, like other headers (such as limits.h) do.

Reviewers: jfb

Subscribers: dexonsmith, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339016 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoclang-cl: Parse the new /JMC flag
Hans Wennborg [Mon, 6 Aug 2018 11:34:46 +0000 (11:34 +0000)]
clang-cl: Parse the new /JMC flag

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339008 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-rename] make clang-rename.py vim integration python3 compatible
Jonas Toth [Mon, 6 Aug 2018 09:08:06 +0000 (09:08 +0000)]
[clang-rename] make clang-rename.py vim integration python3 compatible

Summary:
This patch makes the clang-rename.py script useable for vim with only python3
support. It uses the print-function and adjust the doc slightly to mention
the correct python3 command for the letter mapping in vim.

Reviewers: arphaman, klimek, aaron.ballman, hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338996 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[DebugInfo] Generate debug information for labels. (Fix PR37395)"
Hsiangkai Wang [Mon, 6 Aug 2018 07:07:18 +0000 (07:07 +0000)]
Revert "[DebugInfo] Generate debug information for labels. (Fix PR37395)"

Build failed in
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/27258

In lib/CodeGen/LiveDebugVariables.cpp:589, it uses std::prev(MBBI) to
get DebugValue's SlotIndex. however, the previous instruction may be
also a debug instruction.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338992 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfo] Generate debug information for labels. (Fix PR37395)
Hsiangkai Wang [Mon, 6 Aug 2018 05:58:59 +0000 (05:58 +0000)]
[DebugInfo] Generate debug information for labels. (Fix PR37395)

Generate DILabel metadata and call llvm.dbg.label after label
statement to associate the metadata with the label.

After fixing PR37395.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338989 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfo] Use DbgVariableIntrinsic as the base class of variables.
Hsiangkai Wang [Mon, 6 Aug 2018 04:00:08 +0000 (04:00 +0000)]
[DebugInfo] Use DbgVariableIntrinsic as the base class of variables.

After refactoring DbgInfoIntrinsic class hierarchy, we use
DbgVariableIntrinsic as the base class of variable debug info.

In resolveTopLevelMetadata() in CGVTables.cpp, we only care about
dbg.value, so we try to cast the instructions to DbgVariableIntrinsic
before resolving variables.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338985 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[docs] Don't use the `asm` syntax highlighting (which our docs builder
Chandler Carruth [Mon, 6 Aug 2018 01:28:42 +0000 (01:28 +0000)]
[docs] Don't use the `asm` syntax highlighting (which our docs builder
errors on) and clean up the formattting.

This isn't actualy assembly anyways, so dropping the highlighting is
probably for the best.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338979 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix tests for changed opt remarks format
David Bolvansky [Sun, 5 Aug 2018 14:53:34 +0000 (14:53 +0000)]
Fix tests for changed opt remarks format

Summary:
Optimization remark format is slightly changed by LLVM patch D49412.
Two tests are fixed with expected messages changed.
Frankly speaking I have not tested this change yet. I will test when manage to setup the project.

Reviewers: xbolva00

Reviewed By: xbolva00

Subscribers: mehdi_amini, eraman, steven_wu, dexonsmith

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338971 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST][NFC] Remove unneeded forward declarations in Type.h
Bruno Ricci [Sun, 5 Aug 2018 09:48:59 +0000 (09:48 +0000)]
[AST][NFC] Remove unneeded forward declarations in Type.h

These forward declarations for various classes in the Type
hierarchy are not needed since they are all forward declared
systematically a few lines below.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338966 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUse Optional instead of unique_ptr; NFC
George Burgess IV [Sun, 5 Aug 2018 01:37:07 +0000 (01:37 +0000)]
Use Optional instead of unique_ptr; NFC

Looks like the only reason we use a unique_ptr here is so that we can
conditionally construct a LogicalErrorHandler. It's a small type, and
Optional can do the same thing with 100% fewer heap allocations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338962 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[clang-fuzzer] Remove unused typedef.
Matt Morehouse [Sat, 4 Aug 2018 01:42:47 +0000 (01:42 +0000)]
[clang-fuzzer] Remove unused typedef.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338946 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAvoid creating conditional cleanup blocks that contain only @llvm.lifetime.end calls
Richard Smith [Sat, 4 Aug 2018 01:25:06 +0000 (01:25 +0000)]
Avoid creating conditional cleanup blocks that contain only @llvm.lifetime.end calls

When a non-extended temporary object is created in a conditional branch, the
lifetime of that temporary ends outside the conditional (at the end of the
full-expression). If we're inserting lifetime markers, this means we could end
up generating

  if (some_cond) {
    lifetime.start(&tmp);
    Tmp::Tmp(&tmp);
  }
  // ...
  if (some_cond) {
    lifetime.end(&tmp);
  }

... for a full-expression containing a subexpression of the form `some_cond ?
Tmp().x : 0`. This patch moves the lifetime start for such a temporary out of
the conditional branch so that we don't need to generate an additional basic
block to hold the lifetime end marker.

This is disabled if we want precise lifetime markers (for asan's
stack-use-after-scope checks) or of the temporary has a non-trivial destructor
(in which case we'd generate an extra basic block anyway to hold the destructor
call).

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338945 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoLLVM Proto Fuzzer - Run Functions on Suite of Inputs
Emmett Neyman [Sat, 4 Aug 2018 01:18:37 +0000 (01:18 +0000)]
LLVM Proto Fuzzer - Run Functions on Suite of Inputs

Summary:
Added corpus of arrays to use as inputs for the functions. Check that the two
functions modify the inputted arrays in the same way.

Reviewers: kcc, morehouse

Reviewed By: morehouse

Subscribers: mgorny, cfe-commits, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338943 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[www] Update cxx_status and cxx_dr_status now that Clang 7 has branched.
Richard Smith [Sat, 4 Aug 2018 01:02:00 +0000 (01:02 +0000)]
[www] Update cxx_status and cxx_dr_status now that Clang 7 has branched.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338942 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[constexpr] Support for constant evaluation of __builtin_memcpy and
Richard Smith [Sat, 4 Aug 2018 00:57:17 +0000 (00:57 +0000)]
[constexpr] Support for constant evaluation of __builtin_memcpy and
__builtin_memmove (in non-type-punning cases).

This is intended to permit libc++ to make std::copy etc constexpr
without sacrificing the optimization that uses memcpy on
trivially-copyable types.

__builtin_strcpy and __builtin_wcscpy are not handled by this change.
They'd be straightforward to add, but we haven't encountered a need for
them just yet.

This reinstates r338455, reverted in r338602, with a fix to avoid trying
to constant-evaluate a memcpy call if either pointer operand has an
invalid designator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338941 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Do not crash in NoStoreFuncVisitor notes if an unexpected region is found.
George Karpenkov [Fri, 3 Aug 2018 23:19:07 +0000 (23:19 +0000)]
[analyzer] Do not crash in NoStoreFuncVisitor notes if an unexpected region is found.

Just do not generate the note at all in that case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338935 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.
Volodymyr Sapsai [Fri, 3 Aug 2018 23:12:37 +0000 (23:12 +0000)]
[Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

Libc++ needs to know when aligned allocation is supported by clang, but is
otherwise unavailable at link time. Otherwise, libc++ will incorrectly end up
generating calls to `__builtin_operator_new`/`__builtin_operator_delete` with
alignment arguments.

This patch implements the following changes:

* The `__cpp_aligned_new` feature test macro to no longer be defined when
  aligned allocation is otherwise enabled but unavailable.

* The Darwin driver no longer passes `-faligned-alloc-unavailable` when the
  user manually specifies `-faligned-allocation` or `-fno-aligned-allocation`.

* Instead of a warning Clang now generates a hard error when an aligned
  allocation or deallocation function is referenced but unavailable.

Patch by Eric Fiselier.

Reviewers: rsmith, vsapsai, erik.pilkington, ahatanak, dexonsmith

Reviewed By: rsmith

Subscribers: Quuxplusone, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338934 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoDiagnose invalid cv-qualifiers for friend decls.
Eli Friedman [Fri, 3 Aug 2018 22:09:44 +0000 (22:09 +0000)]
Diagnose invalid cv-qualifiers for friend decls.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338931 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Add test for a crash fixed in r338775.
Reka Kovacs [Fri, 3 Aug 2018 20:42:02 +0000 (20:42 +0000)]
[analyzer] Add test for a crash fixed in r338775.

Do not crash if a CXXRecordDecl cannot be obtained for an object.

Special thanks for the reproduction to Alexander Kornienko.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338918 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OpenMP] Encode offload target triples into comdat key for offload initialization...
Sergey Dmitriev [Fri, 3 Aug 2018 20:19:28 +0000 (20:19 +0000)]
[OpenMP] Encode offload target triples into comdat key for offload initialization code

Encoding offload target triples onto comdat group key for offload initialization
code guarantees that it will be executed once per each unique combination of
offload targets.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338916 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoProperly add shared locks to the initial list of locks being tracked, instead of...
Aaron Ballman [Fri, 3 Aug 2018 19:37:45 +0000 (19:37 +0000)]
Properly add shared locks to the initial list of locks being tracked, instead of assuming unlock functions always use exclusive locks.

Patch by Aaron Puchert.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338912 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Initialize a variable to prevent future invalid deref.
Erich Keane [Fri, 3 Aug 2018 18:08:36 +0000 (18:08 +0000)]
[NFC] Initialize a variable to prevent future invalid deref.

Found by KlockWorks, this variable is properly protected, however
the conditions in the test that initializes it and the one that uses
it could diverge, it seems to me that this is a 'free' init that will
prevent issues if one of the conditions is ever modified without the other.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338909 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[OpenCL] Always emit alloca in entry block for enqueue_kernel builtin"
Vlad Tsyrklevich [Fri, 3 Aug 2018 17:47:58 +0000 (17:47 +0000)]
Revert "[OpenCL] Always emit alloca in entry block for enqueue_kernel builtin"

This reverts commit r338899, it was causing ASan test failures on sanitizer-x86_64-linux-fast.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338904 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[OpenCL] Always emit alloca in entry block for enqueue_kernel builtin
Scott Linder [Fri, 3 Aug 2018 15:50:52 +0000 (15:50 +0000)]
[OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

Ensures the statically sized alloca is not converted to DYNAMIC_STACKALLOC
later because it is not in the entry block.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338899 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix asm label testcase flaw
Graham Yiu [Fri, 3 Aug 2018 14:36:44 +0000 (14:36 +0000)]
Fix asm label testcase flaw

- Testcase attempts to (not) grep 'g0' in output to ensure asm symbol is
  properly renamed, but g0 is too generic and can be part of the
  module's path in LLVM IR output.
- Changed to grep '@g0', which is what the proper global symbol name
  would be if not using asm.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338895 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agorevert r338831 - Fix unused variable warning in tablegen generated code
Erich Keane [Fri, 3 Aug 2018 14:24:34 +0000 (14:24 +0000)]
revert r338831 - Fix unused variable warning in tablegen generated code

No longer necessary thanks to r338889 (and friends).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338893 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoclang-format: [JS] don't break comments before any '{'
Martin Probst [Fri, 3 Aug 2018 13:58:33 +0000 (13:58 +0000)]
clang-format: [JS] don't break comments before any '{'

Summary:
Previously, clang-format would avoid breaking before the first `{`
found, but then happily break before subsequent '{'s on the line. This
change fixes that by looking for the first location that has no opening
curly, if any.

This fixes the original commit by correcting the loop condition.

This reverts commit 66dc646e09b795b943668179c33d09da71a3b6bc.

Reviewers: krasimir

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338890 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFCI] My attempt to fix a warning in r338886 broke the build! Fix it.
Erich Keane [Fri, 3 Aug 2018 13:51:35 +0000 (13:51 +0000)]
[NFCI] My attempt to fix a warning in r338886 broke the build! Fix it.

Clang format got the best of me... it introduced spaces around something
in a table-genned file, so it was interpreted as an array and not a
code block.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338889 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST][NFC] Add missing doc for ObjCMethodDecl and ObjCContainerDecl
Bruno Ricci [Fri, 3 Aug 2018 13:47:12 +0000 (13:47 +0000)]
[AST][NFC] Add missing doc for ObjCMethodDecl and ObjCContainerDecl

Add a comment in ObjCMethodDecl and ObjCContainerDecl stating that
we store some bits in ObjCMethodDeclBits and ObjCContainerDeclBits.

This was missed by the recent move in
r338641 : [AST][4/4] Move the bit-fields from ObjCMethodDecl
          and ObCContainerDecl into DeclContext

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338888 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST][NFC] Small doc update for DeclContext
Bruno Ricci [Fri, 3 Aug 2018 13:31:20 +0000 (13:31 +0000)]
[AST][NFC] Small doc update for DeclContext

Factored out from https://reviews.llvm.org/D49729
following @erichkeane comments.

* Add missing classes in the list of classes
  deriving directly from DeclContext.
* Move the friend declarations together and
  add a comment for why they are required.

Reviewed By: erichkeane

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338887 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Fix unused expression warning introduced in r338884
Erich Keane [Fri, 3 Aug 2018 13:23:04 +0000 (13:23 +0000)]
[NFC] Fix unused expression warning introduced in r338884

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338886 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoTest commit
Bruno Ricci [Fri, 3 Aug 2018 13:13:05 +0000 (13:13 +0000)]
Test commit

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338885 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Silence unused variable warning in Attr.td/AttrParsedAttrImpl.inc
Erich Keane [Fri, 3 Aug 2018 13:01:32 +0000 (13:01 +0000)]
[NFC] Silence unused variable warning in Attr.td/AttrParsedAttrImpl.inc

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338884 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "clang-format: [JS] don't break comments before any '{'"
Tim Northover [Fri, 3 Aug 2018 12:19:22 +0000 (12:19 +0000)]
Revert "clang-format: [JS] don't break comments before any '{'"

This reverts commit r338837, it introduced an infinite loop on all bots.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338879 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoclang-format-diff: Make it work with python3 too
Krasimir Georgiev [Fri, 3 Aug 2018 10:04:58 +0000 (10:04 +0000)]
clang-format-diff: Make it work with python3 too

Summary: It is not necessary, but would be nice if the script run on python3 as well (as opposed to only python2, which is going to be deprecated https://pythonclock.org/)

Contributed by MarcoFalke!

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: lebedev.ri, sammccall, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338839 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoclang-format: [JS] don't break comments before any '{'
Martin Probst [Fri, 3 Aug 2018 09:34:41 +0000 (09:34 +0000)]
clang-format: [JS] don't break comments before any '{'

Summary:
Previously, clang-format would avoid breaking before the first `{`
found, but then happily break before subsequent '{'s on the line. This
change fixes that by looking for the first location that has no opening
curly, if any.

Reviewers: krasimir

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338837 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFully qualify the renamed symbol if the shortened name is ambiguous.
Eric Liu [Fri, 3 Aug 2018 09:16:07 +0000 (09:16 +0000)]
Fully qualify the renamed symbol if the shortened name is ambiguous.

Summary:
For example, when renaming `a::b::x::foo` to `y::foo` below, replacing
`x::foo()` with `y::foo()` can cause ambiguity. In such cases, we simply fully
qualify the name with leading `::`.
```
namespace a {
namespace b {
namespace x { void foo() {} }
namespace y { void foo() {} }
}
}

namespace a {
namespace b {
void f() { x::foo(); }
}
}
```

Reviewers: ilya-biryukov, hokein

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338832 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix unused variable warning in tablegen generated code
Karl-Johan Karlsson [Fri, 3 Aug 2018 09:13:15 +0000 (09:13 +0000)]
Fix unused variable warning in tablegen generated code

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338831 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang 8/8] Add support for the flag_enum attribute
Michael Wu [Fri, 3 Aug 2018 05:55:40 +0000 (05:55 +0000)]
[libclang 8/8] Add support for the flag_enum attribute

Summary:
This adds support to libclang for reading the flag_enum attribute.

This also bumps CINDEX_VERSION_MINOR for this patch series.

Reviewers: yvvan, jbcoe

Reviewed By: yvvan

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338820 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang 7/8] Add support for getting property setter and getter names
Michael Wu [Fri, 3 Aug 2018 05:38:29 +0000 (05:38 +0000)]
[libclang 7/8] Add support for getting property setter and getter names

Summary: This allows libclang to access the actual names of property setters and getters without needing to go through the indexer API. Usually default names are used, but the property can specify a different name.

Reviewers: yvvan, jbcoe

Reviewed By: yvvan

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338816 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang 6/8] Add support for reading implicit attributes
Michael Wu [Fri, 3 Aug 2018 05:20:23 +0000 (05:20 +0000)]
[libclang 6/8] Add support for reading implicit attributes

Summary:
Having access to implicit attributes is sometimes useful so users of libclang don't have to duplicate some of the logic in sema.

This depends on D49081 since it also adds a CXTranslationUnit flag.

Reviewers: yvvan, jbcoe

Reviewed By: yvvan

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338815 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang 5/8] Add support for ObjC attributes without args
Michael Wu [Fri, 3 Aug 2018 05:03:22 +0000 (05:03 +0000)]
[libclang 5/8] Add support for ObjC attributes without args

Summary:
This adds support to libclang for identifying ObjC related attributes that don't take arguments.

All attributes but NSObject and NSConsumed are tested.

Reviewers: yvvan, jbcoe

Reviewed By: yvvan

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338813 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Emit parallel_loop_access for each loop in the loop stack.
Michael Kruse [Fri, 3 Aug 2018 04:42:52 +0000 (04:42 +0000)]
[CodeGen] Emit parallel_loop_access for each loop in the loop stack.

Summary:
Emit !llvm.mem.parallel_loop_access metadata for memory accesses even if the parallel loop is not the top on the loop stack.

Fixes llvm.org/PR37558.

Reviewers: ABataev, hfinkel, amusman, tyler.nowicki

Reviewed By: hfinkel

Subscribers: Meinersbur, hfinkel, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338810 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang 4/8] Add the clang_Type_getNullability() API
Michael Wu [Fri, 3 Aug 2018 04:38:04 +0000 (04:38 +0000)]
[libclang 4/8] Add the clang_Type_getNullability() API

Summary:
This patch adds a clang-c API for querying the nullability of an AttributedType.

The test here also tests D49081

Reviewers: yvvan, jbcoe

Reviewed By: yvvan

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338809 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang 3/8] Add support for AttributedType
Michael Wu [Fri, 3 Aug 2018 04:21:25 +0000 (04:21 +0000)]
[libclang 3/8] Add support for AttributedType

Summary:
This patch adds support to the libclang API for identifying AttributedTypes in CXTypes and reading the modified type that the type points to. Currently AttributedTypes are skipped. This patch continues to skip AttributedTypes by default, but adds a parsing option to CXTranslationUnit to include AttributedTypes.

This patch depends on D49066 since it also adds a CXType.

Testing will be added in another patch which depends on this one.

Reviewers: yvvan, jbcoe

Reviewed By: yvvan

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338808 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang 2/8] Add support for ObjCTypeParam
Michael Wu [Fri, 3 Aug 2018 04:02:40 +0000 (04:02 +0000)]
[libclang 2/8] Add support for ObjCTypeParam

Summary:
This patch adds support to the libclang API for identifying ObjCTypeParams in CXTypes.

This patch depends on D49063 since both patches add new values to CXTypeKind.

Reviewers: yvvan, jbcoe

Reviewed By: yvvan

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338807 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSema: Fix explicit address space cast involving void pointers
Yaxun Liu [Fri, 3 Aug 2018 03:18:56 +0000 (03:18 +0000)]
Sema: Fix explicit address space cast involving void pointers

Explicit cast of a void pointer to a pointer type in different address space is
incorrectly classified as bitcast, which causes invalid bitcast in codegen.

The patch fixes that by checking the address space of the source and destination
type and set the correct cast kind.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338805 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[libclang 1/8] Add support for ObjCObjectType
Michael Wu [Fri, 3 Aug 2018 03:03:20 +0000 (03:03 +0000)]
[libclang 1/8] Add support for ObjCObjectType

Summary: This patch adds support to the clang-c API for identifying ObjCObjects in CXTypes, enumerating type args and protocols on ObjCObjectTypes, and retrieving the base type of ObjCObjectTypes. Currently only ObjCInterfaceTypes are exposed, which do not have type args or protocols.

Reviewers: yvvan, jbcoe

Reviewed By: yvvan

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338804 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFold two cast plus a cast in a loop into a variable.
Nicolas Lesser [Fri, 3 Aug 2018 01:24:52 +0000 (01:24 +0000)]
Fold two cast plus a cast in a loop into a variable.

This avoids to recast `Record` multiple times.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338801 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAppend new attributes to the end of an AttributeList.
Michael Kruse [Fri, 3 Aug 2018 01:21:16 +0000 (01:21 +0000)]
Append new attributes to the end of an AttributeList.

Recommit of r335084 after revert in r335516.

... instead of prepending it at the beginning (the original behavior
since implemented in r122535 2010-12-23). This builds up an
AttributeList in the the order in which the attributes appear in the
source.

The reverse order caused nodes for attributes in the AST (e.g. LoopHint)
to be in the reverse order, and therefore printed in the wrong order in
-ast-dump. Some TODO comments mention this. The order was explicitly
reversed for enable_if attribute overload resolution and name mangling,
which is not necessary anymore with this patch.

The change unfortunately has some secondary effect, especially on
diagnostic output. In the simplest cases, the CHECK lines or expected
diagnostic were changed to the the new output. If the kind of
error/warning changed, the attributes' order was changed instead.

This unfortunately causes some 'previous occurrence here' hints to be
textually after the main marker. This typically happens when attributes
are merged, but are incompatible to each other. Interchanging the role
of the the main and note SourceLocation will also cause the case where
two different declaration's attributes (in contrast to multiple
attributes of the same declaration) are merged to be reverse. There is
no easy fix because sometimes previous attributes are merged into a new
declaration's attribute list, sometimes new attributes are added to a
previous declaration's attribute list. Since 'previous occurrence here'
pointing to locations after the main marker is not rare, I left the
markers as-is; it is only relevant when the attributes are declared in
the same declaration anyway.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338800 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[modules] Defer merging deduced return types.
Richard Smith [Fri, 3 Aug 2018 01:00:01 +0000 (01:00 +0000)]
[modules] Defer merging deduced return types.

We can't read a deduced return type until we are sure that the types referred
to by it are not in the middle of being loaded. So defer all reading of such
deduced return types until the end of the recursive deserialization step.

Also, when we load a function type that has a deduced return type, update all
other redeclarations of the function to have that deduced return type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338798 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Detect pointers escaped after ReturnStmt execution in MallocChecker.
Reka Kovacs [Thu, 2 Aug 2018 23:02:08 +0000 (23:02 +0000)]
[analyzer] Detect pointers escaped after ReturnStmt execution in MallocChecker.

Objects local to a function are destroyed right after the statement returning
(part of) them is executed in the analyzer. This patch enables MallocChecker to
warn in these cases.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338780 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Obtain a ReturnStmt from a CFGAutomaticObjDtor.
Reka Kovacs [Thu, 2 Aug 2018 22:31:03 +0000 (22:31 +0000)]
[analyzer] Obtain a ReturnStmt from a CFGAutomaticObjDtor.

The CoreEngine only gives us a ReturnStmt if the last element in the
CFGBlock is a CFGStmt, otherwise the ReturnStmt is nullptr.
This patch adds support for the case when the last element is a
CFGAutomaticObjDtor, by returning its TriggerStmt as a ReturnStmt.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338777 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Add a safety check to InnerPointerChecker.
Reka Kovacs [Thu, 2 Aug 2018 22:19:57 +0000 (22:19 +0000)]
[analyzer] Add a safety check to InnerPointerChecker.

Do not crash if the CXXRecordDecl of an object is not available.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338775 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WebAssembly] Support for atomic.wait / atomic.wake builtins
Heejin Ahn [Thu, 2 Aug 2018 21:44:40 +0000 (21:44 +0000)]
[WebAssembly] Support for atomic.wait / atomic.wake builtins

Summary:
Add support for atomic.wait / atomic.wake builtins based on the Wasm
thread proposal.

Reviewers: dschuff

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

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338771 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix assertion failure when emitting code for a merged lambda.
Richard Smith [Thu, 2 Aug 2018 20:30:52 +0000 (20:30 +0000)]
Fix assertion failure when emitting code for a merged lambda.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338766 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Fix tests.
George Karpenkov [Thu, 2 Aug 2018 18:41:25 +0000 (18:41 +0000)]
[analyzer] Fix tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338756 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAMDGPU: Fix missing declaration of queue ptr builtin
Matt Arsenault [Thu, 2 Aug 2018 18:24:55 +0000 (18:24 +0000)]
AMDGPU: Fix missing declaration of queue ptr builtin

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338754 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Forward arguments in registerChecker to avoid accidental copies
George Karpenkov [Thu, 2 Aug 2018 18:17:01 +0000 (18:17 +0000)]
[analyzer] Forward arguments in registerChecker to avoid accidental copies

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338753 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoWork around more GCC miscompiles exposed by r338464.
Martin Storsjo [Thu, 2 Aug 2018 18:12:08 +0000 (18:12 +0000)]
Work around more GCC miscompiles exposed by r338464.

This is the same fix as in r338478, for another occurrance of the
same pattern from r338464.

See gcc.gnu.org/PR86769 for details of the bug.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338749 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago__c11_atomic_load's _Atomic can be const
JF Bastien [Thu, 2 Aug 2018 17:35:46 +0000 (17:35 +0000)]
__c11_atomic_load's _Atomic can be const

Summary:
C++11 onwards specs the non-member functions atomic_load and atomic_load_explicit as taking the atomic<T> by const (potentially volatile) pointer. C11, in its infinite wisdom, decided to drop the const, and C17 will fix this with DR459 (the current draft forgot to fix B.16, but that’s not the normative part).

clang’s lib/Headers/stdatomic.h implements these as #define to the __c11_* equivalent, which are builtins with custom typecheck. Fix the typecheck.

D47613 takes care of the libc++ side.

Discussion: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058129.html

<rdar://problem/27426936>

Reviewers: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338743 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[c-index-test] Use correct executable path to discover resource directory.
Volodymyr Sapsai [Thu, 2 Aug 2018 17:29:53 +0000 (17:29 +0000)]
[c-index-test] Use correct executable path to discover resource directory.

Driver builds resource directory path based on provided executable path.
Instead of string "clang" use actual executable path.

rdar://problem/42699514

Reviewers: nathawes, akyrtzi, bob.wilson

Reviewed By: akyrtzi

Subscribers: dexonsmith, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338741 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Make RegionVector use const reference
Fangrui Song [Thu, 2 Aug 2018 16:29:36 +0000 (16:29 +0000)]
[analyzer] Make RegionVector use const reference

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338732 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoTry to make builtin address space declarations not useless
Matt Arsenault [Thu, 2 Aug 2018 12:14:28 +0000 (12:14 +0000)]
Try to make builtin address space declarations not useless

The way address space declarations for builtins currently work
is nearly useless. The code assumes the address spaces used for
builtins is a confusingly named "target address space" from user
code using __attribute__((address_space(N))) that matches
the builtin declaration. There's no way to use this to declare
a builtin that returns a language specific address space.
The terminology used is highly cofusing since it has nothing
to do with the the address space selected by the target to use
for a language address space.

This feature is essentially unused as-is. AMDGPU and NVPTX
are the only in-tree targets attempting to use this. The AMDGPU
builtins certainly do not behave as intended (i.e. all of the
builtins returning pointers can never compile because the numbered
address space never matches the expected named address space).

The NVPTX builtins are missing tests for some, and the others
seem to rely on an implicit addrspacecast.

Change the used address space for builtins based on a target
hook to allow using a language address space for a builtin.
This allows the same builtin declaration to be used for multiple
languages with similarly purposed address spaces (e.g. the same
AMDGPU builtin can be used in OpenCL and CUDA even though the
constant address spaces are arbitarily different).

This breaks the possibility of using arbitrary numbered
address spaces alongside the named address spaces for builtins.
If this is an issue we probably need to introduce another builtin
declaration character to distinguish language address spaces from
so-called "target address spaces".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338707 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoclang-format: fix a crash in comment wraps.
Martin Probst [Thu, 2 Aug 2018 11:52:08 +0000 (11:52 +0000)]
clang-format: fix a crash in comment wraps.

Summary:
Previously, clang-format would crash if it tried to wrap an overlong
single line comment, because two parts of the code inserted a break in
the same location.

    /** heregoesalongcommentwithnospace */

This wasn't previously noticed as it could only trigger for an overlong
single line comment that did have no breaking opportunities except for a
whitespace at the very beginning.

This also introduces a check for JavaScript to not ever wrap a comment
before an opening curly brace:

    /** @mods {donotbreakbeforethecurly} */

This is because some machinery parsing these tags sometimes supports
breaks before a possible `{`, but in some other cases does not.
Previously clang-format was careful never to wrap a line with certain
tags on it. The better solution is to specifically disable wrapping
before the problematic token: this allows wrapping and aligning comments
but still avoids the problem.

Reviewers: krasimir

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338706 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoTest commit access
Michael Wu [Thu, 2 Aug 2018 07:28:11 +0000 (07:28 +0000)]
Test commit access

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338675 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[analyzer] Extend NoStoreFuncVisitor to follow fields.
George Karpenkov [Thu, 2 Aug 2018 02:02:40 +0000 (02:02 +0000)]
[analyzer] Extend NoStoreFuncVisitor to follow fields.

rdar://39701823

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338667 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoPass triple to RUN line to fix failing bots.
Akira Hatanaka [Thu, 2 Aug 2018 01:52:17 +0000 (01:52 +0000)]
Pass triple to RUN line to fix failing bots.

This is a follow-up to r338656.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338664 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoSerialize DoesNotEscape.
Akira Hatanaka [Wed, 1 Aug 2018 23:51:53 +0000 (23:51 +0000)]
Serialize DoesNotEscape.

I forgot to commit this in r326530.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338656 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Remove the static_assert check in ObjCMethodDecl::ObjCMethodDecl
Vlad Tsyrklevich [Wed, 1 Aug 2018 22:41:03 +0000 (22:41 +0000)]
[AST] Remove the static_assert check in ObjCMethodDecl::ObjCMethodDecl

Summary:
This check was introduced by r338641
but this broke some builds. For now remove it.

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338648 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix -Wcovered-switch-default uncovered after r338630
Reid Kleckner [Wed, 1 Aug 2018 22:10:03 +0000 (22:10 +0000)]
Fix -Wcovered-switch-default uncovered after r338630

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338643 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST][4/4] Move the bit-fields from ObjCMethodDecl and ObjCContainerDecl into DeclContext
Erich Keane [Wed, 1 Aug 2018 21:31:08 +0000 (21:31 +0000)]
[AST][4/4] Move the bit-fields from ObjCMethodDecl and ObjCContainerDecl into DeclContext

This patch follows https://reviews.llvm.org/D49729,
https://reviews.llvm.org/D49732 and
https://reviews.llvm.org/D49733.

Move the bits from ObjCMethodDecl and ObjCContainerDecl
into DeclContext.

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

Patch By: bricci

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338641 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC][CodeGenCXX] Use -emit-llvm-only instead of -emit-llvm and ignoring it.
Roman Lebedev [Wed, 1 Aug 2018 21:20:58 +0000 (21:20 +0000)]
[NFC][CodeGenCXX] Use -emit-llvm-only instead of -emit-llvm and ignoring it.

As pointed out by Richard Smith in post-review of r338489.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338640 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST][3/4] Move the bit-fields from BlockDecl, LinkageSpecDecl and OMPDeclareReductio...
Erich Keane [Wed, 1 Aug 2018 21:16:54 +0000 (21:16 +0000)]
[AST][3/4] Move the bit-fields from BlockDecl, LinkageSpecDecl and OMPDeclareReductionDecl into DeclContext

This patch follows https://reviews.llvm.org/D49729
and https://reviews.llvm.org/D49732, and is
followed by https://reviews.llvm.org/D49734.

Move the bits from BlockDecl, LinkageSpecDecl and
OMPDeclareReductionDecl into DeclContext.

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

Patch By: bricci

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338639 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST][2/4] Move the bit-fields from FunctionDecl and CXXConstructorDecl into DeclContext
Erich Keane [Wed, 1 Aug 2018 21:02:40 +0000 (21:02 +0000)]
[AST][2/4] Move the bit-fields from FunctionDecl and CXXConstructorDecl into DeclContext

This patch follows https://reviews.llvm.org/D49729
and is followed by https://reviews.llvm.org/D49733
and https://reviews.llvm.org/D49734.

Move the bits from FunctionDecl and CXXConstructorDecl
into DeclContext.

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

Patch By: bricci

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338636 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST][1/4] Move the bit-fields from TagDecl, EnumDecl and RecordDecl into DeclContext
Erich Keane [Wed, 1 Aug 2018 20:48:16 +0000 (20:48 +0000)]
[AST][1/4] Move the bit-fields from TagDecl, EnumDecl and RecordDecl into DeclContext

DeclContext has a little less than 8 bytes free due to the alignment
requirements on 64 bits archs. This set of patches moves the
bit-fields from classes deriving from DeclContext into DeclContext.

On 32 bits archs this increases the size of DeclContext by 4 bytes
but this is balanced by an equal or larger reduction in the size
of the classes deriving from it.

On 64 bits archs the size of DeclContext stays the same but
most of the classes deriving from it shrink by 8/16 bytes.
(-print-stats diff here https://reviews.llvm.org/D49728)
When doing an -fsyntax-only on all of Boost this result
in a 3.6% reduction in the size of all Decls and
a 1% reduction in the run time due to the lower cache
miss rate.

For now CXXRecordDecl is not touched but there is
an easy 6 (if I count correctly) bytes gain available there
by moving some bits from DefinitionData into the free
space of DeclContext. This will be the subject of another patch.

This patch sequence also enable the possibility of refactoring
FunctionDecl: To save space some bits from classes deriving from
FunctionDecl were moved to FunctionDecl. This resulted in a
lot of stuff in FunctionDecl which do not belong logically to it.
After this set of patches however it is just a simple matter of
adding a SomethingDeclBitfields in DeclContext and moving the
bits to it from FunctionDecl.

This first patch introduces the anonymous union in DeclContext
and all the *DeclBitfields classes holding the bit-fields, and moves
the bits from TagDecl, EnumDecl and RecordDecl into DeclContext.

This patch is followed by https://reviews.llvm.org/D49732,
https://reviews.llvm.org/D49733 and https://reviews.llvm.org/D49734.

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

Patch By: bricci

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338630 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[test] Fix %hmaptool path for standalone builds
Michal Gorny [Wed, 1 Aug 2018 20:38:22 +0000 (20:38 +0000)]
[test] Fix %hmaptool path for standalone builds

Fix %hmaptool path to refer to clang_tools_dir instead of
llvm_tools_dir, in order to fix standalone builds.  The tool is built
as part of clang, so it won't be found in installed LLVM tools.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338627 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Android] Increase default new alignment for Android
Pirama Arumuga Nainar [Wed, 1 Aug 2018 17:55:34 +0000 (17:55 +0000)]
[Android] Increase default new alignment for Android

Summary:
Android's memory allocators also guarantee 8-byte alignment for 32-bit
architectures and 16-byte alignment for 64-bit.

Reviewers: rsmith

Subscribers: cfe-commits, srhines, enh

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338603 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert r338455 "[constexpr] Support for constant evaluation of __builtin_memcpy and...
Hans Wennborg [Wed, 1 Aug 2018 17:51:23 +0000 (17:51 +0000)]
Revert r338455 "[constexpr] Support for constant evaluation of __builtin_memcpy and __builtin_memmove (in non-type-punning cases)."

It caused asserts during Chromium builds, see reply on the cfe-commits thread.

> This is intended to permit libc++ to make std::copy etc constexpr
> without sacrificing the optimization that uses memcpy on
> trivially-copyable types.
>
> __builtin_strcpy and __builtin_wcscpy are not handled by this change.
> They'd be straightforward to add, but we haven't encountered a need for
> them just yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338602 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Format] Fix for bug 35641
Ilya Biryukov [Wed, 1 Aug 2018 15:32:56 +0000 (15:32 +0000)]
[Format] Fix for bug 35641

Summary:
Bug was caused due to comments at the start of scope. For a code like:
```
int func() { //
  int b;
  int c;
}
```
the comment at the first line gets IndentAndNestingLevel (1,1) whereas
the following declarations get only (0,1) which prevents them from insertion
of a new scope. So, I changed the AlignTokenSequence to look at previous
*non-comment* token when deciding whether to introduce a new scope into
stack or not.

Patch by Kadir Cetinkaya!

Reviewers: rsmith, djasper

Reviewed By: djasper

Subscribers: lebedev.ri, cfe-commits, klimek

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338578 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[UnrollAndJam] Add unroll_and_jam pragma handling
David Green [Wed, 1 Aug 2018 14:36:12 +0000 (14:36 +0000)]
[UnrollAndJam] Add unroll_and_jam pragma handling

This adds support for the unroll_and_jam pragma, to go with the recently
added unroll and jam pass. The name of the pragma is the same as is used
in the Intel compiler, and most of the code works the same as for unroll.

#pragma clang loop unroll_and_jam has been separated into a different
patch. This part adds #pragma unroll_and_jam with an optional count, and
#pragma no_unroll_and_jam to disable the transform.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338566 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUpdate docs version and clear release notes after 8.0.0 version bump
Hans Wennborg [Wed, 1 Aug 2018 14:01:27 +0000 (14:01 +0000)]
Update docs version and clear release notes after 8.0.0 version bump

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338557 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoUse a dummy target so the test passes when default target is for a toolchain implemen...
Filipe Cabecinhas [Wed, 1 Aug 2018 13:41:42 +0000 (13:41 +0000)]
Use a dummy target so the test passes when default target is for a toolchain implements useIntegratedAs() -> true

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338553 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd REQUIRES: native to a test that assumes it
Filipe Cabecinhas [Wed, 1 Aug 2018 13:41:11 +0000 (13:41 +0000)]
Add REQUIRES: native to a test that assumes it

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338552 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Silence warning about ptr-to-func to ptr-to-obj cast in clang-fuzzer/handle...
Andrei Elovikov [Wed, 1 Aug 2018 13:34:18 +0000 (13:34 +0000)]
[NFC] Silence warning about ptr-to-func to ptr-to-obj cast in clang-fuzzer/handle-llvm/handle_llvm.cpp.

Summary:
I don't have the whole list of GCC binaries available so I determined the exact
version where the warning disappeared via:

https://github.com/gcc-mirror/gcc/blob/gcc-4_9_0-release/gcc/cp/typeck.c#L6863
https://github.com/gcc-mirror/gcc/blob/gcc-4_8_5-release/gcc/cp/typeck.c#L6652

Reviewers: emmettneyman, erichkeane

Reviewed By: emmettneyman, erichkeane

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338551 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoMake test/Frontend/clang-abi-compat.cpp pass when the version goes to 8
Hans Wennborg [Wed, 1 Aug 2018 13:19:14 +0000 (13:19 +0000)]
Make test/Frontend/clang-abi-compat.cpp pass when the version goes to 8

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338534 91177308-0d34-0410-b5e6-96231b3b80d8