]> granicus.if.org Git - clang/log
clang
4 years ago[c++20] Implement most of P1152R4.
Richard Smith [Wed, 9 Oct 2019 00:49:40 +0000 (00:49 +0000)]
[c++20] Implement most of P1152R4.

Diagnose some now-deprecated uses of volatile types:
 * as function parameter types and return types
 * as the type of a structured binding declaration
 * as the type of the lvalue operand of an increment / decrement /
   compound assignment operator

This does not implement a check for the deprecation of simple
assignments whose results are used; that check requires somewhat
more complexity and will be addressed separately.

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

4 years ago[cxx_status] Note that Clang has supported std::source_location since
Richard Smith [Tue, 8 Oct 2019 23:39:56 +0000 (23:39 +0000)]
[cxx_status] Note that Clang has supported std::source_location since
version 9.

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

4 years agoFactor out some duplication. NFC.
Richard Smith [Tue, 8 Oct 2019 23:37:49 +0000 (23:37 +0000)]
Factor out some duplication. NFC.

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

4 years ago[clang-scan-deps] Improve string/character literal skipping
Alex Lorenz [Tue, 8 Oct 2019 22:42:44 +0000 (22:42 +0000)]
[clang-scan-deps] Improve string/character literal skipping

The existing string/character literal skipping code in the
dependency directives source minimizer has two issues:

- It doesn't stop the scanning when a newline is reached before the terminating character,
unlike the lexer which considers the token to be done (even if it's invalid) at the end of the line.

- It doesn't support whitespace between '\' and the newline when looking if the '\' is used as a line continuation character.

This commit fixes both issues.

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

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

4 years ago[IRGen] Emit lifetime markers for temporary struct allocas
Francis Visoiu Mistrih [Tue, 8 Oct 2019 22:10:38 +0000 (22:10 +0000)]
[IRGen] Emit lifetime markers for temporary struct allocas

When passing arguments using temporary allocas, we need to add the
appropriate lifetime markers so that the stack coloring passes can
re-use the stack space.

This patch keeps track of all the lifetime.start calls emited before the
codegened call, and adds the corresponding lifetime.end calls after the
call.

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

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

4 years agoFix crash or wrong code bug if a lifetime-extended temporary contains a
Richard Smith [Tue, 8 Oct 2019 21:26:03 +0000 (21:26 +0000)]
Fix crash or wrong code bug if a lifetime-extended temporary contains a
"non-constant" value.

If the constant evaluator evaluates part of a variable initializer,
including the initializer for some lifetime-extended temporary, but
fails to fully evaluate the initializer, it can leave behind wrong
values for temporaries encountered in that initialization. Don't try to
emit those from CodeGen! Instead, look at the values that constant
evaluation produced if (and only if) it actually succeeds and we're
emitting the lifetime-extending declaration's initializer as a constant.

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

4 years ago[clang] enable_trivial_var_init_zero should not be Joined<>
Vitaly Buka [Tue, 8 Oct 2019 20:34:53 +0000 (20:34 +0000)]
[clang] enable_trivial_var_init_zero should not be Joined<>

Reviewers: rnk

Subscribers: cfe-commits

Tags: #clang

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

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

4 years ago[clang] Add llvm-ifs in test deps
Vitaly Buka [Tue, 8 Oct 2019 20:23:24 +0000 (20:23 +0000)]
[clang] Add llvm-ifs in test deps

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

4 years ago[OPENMP50]Multiple vendors in vendor context must be treated as logical
Alexey Bataev [Tue, 8 Oct 2019 19:44:16 +0000 (19:44 +0000)]
[OPENMP50]Multiple vendors in vendor context must be treated as logical
and of vendors, not or.

If several vendors are provided in the same vendor context trait, the
context shall match only if all vendors are matching, not one of them.
This is per OpenMP 5.0, 2.3.3 Matching and Scoring Context Selectors,
all selectors in the construct, device, and implementation sets of the
context selector appear in the corresponding trait set of the OpenMP
context.

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

4 years agoTry to get ubsan-blacklist-vfs.c pass more on Windows
Nico Weber [Tue, 8 Oct 2019 19:25:49 +0000 (19:25 +0000)]
Try to get ubsan-blacklist-vfs.c pass more on Windows

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

4 years ago[BPF] do compile-once run-everywhere relocation for bitfields
Yonghong Song [Tue, 8 Oct 2019 18:23:17 +0000 (18:23 +0000)]
[BPF] do compile-once run-everywhere relocation for bitfields

A bpf specific clang intrinsic is introduced:
   u32 __builtin_preserve_field_info(member_access, info_kind)
Depending on info_kind, different information will
be returned to the program. A relocation is also
recorded for this builtin so that bpf loader can
patch the instruction on the target host.
This clang intrinsic is used to get certain information
to facilitate struct/union member relocations.

The offset relocation is extended by 4 bytes to
include relocation kind.
Currently supported relocation kinds are
 enum {
    FIELD_BYTE_OFFSET = 0,
    FIELD_BYTE_SIZE,
    FIELD_EXISTENCE,
    FIELD_SIGNEDNESS,
    FIELD_LSHIFT_U64,
    FIELD_RSHIFT_U64,
 };
for __builtin_preserve_field_info. The old
access offset relocation is covered by
    FIELD_BYTE_OFFSET = 0.

An example:
struct s {
    int a;
    int b1:9;
    int b2:4;
};
enum {
    FIELD_BYTE_OFFSET = 0,
    FIELD_BYTE_SIZE,
    FIELD_EXISTENCE,
    FIELD_SIGNEDNESS,
    FIELD_LSHIFT_U64,
    FIELD_RSHIFT_U64,
};

void bpf_probe_read(void *, unsigned, const void *);
int field_read(struct s *arg) {
  unsigned long long ull = 0;
  unsigned offset = __builtin_preserve_field_info(arg->b2, FIELD_BYTE_OFFSET);
  unsigned size = __builtin_preserve_field_info(arg->b2, FIELD_BYTE_SIZE);
 #ifdef USE_PROBE_READ
  bpf_probe_read(&ull, size, (const void *)arg + offset);
  unsigned lshift = __builtin_preserve_field_info(arg->b2, FIELD_LSHIFT_U64);
 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  lshift = lshift + (size << 3) - 64;
 #endif
 #else
  switch(size) {
  case 1:
    ull = *(unsigned char *)((void *)arg + offset); break;
  case 2:
    ull = *(unsigned short *)((void *)arg + offset); break;
  case 4:
    ull = *(unsigned int *)((void *)arg + offset); break;
  case 8:
    ull = *(unsigned long long *)((void *)arg + offset); break;
  }
  unsigned lshift = __builtin_preserve_field_info(arg->b2, FIELD_LSHIFT_U64);
 #endif
  ull <<= lshift;
  if (__builtin_preserve_field_info(arg->b2, FIELD_SIGNEDNESS))
    return (long long)ull >> __builtin_preserve_field_info(arg->b2, FIELD_RSHIFT_U64);
  return ull >> __builtin_preserve_field_info(arg->b2, FIELD_RSHIFT_U64);
}

There is a minor overhead for bpf_probe_read() on big endian.

The code and relocation generated for field_read where bpf_probe_read() is
used to access argument data on little endian mode:
        r3 = r1
        r1 = 0
        r1 = 4  <=== relocation (FIELD_BYTE_OFFSET)
        r3 += r1
        r1 = r10
        r1 += -8
        r2 = 4  <=== relocation (FIELD_BYTE_SIZE)
        call bpf_probe_read
        r2 = 51 <=== relocation (FIELD_LSHIFT_U64)
        r1 = *(u64 *)(r10 - 8)
        r1 <<= r2
        r2 = 60 <=== relocation (FIELD_RSHIFT_U64)
        r0 = r1
        r0 >>= r2
        r3 = 1  <=== relocation (FIELD_SIGNEDNESS)
        if r3 == 0 goto LBB0_2
        r1 s>>= r2
        r0 = r1
LBB0_2:
        exit

Compare to the above code between relocations FIELD_LSHIFT_U64 and
FIELD_LSHIFT_U64, the code with big endian mode has four more
instructions.
        r1 = 41   <=== relocation (FIELD_LSHIFT_U64)
        r6 += r1
        r6 += -64
        r6 <<= 32
        r6 >>= 32
        r1 = *(u64 *)(r10 - 8)
        r1 <<= r6
        r2 = 60   <=== relocation (FIELD_RSHIFT_U64)

The code and relocation generated when using direct load.
        r2 = 0
        r3 = 4
        r4 = 4
        if r4 s> 3 goto LBB0_3
        if r4 == 1 goto LBB0_5
        if r4 == 2 goto LBB0_6
        goto LBB0_9
LBB0_6:                                 # %sw.bb1
        r1 += r3
        r2 = *(u16 *)(r1 + 0)
        goto LBB0_9
LBB0_3:                                 # %entry
        if r4 == 4 goto LBB0_7
        if r4 == 8 goto LBB0_8
        goto LBB0_9
LBB0_8:                                 # %sw.bb9
        r1 += r3
        r2 = *(u64 *)(r1 + 0)
        goto LBB0_9
LBB0_5:                                 # %sw.bb
        r1 += r3
        r2 = *(u8 *)(r1 + 0)
        goto LBB0_9
LBB0_7:                                 # %sw.bb5
        r1 += r3
        r2 = *(u32 *)(r1 + 0)
LBB0_9:                                 # %sw.epilog
        r1 = 51
        r2 <<= r1
        r1 = 60
        r0 = r2
        r0 >>= r1
        r3 = 1
        if r3 == 0 goto LBB0_11
        r2 s>>= r1
        r0 = r2
LBB0_11:                                # %sw.epilog
        exit

Considering verifier is able to do limited constant
propogation following branches. The following is the
code actually traversed.
        r2 = 0
        r3 = 4   <=== relocation
        r4 = 4   <=== relocation
        if r4 s> 3 goto LBB0_3
LBB0_3:                                 # %entry
        if r4 == 4 goto LBB0_7
LBB0_7:                                 # %sw.bb5
        r1 += r3
        r2 = *(u32 *)(r1 + 0)
LBB0_9:                                 # %sw.epilog
        r1 = 51   <=== relocation
        r2 <<= r1
        r1 = 60   <=== relocation
        r0 = r2
        r0 >>= r1
        r3 = 1
        if r3 == 0 goto LBB0_11
        r2 s>>= r1
        r0 = r2
LBB0_11:                                # %sw.epilog
        exit

For native load case, the load size is calculated to be the
same as the size of load width LLVM otherwise used to load
the value which is then used to extract the bitfield value.

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

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

4 years ago[NFC] Attempt to make ubsan-blacklist-vfs test pass on Windows
Jan Korous [Tue, 8 Oct 2019 18:13:04 +0000 (18:13 +0000)]
[NFC] Attempt to make ubsan-blacklist-vfs test pass on Windows

Previously disabled in d0c2d5daa3e

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

4 years ago[driver][hip] Skip bundler if host action is nothing.
Michael Liao [Tue, 8 Oct 2019 18:06:51 +0000 (18:06 +0000)]
[driver][hip] Skip bundler if host action is nothing.

Reviewers: sfantao, tra, yaxunl

Subscribers: cfe-commits

Tags: #clang

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

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

4 years ago[OPENMP50]Do not allow multiple same context traits in the same context
Alexey Bataev [Tue, 8 Oct 2019 17:47:52 +0000 (17:47 +0000)]
[OPENMP50]Do not allow multiple same context traits in the same context
selector.

According to OpenMP 5.0, 2.3.2 Context Selectors, Restrictions, each
trait-selector-name can only be specified once. Added check for this
restriction.

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

4 years ago[OPENMP50]Prohibit multiple context selector sets in context selectors.
Alexey Bataev [Tue, 8 Oct 2019 15:56:43 +0000 (15:56 +0000)]
[OPENMP50]Prohibit multiple context selector sets in context selectors.

According to OpenMP 5.0, 2.3.2 Context Selectors, Restrictions, each
trait-set-selector-name can only be specified once. Added check to
implement this restriction.

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

4 years ago[clang][ifs] Clang Interface Stubs ToolChain plumbing.
Puyan Lotfi [Tue, 8 Oct 2019 15:23:14 +0000 (15:23 +0000)]
[clang][ifs] Clang Interface Stubs ToolChain plumbing.

Second Landing Attempt:

This patch enables end to end support for generating ELF interface stubs
directly from clang. Now the following:

clang -emit-interface-stubs -o libfoo.so a.cpp b.cpp c.cpp

will product an ELF binary with visible symbols populated. Visibility attributes
and -fvisibility can be used to control what gets populated.

* Adding ToolChain support for clang Driver IFS Merge Phase
* Implementing a default InterfaceStubs Merge clang Tool, used by ToolChain
* Adds support for the clang Driver to involve llvm-ifs on ifs files.
* Adds -emit-merged-ifs flag, to tell llvm-ifs to emit a merged ifs text file
  instead of the final object format (normally ELF)

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

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

4 years ago[OPENMP50]Allow functions in declare variant directive to have different
Alexey Bataev [Tue, 8 Oct 2019 14:56:20 +0000 (14:56 +0000)]
[OPENMP50]Allow functions in declare variant directive to have different
C linkage.

After some discussion with OpenMP developers, it was decided that the
functions with the different C linkage can be used in declare variant
directive.

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

4 years ago[SVE][IR] Scalable Vector size queries and IR instruction support
Graham Hunter [Tue, 8 Oct 2019 12:53:54 +0000 (12:53 +0000)]
[SVE][IR] Scalable Vector size queries and IR instruction support

* Adds a TypeSize struct to represent the known minimum size of a type
  along with a flag to indicate that the runtime size is a integer multiple
  of that size
* Converts existing size query functions from Type.h and DataLayout.h to
  return a TypeSize result
* Adds convenience methods (including a transparent conversion operator
  to uint64_t) so that most existing code 'just works' as if the return
  values were still scalars.
* Uses the new size queries along with ElementCount to ensure that all
  supported instructions used with scalable vectors can be constructed
  in IR.

Reviewers: hfinkel, lattner, rkruppe, greened, rovka, rengolin, sdesmalen

Reviewed By: rovka, sdesmalen

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

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

4 years ago[Diagnostics] Silence -Wsizeof-array-div for character buffers
James Clarke [Tue, 8 Oct 2019 11:34:02 +0000 (11:34 +0000)]
[Diagnostics] Silence -Wsizeof-array-div for character buffers

Summary:
Character buffers are sometimes used to represent a pool of memory that
contains non-character objects, due to them being synonymous with a stream of
bytes on almost all modern architectures. Often, when interacting with hardware
devices, byte buffers are therefore used as an intermediary and so we can end
Character buffers are sometimes used to represent a pool of memory that
contains non-character objects, due to them being synonymous with a stream of
bytes on almost all modern architectures. Often, when interacting with hardware
devices, byte buffers are therefore used as an intermediary and so we can end
up generating lots of false-positives.

Moreover, due to the ability of character pointers to alias non-character
pointers, the strict aliasing violations that would generally be implied by the
calculations caught by the warning (if the calculation itself is in fact
correct) do not apply here, and so although the length calculation may be
wrong, that is the only possible issue.

Reviewers: rsmith, xbolva00, thakis

Reviewed By: xbolva00, thakis

Subscribers: thakis, lebedev.ri, cfe-commits

Tags: #clang

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

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

4 years agoRemove an useless allocation (from by clang-analyzer/scan-build)
Sylvestre Ledru [Tue, 8 Oct 2019 09:17:46 +0000 (09:17 +0000)]
Remove an useless allocation (from by clang-analyzer/scan-build)
https://llvm.org/reports/scan-build/report-TargetInfo.cpp-detectFPCCEligibleStruct-9-1.html#EndPath

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

4 years ago[ItaniumMangle] Fix mangling of GNU __null in an expression to match GCC
James Clarke [Tue, 8 Oct 2019 02:28:57 +0000 (02:28 +0000)]
[ItaniumMangle] Fix mangling of GNU __null in an expression to match GCC

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: erik.pilkington, cfe-commits

Tags: #clang

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

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

4 years ago[NFC] Fix ubsan-blacklist test
Jan Korous [Tue, 8 Oct 2019 02:26:17 +0000 (02:26 +0000)]
[NFC] Fix ubsan-blacklist test

Restored original test and marked tests for VFS as unsupported on Windows.

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

4 years agoReland 'Add VFS support for sanitizers' blacklist'
Jan Korous [Tue, 8 Oct 2019 01:13:17 +0000 (01:13 +0000)]
Reland 'Add VFS support for sanitizers' blacklist'

The original patch broke the test for Windows.
Trying to fix as per Reid's suggestions outlined here:
https://reviews.llvm.org/rC371663

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

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

4 years agoRevert "Add VFS support for sanitizers' blacklist"
Jan Korous [Tue, 8 Oct 2019 00:36:19 +0000 (00:36 +0000)]
Revert "Add VFS support for sanitizers' blacklist"

Fix tests on Windows for now.

This reverts commit 96ac97a4213287003f08636d0c372b3f71e9cfca.

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

4 years ago[clang] Accept -ftrivial-auto-var-init in clang-cl
Vitaly Buka [Mon, 7 Oct 2019 23:57:11 +0000 (23:57 +0000)]
[clang] Accept -ftrivial-auto-var-init in clang-cl

Reviewers: eugenis, rnk

Subscribers: cfe-commits

Tags: #clang

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

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

4 years agoAdd VFS support for sanitizers' blacklist
Jan Korous [Mon, 7 Oct 2019 22:36:19 +0000 (22:36 +0000)]
Add VFS support for sanitizers' blacklist

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

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

4 years ago[Diagnostics] Emit better -Wbool-operation's warning message if we known that the...
David Bolvansky [Mon, 7 Oct 2019 21:57:03 +0000 (21:57 +0000)]
[Diagnostics] Emit better -Wbool-operation's warning message if we known that the result is always true

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

4 years ago[OPENMP]Fix caonical->canonical, NFC.
Alexey Bataev [Mon, 7 Oct 2019 19:57:40 +0000 (19:57 +0000)]
[OPENMP]Fix caonical->canonical, NFC.

Fixed typo.

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

4 years agoFix for expanding __pragmas in macro arguments
Amy Huang [Mon, 7 Oct 2019 19:41:53 +0000 (19:41 +0000)]
Fix for expanding __pragmas in macro arguments

Summary:
Avoid parsing __pragma into an annotation token when macro arguments are pre-expanded.
This is what clang currently does when parsing _Pragmas.

Fixes https://bugs.llvm.org/show_bug.cgi?id=41128, where clang crashed
when trying to get the length of an annotation token.

Subscribers: cfe-commits

Tags: #clang

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

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

4 years ago[OPENMP50]Treat range-based for as canonical loop.
Alexey Bataev [Mon, 7 Oct 2019 18:54:57 +0000 (18:54 +0000)]
[OPENMP50]Treat range-based for as canonical loop.

According to OpenMP 5.0, range-based for is also considered as a
canonical form of loops.

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

4 years ago[clang] [cmake] Support LLVM_DISTRIBUTION_COMPONENTS in stand-alone build
Michal Gorny [Mon, 7 Oct 2019 18:14:56 +0000 (18:14 +0000)]
[clang] [cmake] Support LLVM_DISTRIBUTION_COMPONENTS in stand-alone build

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

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

4 years agoFix Calling Convention through aliases
Erich Keane [Mon, 7 Oct 2019 17:28:03 +0000 (17:28 +0000)]
Fix Calling Convention through aliases

r369697 changed the behavior of stripPointerCasts to no longer include
aliases.  However, the code in CGDeclCXX.cpp's createAtExitStub counted
on the looking through aliases to properly set the calling convention of
a call.

The result of the change was that the calling convention mismatch of the
call would be replaced with a llvm.trap, causing a runtime crash.

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

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

4 years ago[libTooling][NFC] Fix build break in r373916.
Yitzhak Mandelbaum [Mon, 7 Oct 2019 17:24:23 +0000 (17:24 +0000)]
[libTooling][NFC] Fix build break in r373916.

r373916 used raw strings inside macro calls, which breaks some builds.

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

4 years ago[clang-format] [PR27004] omits leading space for noexcept when formatting operator...
Paul Hoad [Mon, 7 Oct 2019 17:03:44 +0000 (17:03 +0000)]
[clang-format] [PR27004] omits leading space for noexcept when formatting operator delete()

Summary:
clang-format is incorrectly thinking the parameter parens are part of a cast operation, this is resulting in there sometimes being not space between the paren and the noexcept (and other keywords like volatile etc..)

```
void operator++(int) noexcept;
void operator++(int &) noexcept;
void operator delete(void *, std::size_t, const std::nothrow_t &)noexcept;
```

Reviewers: klimek, owenpan, mitchell-stellar

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

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

4 years ago[clang-format] [NFC] Ensure clang-format is itself clang-formatted.
Paul Hoad [Mon, 7 Oct 2019 16:53:35 +0000 (16:53 +0000)]
[clang-format] [NFC] Ensure clang-format is itself clang-formatted.

Summary:
Before making a proposed change, ensure ClangFormat.cpp is fully clang-formatted,

no functional change just clang-formatting using the in tree .clang-format.

Reviewers: mitchell-stellar

Reviewed By: mitchell-stellar

Subscribers: Eugene.Zelenko, cfe-commits

Tags: #clang-format, #clang

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

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

4 years agoCodegen - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Mon, 7 Oct 2019 16:42:25 +0000 (16:42 +0000)]
Codegen - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years ago[libTooling] Add `toString` method to the Stencil class
Yitzhak Mandelbaum [Mon, 7 Oct 2019 16:20:22 +0000 (16:20 +0000)]
[libTooling] Add `toString` method to the Stencil class

Summary:
`toString` generates a string representation of the stencil.

Patch by Harshal T. Lehri.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

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

4 years agoSema - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Mon, 7 Oct 2019 14:25:46 +0000 (14:25 +0000)]
Sema - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years ago[clang] Add test for FindNextToken in Lexer.
Utkarsh Saxena [Mon, 7 Oct 2019 14:20:46 +0000 (14:20 +0000)]
[clang] Add test for FindNextToken in Lexer.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

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

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

4 years agoRewriteModernObjC - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Mon, 7 Oct 2019 13:58:15 +0000 (13:58 +0000)]
RewriteModernObjC - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years agoAST - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Mon, 7 Oct 2019 13:58:05 +0000 (13:58 +0000)]
AST - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years ago[ASTImporter][NFC] Enable disabled but passing test
Gabor Marton [Mon, 7 Oct 2019 11:34:54 +0000 (11:34 +0000)]
[ASTImporter][NFC] Enable disabled but passing test

RedeclChainShouldBeCorrectAmongstNamespaces

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

4 years ago[ASTImporter][NFC] Update ASTImporter internals docs
Gabor Marton [Mon, 7 Oct 2019 11:15:18 +0000 (11:15 +0000)]
[ASTImporter][NFC] Update ASTImporter internals docs

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

4 years ago[ASTImporter][NFC] Fix typo in user docs
Gabor Marton [Mon, 7 Oct 2019 11:14:53 +0000 (11:14 +0000)]
[ASTImporter][NFC] Fix typo in user docs

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

4 years agoclang-cl: Ignore the new /ZH options
Hans Wennborg [Mon, 7 Oct 2019 09:30:15 +0000 (09:30 +0000)]
clang-cl: Ignore the new /ZH options

These were added to the MS docs in
https://github.com/MicrosoftDocs/cpp-docs/commit/85b9b6967e58e485251450f7451673f6fc873e88
and are supposedly available in VS 2019 16.4 (though my 2019 Preview,
version 16.4.0-pre.1.0 don't seem to have them.)

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

4 years ago[c++20] Check for a class-specific operator delete when deleting an
Richard Smith [Mon, 7 Oct 2019 03:14:28 +0000 (03:14 +0000)]
[c++20] Check for a class-specific operator delete when deleting an
object of class type with a virtual destructor.

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

4 years agoFix behavior of __builtin_bit_cast when the From and To types are the
Richard Smith [Mon, 7 Oct 2019 02:45:12 +0000 (02:45 +0000)]
Fix behavior of __builtin_bit_cast when the From and To types are the
same.

We were missing the lvalue-to-rvalue conversion entirely in this case,
and in fact still need the full CK_LValueToRValueBitCast conversion to
perform a load with no TBAA.

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

4 years agoImplements CWG 1601 in [over.ics.rank/4.2]
Richard Smith [Sun, 6 Oct 2019 18:50:40 +0000 (18:50 +0000)]
Implements CWG 1601 in [over.ics.rank/4.2]

Summary:
The overload resolution for enums with a fixed underlying type has changed in the C++14 standard. This patch implements the new rule.

Patch by Mark de Wever!

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Tags: #clang

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

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

4 years ago[Sema] Avoids an assertion failure when an invalid conversion declaration is used
Richard Smith [Sun, 6 Oct 2019 18:40:59 +0000 (18:40 +0000)]
[Sema] Avoids an assertion failure when an invalid conversion declaration is used

Summary:
When using a user-defined conversion function template with a deduced return type the compiler gives a set of warnings:
```
bug.cc:252:44: error: cannot specify any part of a return type in the declaration of a conversion function; use an alias template to declare a conversion to 'auto (Ts &&...) const'
  template <typename... Ts> operator auto()(Ts &&... xs) const;
                                           ^~~~~~~~~~~~~~~~~~~
bug.cc:252:29: error: conversion function cannot convert to a function type
  template <typename... Ts> operator auto()(Ts &&... xs) const;
                            ^
error: pointer to function type cannot have 'const' qualifier
```
after which it triggers an assertion failure. It seems the last error is incorrect and doesn't have any location information. This patch stops the compilation after the second warning.

Fixes bug 31422.

Patch by Mark de Wever!

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: bbannier, cfe-commits

Tags: #clang

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

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

4 years ago[InstCombine] don't assume 'inbounds' for bitcast pointer to GEP transform (PR43501)
Sanjay Patel [Sun, 6 Oct 2019 13:08:08 +0000 (13:08 +0000)]
[InstCombine] don't assume 'inbounds' for bitcast pointer to GEP transform (PR43501)

https://bugs.llvm.org/show_bug.cgi?id=43501
We can't declare a GEP 'inbounds' in general. But we may salvage that information if
we have known dereferenceable bytes on the source pointer.

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

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

4 years ago[clang-format][docs] Fix the Google C++ and Chromium style guide URLs
Paul Hoad [Sun, 6 Oct 2019 09:37:58 +0000 (09:37 +0000)]
[clang-format][docs] Fix the Google C++ and Chromium style guide URLs

Summary: The Google C++ and Chromium style guides are broken in the clang-format docs. This patch updates them.

Reviewers: djasper, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang

Patch by: m4tx

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

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

4 years agoTry to fix sphinx indentation error
Simon Pilgrim [Sat, 5 Oct 2019 16:08:17 +0000 (16:08 +0000)]
Try to fix sphinx indentation error

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

4 years agoRewriteObjC - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Sat, 5 Oct 2019 13:42:14 +0000 (13:42 +0000)]
RewriteObjC - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years ago[Diagnostics] Highlight expr's source range for -Wbool-operation
David Bolvansky [Sat, 5 Oct 2019 13:28:15 +0000 (13:28 +0000)]
[Diagnostics] Highlight expr's source range for -Wbool-operation

Warning message looks better; and GCC adds it too.

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

4 years agoSemaTemplate - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Sat, 5 Oct 2019 13:21:08 +0000 (13:21 +0000)]
SemaTemplate - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years agoTreeTransform - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Sat, 5 Oct 2019 13:20:59 +0000 (13:20 +0000)]
TreeTransform - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years agoRemove redundant !HasDependentValue check. NFCI.
Simon Pilgrim [Sat, 5 Oct 2019 13:20:51 +0000 (13:20 +0000)]
Remove redundant !HasDependentValue check. NFCI.

Fixes cppcheck warning.

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

4 years agoSemaStmt - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Sat, 5 Oct 2019 13:20:42 +0000 (13:20 +0000)]
SemaStmt - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years ago[clang-format] SpacesInSquareBrackets should affect lambdas with parameters too
Paul Hoad [Sat, 5 Oct 2019 09:55:23 +0000 (09:55 +0000)]
[clang-format] SpacesInSquareBrackets should affect lambdas with parameters too

Summary:
This patch makes the `SpacesInSquareBrackets` setting also apply to C++ lambdas with parameters.

Looking through the revision history, it appears support for only array brackets was added, and lambda brackets were ignored. Therefore, I am inclined to think it was simply an omission, rather than a deliberate choice.

See https://bugs.llvm.org/show_bug.cgi?id=17887 and https://reviews.llvm.org/D4944.

Reviewers: MyDeveloperDay, reuk, owenpan

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits

Patch by: mitchell-stellar

Tags: #clang-format, #clang

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

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

4 years ago[NFCI] Slightly improve warning message
David Bolvansky [Sat, 5 Oct 2019 08:09:06 +0000 (08:09 +0000)]
[NFCI] Slightly improve warning message

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

4 years ago[Diagnostics] Use Expr::isKnownToHaveBooleanValue() to check bitwise negation of...
David Bolvansky [Sat, 5 Oct 2019 08:02:11 +0000 (08:02 +0000)]
[Diagnostics] Use Expr::isKnownToHaveBooleanValue() to check bitwise negation of bool in languages without a bool type

Thanks for this advice, Richard Trieu!

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

4 years ago[clang] fix a typo from r372531
Yuanfang Chen [Fri, 4 Oct 2019 21:37:20 +0000 (21:37 +0000)]
[clang] fix a typo from r372531

Reviewers: xbolva00

Subscribers: cfe-commits

Tags: #clang

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

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

4 years ago[clang] [cmake] Use add_clang_tool() to install all tools
Michal Gorny [Fri, 4 Oct 2019 20:28:59 +0000 (20:28 +0000)]
[clang] [cmake] Use add_clang_tool() to install all tools

Switch clang-check, clang-extdef-mapping and clang-offload-bundler
to use add_clang_tool() rather than add_clang_executable() with a custom
install rule.  This makes them LLVM_DISTRIBUTION_COMPONENTS-friendly.

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

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

4 years ago[Sema] Split out -Wformat-type-confusion from -Wformat-pedantic
Erik Pilkington [Fri, 4 Oct 2019 19:20:27 +0000 (19:20 +0000)]
[Sema] Split out -Wformat-type-confusion from -Wformat-pedantic

The warnings now in -Wformat-type-confusion don't align with how we interpret
'pedantic' in clang, and don't belong in -pedantic.

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

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

4 years agoAdd missing null pointer check in -ftime-trace code
Reid Kleckner [Fri, 4 Oct 2019 18:57:01 +0000 (18:57 +0000)]
Add missing null pointer check in -ftime-trace code

createOutputFile diagnoses the error for the caller already, so recover
by not writing the output.

Fixes PR43555

No test, since I couldn't think of a good, portable, simple way to make
the regular -o output file writable, but outputfile.json not writable.

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

4 years ago[CMake] Clang: Don't use object libraries with Xcode
Jordan Rose [Fri, 4 Oct 2019 18:17:58 +0000 (18:17 +0000)]
[CMake] Clang: Don't use object libraries with Xcode

Undoes some of the effects of r360946 when using the Xcode CMake
generator---it doesn't handle object libraries correctly at all.
Attempts to still honor BUILD_SHARED_LIBS for Xcode, but I didn't
actually test it. Should have no effect on non-Xcode generators.

https://reviews.llvm.org/D68430

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

4 years ago[OPENMP50]Suppport for multiple vendors in the same vendor context
Alexey Bataev [Fri, 4 Oct 2019 15:58:45 +0000 (15:58 +0000)]
[OPENMP50]Suppport for multiple vendors in the same vendor context
selector.

According to OpenMP 5.0, multiple vendors could be specified in the
vendor context selector via ',' as a separator.

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

4 years agoSemaDeclAttr - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Fri, 4 Oct 2019 15:02:46 +0000 (15:02 +0000)]
SemaDeclAttr - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years agoCGBlocks - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Fri, 4 Oct 2019 15:01:54 +0000 (15:01 +0000)]
CGBlocks - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years ago[clang-format] C++11 braced lists should respect the SpacesInParentheses setting
Paul Hoad [Fri, 4 Oct 2019 14:25:20 +0000 (14:25 +0000)]
[clang-format] C++11 braced lists should respect the SpacesInParentheses setting

Summary:
According to the clang-format documentation, "Fundamentally, C++11 braced lists are formatted exactly like function calls would be formatted in their place. If the braced list follows a name (e.g. a type or variable name), clang-format formats as if the `{}` were the parentheses of a function call with that name."

This patch furthers the treatment of C++11 braced list braces as parentheses by respecting the `SpacesInParentheses` setting.

Reviewers: MyDeveloperDay, reuk, owenpan

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang-format, #clang

Patch By: mitchell-stellar

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

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

4 years ago[clang-format] [PR43531] clang-format damages "alternative representations" for operators
Paul Hoad [Fri, 4 Oct 2019 14:16:59 +0000 (14:16 +0000)]
[clang-format] [PR43531] clang-format damages "alternative representations" for operators

Summary:
https://bugs.llvm.org/show_bug.cgi?id=43531

Fix for clang-format incorrectly handles "alternative operators" as described by https://en.cppreference.com/w/cpp/language/operator_alternative

compl = ~
not = !

these are unary operators, and clang-format will remove the space between them and a numeric constant

this incorrectly formats the following code

```
int a compl 5;
int a not 5;
```

into:

```
int a compl5;
int a not5;
```

The code adds FIXME unit tests for "alternative token" representations for {} [] and # as defined by the same link, which would require a more detailed change to the FormatTokenLexer

Reviewers: klimek, reuk, owenpan, mitchell-stellar, STL_MSFT

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang-format, #clang-tools-extra, #clang

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

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

4 years agoFurther improve -Wbool-operation bitwise negation message
Sam McCall [Fri, 4 Oct 2019 14:11:05 +0000 (14:11 +0000)]
Further improve -Wbool-operation bitwise negation message

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

4 years ago[clang-rename] Fix a crash when renaming a class without definition.
Haojian Wu [Fri, 4 Oct 2019 14:09:31 +0000 (14:09 +0000)]
[clang-rename] Fix a crash when renaming a class without definition.

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

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

4 years ago[clang-format] [PR42417] clang-format inserts a space after '->' for operator->(...
Paul Hoad [Fri, 4 Oct 2019 13:24:15 +0000 (13:24 +0000)]
[clang-format] [PR42417] clang-format inserts a space after '->' for operator->() overloading

Summary:
https://bugs.llvm.org/show_bug.cgi?id=42417

This revision removes the extra space between the opertor-> and the parens ()

```
class Bug {
    auto operator-> () -> int*;
    auto operator++(int) -> int;
};
```

Reviewers: klimek, owenpan, byoungyoung, mitchell-stellar

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

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

4 years ago[clang] Prevent false positives in arm-mfpu-none codegen test.
Simon Tatham [Fri, 4 Oct 2019 13:01:41 +0000 (13:01 +0000)]
[clang] Prevent false positives in arm-mfpu-none codegen test.

A user pointed out to me in private email that this test will fail if
it sees the letter 's' followed by a digit in any part of clang's
assembly output after the function label. That includes the .ident at
the end, which can include a full pathname or hostname or both from
the system clang was built on. So if that path or hostname includes
any text like 's5' then it will cause the test to fail.

Fixed by adding a check for `.fnend`, to limit the scope of the
`CHECK-NOT` to only the actual generated code for the test function.

(Committed without prior review on the basis that it's a simple and
obvious pure test-suite fix and also in a test I contributed myself.)

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

4 years ago[NFCI] Improve the -Wbool-operation's warning message
David Bolvansky [Fri, 4 Oct 2019 12:55:13 +0000 (12:55 +0000)]
[NFCI] Improve the -Wbool-operation's warning message

Based on the request from the post commit review. Also added one new test.

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

4 years ago[Format] Fix docs after r373439
Sam McCall [Fri, 4 Oct 2019 09:52:54 +0000 (09:52 +0000)]
[Format] Fix docs after r373439

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

4 years ago[Driver] NFC: Remove duplicate call to getLibGccType
Cullen Rhodes [Fri, 4 Oct 2019 08:26:37 +0000 (08:26 +0000)]
[Driver] NFC: Remove duplicate call to getLibGccType

Reviewed By: saugustine

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

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

4 years ago[lldb][modern-type-lookup] No longer import temporary declarations into the persisten...
Raphael Isemann [Fri, 4 Oct 2019 08:26:17 +0000 (08:26 +0000)]
[lldb][modern-type-lookup] No longer import temporary declarations into the persistent AST

Summary:
As we figured out in D67803, importing declarations from a temporary ASTContext that were originally from a persistent ASTContext
causes a bunch of duplicated declarations where we end up having declarations in the target AST that have no associated ASTImporter that
can complete them.

I haven't figured out how/if we can solve this in the current way we do things in LLDB, but in the modern-type-lookup this is solvable
as we have a saner architecture with the ExternalASTMerger. As we can (hopefully) make modern-type-lookup the default mode in the future,
I would say we try fixing this issue here. As we don't use the hack that was reinstated in D67803 during modern-type-lookup, the test case for this
is essentially just printing any kind of container in `std::` as we would otherwise run into the issue that required a hack like D67803.

What this patch is doing in essence is that instead of importing a declaration from a temporary ASTContext, we instead check if the
declaration originally came from a persistent ASTContext (e.g. the debug information) and we directly import from there. The ExternalASTMerger
is already connected with ASTImporters to these different sources, so this patch is essentially just two parts:
1. Mark our temporary ASTContext/ImporterSource as temporary when we import from the expression AST.
2. If the ExternalASTMerger sees we import from the expression AST, instead of trying to import these temporary declarations, check if we
can instead import from the persistent ASTContext that is already connected. This ensures that all records from the persistent source actually
come from the persistent source and are minimally imported in a way that allows them to be completed later on in the target AST.

The next step is to run the ASTImporter for these temporary expressions with the MinimalImport mode disabled, but that's a follow up patch.

This patch fixes most test failures with modern-type-lookup enabled by default (down to 73 failing tests, which includes the 22 import-std-module tests
which need special treatment).

Reviewers: shafik, martong

Reviewed By: martong

Subscribers: aprantl, rnkovacs, christof, abidh, JDevlieghere, lldb-commits

Tags: #lldb

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

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

4 years ago[CodeComplete] Ensure object is the same in compareOverloads()
Ilya Biryukov [Fri, 4 Oct 2019 08:10:27 +0000 (08:10 +0000)]
[CodeComplete] Ensure object is the same in compareOverloads()

Summary:
This fixes a regression that led to size() not being available in clangd
when completing 'deque().^' and using libc++.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

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

4 years ago[clang-format] [PR43338] C# clang format has space issues betweern C# only keywords
Paul Hoad [Fri, 4 Oct 2019 08:10:22 +0000 (08:10 +0000)]
[clang-format] [PR43338] C# clang format has space issues betweern C# only keywords

Summary:
When formatting C# there can be issues with a lack of spaces between `using (` , `foreach (` and generic types

The C# code

```
public class Foo
{
    Dictionary<string,string> foo;
}

```
will be formatted as

```
public class Foo
{
    Dictionary<string, string>foo;
                           ^^^^^   missing a space
}
```

This revision also reverts some of {D66662} in order to make this cleaner and resolve an issues seen by @owenpan that the formatting didn't add a space when not in a code block

This also transforms C# foreach commands to be seen as tok::kw_for commands (to ensure foreach gets the same Brace Wrapping behavior as for without littering the code with `if(Style.isCSharp())`

Reviewers: owenpan, klimek, russellmcc, mitchell-stellar

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang, #clang-format

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

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

4 years ago[clang-format] [PR43333] Fix C# breaking before function name when using Attributes
Paul Hoad [Fri, 4 Oct 2019 07:56:49 +0000 (07:56 +0000)]
[clang-format] [PR43333] Fix C# breaking before function name when using Attributes

Summary:
This is  a fix for https://bugs.llvm.org/show_bug.cgi?id=43333

This comes with 3 main parts

  - C# attributes cause function names on a new line even when AlwaysBreakAfterReturnType is set to None
  - Add AlwaysBreakAfterReturnType  to None by default in the Microsoft style,
  - C# unit tests are not using Microsoft style (which we created to define the default C# style to match a vanilla C# project).

Reviewers: owenpan, klimek, russellmcc, mitchell-stellar

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang-tools-extra, #clang, #clang-format

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

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

4 years ago[clang] [cmake] Add distribution install targets for remaining components
Michal Gorny [Fri, 4 Oct 2019 05:43:20 +0000 (05:43 +0000)]
[clang] [cmake] Add distribution install targets for remaining components

Add install targets as necessary to install bash-autocomplete,
scan-build and scan-view via LLVM_DISTRIBUTION_TARGETS.

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

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

4 years agoProperly handle instantiation-dependent array bounds.
Richard Smith [Fri, 4 Oct 2019 01:25:59 +0000 (01:25 +0000)]
Properly handle instantiation-dependent array bounds.

We previously failed to treat an array with an instantiation-dependent
but not value-dependent bound as being an instantiation-dependent type.
We now track the array bound expression as part of a constant array type
if it's an instantiation-dependent expression.

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

4 years ago[OPENMP]Fix the test on Windows, NFC.
Alexey Bataev [Thu, 3 Oct 2019 22:10:33 +0000 (22:10 +0000)]
[OPENMP]Fix the test on Windows, NFC.

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

4 years agoASTContext - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Thu, 3 Oct 2019 21:47:42 +0000 (21:47 +0000)]
ASTContext - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but we should be able to use castAs<> directly and if not assert will fire for us.

We can also remove a number of explicit asserts and reply on the internal asserts in castAs<>

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

4 years agoOverloadCandidate::getNumParams - silence static analyzer getAs<FunctionProtoType...
Simon Pilgrim [Thu, 3 Oct 2019 21:27:02 +0000 (21:27 +0000)]
OverloadCandidate::getNumParams - silence static analyzer getAs<FunctionProtoType> null dereference warning. NFCI.

The static analyzer is warning about a potential null dereference, but we should be able to use castAs<FunctionProtoType> directly and if not assert will fire for us.

Also replaces an auto to make the type more obvious.

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

4 years ago[OPENMP50]Codegen support for scores in context selectors.
Alexey Bataev [Thu, 3 Oct 2019 20:49:48 +0000 (20:49 +0000)]
[OPENMP50]Codegen support for scores in context selectors.

If the context selector has associated score and several contexts
selectors matches current context, the function with the highest score
must be selected.

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

4 years ago[HIP] Use option -nogpulib to disable linking device lib
Yaxun Liu [Thu, 3 Oct 2019 18:59:56 +0000 (18:59 +0000)]
[HIP] Use option -nogpulib to disable linking device lib

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

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

4 years agoCheck for qualified function types after substituting into the operand
Richard Smith [Thu, 3 Oct 2019 18:55:23 +0000 (18:55 +0000)]
Check for qualified function types after substituting into the operand
of 'typeid'.

This is a rare place where it's valid for a function type to be
substituted but not valid for a qualified function type to be
substituted, so needs a special check.

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

4 years ago[clang-format] Add ability to wrap braces after multi-line control statements
Paul Hoad [Thu, 3 Oct 2019 18:42:31 +0000 (18:42 +0000)]
[clang-format] Add ability to wrap braces after multi-line control statements

Summary:
Change the BraceWrappingFlags' AfterControlStatement from a bool to an enum with three values:

* "Never": This is the default, and does not do any brace wrapping after control statements.
* "MultiLine": This only wraps braces after multi-line control statements (this really only happens when a ColumnLimit is specified).
* "Always": This always wraps braces after control statements.

The first and last options are backwards-compatible with "false" and "true", respectively.

The new "MultiLine" option is useful for when a wrapped control statement's indentation matches the subsequent block's indentation. It makes it easier to see at a glance where the control statement ends and where the block's code begins. For example:

```
if (
  foo
  && bar )
{
  baz();
}
```

vs.

```
if (
  foo
  && bar ) {
  baz();
}
```

Short control statements (1 line) do not wrap the brace to the next line, e.g.

```
if (foo) {
  bar();
} else {
  baz();
}
```

Reviewers: sammccall, owenpan, reuk, MyDeveloperDay, klimek

Reviewed By: MyDeveloperDay

Subscribers: MyDeveloperDay, cfe-commits

Patch By: mitchell-stellar

Tags: #clang-format, #clang, #clang-tools-extra

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

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

4 years agoPR43547: substitute into the type of a non-type template parameter if
Richard Smith [Thu, 3 Oct 2019 18:24:40 +0000 (18:24 +0000)]
PR43547: substitute into the type of a non-type template parameter if
it's instantiation-dependent, even if it's not dependent.

There might be a SFINAE check in the parameter type.

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

4 years ago[HIP] Enable specifying different default gpu arch for HIP/CUDA.
Michael Liao [Thu, 3 Oct 2019 17:49:20 +0000 (17:49 +0000)]
[HIP] Enable specifying different default gpu arch for HIP/CUDA.

Reviewers: tra, yaxunl

Subscribers: cfe-commits

Tags: #clang

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

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

4 years agoDeclBase/DeclCXX/DeclTemplate - silence static analyzer getAs<> null dereference...
Simon Pilgrim [Thu, 3 Oct 2019 16:58:01 +0000 (16:58 +0000)]
DeclBase/DeclCXX/DeclTemplate - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

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

4 years ago[OPENMP]Fix emission of the declare target variables in device mode.
Alexey Bataev [Thu, 3 Oct 2019 16:46:49 +0000 (16:46 +0000)]
[OPENMP]Fix emission of the declare target variables in device mode.

Declare target variables must be emitted in device mode, target triples
can be empty in this case.

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

4 years ago[OPENMP]Improve diagnostics for not found declare target entries.
Alexey Bataev [Thu, 3 Oct 2019 16:20:34 +0000 (16:20 +0000)]
[OPENMP]Improve diagnostics for not found declare target entries.

We can point to the target region + emit parent functions names/real var
names if they were not found in host module during device codegen.

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

4 years ago[NFC] Added missing changes for rL373614
David Bolvansky [Thu, 3 Oct 2019 15:26:26 +0000 (15:26 +0000)]
[NFC] Added missing changes for rL373614

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

4 years ago[Diagnostics] Bitwise negation of a boolean expr always evaluates to true; warn with...
David Bolvansky [Thu, 3 Oct 2019 15:17:59 +0000 (15:17 +0000)]
[Diagnostics] Bitwise negation of a boolean expr always evaluates to true; warn with -Wbool-operation

Requested here:
http://lists.llvm.org/pipermail/cfe-dev/2019-October/063452.html

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

4 years agoFix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.
Simon Pilgrim [Thu, 3 Oct 2019 15:10:47 +0000 (15:10 +0000)]
Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.

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

4 years agoExprConstant - silence static analyzer getAs<> null dereference warnings. NFCI.
Simon Pilgrim [Thu, 3 Oct 2019 15:08:30 +0000 (15:08 +0000)]
ExprConstant - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

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