Commit Graph

59899 Commits

Author SHA1 Message Date
Dimitry Andric fc2dac4116 [PPC] Fix platform definitions when compiling FreeBSD powerpc64 as LE
As a prerequisite to doing experimental buids of pieces of FreeBSD PowerPC64 as little-endian, allow actually targeting it.

This is needed so basic platform definitions are pulled in. Without it, the compiler will only run freestanding.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D73425
2020-08-29 12:03:20 +02:00
Marco Vanotti 2e800495a7 [clang] Enable -fsanitize=thread on Fuchsia.
This CL modifies clang enabling using -fsanitize=thread on fuchsia. The
change doesn't build the runtime for fuchsia, it just enables the
instrumentation to be used.

pair-programmed-with: mdempsky@google.com
Change-Id: I816c4d240d1f15e9eae2803fb8ba3a7bf667ed51

Reviewed By: mcgrathr, phosek

Differential Revision: https://reviews.llvm.org/D86822
2020-08-28 17:26:27 -07:00
Fangrui Song b5ef137c11 [gcov] Increment counters with atomicrmw if -fsanitize=thread
Without this patch, `clang --coverage -fsanitize=thread` may fail spuriously
because non-atomic counter increments can be detected as data races.
2020-08-28 16:32:35 -07:00
Richard Smith 0e00a95b4f Add new warning for compound punctuation tokens that are split across macro expansions or split by whitespace.
For example:

    #define FOO(x) (x)
    FOO({});

... forms a statement-expression after macro expansion. This warning
applies to '({' and '})' delimiting statement-expressions, '[[' and ']]'
delimiting attributes, and '::*' introducing a pointer-to-member.

The warning for forming these compound tokens across macro expansions
(or across files!) is enabled by default; the warning for whitespace
within the tokens is not, but is included in -Wall.

Differential Revision: https://reviews.llvm.org/D86751
2020-08-28 13:35:50 -07:00
Benjamin Kramer 8782c72765 Strength-reduce SmallVectors to arrays. NFCI. 2020-08-28 21:14:20 +02:00
Albion Fung 331dcc43ea [PowerPC] Implemented Vector Load with Zero and Signed Extend Builtins
This patch implements the builtins for Vector Load with Zero and Signed Extend Builtins (lxvr_x for b, h, w, d), and adds the appropriate test cases for these builtins. The builtins utilize the vector load instructions itnroduced with ISA 3.1.

Differential Revision: 	https://reviews.llvm.org/D82502#inline-797941
2020-08-28 11:28:58 -05:00
Cullen Rhodes 2ddf795e8c Reland "[CodeGen][AArch64] Support arm_sve_vector_bits attribute"
This relands D85743 with a fix for test
CodeGen/attr-arm-sve-vector-bits-call.c that disables the new pass
manager with '-fno-experimental-new-pass-manager'. Test was failing due
to IR differences with the new pass manager which broke the Fuchsia
builder [1]. Reverted in 2e7041f.

[1] http://lab.llvm.org:8011/builders/fuchsia-x86_64-linux/builds/10375

Original summary:

This patch implements codegen for the 'arm_sve_vector_bits' type
attribute, defined by the Arm C Language Extensions (ACLE) for SVE [1].
The purpose of this attribute is to define vector-length-specific (VLS)
versions of existing vector-length-agnostic (VLA) types.

VLSTs are represented as VectorType in the AST and fixed-length vectors
in the IR everywhere except in function args/return. Implemented in this
patch is codegen support for the following:

  * Implicit casting between VLA <-> VLS types.
  * Coercion of VLS types in function args/return.
  * Mangling of VLS types.

Casting is handled by the CK_BitCast operation, which has been extended
to support the two new vector kinds for fixed-length SVE predicate and
data vectors, where the cast is implemented through memory rather than a
bitcast which is unsupported. Implementing this as a normal bitcast
would require relaxing checks in LLVM to allow bitcasting between
scalable and fixed types. Another option was adding target-specific
intrinsics, although codegen support would need to be added for these
intrinsics. Given this, casting through memory seemed like the best
approach as it's supported today and existing optimisations may remove
unnecessary loads/stores, although there is room for improvement here.

Coercion of VLSTs in function args/return from fixed to scalable is
implemented through the AArch64 ABI in TargetInfo.

The VLA and VLS types are defined by the ACLE to map to the same
machine-level SVE vectors. VLS types are mangled in the same way as:

  __SVE_VLS<typename, unsigned>

where the first argument is the underlying variable-length type and the
second argument is the SVE vector length in bits. For example:

  #if __ARM_FEATURE_SVE_BITS==512
  // Mangled as 9__SVE_VLSIu11__SVInt32_tLj512EE
  typedef svint32_t vec __attribute__((arm_sve_vector_bits(512)));
  // Mangled as 9__SVE_VLSIu10__SVBool_tLj512EE
  typedef svbool_t pred __attribute__((arm_sve_vector_bits(512)));
  #endif

The latest ACLE specification (00bet5) does not contain details of this
mangling scheme, it will be specified in the next revision.  The
mangling scheme is otherwise defined in the appendices to the Procedure
Call Standard for the Arm Architecture, see [2] for more information.

[1] https://developer.arm.com/documentation/100987/latest
[2] https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#appendix-c-mangling

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D85743
2020-08-28 15:57:09 +00:00
David Sherwood f4257c5832 [SVE] Make ElementCount members private
This patch changes ElementCount so that the Min and Scalable
members are now private and can only be accessed via the get
functions getKnownMinValue() and isScalable(). In addition I've
added some other member functions for more commonly used operations.
Hopefully this makes the class more useful and will reduce the
need for calling getKnownMinValue().

Differential Revision: https://reviews.llvm.org/D86065
2020-08-28 14:43:53 +01:00
Eduardo Caldas a1461953f4 [SyntaxTree] Add coverage for declarators and init-declarators 2020-08-28 12:19:38 +00:00
Eduardo Caldas 38bc0060e6 [SyntaxTree][NFC] Refactor function templates into functions taking base class
The refactored functions were
* `isReponsibleForCreatingDeclaration`
* `getQualifiedNameStart`

Differential Revision: https://reviews.llvm.org/D86719
2020-08-28 12:19:38 +00:00
Alex Richardson 96824abe7d [clang-format] Detect pointer qualifiers in cast expressions
When guessing whether a closing paren is then end of a cast expression also
skip over pointer qualifiers while looking for TT_PointerOrReference.
This prevents some address-of and dereference operators from being parsed
as a binary operator.

Before:
x = (foo *const) * v;
x = (foo *const volatile restrict __attribute__((foo)) _Nonnull _Null_unspecified _Nonnull) & v;

After:
x = (foo *const)*v;
x = (foo *const volatile restrict __attribute__((foo)) _Nonnull _Null_unspecified _Nonnull)&v;

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D86716
2020-08-28 11:31:47 +01:00
Alex Richardson d304360dec [clang-format] Parse nullability attributes as a pointer qualifier
Before:
void f() { MACRO(A * _Nonnull a); }
void f() { MACRO(A * _Nullable a); }
void f() { MACRO(A * _Null_unspecified a); }

After:
void f() { MACRO(A *_Nonnull a); }
void f() { MACRO(A *_Nullable a); }
void f() { MACRO(A *_Null_unspecified a); }

Reviewed By: JakeMerdichAMD

Differential Revision: https://reviews.llvm.org/D86713
2020-08-28 11:31:47 +01:00
Alex Richardson 37cdabdb82 [clang-format] Parse __attribute((foo)) as a pointer qualifier
Before: void f() { MACRO(A * __attribute((foo)) a); }
After:  void f() { MACRO(A *__attribute((foo)) a); }

Also check that the __attribute__ alias is handled.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D86711
2020-08-28 11:31:47 +01:00
Alex Richardson 4f10369564 [clang-format] Parse restrict as a pointer qualifier
Before: void f() { MACRO(A * restrict a); }
After:  void f() { MACRO(A *restrict a); }

Also check that the __restrict and __restrict__ aliases are handled.

Reviewed By: JakeMerdichAMD

Differential Revision: https://reviews.llvm.org/D86710
2020-08-28 11:31:47 +01:00
Alex Richardson 1908da2658 [clang-format] Parse volatile as a pointer qualifier
Before: void f() { MACRO(A * volatile a); }
After:  void f() { MACRO(A *volatile a); }

Also check that the __volatile and __volatile__ aliases are handled.

Reviewed By: JakeMerdichAMD

Differential Revision: https://reviews.llvm.org/D86708
2020-08-28 11:31:47 +01:00
JF Bastien 82d29b397b Add an unsigned shift base sanitizer
It's not undefined behavior for an unsigned left shift to overflow (i.e. to
shift bits out), but it has been the source of bugs and exploits in certain
codebases in the past. As we do in other parts of UBSan, this patch adds a
dynamic checker which acts beyond UBSan and checks other sources of errors. The
option is enabled as part of -fsanitize=integer.

The flag is named: -fsanitize=unsigned-shift-base
This matches shift-base and shift-exponent flags.

<rdar://problem/46129047>

Differential Revision: https://reviews.llvm.org/D86000
2020-08-27 19:50:10 -07:00
Cullen Rhodes 2e7041fdc2 Revert "[CodeGen][AArch64] Support arm_sve_vector_bits attribute"
Test CodeGen/attr-arm-sve-vector-bits-call.c is failing on some builders
[1][2]. Reverting whilst I investigate.

[1] http://lab.llvm.org:8011/builders/fuchsia-x86_64-linux/builds/10375
[2] https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-x64/b8870800848452818112

This reverts commit 42587345a3.
2020-08-27 21:31:05 +00:00
Alexey Bataev ba1de5f2f7 [OPENMP]Do not crash for globals in inner regions with outer target
region.

If the global variable is used in the target region,it is always
captured, if not marked as declare target.
2020-08-27 17:07:53 -04:00
Craig Topper 17ceda99d3 [CodeGen] Use an AttrBuilder to bulk remove 'target-cpu', 'target-features', and 'tune-cpu' before re-adding in CodeGenModule::setNonAliasAttributes.
I think the removeAttributes interface should be faster than
calling removeAttribute 3 times.
2020-08-27 12:54:20 -07:00
Yang Fan 6e26e49edf [analyzer] NFC: Fix wrong parameter name in printFormattedEntry.
Parameters were in a different order in the header and in the implementation.

Fix surrounding comments a bit.

Differential Revision: https://reviews.llvm.org/D86691
2020-08-27 12:15:26 -07:00
Yang Fan 37c21dbb3a [analyzer] Fix the debug print about debug egraph dumps requiring asserts.
There's no need to remind people about that when clang *is* built with asserts.

Differential Revision: https://reviews.llvm.org/D86334
2020-08-27 12:15:26 -07:00
Adam Balogh 4448affede [analyzer] pr47037: CastValueChecker: Support for the new variadic isa<>.
llvm::isa<>() and llvm::isa_and_not_null<>() template functions recently became
variadic. Unfortunately this causes crashes in case of isa_and_not_null<>()
and incorrect behavior in isa<>(). This patch fixes this issue.

Differential Revision: https://reviews.llvm.org/D85728
2020-08-27 12:15:25 -07:00
Adam Balogh 5a9e778939 [analyzer] NFC: Store the pointee/referenced type for dynamic type tracking.
The successfulness of a dynamic cast depends only on the C++ class, not the pointer or reference. Thus if *A is a *B, then &A is a &B,
const *A is a const *B etc. This patch changes DynamicCastInfo to store
and check the cast between the unqualified pointed/referenced types.
It also removes e.g. SubstTemplateTypeParmType from both the pointer
and the pointed type.

Differential Revision: https://reviews.llvm.org/D85752
2020-08-27 12:15:23 -07:00
Mikhail Maltsev ae1396c7d4 [ARM][BFloat16] Change types of some Arm and AArch64 bf16 intrinsics
This patch adjusts the following ARM/AArch64 LLVM IR intrinsics:
- neon_bfmmla
- neon_bfmlalb
- neon_bfmlalt
so that they take and return bf16 and float types. Previously these
intrinsics used <8 x i8> and <4 x i8> vectors (a rudiment from
implementation lacking bf16 IR type).

The neon_vbfdot[q] intrinsics are adjusted similarly. This change
required some additional selection patterns for vbfdot itself and
also for vector shuffles (in a previous patch) because of SelectionDAG
transformations kicking in and mangling the original code.

This patch makes the generated IR cleaner (less useless bitcasts are
produced), but it does not affect the final assembly.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D86146
2020-08-27 18:43:16 +01:00
Teresa Johnson 7ed8124d46 [HeapProf] Clang and LLVM support for heap profiling instrumentation
See RFC for background:
http://lists.llvm.org/pipermail/llvm-dev/2020-June/142744.html

Note that the runtime changes will be sent separately (hopefully this
week, need to add some tests).

This patch includes the LLVM pass to instrument memory accesses with
either inline sequences to increment the access count in the shadow
location, or alternatively to call into the runtime. It also changes
calls to memset/memcpy/memmove to the equivalent runtime version.
The pass is modeled on the address sanitizer pass.

The clang changes add the driver option to invoke the new pass, and to
link with the upcoming heap profiling runtime libraries.

Currently there is no attempt to optimize the instrumentation, e.g. to
aggregate updates to the same memory allocation. That will be
implemented as follow on work.

Differential Revision: https://reviews.llvm.org/D85948
2020-08-27 08:50:35 -07:00
Cullen Rhodes 42587345a3 [CodeGen][AArch64] Support arm_sve_vector_bits attribute
This patch implements codegen for the 'arm_sve_vector_bits' type
attribute, defined by the Arm C Language Extensions (ACLE) for SVE [1].
The purpose of this attribute is to define vector-length-specific (VLS)
versions of existing vector-length-agnostic (VLA) types.

VLSTs are represented as VectorType in the AST and fixed-length vectors
in the IR everywhere except in function args/return. Implemented in this
patch is codegen support for the following:

  * Implicit casting between VLA <-> VLS types.
  * Coercion of VLS types in function args/return.
  * Mangling of VLS types.

Casting is handled by the CK_BitCast operation, which has been extended
to support the two new vector kinds for fixed-length SVE predicate and
data vectors, where the cast is implemented through memory rather than a
bitcast which is unsupported. Implementing this as a normal bitcast
would require relaxing checks in LLVM to allow bitcasting between
scalable and fixed types. Another option was adding target-specific
intrinsics, although codegen support would need to be added for these
intrinsics. Given this, casting through memory seemed like the best
approach as it's supported today and existing optimisations may remove
unnecessary loads/stores, although there is room for improvement here.

Coercion of VLSTs in function args/return from fixed to scalable is
implemented through the AArch64 ABI in TargetInfo.

The VLA and VLS types are defined by the ACLE to map to the same
machine-level SVE vectors. VLS types are mangled in the same way as:

  __SVE_VLS<typename, unsigned>

where the first argument is the underlying variable-length type and the
second argument is the SVE vector length in bits. For example:

  #if __ARM_FEATURE_SVE_BITS==512
  // Mangled as 9__SVE_VLSIu11__SVInt32_tLj512EE
  typedef svint32_t vec __attribute__((arm_sve_vector_bits(512)));
  // Mangled as 9__SVE_VLSIu10__SVBool_tLj512EE
  typedef svbool_t pred __attribute__((arm_sve_vector_bits(512)));
  #endif

The latest ACLE specification (00bet5) does not contain details of this
mangling scheme, it will be specified in the next revision.  The
mangling scheme is otherwise defined in the appendices to the Procedure
Call Standard for the Arm Architecture, see [2] for more information.

[1] https://developer.arm.com/documentation/100987/latest
[2] https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#appendix-c-mangling

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D85743
2020-08-27 15:11:58 +00:00
Sam McCall 266825620c [Tooling][Format] Treat compound extensions (foo.bar.cc) as matching foo.h
Motivating use case is ".cu.cc" extensions used in some bazel projects.

Alternative is to work around this with IncludeIsMainRegex in styles.
I proposed this approach because it seems like a better default.

Differential Revision: https://reviews.llvm.org/D86597
2020-08-27 15:24:17 +02:00
Eduardo Caldas ac87a0b587 [SyntaxTree][NFC][Style] Functions start with lowercase
Differential Revision: https://reviews.llvm.org/D86682
2020-08-27 12:55:24 +00:00
Eduardo Caldas fda3fa822c [SyntaxTree][NFC] Append "get" to syntax Nodes accessor names
Differential Revision: https://reviews.llvm.org/D86679
2020-08-27 12:55:23 +00:00
Cullen Rhodes feed5a7239 [Sema][AArch64] Support arm_sve_vector_bits attribute
This patch implements the semantics for the 'arm_sve_vector_bits' type
attribute, defined by the Arm C Language Extensions (ACLE) for SVE [1].
The purpose of this attribute is to define vector-length-specific (VLS)
versions of existing vector-length-agnostic (VLA) types.

The semantics were already implemented by D83551, although the
implementation approach has since changed to represent VLSTs as
VectorType in the AST and fixed-length vectors in the IR everywhere
except in function args/returns. This is described in the prototype
patch D85128 demonstrating the new approach.

The semantic changes added in D83551 are changed since the
AttributedType is replaced by VectorType in the AST. Minimal changes
were necessary in the previous patch as the canonical type for both VLA
and VLS was the same (i.e. sizeless), except in constructs such as
globals and structs where sizeless types are unsupported. This patch
reverts the changes that permitted VLS types that were represented as
sizeless types in such circumstances, and adds support for implicit
casting between VLA <-> VLS types as described in section 3.7.3.2 of the
ACLE.

Since the SVE builtin types for bool and uint8 are both represented as
BuiltinType::UChar in VLSTs, two new vector kinds are implemented to
distinguish predicate and data vectors.

[1] https://developer.arm.com/documentation/100987/latest

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D85736
2020-08-27 10:38:32 +00:00
Sander de Smalen 4e9b66de3f [AArch64][SVE] Add missing debug info for ACLE types.
This patch adds type information for SVE ACLE vector types,
by describing them as vectors, with a lower bound of 0, and
an upper bound described by a DWARF expression using the
AArch64 Vector Granule register (VG), which contains the
runtime multiple of 64bit granules in an SVE vector.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D86101
2020-08-27 10:56:42 +01:00
Eduardo Caldas 718e550cd0 [SyntaxTree] Refactor `NodeRole`s
Previously a NodeRole would generally be prefixed with the `NodeKind`,
we remove this prefix, as it we redundant and made tests more noisy.

Differential Revision: https://reviews.llvm.org/D86636
2020-08-27 05:16:00 +00:00
Brad Smith a45ccc983b Default to -fuse-init-array on OpenBSD. 2020-08-27 01:12:16 -04:00
Amy Kwan 76b0f99ea8 [PowerPC] Implement Vector Multiply High/Divide Extended Builtins in LLVM/Clang
This patch implements the function prototypes vec_mulh and vec_dive in order to
utilize the vector multiply high (vmulh[s|u][w|d]) and vector divide extended
(vdive[s|u][w|d]) instructions introduced in Power10.

Differential Revision: https://reviews.llvm.org/D82609
2020-08-26 23:14:34 -05:00
Craig Topper 71f3169e1b [X86] Default to -mtune=generic unless -march is passed to the driver. Add TuneCPU to the AST serialization
This patch defaults to -mtune=generic unless -march is present. If -march is present we'll use the empty string unless its overridden by mtune. The back should use the target cpu if the tune-cpu isn't present.

It also adds AST serialization support to fix some tests that emit AST and parse it back. These tests diff the IR against the output from not going through AST. So if we don't serialize the tune CPU we fail the diff.

Differential Revision: https://reviews.llvm.org/D86488
2020-08-26 14:52:03 -07:00
Christopher Tetreault 19e883fc59 [SVE] Remove calls to VectorType::getNumElements from clang
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D82582
2020-08-26 11:12:26 -07:00
Adam Czachorowski eed0af6179 [clang] Exclude invalid destructors from lookups.
This fixes a crash when declaring a destructor with a wrong name, then
writing result to pch file and loading it again. The PCH storage uses
DeclarationNameKey as key and it is the same key for both the invalid
destructor and the implicit one that was created because the other one
was invalid. When querying for the Foo::~Foo we end up getting
Foo::~Bar, which is then rejected and we end up with nullptr in
CXXRecordDecl::GetDestructor().

Fixes https://bugs.llvm.org/show_bug.cgi?id=47270

Differential Revision: https://reviews.llvm.org/D86624
2020-08-26 19:29:30 +02:00
Eduardo Caldas dc3d474327 [SyntaxTree] Migrate `ParamatersAndQualifiers` to use the new List API
Fix: Add missing `List::getTerminationKind()`, `List::canBeEmpty()`,
`List::getDelimiterTokenKind()` for `CallArguments`.

Differential Revision: https://reviews.llvm.org/D86600
2020-08-26 16:46:19 +00:00
Kai Nacke ed07e1fe0f [SystemZ/ZOS] Add header file to encapsulate use of <sysexits.h>
The non-standard header file `<sysexits.h>` provides some return values.
`EX_IOERR` is used to as a special value to signal a broken pipe to the clang driver.
On z/OS Unix System Services, this header file does not exists. This patch

- adds a check for `<sysexits.h>`, removing the dependency on `LLVM_ON_UNIX`
- adds a new header file `llvm/Support/ExitCodes`, which either includes
  `<sysexits.h>` or defines `EX_IOERR`
- updates the users of `EX_IOERR` to include the new header file

Reviewed By: hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D83472
2020-08-26 12:44:30 -04:00
Zachary Henkel 0870471442 Add clang-cl "vctoolsdir" option to specify the location of the msvc toolchain
Add an option to directly specify where the msvc toolchain lives for
clang-cl and avoid unwanted file and registry probes.

Differential revision: https://reviews.llvm.org/D85998
2020-08-26 15:09:18 +02:00
Nithin Vadukkumchery Rajendrakumar 20676cab11 [analyzer] Add modeling of assignment operator in smart ptr
Summary: Support for 'std::unique_ptr>::operator=' in SmartPtrModeling

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ, vsavchenko, xazax.hun

Subscribers: martong, cfe-commits
Tags: #clang

Differential Revision: https://reviews.llvm.org/D86293
2020-08-26 11:22:55 +02:00
Eduardo Caldas 2de2ca348d [SyntaxTree] Add support for `CallExpression`
* Generate `CallExpression` syntax node for all semantic nodes inheriting from
`CallExpr` with call-expression syntax - except `CUDAKernelCallExpr`.
* Implement all the accessors
* Arguments of `CallExpression` have their own syntax node which is based on
the `List` base API

Differential Revision: https://reviews.llvm.org/D86544
2020-08-26 07:03:49 +00:00
Volodymyr Sapsai 8839e278ff [Modules] Improve error message when cannot find parent module for submodule definition.
Before the change the diagnostic for

    module unknown.submodule {}

was "error: expected module name" which is incorrect and misleading
because both "unknown" and "submodule" are valid module names.

We already have a better error message when a parent module is a
submodule itself and is missing. Make the error for a missing top-level
module more like the one for a submodule.

rdar://problem/64424407

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D84458
2020-08-25 16:31:27 -07:00
Zequan Wu 9500a72091 Revert "[Coverage] Enable emitting gap area between macros"
This reverts commit a31c89c1b7.
2020-08-25 15:28:42 -07:00
Abhina Sreeskantharajan 97ccf93b36 [SystemZ][z/OS] Add z/OS Target and define macros
This patch adds the z/OS target and defines macros as a stepping stone
towards enabling a native build on z/OS.

Reviewed By: hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D85324
2020-08-25 15:51:59 -04:00
Amy Huang b1009ee84f Reland "[DebugInfo] Move constructor homing case in shouldOmitDefinition."
For some reason the ctor homing case was before the template
specialization case, and could have returned false too early.
I moved the code out into a separate function to avoid this.

This reverts commit 05777ab941.
2020-08-25 12:36:11 -07:00
Jeremy Morse 121a49d839 [LiveDebugValues] Add switches for using instr-ref variable locations
This patch adds the -Xclang option
"-fexperimental-debug-variable-locations" and same LLVM CodeGen option,
to pick which variable location tracking solution to use.

Right now all the switch does is pick which LiveDebugValues
implementation to use, the normal VarLoc one or the instruction
referencing one in rGae6f78824031. Over time, the aim is to add fragments
of support in aid of the value-tracking RFC:

  http://lists.llvm.org/pipermail/llvm-dev/2020-February/139440.html

also controlled by this command line switch. That will slowly move
variable locations to be defined by an instruction calculating a value,
and a DBG_INSTR_REF instruction referring to that value. Thus, this is
going to grow into a "use the new kind of variable locations" switch,
rather than just "use the new LiveDebugValues implementation".

Differential Revision: https://reviews.llvm.org/D83048
2020-08-25 14:58:48 +01:00
Eduardo Caldas c655d80815 [SyntaxTree] Extend the syntax tree dump to also cover `NodeRole`
We should see `NodeRole` information in the dump because that exposes how the
accessors will behave.

Functional changes in the dump:
* Surround Leaf tokens with `'`
* Append `Node` dumps with `NodeRole` information, except for unknown roles
* Append marks to `Node` dumps, instead of prepending

Non-functional changes:
* `::dumpTokens(llvm::raw_ostream, ArrayRef<syntax::Token>, const
SourceManager &SM)` always received as parameter a `syntax::Token *`
pointing to `Leaf::token()`. Changed the function to
`dumpLeaf(llvm::raw_ostream, syntax::Leaf *, const SourceManager&)`
* `dumpTree` acted on a Node, rename to `dumpNode`

Differential Revision: https://reviews.llvm.org/D85330
2020-08-25 06:34:40 +00:00
Richard Smith 04ba185633 PR37556: Don't diagnose conflicts between instantiated unqualified
friend declarations and declarations found in inline namespaces within
the target context.
2020-08-24 23:26:15 -07:00
Freddy Ye e02d081f2b [X86] Support -march=sapphirerapids
Support -march=sapphirerapids for x86.
Compare with Icelake Server, it includes 14 more new features. They are
amxtile, amxint8, amxbf16, avx512bf16, avx512vp2intersect, cldemote,
enqcmd, movdir64b, movdiri, ptwrite, serialize, shstk, tsxldtrk, waitpkg.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D86503
2020-08-25 14:21:21 +08:00
Eric Christopher 05777ab941 Temporarily Revert "[DebugInfo] Move constructor homing case in shouldOmitDefinition."
as it's causing test failures.

This reverts commit 589ce5f705.
2020-08-24 21:51:31 -07:00
Amy Huang 589ce5f705 [DebugInfo] Move constructor homing case in shouldOmitDefinition.
For some reason the ctor homing case was before the template
specialization case, and could have returned false too early.
I moved the code out into a separate function to avoid this.

Also added a run line to the template specialization test. I guess
all the -debug-info-kind=limited tests should still pass with =constructor,
but it's probably unnecessary to test for all of those.

Differential Revision: https://reviews.llvm.org/D86491
2020-08-24 20:17:59 -07:00
Richard Smith 91604949ef Properly pass modules flags to frontend when using -std=c++20 instead of -std=c++2a.
In passing, also teach the driver to map /std:c++latest to -std=c++20
not -std=c++2a.
2020-08-24 17:49:58 -07:00
Baptiste Saleil 512e256c0d [PowerPC] Add clang options to control MMA support
This patch adds frontend and backend options to enable and disable
the PowerPC MMA operations added in ISA 3.1. Instructions using these
options will be added in subsequent patches.

Differential Revision: https://reviews.llvm.org/D81442
2020-08-24 09:35:55 -05:00
Alexey Bataev bedc841a50 [OPENMP]Fix PR47158, case 3: allow devic_typein nested declare target region.
OpenMP 5.0 supports nested declare target regions. So, in general,it is
allow to mark a declarationas declare target with different device_type
or link type. Patch adds support for such kind of nesting.

Differential Revision: https://reviews.llvm.org/D86239
2020-08-24 09:58:37 -04:00
Raphael Isemann 105151ca56 Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"
The orignal patch with the missing 'REQUIRES: asserts' as there is a debug-only
flag used in the test.

Original summary:

D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5
uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations
that creates the dwoID in the module from the ASTFileSignature
(`Buffer->Signature` being the array subclass that is now `std::array<uint8_t,
20>` instead of `std::array<uint32_t, 5>`).

```
  uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
```

This code works with the old ASTFileSignature (where two uint32_t are enough to
fill the uint64_t), but after the patch this only took two bytes from the
ASTFileSignature and only partly filled the Signature uint64_t.

This caused that the dwoID in the module ref and the dwoID in the actual module
no longer match (which in turns causes that LLDB keeps warning about the dwoID's
not matching when debugging -gmodules-compiled binaries).

This patch just unifies the logic for turning the ASTFileSignature into an
uint64_t which makes the dwoID match again (and should prevent issues like that
in the future).

Reviewed By: aprantl, dang

Differential Revision: https://reviews.llvm.org/D84013
2020-08-24 14:52:53 +02:00
Bevin Hansson 577f8b157a [Fixed Point] Add codegen for fixed-point shifts.
This patch adds codegen to Clang for fixed-point shift
operations.

Reviewed By: leonardchan

Differential Revision: https://reviews.llvm.org/D83294
2020-08-24 14:37:16 +02:00
Bevin Hansson 808ac54645 [Fixed Point] Use FixedPointBuilder to codegen fixed-point IR.
This changes the methods in CGExprScalar to use
FixedPointBuilder to generate IR for fixed-point
conversions and operations.

Since FixedPointBuilder emits padded operations slightly
differently than the original code, some tests change.

Reviewed By: leonardchan

Differential Revision: https://reviews.llvm.org/D86282
2020-08-24 14:37:07 +02:00
Haojian Wu 09e7fe9859 [AST][RecoveryAST] Preserve the type by default for recovery expression.
Differential Revision: https://reviews.llvm.org/D82657
2020-08-24 14:28:28 +02:00
Raphael Isemann 2b3074c0d1 Revert "Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)""
This reverts commit ada2e8ea67. Still breaking
on Fuchsia (and also Fedora) with exit code 1, so back to investigating.
2020-08-24 12:54:25 +02:00
Raphael Isemann ada2e8ea67 Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"
This relands D84013 but with a test that relies on less shell features to
hopefully make the test pass on Fuchsia (where the test from the previous patch
version strangely failed with a plain "Exit code 1").

Original summary:

D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5 uint32_t.
However, it didn't update the code in ObjectFilePCHContainerOperations that creates
the dwoID in the module from the ASTFileSignature (`Buffer->Signature` being the
array subclass that is now `std::array<uint8_t, 20>` instead of `std::array<uint32_t, 5>`).

```
  uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
```

This code works with the old ASTFileSignature  (where two uint32_t are enough to
fill the uint64_t), but after the patch this only took two bytes from the ASTFileSignature
and only partly filled the Signature uint64_t.

This caused that the dwoID in the module ref and the dwoID in the actual module no
longer match (which in turns causes that LLDB keeps warning about the dwoID's not
matching when debugging -gmodules-compiled binaries).

This patch just unifies the logic for turning the ASTFileSignature into an uint64_t which
makes the dwoID match again (and should prevent issues like that in the future).

Reviewed By: aprantl, dang

Differential Revision: https://reviews.llvm.org/D84013
2020-08-24 11:51:32 +02:00
Brad Smith bf3577ef64 [clang][Driver] Implement addLibCxxIncludePaths and getCompilerRT for the OpenBSD clang driver. 2020-08-23 20:44:29 -04:00
Brad Smith 2b37174b9a [clang][Driver] Implement AddClangSystemIncludeArgs and HasNativeLLVMSupport for the OpenBSD clang driver.
If not overridden, AddClangSystemIncludeArgs's implementation is empty, so by
default, no system include args are added to the Clang driver. This means that
invoking Clang without the frontend must include a manual -I/usr/include flag,
which is inconsistent behavior. Therefore, override and implement this method
to match. Some boilerplate is also borrowed for handling of the other driver
flags.

While we are here, also override and enable HasNativeLLVMSupport.

Patch by: 3405691582 (dana koch)

Differential Revision: https://reviews.llvm.org/D86412
2020-08-23 20:08:40 -04:00
Simon Pilgrim a1dc3d241b [X86] Enable constexpr on ROTL/ROTR intrinsics (PR31446)
This enables constexpr rotate intrinsics defined in ia32intrin.h, including the MS specific builtins.
2020-08-23 16:11:58 +01:00
Nithin Vadukkumchery Rajendrakumar 55208f5a21 [analyzer] Add modeling for unque_ptr::get()
Summary: Implemented  modeling for get() method in SmartPtrModeling

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ, xazax.hun

Subscribers: martong, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D86029
2020-08-23 14:50:26 +02:00
Simon Pilgrim f8e0e5db48 [X86] Enable constexpr on _cast fp<-> uint intrinsics (PR31446)
As suggested by @rsmith on PR47267, by replacing the builtin_memcpy bitcast pattern with builtin_bit_cast we can use _castf32_u32, _castu32_f32, _castf64_u64 and _castu64_f64 inside constant expresssions (constexpr). Although __builtin_bit_cast was added for c++20 it works on all clang c/c++ modes.

Differential Revision: https://reviews.llvm.org/D86398
2020-08-23 10:27:46 +01:00
Craig Topper cc7bf9bcbf [X86] Allow 32-bit mode only CPUs with -mtune on 64-bit targets
gcc errors on this, but I'm nervous that since -mtune has been
ignored by clang for so long that there may be code bases out
there that pass 32-bit cpus to clang.
2020-08-22 16:38:05 -07:00
Simon Pilgrim 42b993d97d [X86] ia32intrin.h - pull out common attributes used in cast helpers into define. NFCI. 2020-08-22 15:25:15 +01:00
Simon Pilgrim e7d9182a66 Enable constexpr on BITREVERSE builtin intrinsics (PR47249)
This enables us to use the __builtin_bitreverse 8/16/32/64 intrinsics inside constexpr code.

Differential Revision: https://reviews.llvm.org/D86339
2020-08-22 14:43:22 +01:00
Simon Pilgrim 2ceac91ec0 Enable constexpr on ROTATELEFT/ROTATERIGHT builtin intrinsics (PR47249)
This enables us to use the __builtin_rotateleft / __builtin_rotateright 8/16/32/64 intrinsics inside constexpr code.

Differential Revision: https://reviews.llvm.org/D86342
2020-08-22 14:43:21 +01:00
Vaibhav Garg aca191cce1 Re-land 7a527f1777 with fixes.
The original commit was reverted in 58c305f466
due to broken bots. This commit corrects the triple and command line paths.
2020-08-21 14:40:09 -04:00
Aaron Ballman 58c305f466 Revert "Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute"
This reverts commit 7a527f1777.

It caused some buildbot failures:
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/13600
http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/20294
2020-08-21 12:42:10 -04:00
Vaibhav Garg 7a527f1777 Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute
This commit teaches ASTDeclReader::attachPreviousDecl to successfully merge
two Decl's when one contains an inheritable attribute like the
MSInheritanceAttr. Usually, attributes that are needed to be present along the
redeclaration chain are attached during ASTReading from
ASTDeclReader::attachPreviousDecl, but no such thing is done for inheritable
attributes. Currently, only the logic for merging MSInheritanceAttr is
provided.
2020-08-21 12:04:43 -04:00
Raphael Isemann c1dd5df425 Revert "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"
This reverts commit a4c3ed42ba.

The test is curiously failing with a plain exit code 1 on Fuchsia.
2020-08-21 16:08:37 +02:00
Haojian Wu 466590192b [AST][RecoveryExpr] Fix a bogus unused diagnostic when the type is preserved.
Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D85716
2020-08-21 15:48:59 +02:00
Raphael Isemann a4c3ed42ba Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)
D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5
uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations
that creates the dwoID in the module from the ASTFileSignature
(`Buffer->Signature` being the array subclass that is now `std::array<uint8_t,
20>` instead of `std::array<uint32_t, 5>`).

```
  uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
```

This code works with the old ASTFileSignature (where two uint32_t are enough to
fill the uint64_t), but after the patch this only took two bytes from the
ASTFileSignature and only partly filled the Signature uint64_t.

This caused that the dwoID in the module ref and the dwoID in the actual module
no longer match (which in turns causes that LLDB keeps warning about the dwoID's
not matching when debugging -gmodules-compiled binaries).

This patch just unifies the logic for turning the ASTFileSignature into an
uint64_t which makes the dwoID match again (and should prevent issues like that
in the future).

Reviewed By: aprantl, dang

Differential Revision: https://reviews.llvm.org/D84013
2020-08-21 15:05:02 +02:00
Simon Pilgrim 9ffc412e1a [X86] Enable constexpr on BITSCAN intrinsics (PR31446)
This enables constexpr BSF/BSR intrinsics defined in ia32intrin.h
2020-08-21 11:44:20 +01:00
Simon Pilgrim c8e6bf0a65 [X86] Enable constexpr on BSWAP intrinsics (PR31446)
This enables constexpr BSWAP intrinsics defined in ia32intrin.h
2020-08-21 10:55:15 +01:00
Simon Pilgrim c6863a4ab8 [X86] Enable constexpr on POPCNT intrinsics (PR31446)
Followup to D86229, this enables constexpr on the alternative (which fallback to generic code) POPCNT intrinsics defined in ia32intrin.h
2020-08-21 10:20:37 +01:00
Simon Pilgrim 33bb80bc7a [X86] ia32intrin.h - pull out common attributes into defines. NFCI.
Matches what we do in most other x86 headers
2020-08-21 10:03:28 +01:00
Eduardo Caldas 85c15f17cc [SyntaxTree] Add support for `this`
Differential Revision: https://reviews.llvm.org/D86298
2020-08-21 08:01:29 +00:00
Gousemoodhin Nadaf fe86dbb32d [clang]: Remove assertion which checks explicit declaration
explicit keyword is declared outside of class is invalid, invalid explicit declaration is handled inside DiagnoseFunctionSpecifiers() function. To avoid compiler crash in case of invalid explicit declaration, remove assertion.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D83929
2020-08-20 18:15:43 -07:00
Volodymyr Sapsai 7ac737e56b [HeaderSearch] Fix processing #import-ed headers multiple times with modules enabled.
HeaderSearch was marking requested HeaderFileInfo as Resolved only based on
the presence of ExternalSource. As the result, using any module was enough
to set ExternalSource and headers unknown to this module would have
HeaderFileInfo with empty fields, including `isImport = 0`, `NumIncludes = 0`.
Such HeaderFileInfo was preserved without changes regardless of how the
header was used in other modules and caused incorrect result in
`HeaderSearch::ShouldEnterIncludeFile`.

Fix by marking HeaderFileInfo as Resolved only if ExternalSource knows
about this header.

rdar://problem/62126911

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D80263
2020-08-20 17:41:28 -07:00
Richard Smith 70923983e5 Improve pretty-printing for APValues of void type.
No functionality change intended: there doesn't seem to be any way to
cause Clang to print such a value, but they can show up when dumping
APValues from a debugger.
2020-08-20 17:14:22 -07:00
Richard Smith 038edf6029 Don't reject uses of void-returning consteval functions. 2020-08-20 15:40:09 -07:00
Simon Pilgrim cff0db0876 [X86] Enable constexpr on POPCNT intrinsics (PR31446)
This is a first step patch to enable constexpr support and testing to a large number of x86 intrinsics.

All I've done here is provide a DEFAULT_FN_ATTRS_CONSTEXPR variant to our existing DEFAULT_FN_ATTRS tag approach that adds constexpr on c++ builds. The clang cuda headers do something similar.

I've started with POPCNT mainly as its tiny and are wrappers to generic __builtin_* intrinsics which already act as constexpr.

Differential Revision: https://reviews.llvm.org/D86229
2020-08-20 21:38:04 +01:00
Eduardo Caldas a4ef9e8643 [SyntaxTree] Unify logic for generating `id-expression` 2020-08-20 14:57:35 +00:00
Eduardo Caldas ba32915db2 [SyntaxTree] Add support for `MemberExpression`
Differential Revision: https://reviews.llvm.org/D86227
2020-08-20 14:57:35 +00:00
Alex Bradbury 1ecf120246 [index-while-building] Fix build with -DBUILD_SHARED_LIBS=True
The dependencies in clang/lib/IndexSerialization/CMakeLists.txt were
incomplete, leading to link errors for a -DBUILD_SHARED_LIBS=True build.
2020-08-20 15:12:56 +01:00
Adam Czachorowski baeff989b0 [clang] When loading preamble from AST file, re-export modules in Sema.
This addresses a FIXME in ASTReader.

Modules were already re-exported for Preprocessor, but not for Sema.
The result was that, with -fmodules-local-submodule-visibility, all AST
nodes belonging to a module that was loaded in a premable where not
accesible from the main part of the file and a diagnostic recommending
importing those modules would be generated.

Differential Revision: https://reviews.llvm.org/D86069
2020-08-20 14:19:52 +02:00
Adam Czachorowski 53b9199a5c [clangd] Fix crash-bug in preamble indexing when using modules.
When preamble contains #undef, indexing code finds the matching #define
and uses that during indexing. However, it would only look for local
definitions. If the macro was defined in a module, MacroInfo
would be nullptr and clangd would crash.

This change makes clangd ignore any #undef without a matching #define
inside the same TU.

The indexing of macros happens for preamble only, so then #undef must be
in the preamble, which is why we need two .h files in a test.

Note that clangd is currently not ready for module support, but this
brings us one step closer.

This was previously attempted in
4061d9e42c, but had to be reverted due to
broken test. This version fixes that test-only bug by setting a custom module
cache path to avoid re-use of modules across test invocations.

Differential Revision: https://reviews.llvm.org/D85923
2020-08-20 14:19:52 +02:00
Bevin Hansson 1a995a0af3 [ADT] Move FixedPoint.h from Clang to LLVM.
This patch moves FixedPointSemantics and APFixedPoint
from Clang to LLVM ADT.

This will make it easier to use the fixed-point
classes in LLVM for constructing an IR builder for
fixed-point and for reusing the APFixedPoint class
for constant evaluation purposes.

RFC: http://lists.llvm.org/pipermail/llvm-dev/2020-August/144025.html

Reviewed By: leonardchan, rjmccall

Differential Revision: https://reviews.llvm.org/D85312
2020-08-20 10:29:45 +02:00
Bevin Hansson 1e7ec4842c [AST] Get field size in chars rather than bits in RecordLayoutBuilder.
In D79719, LayoutField was refactored to fetch the size of field
types in bits and then convert to chars, rather than fetching
them in chars directly. This is not ideal, since it makes the
calculations char size dependent, and breaks for sizes that
are not a multiple of the char size.

This patch changes it to use getTypeInfoInChars instead of
getTypeInfo.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D85191
2020-08-20 10:29:29 +02:00
Craig Topper 724f570ad2 [X86] Add support 'tune' in target attribute
This adds parsing and codegen support for tune in target attribute.

I've implemented this so that arch in the target attribute implicitly disables tune from the command line. I'm not sure what gcc does here. But since -march implies -mtune. I assume 'arch' in the target attribute implies tune in the target attribute.

Differential Revision: https://reviews.llvm.org/D86187
2020-08-19 15:58:19 -07:00
Richard Smith c1c1bed5d0 [c++14] Implement missed piece of N3323: use "converted constant" rules
for array bounds, not "integer constant" rules.

For an array bound of class type, this causes us to perform an implicit
conversion to size_t, instead of looking for a unique conversion to
integral or unscoped enumeration type. This affects which cases are
valid when a class has multiple implicit conversion functions to
different types.
2020-08-19 15:45:51 -07:00
Richard Smith 6f33936719 Explain why the array bound is non-constant in VLA diagnostics.
In passing, also use a more precise diagnostic to explain why an
expression is not an ICE if it's not of integral type.
2020-08-19 15:45:51 -07:00
Craig Topper 7cffaf510f [X89] Ignore -mtune=generic to fix failures some users are seeing after D85384
Some code bases out there pass -mtune=generic to clang. This would have
been ignored prior to D85384. Now it results in an error
because "generic" isn't recognized by isValidCPUName.

And if we let it go through to the backend as a tune
setting it would get the tune flags closer to i386 rather
than a modern CPU.

I plan to change what tune=generic does in the backend in
a future patch. And allow this in the frontend.
But this should be a quick fix for the error some users
are seeing.
2020-08-19 13:17:57 -07:00
Alexey Bataev fb4acd37fe [OPENMP]Fix PR47158, case 2: do not report host-only functions in unused function in device mode.
If the function is not marked exlicitly as declare target and it calls
function(s), marked as declare target device_type(host), these host-only
functions should not be dignosed as used in device mode, if the caller
function is not used in device mode too.

Differential Revision: https://reviews.llvm.org/D86164
2020-08-19 16:14:33 -04:00
Jan Korous 4da126c374 [index-while-building] PathIndexer
Differential Revision: https://reviews.llvm.org/D66854
2020-08-19 11:25:21 -07:00
Mehdi Amini a407ec9b6d Revert "Revert "[NFC][llvm] Make the contructors of `ElementCount` private.""
Was reverted because MLIR/Flang builds were broken, these APIs have been
fixed in the meantime.
2020-08-19 17:26:36 +00:00
Mehdi Amini 4fc56d70aa Revert "[NFC][llvm] Make the contructors of `ElementCount` private."
This reverts commit 264afb9e6a.
(and dependent 6b742cc48 and fc53bd610f)

MLIR/Flang are broken.
2020-08-19 17:21:37 +00:00
Jon Chesterfield bcaa806a47 [Clang] Fix BZ47169, loader_uninitialized on incomplete types
[Clang] Fix BZ47169, loader_uninitialized on incomplete types

Reported by @erichkeane. Fix proposed by @erichkeane works, tests included.
Bug introduced in D74361. Crash was on querying a CXXRecordDecl for
hasTrivialDefaultConstructor on an incomplete type. Fixed by calling
RequireCompleteType in the right place.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D85990
2020-08-19 18:11:50 +01:00
Jonas Devlieghere 6b742cc48d [clang] Replace call to private ctor with ElementCount::getScalable (2/2)
Update the code for D86120 which made the constructors of `ElementCount`
private. Apparently I missed another instance in the macro just below.
2020-08-19 09:40:46 -07:00
Jonas Devlieghere fc53bd610f [clang] Replace call to private ctor with ElementCount::getScalable
Update the code for D86120 which made the constructors of `ElementCount`
private.
2020-08-19 09:35:08 -07:00
Benjamin Kramer b98e25b6d7 Make helpers static. NFC. 2020-08-19 16:00:03 +02:00
Aaron Puchert 916b750a8d [CodeGen] Use existing EmitLambdaVLACapture (NFC) 2020-08-19 15:20:05 +02:00
Sander de Smalen 0353848cc9 [Clang][SVE] NFC: Move info about ACLE types into separate function.
This function returns a struct `BuiltinVectorTypeInfo` that contains
the builtin vector's element type, element count and number of vectors
(used for vector tuples).

Reviewed By: c-rhodes

Differential Revision: https://reviews.llvm.org/D86100
2020-08-19 11:04:20 +01:00
Martin Storsjö cb6cf18ff5 [clang] Remove stray semicolons, fixing GCC warnings. NFC. 2020-08-19 10:41:03 +03:00
Haojian Wu 5b797eb5b4 [AST] Fix a crash on mangling a binding decl from a DeclRefExpr.
Differential Revision: https://reviews.llvm.org/D86130
2020-08-19 09:05:12 +02:00
Craig Topper b32f203edc [X86][Driver] Remove code that forced a core2 mtune from MachO::TranslateArgs.
mtune was previously ignored by the compiler so I'm not sure this
did anything. But after D85384 we're starting to support mtune
and this code is now causing a couple test failures on MacOS.
2020-08-18 23:44:36 -07:00
Yaxun (Sam) Liu 7546b29e76 [HIP] Support target id by --offload-arch
This patch introduces support of target id by
-offload-arch.

Differential Revision: https://reviews.llvm.org/D60620
2020-08-18 23:43:53 -04:00
Brad Smith d9ff48d038 WCharType and WIntType are always signed int on OpenBSD. 2020-08-18 19:59:54 -04:00
Brad Smith 592b8996bf Hook up OpenBSD 64-bit RISC-V support 2020-08-18 18:59:55 -04:00
Craig Topper 4cbceb74bb [X86] Add basic support for -mtune command line option in clang
Building on the backend support from D85165. This parses the command line option in the driver, passes it on to CC1 and adds a function attribute.

-Still need to support tune on the target attribute.
-Need to use "generic" as the tuning by default. But need to change generic in the backend first.
-Need to set tune if march is specified and mtune isn't.
-May need to disable getHostCPUName's ability to guess CPU name from features when it doesn't have a family/model match for mtune=native. That's what gcc appears to do.

Differential Revision: https://reviews.llvm.org/D85384
2020-08-18 15:13:19 -07:00
Nithin Vadukkumchery Rajendrakumar b34b1e3838 [Analysis] Bug fix for exploded graph branching in evalCall for constructor
Summary:
Make exactly single NodeBuilder exists at any given time

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ

Subscribers: martong, cfe-commits
Tags: #clang

Differential Revision: https://reviews.llvm.org/D85796
2020-08-19 00:03:31 +02:00
Zequan Wu 84fffa6728 [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same file as regions' {start, end}Loc
Fix a bug if {Prev, Next}TokLoc is in different file from skipped regions' {start, end}Loc

Differential Revision: https://reviews.llvm.org/D86116
2020-08-18 13:26:19 -07:00
Eli Friedman 673dbe1b5e [clang codegen] Use IR "align" attribute for static array arguments.
Without the "align" attribute, marking the argument dereferenceable is
basically useless.  See also D80166.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46876 .

Differential Revision: https://reviews.llvm.org/D84992
2020-08-18 12:51:16 -07:00
Craig Topper 6b1f9f2bd4 [X86] Don't call SemaBuiltinConstantArg from CheckX86BuiltinTileDuplicate if Argument is Type or Value Dependent.
SemaBuiltinConstantArg has an early exit for that case that doesn't
produce an error and doesn't update the APInt. We need to detect that
case and not use the APInt value.

While there delete the signature of CheckX86BuiltinTileArgumentsRange
that takes a single Argument index to check. There's another version
that takes an ArrayRef and single value is convertible to an ArrayRef.
2020-08-18 12:33:40 -07:00
Mott, Jeffrey T ca77ab494a Disable use of _ExtInt with '__atomic' builtins
We're (temporarily) disabling ExtInt for the '__atomic' builtins so we can better design their behavior later. The idea is until we do an audit/design for the way atomic builtins are supposed to work with _ExtInt, we should leave them restricted so they don't limit our future options, such as by binding us to a sub-optimal implementation via ABI.

Example after this change:

    $ cat test.c

        void f(_ExtInt(64) *ptr) {
          __atomic_fetch_add(ptr, 1, 0);
        }

    $ clang -c test.c

        test.c:2:22: error: argument to atomic builtin of type '_ExtInt' is not supported
          __atomic_fetch_add(ptr, 1, 0);
                             ^
        1 error generated.

Differential Revision: https://reviews.llvm.org/D84049
2020-08-18 09:17:26 -07:00
Alexey Bataev 1b93ebccaa [OPENMP]Do not capture base pointer by reference if it is used as a base for array-like reduction.
If the declaration is used in the reduction clause, it is captured by
reference by default. But if the declaration is a pointer and it is a
base for array-like reduction, this declaration can be captured by
value, since the pointee is reduced but not the original declaration.

Differential Revision: https://reviews.llvm.org/D85321
2020-08-18 09:05:35 -04:00
Amy Kwan c7ec3a7e33 [PowerPC] Implement Vector Extract Mask builtins in LLVM/Clang
This patch implements the vec_extractm function prototypes in altivec.h in
order to utilize the vector extract with mask instructions introduced in Power10.

Differential Revision: https://reviews.llvm.org/D82675
2020-08-17 21:14:17 -05:00
Luís Marques 687e7d3425 [NFC] Tweak a comment about the lock-free builtins 2020-08-17 13:43:53 +01:00
Kadir Cetinkaya 53c593c2c8
[clang] Make signature help work with dependent args
Fixes https://github.com/clangd/clangd/issues/490

Differential Revision: https://reviews.llvm.org/D85826
2020-08-17 10:06:36 +02:00
Yonghong Song 000ad1a976 [clang] fix a compilation bug
With gcc 6.3.0, I hit the following compilation bug:
  /home/yhs/work/llvm-project/clang/lib/Frontend/CompilerInvocation.cpp:
  In function ‘bool ParseCodeGenArgs(clang::CodeGenOptions&, llvm::opt::ArgList&,
  clang::InputKind, clang::DiagnosticsEngine&, const clang::TargetOptions&,
  const clang::FrontendOptions&)’:
  /home/yhs/work/llvm-project/clang/lib/Frontend/CompilerInvocation.cpp:780:12:
    error: unused variable ‘A’ [-Werror=unused-variable]
     if (Arg *A = Args.getLastArg(OPT_fuse_ctor_homing))
              ^
  cc1plus: all warnings being treated as errors

The bug is introduced by Commit ae6523cd62 ("[DebugInfo] Add
-fuse-ctor-homing cc1 flag so we can turn on constructor homing only
if limited debug info is already on.")
2020-08-16 21:53:37 -07:00
Richard Smith 948219d109 Replace setter named 'getAsOpaqueInt' with a real getter.
Clean up a bunch of places where the opaque forms of FPOptions and
FPOptionsOverride were being used inappropriately.
2020-08-16 16:38:33 -07:00
Richard Smith ae3067055b Use consistent code for setting FPFeatures from operator constructors. 2020-08-16 15:40:38 -07:00
Richard Smith 9860e68450 Don't leave the FPOptions in a UnaryOperator uninitialized.
We don't appear to use these FPOptions for anything right now, but
they shouldn't be uninitialized because that makes our AST file output
nondeterministic.
2020-08-16 15:16:12 -07:00
Johannes Doerfert 95a25e4c32 [OpenMP][FIX] Do not use TBAA in type punning reduction GPU code PR46156
When we implement OpenMP GPU reductions we use type punning a lot during
the shuffle and reduce operations. This is not always compatible with
language rules on aliasing. So far we generated TBAA which later allowed
to remove some of the reduce code as accesses and initialization were
"known to not alias". With this patch we avoid TBAA in this step,
hopefully for all accesses that we need to.

Verified on the reproducer of PR46156 and QMCPack.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D86037
2020-08-16 14:38:31 -05:00
Mark de Wever fef2607124 [Sema] Use the proper cast for a fixed bool enum.
When casting an enumerate with a fixed bool type the casting should use
an IntegralToBoolean instead of an IntegralCast as is required per Core
Issue 2338.

Fixes PR47055: Incorrect codegen for enum with bool underlying type

Differential Revision: https://reviews.llvm.org/D85612
2020-08-16 18:40:08 +02:00
Mark de Wever 827ba67e38 [Sema] Validate calls to GetExprRange.
When a conditional expression has a throw expression it called
GetExprRange with a void expression, which caused an assertion failure.

This approach was suggested by Richard Smith.

Fixes PR46484: Clang crash in clang/lib/Sema/SemaChecking.cpp:10028

Differential Revision: https://reviews.llvm.org/D85601
2020-08-16 18:32:38 +02:00
Brad Smith 44613bbec8 Create strict aligned code for OpenBSD/arm64. 2020-08-16 07:14:34 -04:00
Gui Andrade 909a851dbf [CGAtomic] Mark atomic libcall functions `nounwind`
These functions won't ever unwind. This is useful for MemorySanitizer
as it simplifies handling __atomic_load in particular.

Differential Revision: https://reviews.llvm.org/D85573
2020-08-14 07:46:43 +00:00
Amy Huang ae6523cd62 [DebugInfo] Add -fuse-ctor-homing cc1 flag so we can turn on constructor homing only if limited debug info is already on.
This adds a cc1 flag to enable constructor homing but doesn't turn on debug
info if it wasn't enabled already (which is what using
-debug-info-kind=constructor does). This will be used for testing, and won't
be needed anymore once ctor homing is used as default / merged into =limited.

Bug to enable ctor homing: https://bugs.llvm.org/show_bug.cgi?id=46537

Differential Revision: https://reviews.llvm.org/D85799
2020-08-13 15:48:55 -07:00
Rainer Orth f59bec7acb [clang][Driver] Default to /usr/bin/ld on Solaris
`clang` currently requires the native linker on Solaris:

  - It passes `-C` to `ld` which GNU `ld` doesn't understand.

  - To use `gld`, one needs to pass the correct `-m EMU` option to select
    the right emulation.  Solaris `ld` cannot handle that option.

So far I've worked around this by passing `-DCLANG_DEFAULT_LINKER=/usr/bin/ld`
to `cmake`.  However, if someone forgets this, it depends on the user's
`PATH` whether or not `clang` finds the correct linker, which doesn't make
for a good user experience.

While it would be nice to detect the linker flavor at runtime, this is more
involved.  Instead, this patch defaults to `/usr/bin/ld` on Solaris.  This
doesn't work on its own, however: a link fails with

  clang-12: error: unable to execute command: Executable "x86_64-pc-solaris2.11-/usr/bin/ld" doesn't exist!

I avoid this by leaving absolute paths alone in `ToolChain::GetLinkerPath`.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D84029
2020-08-13 22:42:58 +02:00
Abhina Sreeskantharajan dedaf78fa7 [SystemZ][z/OS] enable trigraphs by default on z/OS
This patch enables trigraphs on z/OS.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D85722
2020-08-13 16:02:07 -04:00
Alex Lorenz c2807b2e56 [darwin][driver] fix isMacosxVersionLT minimum supported OS version check
The previous Driver's triple check only worked for -target, but not for -arch -mmacosx-version-min invocations
2020-08-13 12:06:45 -07:00
Dávid Bolvanský 2f7adf5ee3 [Diagnostics] Skip var decl of structs for -Wstring-concatenation 2020-08-13 20:20:26 +02:00
Adam Czachorowski 73f0772c0b [clangd] Revert "[clangd] Fix crash-bug in preamble indexing when using modules."
This reverts commit 4061d9e42c.
Tests are failing in some configuration, likely due to not cleaning up
module cache path before running the test.

Differential Revision: https://reviews.llvm.org/D85907
2020-08-13 17:09:54 +02:00
Valeriy Savchenko 9cbfdde2ea [analyzer] Fix crash with pointer to members values
This fix unifies all of the different ways we handled pointer to
members into one.  The crash was caused by the fact that the type
of pointer-to-member values was `void *`, and while this works
for the vast majority of cases it breaks when we actually need
to explain the path for the report.

rdar://problem/64202361

Differential Revision: https://reviews.llvm.org/D85817
2020-08-13 18:03:59 +03:00
Michael Forster a5b8757506 Introduce ns_error_domain attribute.
ns_error_domain can be used by, e.g. NS_ERROR_ENUM, in order to
identify a global declaration representing the domain constant.

Introduces the attribute, Sema handling, diagnostics, and test case.

This is cherry-picked from a14779f504
and adapted to updated Clang APIs.

Reviewed By: gribozavr2, aaron.ballman

Differential Revision: https://reviews.llvm.org/D84005
2020-08-13 15:05:12 +02:00
Sam McCall c286d6fdee [Parser] Suppress -Wempty-translation-unit if this is a header file
This is motivated by tooling (clangd, libclang etc) - headers without
declarations are legitimate even if they're not valid TUs.

The other use -x c-header cases (PCH/modules) are nonstandard anyway and this
warning doesn't seem necessary there either.

Differential Revision: https://reviews.llvm.org/D85789
2020-08-13 09:43:27 +02:00
Richard Smith bd08e0cf1c PR47143: Don't crash while constant-evaluating value-initialization of
an array of unknown bound as the initializer of an array new expression.
2020-08-12 16:53:45 -07:00
Albion Fung 3136cbe29e [PowerPC] Implement Vector Shift Builtins
This patch implements the builtins for the vector shifts (shl, srl, sra), and
adds the appropriate test cases for these builtins. The builtins utilize the
vector shift instructions introduced within ISA 3.1.

Differential Revision: https://reviews.llvm.org/D83338
2020-08-12 18:26:58 -05:00
Zequan Wu a31c89c1b7 [Coverage] Enable emitting gap area between macros
Differential Revision: https://reviews.llvm.org/D85176
2020-08-12 16:25:27 -07:00
Craig Topper 5c1fe4e20f [Target] Cache the command line derived feature map in TargetOptions.
We can use this to remove some calls to initFeatureMap from Sema
and CodeGen when a function doesn't have a target attribute.

This reduces compile time of the linux kernel where this map
is needed to diagnose some inline assembly constraints based
on whether sse, avx, or avx512 is enabled.

Differential Revision: https://reviews.llvm.org/D85807
2020-08-12 12:37:23 -07:00
Richard Smith 269bc3f5df PR47138: Don't crash if the preferred alignment of an invalid record
type is requested.
2020-08-12 12:31:20 -07:00
Aleksandr Platonov 3fa0a039ab [clang] Check `expr` inside `InitListChecker::UpdateStructuredListElement()`
- Prevent nullptr-deference at try to emit warning for invalid `expr`
- Simplify `InitListChecker::UpdateStructuredListElement()` usages. We do not need to check `expr` and increment `StructuredIndex` (for invalid `expr`) before the call anymore.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D85193
2020-08-12 22:12:43 +03:00
Craig Topper 2b8ad6b604 [WebAssembly] Don't depend on the flags set by handleTargetFeatures in initFeatureMap.
Properly set "simd128" in the feature map when "unimplemented-simd128"
is requested.

initFeatureMap is used to create the feature vector used by
handleTargetFeatures. There are later calls to initFeatureMap in
CodeGen that were using these flags to recreate the map. But the
original feature vector should be passed to those calls. So that
should be enough to rebuild the map.

The only issue seemed to be that simd128 was not enabled in the
map by the first call to initFeatureMap. Using the SIMDLevel set
by handleTargetFeatures in the later calls allowed simd128 to be
set in the later versions of the map.

To fix this I've added an override of setFeatureEnabled that
will update the map the first time with the correct simd dependency.

Differential Revision: https://reviews.llvm.org/D85806
2020-08-12 11:43:46 -07:00
Dávid Bolvanský df3bfaa390 [Driver] Change -fnostack-clash-protection to -fno-stack-clash-protection
Clang command line docs mention `-fno-stack-clash-protection`, and GCC also uses  -fno-stack-clash-protection.

Fixes PR47139

Reviewed By: tstellar

Differential Revision: https://reviews.llvm.org/D85844
2020-08-12 18:36:26 +02:00
Alexey Bataev fbd6d2c54e [OPENMP] Fix PR47063: crash when trying to get captured statetment.
Need to call getRawStmt() function instead, when trying to get inner
associated statement for the executable directive. Not all directives
use captured statements.
2020-08-12 12:05:58 -04:00
Alexey Bataev f4f3f678f1 [OPENMP]Fix PR37671: Privatize local(private) variables in untied tasks.
In untied tasks, need to allocate the space for local variales, declared
in task region, when the memory for task data is allocated. THe function
can be interrupted and we can exit from the function in untied task
switch. Need to keep the state of the local variables in this case.
Also, the compiler should not call cleanup when exiting in untied task
switch until the real exit out of the declaration scope is met during
 execution.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D84457
2020-08-12 11:28:19 -04:00
Anastasia Stulova 3c8a4ee076 [OpenCL] Remove warning for variadic macros in C++ for OpenCL.
Patch by Ole Strohm (olestrohm)!

Tags: #clang

Differential Revision: https://reviews.llvm.org/D85429
2020-08-12 16:17:54 +01:00
Zurab Tsinadze 25bbe234e4 [analyzer] StdLibraryFunctionsChecker: Add support for new functions
`toupper`, `tolower`, `toascii` functions were added to
StdLibraryFunctionsChecker to fully cover CERT STR37-C rule:
https://wiki.sei.cmu.edu/confluence/x/BNcxBQ

Differential Revision: https://reviews.llvm.org/D85093
2020-08-12 16:20:00 +02:00
Alexey Bataev ddbd21d288 [OPENMP]Do not add TGT_OMP_TARGET_PARAM flag to non-captured mapped arguments.
If the arguments are mapped, but are actually not used in the target
region, the compiler still adds attribute TGT_OMP_TARGET_PARAM for such
arguments. It makes the libomptarget to add such parameters to the list
of arguments, passed to the kernel at the runtime, and may lead to
incorrect results/crashes during execution.

Differential Revision: https://reviews.llvm.org/D85755
2020-08-12 10:06:52 -04:00
Alexey Bataev 3651658bdd Revert "[OPENMP]Fix PR37671: Privatize local(private) variables in untied tasks."
This reverts commit ec9563c54e to
investigate compiler crash revelaed by the buildbots.
2020-08-12 09:50:32 -04:00
Alexey Bataev ec9563c54e [OPENMP]Fix PR37671: Privatize local(private) variables in untied tasks.
Summary:
In untied tasks, need to allocate the space for local variales, declared
in task region, when the memory for task data is allocated. THe function
can be interrupted and we can exit from the function in untied task
switch. Need to keep the state of the local variables in this case.
Also, the compiler should not call cleanup when exiting in untied task
switch until the real exit out of the declaration scope is met during
 execution.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, cfe-commits, sstefan1, caomhin

Tags: #clang

Differential Revision: https://reviews.llvm.org/D84457
2020-08-12 09:37:24 -04:00
Erich Keane aa4bc1cb79 Limit Max Vector alignment on COFF targets to 8192.
COFF targets have a max object alignment of 8192, so trying to create
one with a larger size results in an unreachable in WinCOFFObjectWriter.

For the reproducer I have uses thread local storage, however other
alignments are likely affected as well.

This patch sets the MaxVectorAlign for COFF to 8192.  Additionally,
though there is no longer a way to reproduce that I could find, it
correctly sets the MaxTLSAlign for COFF to that value as well, so that
if anyone comes up with a situation where this is true, it will cause an
error.

Differential Revision: https://reviews.llvm.org/D85543
2020-08-12 06:35:35 -07:00
Eduardo Caldas ac37afa650 [SyntaxTree] Unbox operators into tokens for nodes generated from `CXXOperatorCallExpr`
For an user define `<`, `x < y` would yield the syntax tree:
```
BinaryOperatorExpression
|-IdExpression
| `-UnqualifiedId
|   `-x
|-IdExpression
| `-UnqualifiedId
|   `-<
`-IdExpression
  `-UnqualifiedId
    `-y
```
But there is no syntatic difference at call site between call site or
built-in `<`. As such they should generate the same syntax tree, namely:
```
BinaryOperatorExpression
|-IdExpression
| `-UnqualifiedId
|   `-x
|-<
`-IdExpression
  `-UnqualifiedId
    `-y
```

Differential Revision: https://reviews.llvm.org/D85750
2020-08-12 08:01:18 +00:00
Dávid Bolvanský b9af72bffe [Diagnostics] Reworked -Wstring-concatenation 2020-08-12 02:18:01 +02:00
Nithin Vadukkumchery Rajendrakumar 06d100a69a [Analyzer] Support note tags for smart ptr checker
Summary:
Added support for note tags for null smart_ptr reporting

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ, vsavchenko, xazax.hun

Subscribers: martong, cfe-commits
Tags: #clang

Differential Revision: https://reviews.llvm.org/D84600
2020-08-11 23:27:16 +02:00
Simon Pilgrim b9aaf32f46 Fix MSVC "not all control paths return a value" warning. NFC. 2020-08-11 18:13:03 +01:00
Yitzhak Mandelbaum d8c1f43dcc [libTooling] Move RewriteRule include edits to ASTEdit granularity.
Currently, changes to includes are applied to an entire rule. However,
include changes may be specific to particular edits within a rule (for example,
they may apply to one file but not another). Also, include changes may need to
carry metadata, just like other changes. So, we make include changes first-class
edits.

Reviewed By: tdl-g

Differential Revision: https://reviews.llvm.org/D85734
2020-08-11 16:47:14 +00:00
Yitzhak Mandelbaum 645dd1b3bf [libTooling] Cleanup and reorder `RewriteRule.h`.
This patch lifts `RootID` out of the `RewriteRule` class so that constructs
(e.g. inline functions) can that refer to the root id don't need to depend on
the `RewriteRule` class.

With this dependency, the patch is able to collect all `ASTEdit` helper function
declarations together with the class declaration, before the introduction of the
`RewriteRule` class. In the process, we also adjust some of the comments.

This patch is essentially a NFC.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D85733
2020-08-11 16:35:36 +00:00
Gousemoodhin Nadaf d4408fe17f [clang] Do not crash for unsupported fixed point to floating point conversion
- Fixed point to floating point conversion is unimplemented.
- If one of the operands has a floating type and the other operand has a fixed-point type, the function
   handleFloatConversion() is called because one of the operands has a floating type, but we do not handle fixed
   point type in this function (Implementation of fixed point to floating point conversion is missing), due to this
   compiler crashes. In order to avoid compiler crash, when one of the operands has a floating type and the other
   operand has a fixed-point type, return NULL.
- FIXME: Implementation of fixed point to floating point conversion.
- I am going to resolve FIXME in followup patches.
- Add the test case.

Reviewed By: ebevhan

Differential Revision: https://reviews.llvm.org/D81904
2020-08-11 17:26:19 +02:00
Bevin Hansson 956582aa16 [Sema] Iteratively strip sugar when removing address spaces.
ASTContext::removeAddrSpaceQualType does not properly deal
with sugar. QualTypes derive their ASes from the AS on the
canonical type, not the type itself. However,
removeAddrSpaceQualType only strips the outermost qualifiers,
which means that it can fail to remove addrspace qualifiers
if there is sugar in the way.

Change the function to desugar types until the address space
really no longer exists on the corresponding QualType. This
should guarantee the removal of the address space.

This fixes the erroneous behavior in D62574.

Reviewed By: rjmccall, svenvh

Differential Revision: https://reviews.llvm.org/D83325
2020-08-11 17:26:19 +02:00
Bruno Ricci f4dccf115c
[clang] Add a matcher for template template parameters.
There are already matchers for type template parameters and non-type template
parameters, but somehow no matcher exists for template template parameters
and I need it to write unit tests.

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

Reviewed By: aaron.ballman
2020-08-11 16:01:36 +01:00
Raphael Isemann 02899d7f1b [clang] Don't make ObjCIvarDecl visible twice when adding them to an implicit ObjCInterfaceDecl
`addDecl` is making the ivar visible in its primary context. The primary context
of the ivar here is in a 'fragile' ABI the ObjCInterfaceDecl and in a
'non-fragile' ABI the current ObjCImplementationDecl. The additional call to
`makeDeclVisibleInContext` to make the ivar visible in the ObjCInterfaceDecl is
only necessary in the 'non-fragile' case (as in the 'fragile' case the Decl
becomes automatically visible in the ObjCInterfaceDecl with the `addDecl` call
as thats its primary context). See `Sema::ActOnIvar` for where the ivar is put
into a different context depending on the ABI.

To put this into an example:

```
lang=c++
@implementation SomeClass
{
  id ivar1;
}
@end

fragile case:
implicit ObjCInterfaceDecl 'SomeClass'
`- ivar1 (in primary context and will be automatically made visible)
ObjCImplementationDecl 'SomeClass'

non-fragile case:
implicit ObjCInterfaceDecl 'SomeClass'
`-<<<ivar1 not visible here and needs to be manually marked as visible.>>>
ObjCImplementationDecl 'SomeClass'
`- ivar1 (in its primary context and will be automatically made visible here)
```

Making a Decl visible multiple times in the same context is inefficient and
potentially can lead to crashes. See D84827 for more info and what this is
breaking.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D84829
2020-08-11 16:24:32 +02:00
Raphael Isemann 442a80292d [clang] Don't make synthesized accessor stub functions visible twice
`addDecl` is making the Decl visible, so there is no need to make it explicitly
visible again. Making it visible twice will also make the lookup storage less
efficient and potentially lead to crashes, see D84827 for that.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D84828
2020-08-11 16:23:51 +02:00
Kadir Cetinkaya ea8e71c3da
[clang][HeaderInsert] Do not treat defines with values as header guards
This was resulting in inserting headers at bogus locations, see
https://github.com/ycm-core/YouCompleteMe/issues/3736 for an example.

Differential Revision: https://reviews.llvm.org/D85590
2020-08-11 16:02:11 +02:00
Maximilian Fickert b18c63e85a [clang-format] use spaces for alignment of binary/ternary expressions with UT_AlignWithSpaces
Use spaces to align binary and ternary expressions when using AlignOperands and UT_AlignWithSpaces.

This fixes an oversight in the new UT_AlignWithSpaces option (see D75034), which did not correctly identify the alignment of binary/ternary expressions.

Reviewed By: curdeius

Patch by: fickert

Differential Revision: https://reviews.llvm.org/D85600
2020-08-11 14:56:26 +02:00
Haojian Wu 031738a561 [AST][RecoveryExpr] Don't preserve the return type if the FunctionDecl is invalid.
If a functionDecl is invalid (e.g. return type cannot be formed), int is
use as he fallback type, which may lead to some bogus diagnostics.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D85714
2020-08-11 13:49:57 +02:00
Kai Nacke b3aece0531 [SystemZ/ZOS] Add binary format goff and operating system zos to the triple
Adds the binary format goff and the operating system zos to the triple
class. goff is selected as default binary format if zos is choosen as
operating system. No further functionality is added.

Reviewers: efriedma, tahonermann, hubert.reinterpertcast, MaskRay

Reviewed By: efriedma, tahonermann, hubert.reinterpertcast

Differential Revision: https://reviews.llvm.org/D82081
2020-08-11 05:26:26 -04:00
Balázs Kéri 497d060d0a [Analyzer] Improve invalid dereference bug reporting in DereferenceChecker.
Report undefined pointer dereference in similar way as null pointer dereference.

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D84520
2020-08-11 10:10:13 +02:00
Brad Smith 5fe171321c [Sparc] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros on SPARCv9 2020-08-11 00:04:24 -04:00
Zequan Wu 4aaa977003 [Sema] Fix missing warning on initializer lists on field initializers with overloaded operators
Differential Revision: https://reviews.llvm.org/D85574
2020-08-10 19:32:59 -07:00
Wang, Pengfei 9512525947 [X86][FPEnv] Teach X86 mask compare intrinsics to respect strict FP semantics.
When we use mask compare intrinsics under strict FP option, the masked
elements shouldn't raise any exception. So, we cann't replace the
intrinsic with a full compare + "and" operation.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D85385
2020-08-11 10:28:41 +08:00
Zequan Wu 94c6ceab53 [AST] add parenthesis locations for IfStmt and SwitchStmt
Differential Revision: https://reviews.llvm.org/D85696
2020-08-10 19:19:51 -07:00
Richard Smith 0fd3d379e2 Improve diagnostic for an expression that's not constant because it uses
the address of a constexpr local variable.

Suggest adding 'static' to give the constexpr local variable a constant
address.
2020-08-10 17:03:19 -07:00
Yaxun (Sam) Liu fb04d7b4a6 [CUDA][HIP] Do not externalize implicit constant static variable
Differential Revision: https://reviews.llvm.org/D85686
2020-08-10 19:02:49 -04:00
Dávid Bolvanský 4b59dc77dc [Diagnostics] Ignore structs and long text for -Wstring-concatenation 2020-08-11 00:49:58 +02:00
Johannes Doerfert fa5d22a045 [OpenMP][NFC] Reuse OMPIRBuilder `struct ident_t` handling in Clang
Replace the `ident_t` handling in Clang with the methods offered by the
OMPIRBuilder. This cuts down on the clang code as well as the
differences between the two, making further transitions easier. Tests
have changed but there should not be a real functional change. The most
interesting difference is probably that we stop generating local ident_t
allocations for now and just use globals. Given that this happens only
with debug info, the location part of the `ident_t` is probably bigger
than the test anyway. As the location part is already a global, we can
avoid the allocation, memcpy, and store in favor of a constant global
that is slightly bigger. This can be revisited if there are
complications.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D80735
2020-08-10 17:13:26 -05:00
Nick Desaulniers 4f2ad15db5 [Clang] implement -fno-eliminate-unused-debug-types
Fixes pr/11710.
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Resubmit after breaking Windows and OSX builds.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D80242
2020-08-10 15:08:48 -07:00
Dávid Bolvanský b2c9b631bb [Diagnostics] Move -Wstring-concatenation to -Wextra 2020-08-10 23:36:33 +02:00
Dávid Bolvanský 62223ff137 [Diagnostics] Avoid false positives with -Wstring-concatenation 2020-08-10 23:05:01 +02:00
Adam Czachorowski 4061d9e42c [clangd] Fix crash-bug in preamble indexing when using modules.
Summary:
When preamble contains #undef, indexing code finds the matching #define
and uses that during indexing. However, it would only look for local
definitions. If the macro was defined in a module, MacroInfo
would be nullptr and clangd would crash.

This change makes clangd ignore any #undef without a matching #define
inside the same TU.

The indexing of macros happens for preamble only, so then #undef must be
in the preamble, which is why we need two .h files in a test.

Note that clangd is currently not ready for module support, but this
brings us one step closer.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D80525
2020-08-10 18:42:57 +02:00
Adam Czachorowski e2d61ae573 Correctly set CompilingPCH in PrecompilePreambleAction.
This fixes a crash bug in clangd when used with modules. ASTWriter would
end up writing references to submodules into the PCH file, but upon
reading the submodules would not exists and
HeaderFileInfoTrait::ReadData would crash.

Differential Revision: https://reviews.llvm.org/D85532
2020-08-10 17:49:23 +02:00
Eduardo Caldas f9500cc487 [SyntaxTree] Expand support for `NestedNameSpecifier`
Summary:
We want NestedNameSpecifier syntax nodes to be generally supported, not
only for `DeclRefExpr` and `DependentScopedDeclRefExpr`.

To achieve this we:
* Use the `RecursiveASTVisitor`'s API to traverse
`NestedNameSpecifierLoc`s and automatically create its syntax nodes
* Add links from the `NestedNameSpecifierLoc`s to their syntax nodes.

In this way, from any semantic construct that has a `NestedNameSpecifier`,
we implicitly generate its syntax node via RAV and we can easily access
this syntax node via the links we added.
2020-08-10 15:47:20 +00:00
Krzysztof Parzyszek 7406eb4f6a [Hexagon] Avoid creating an empty target feature
If the CPU string is empty, the target feature map may end up having
an empty string inserted to it. The symptom of the problem is a warning
message:
  '+' is not a recognized feature for this target (ignoring feature)
Also, the target-features attribute in the module will have an empty
string in it.
2020-08-10 10:37:24 -05:00
Michael Liao c7b683c126 [PGO][CUDA][HIP] Skip generating profile on the device stub and wrong-side functions.
- Skip generating profile data on `__global__` function in the host
  compilation. It's a host-side stub function only and don't have
  profile instrumentation generated on the real function body. The extra
  profile data results in the malformed instrumentation profile data.
- Skip generating region mapping on functions in the wrong-side, i.e.,
  + For the device compilation, skip host-only functions; and,
  + For the host compilation, skip device-only functions (including
    `__global__` functions.)
- As the device-side profiling is not ready yet, only host-side profile
  code generation is checked.

Differential Revision: https://reviews.llvm.org/D85276
2020-08-10 11:01:46 -04:00
Shuhong Liu b129c9d81a Author: Shuhong Liu <shuhong.liu@ibm.com>
Date:   Mon Aug 10 10:31:50 2020 +0300

    [AIX][Clang][Driver] Generate reference to the C++ library on the link step

    Have the linker find libc++ on its search path by adding -lc++.

    Reviewed by: daltenty, hubert.reinterpretcast, stevewan

    Differential Revision: https://reviews.llvm.org/D85315
2020-08-10 10:27:04 -04:00
Xiangling Liao 6ef801aa6b [AIX] Static init frontend recovery and backend support
On the frontend side, this patch recovers AIX static init implementation to
use the linkage type and function names Clang chooses for sinit related function.

On the backend side, this patch sets correct linkage and function names on aliases
created for sinit/sterm functions.

Differential Revision: https://reviews.llvm.org/D84534
2020-08-10 10:10:49 -04:00
Eduardo Caldas fdbd599653 [SyntaxTree] Implement `NestedNameSpecifier` using the `List` base API 2020-08-10 13:43:21 +00:00
Łukasz Krawczyk 5f104a8099 [clang-format] Add space between method modifier and a tuple return type in C#
"public (string name, int age) methodTuple() {}" is now properly spaced

Patch by lukaszkrawczyk@google.com

Reviewed By: jbcoe, krasimir

Differential Revision: https://reviews.llvm.org/D85016
2020-08-10 14:00:33 +01:00
Eduardo Caldas a90c78ac52 [SyntaxTree] Implement the List construct.
We defined a List construct to help with the implementation of list-like
grammar rules. This is a first implementation of this API.

Differential Revision: https://reviews.llvm.org/D85295
2020-08-10 10:32:28 +00:00
Haojian Wu 626d0f5818 [Concepts] Dump template arguments for immediately declared constraint.
The template arguments were dumped as part of the TemplateTypeParmDecl, which
was incorrect.

Differential Revision: https://reviews.llvm.org/D85282
2020-08-10 09:11:55 +02:00
Nathan Ridge b1c7f84643 [clang] Allow DynTypedNode to store a TemplateArgumentLoc
The patch also adds a templateArgumentLoc() AST matcher.

Differential Revision: https://reviews.llvm.org/D85621
2020-08-10 03:09:18 -04:00
Richard Smith a4ca710d9c More cleanup after removing the ability to reference a dependent
VarTemplateSpecializationDecl.
2020-08-09 23:40:22 -07:00
Richard Smith 617007240c Improve modeling of variable template specializations with dependent
arguments.

Don't build a variable template specialization declaration until its
scope and template arguments are non-dependent.

No functionality change intended, but the AST representation is now more
consistent with how we model other templates.
2020-08-09 23:22:26 -07:00
Brad Smith 92e82a2890 int64_t and intmax_t are always (signed) long long on OpenBSD. 2020-08-09 19:43:16 -04:00
Gousemoodhin Nadaf 898880fe4e [clang] Fix typo in comment
In the handleIntToFloatConversion() function, 6th parameter is ConvertFloat, 7th parameter is ConvertInt.

Reviewed By: njames93, xbolva00

Differential Revision: https://reviews.llvm.org/D85568
2020-08-09 21:04:00 +02:00
Dávid Bolvanský 975467e4aa [Diagnostics] Handle string concat pattern and avoid false positives 2020-08-09 16:02:41 +02:00
Dávid Bolvanský 04a23f1fe0 [Diagnostics] Turn string concat warning to avoid false positives 2020-08-09 12:22:29 +02:00
Brad Smith 430db35bf2 fix typo 2020-08-08 17:58:13 -04:00
Brad Smith 4eb4ebf76a Hook up OpenBSD 64-bit PowerPC support 2020-08-08 17:51:19 -04:00
Simon Pilgrim 090f9d5a55 Fix MSVC "not all control paths return a value" warning. NFC. 2020-08-08 19:12:11 +01:00
Brad Smith cd5ab56bc4 Change the default target CPU for OpenBSD/i386 to i586 2020-08-08 13:49:45 -04:00
Dávid Bolvanský 0fef780aa7 [Clang] Avoid whitespace in fixit note 2020-08-08 19:34:07 +02:00
Dávid Bolvanský dc096a66cb [Diagnostics] Diagnose missing comma in string array initialization
Motivation (from PR37674):

const char *ss[] = {
  "foo", "bar",
  "baz", "qux"  // <-- Missing comma!
  "abc", "xyz"
  };

This kind of bug was recently also found in LLVM codebase (see PR47030).

Solves PR47038, PR37674

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D85545
2020-08-08 19:24:30 +02:00
Richard Smith fb943696cb PR47025, PR47043: Diagnose unexpanded parameter packs in concept
declarations and requires-expressions.
2020-08-07 18:19:39 -07:00
Nick Desaulniers abb9bf4bcf Revert "[Clang] implement -fno-eliminate-unused-debug-types"
This reverts commit e486921fd6.

Breaks windows builds and osx builds.
2020-08-07 16:11:41 -07:00
cchen 3adc9aeb25 [OpenMP 5.0] Fix PR-45212: Shouldn't error out while using overloaded operator for map clause
LValue map checker should handle CXXOperatorCallExpr

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D85563
2020-08-07 18:07:48 -05:00
Nick Desaulniers e486921fd6 [Clang] implement -fno-eliminate-unused-debug-types
Fixes pr/11710.
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D80242
2020-08-07 14:13:48 -07:00
Zequan Wu c354b2e3bf [Clang] Add note for bad conversion when expression is pointer to forward-declared type
Differential Revision: https://reviews.llvm.org/D85390
2020-08-07 11:06:08 -07:00
Eduardo Caldas 8abb5fb68f [SyntaxTree] Use simplified grammar rule for `NestedNameSpecifier` grammar nodes
This is our grammar rule for nested-name-specifiers:
globalbal-specifier:
  /*empty*/
simple-template-specifier:
  template_opt simple-template-id
name-specifier:
  global-specifier
  decltype-specifier
  identifier
  simple-template-specifier
nested-name-specifier:
  list(name-specifier, ::, non-empty, terminated)

It is a relaxed version of C++ [expr.prim.id] and quite simpler to map to our API.

TODO: refine name specifiers, `simple-template-name-specifier` and
decltype-name-specifier` are token soup for now.
2020-08-07 18:05:47 +00:00
Yaxun (Sam) Liu ac3e720dc1 Make clang HIP headers compatible with C++98
Automation to detect compiler features, such as CMake's target_compile_features,
would attempt to detect compiler features by explicitly using langugage flags.
This change ensures that the HIP headers would still work with C++98.

Patch by Siu Chi Chan

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

Change-Id: I304e964b18a525b0fde55efd841da74b6c4dc8ed
2020-08-07 13:50:22 -04:00
Artem Dergachev 47cadd6106 [analyzer] pr47030: MoveChecker: Unforget a comma in the suppression list. 2020-08-07 10:39:28 -07:00
Alexey Bataev 4a7aedb843 [OPENMP]Simplify representation for atomic, critical, master and section
constrcut.

Several constructs may be represented wityout relying on CapturedStmt.
It saves memory and improves compilation speed.
2020-08-07 09:58:23 -04:00
Bevin Hansson aa0d19a0c8 [Fixed Point] Add fixed-point shift operations and consteval.
Reviewers: rjmccall, leonardchan, bjope

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D83212
2020-08-07 15:09:24 +02:00
Vince Bridgers 351aac0985 [Sema] Add casting check for fixed to fixed point conversions
This change squelches the warning for a cast from fixed to fixed point
conversions when -Wbad-function-cast is enabled.

Fixes:

cast from function call of type '_Fract' to non-matching type '_Fract'
[-Wbad-function-cast]

Reviewed By: bjope

Differential Revision: https://reviews.llvm.org/D85157
2020-08-07 07:58:53 -05:00
Simon Pilgrim 18212cbcda Remove duplicate/unreachable break (PR47029) 2020-08-07 11:48:48 +01:00
Simon Pilgrim ffd258f7bb Remove unreachable return (PR47028) 2020-08-07 11:33:23 +01:00
Simon Tatham 1d78294250 [Sema][BFloat] Forbid arithmetic on vectors of bfloat.
Vectors of bfloat are a storage format only; you're supposed to
explicitly convert them to a wider type to do arithmetic on them.
But currently, if you write something like

  bfloat16x4_t test(bfloat16x4_t a, bfloat16x4_t b) { return a + b; }

then the clang frontend accepts it without error, and (ARM or AArch64)
isel fails to generate code for it.

Added a rule in Sema that forbids the attempt from even being made,
and tests that check it. In particular, we also outlaw arithmetic
between vectors of bfloat and any other vector type.

Patch by Luke Cheeseman.

Reviewed By: LukeGeeson

Differential Revision: https://reviews.llvm.org/D85009
2020-08-07 11:25:19 +01:00
Simon Pilgrim 24cca30f7f Remove unreachable return (PR47026) 2020-08-07 11:23:43 +01:00
Kazushi (Jam) Marukawa 3ac1eb6358 [VE] Remove obsoleted getVEAsmModeForCPU function
Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D85507
2020-08-07 18:20:34 +09:00
Haojian Wu 67174765db [AST][RecoveryExpr] Fix the missing type when rebuilding RecoveryExpr in TreeTransform.
Differential Revision: https://reviews.llvm.org/D85423
2020-08-07 11:15:19 +02:00
Eduardo Caldas ba41a0f733 [SyntaxTree][NFC] remove redundant namespace-specifiers
Differential Revision: https://reviews.llvm.org/D85427
2020-08-07 08:45:29 +00:00
biplmish cce1b0e891 [PowerPC] Implement Vector Extract Low/High Order Builtins in LLVM/Clang
This patch implements the function prototypes vec_extractl and vec_extracth in altivec.h to utilize the vector extract double element instructions introduced in Power10.

Differential Revision: https://reviews.llvm.org/D84622
2020-08-07 01:02:29 -05:00
Richard Smith ed5a18fc03 PR30738: Implement two-phase name lookup for fold-expressions. 2020-08-06 16:56:39 -07:00
Richard Smith d6492d8744 Add -Wtautological-value-range-compare warning.
This warning diagnoses cases where an expression is compared to a
constant, and the comparison is tautological due to the form of the
expression (but not merely due to its type). This applies in cases such
as comparisons of bit-fields and the result of bit-masks.

The new warning is added to the Clang diagnostic group
-Wtautological-constant-in-range-compare but not to the
formerly-equivalent GCC-compatibility diagnostic group -Wtype-limits,
which retains its old meaning of diagnosing only tautological
comparisons to extremal values of a type (eg, int > INT_MAX).

Reviewed By: rtrieu

Differential Revision: https://reviews.llvm.org/D85256
2020-08-06 13:28:50 -07:00
Craig Topper 4df38a5589 [X86] Optimize out a few extra strlen calls in getX86TargetCPU. NFCI
We had a conversion from const char * to StringRef and const char *
to std::string conversion. These both do their own
strlen call if the compiler doens't figure out how to share them.
By adding the temporary StringRef we can convert it to std::string
instead.

The other case is to use a StringSwitch<StringRef> instead of
StringSwitch<const char *> since the output values of the switch
are string literals. This allows the length to be computed at
compile time. Otherwise we have to convert from const char *
to std::string after the StringSwitch.
2020-08-06 13:18:15 -07:00
Craig Topper e1cad4234c [X86] Make getX86TargetCPU return std::string instead of const char *. Remove call to MakeArgString. NFCI
I believe this function used to be called directly from X86
specific code and was used to immediately create -target-cpu
command line. A later refactoring changed it to to be called from
a generic getCPU function that returns std::string. So on some
paths we created a string using MakeArgString converted that to
std::string then called MakeArgString again from that.

Instead just return std::string directly like the other targets.
2020-08-06 13:18:15 -07:00
Matt Arsenault 30eeb742f1 clang: Use byref for aggregate kernel arguments
Add address space to indirect abi info and use it for kernels.

Previously, indirect arguments assumed assumed a stack passed object
in the alloca address space using byval. A stack pointer is unsuitable
for kernel arguments, which are passed in a separate, constant buffer
with a different address space.

Start using the new byref for aggregate kernel arguments. Previously
these were emitted as raw struct arguments, and turned into loads in
the backend. These will lower identically, although with byref you now
have the option of applying an explicit alignment. In the future, a
reasonable implementation would use byref for all kernel arguments
(this would be a practical problem at the moment due to losing things
like noalias on pointer arguments).

This is mostly to avoid fighting the optimizer's treatment of
aggregate load/store. SROA and instcombine both turn aggregate loads
and stores into a long sequence of element loads and stores, rather
than the optimizable memcpy I would expect in this situation. Now an
explicit memcpy will be introduced up-front which is better understood
and helps eliminate the alloca in more situations.

This skips using byref in the case where HIP kernel pointer arguments
in structs are promoted to global pointers. At minimum an additional
patch is needed to allow coercion with indirect arguments. This also
skips using it for OpenCL due to the current workaround used to
support kernels calling kernels. Distinct function bodies would need
to be generated up front instead of emitting an illegal call.
2020-08-06 15:52:26 -04:00
Aaron En Ye Shi 96c2d5e99e [HIP] Ignore invalid ar linker options
Instead of accepting the same arguments as regular linker,
the static linker will only accept input files.

Reviewed By: yaxunl

Differential Revision: https://reviews.llvm.org/D85442
2020-08-06 17:39:41 +00:00
Alexey Bataev 0af7835eae [OPENMP]Redesign of OMPExecutableDirective/OMPDeclarativeDirective representation.
Summary:
Introduced OMPChildren class to handle all associated clauses, statement
and child expressions/statements. It allows to represent some directives
more correctly (like flush, depobj etc. with pseudo clauses, ordered
depend directives, which are standalone, and target data directives).
Also, it will make easier to avoid using of CapturedStmt in directives,
if required (atomic, tile etc. directives).
Also, it simplifies serialization/deserialization of the
executable/declarative directives.
Reduces number of allocation operations for mapper declarations.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, jfb, cfe-commits, sstefan1, aaron.ballman, caomhin

Tags: #clang

Differential Revision: https://reviews.llvm.org/D83261
2020-08-06 12:25:19 -04:00
Anatoly Trosinenko 5a07490d76 [ABI][NFC] Fix the confusion of ByVal and ByRef argument names
The second argument of getNaturalAlignIndirect() was `bool ByRef`, but
the implementation was just delegating to getIndirect() with `ByRef`
passed unchanged to `bool ByVal` parameter of getIndirect().

Fix a couple of /*ByRef=*/ comments as well.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D85113
2020-08-06 15:20:18 +03:00
Rainer Orth 710949482e [clang][Driver] Don't hardcode --as-needed/--no-as-needed on Illumos
`ninja check-all` currently fails on Illumos:

  [84/716] Generating default/Asan-i386-inline-Test
  FAILED: projects/compiler-rt/lib/asan/tests/default/Asan-i386-inline-Test
  cd /var/llvm/dist-amd64-release/projects/compiler-rt/lib/asan/tests && /var/llvm/dist-amd64-release/./bin/clang ASAN_INST_TEST_OBJECTS.gtest-all.cc.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_globals_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_interface_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_internal_interface_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_oob_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_mem_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_str_test.cpp.i386-inline.o ASAN_INST_TEST_OBJECTS.asan_test_main.cpp.i386-inline.o -o /var/llvm/dist-amd64-release/projects/compiler-rt/lib/asan/tests/default/./Asan-i386-inline-Test -g --driver-mode=g++ -fsanitize=address -m32
  ld: fatal: unrecognized option '--no-as-needed'
  ld: fatal: use the -z help option for usage information
  clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

`clang` unconditionally passes `--as-needed`/`--no-as-needed` to the
linker.  This works on Solaris 11.[34] which added a couple of option
aliases to the native linker to improve compatibility with GNU `ld`.
Illumos `ld` didn't do this, so one needs to use the corresponding
native options `-z ignore`/`-z record` instead.

Because this works on both Solaris and Illumos, the current patch always
passes the native options on Solaris.  This isn't fully correct, however:
when using GNU `ld` on Solaris (not yet supported; I'm working on that),
one still needs `--as-needed` instead.

I'm hardcoding this decision because a generic detection via a `cmake` test
is hard: many systems have their own implementation of `getDefaultLinker`
and `cmake` would have to duplicate the information encoded there.
Besides, it would still break when `-fuse-ld` is used.

Tested on `amd64-pc-solaris2.11` (Solaris 11.4 and OpenIndiana 2020.04),
`sparcv9-sun-solaris2.11`, and `x86_64-pc-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D84412
2020-08-06 10:47:16 +02:00
Craig Topper 504a197fe5 [X86] Rename X86::getImpliedFeatures to X86::updateImpliedFeatures and pass clang's StringMap directly to it.
No point in building a vector of StringRefs for clang to apply to the
StringMap. Just pass the StringMap and modify it directly.
2020-08-06 00:20:46 -07:00
Jan Korous 820e8d8656 [Analyzer][WebKit] UncountedLambdaCaptureChecker
Differential Revision: https://reviews.llvm.org/D82837
2020-08-05 15:23:55 -08:00
Richard Smith 076b120beb CFG: Destroy temporaries in (a,b) expression in the correct order. 2020-08-05 14:52:53 -07:00
Thomas Lively f496950001 [WebAssembly] Fix types in wasm_simd128.h and add tests
47f7174ffa changed the types used in the Wasm SIMD builtin functions,
but not all of their uses in wasm_simd128.h were updated. This commit
fixes wasm_simd128.h and adds tests to make sure similar problems do
not pass uncaught in the future.

Differential Revision: https://reviews.llvm.org/D85347
2020-08-05 14:00:01 -07:00
Artem Belevich 7d057efddc [CUDA] Work around a bug in rint/nearbyint caused by a broken implementation provided by CUDA.
Normally math functions are forwarded to __nv_* counterparts provided by CUDA's
libdevice bitcode. However, __nv_rint*()/__nv_nearbyint*() functions there have
a bug -- they use round() which rounds *up* instead of rounding towards the
nearest integer, so we end up with rint(2.5f) producing 3.0 instead of expected
2.0. The broken bitcode is not actually used by NVCC itself, which has both a
work-around in CUDA headers and, in recent versions, uses correct
implementations in NVCC's built-ins.

This patch implements equivalent workaround and directs rint*/nearbyint* to
__builtin_* variants that produce correct results.

Differential Revision: https://reviews.llvm.org/D85236
2020-08-05 13:13:48 -07:00
Stanislav Mekhanoshin 105608a4c2 [AMDGPU] Added missing gfx1031 cases to CGOpenMPRuntimeGPU.cpp 2020-08-05 12:39:03 -07:00
Stanislav Mekhanoshin ea7d0e2996 [AMDGPU] gfx1031 target
Differential Revision: https://reviews.llvm.org/D85337
2020-08-05 12:36:26 -07:00
Mitchell Balan 7ad60f6452 [clang-format] fix BreakBeforeBraces.MultiLine with for each macros
Summary:
The MultiLine option in BreakBeforeBraces was only handling standard
control statement, leading to invalid indentation with for each macros:

Previous behavior:

/* invalid: brace should be on the same line */
Q_FOREACH(int a; list)
{
    foo();
}

/* valid */
Q_FOREACH(int longVariable;
          list)
{
    foo();
}

To fix this, simply add the TT_ForEachMacro kind in the list of
recognized control statements for the multiline option.

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

Reviewers: MyDeveloperDay, mitchell-stellar

Reviewed by: mitchell-stellar

Contributed by: vthib

Subscribers: cfe-commits

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

Differential Revision: https://reviews.llvm.org/D85304
2020-08-05 14:31:42 -04:00
Erich Keane 2143a90b34 Fix _ExtInt(1) to be a i1 in memory.
The _ExtInt(1) in getTypeForMem was hitting the bool logic for expanding
to an 8 bit value.  The result was an assert, or store i1 %0, i8* %2, align 1
since the parameter IS an i1.  This patch changes the 'forMem' test to
exclude ext-int from the bool test.
2020-08-05 10:54:51 -07:00
Joel E. Denny 002d61db2b [OpenMP] Fix `present` for exit from `omp target data`
Without this patch, the following example fails but shouldn't
according to OpenMP TR8:

```
 #pragma omp target enter data map(alloc:i)
 #pragma omp target data map(present, alloc: i)
 {
   #pragma omp target exit data map(delete:i)
 } // fails presence check here
```

OpenMP TR8 sec. 2.22.7.1 "map Clause", p. 321, L23-26 states:

> If the map clause appears on a target, target data, target enter
> data or target exit data construct with a present map-type-modifier
> then on entry to the region if the corresponding list item does not
> appear in the device data environment an error occurs and the
> program terminates.

There is no corresponding statement about the exit from a region.
Thus, the `present` modifier should:

1. Check for presence upon entry into any region, including a `target
   exit data` region.  This behavior is already implemented correctly.

2. Should not check for presence upon exit from any region, including
   a `target` or `target data` region.  Without this patch, this
   behavior is not implemented correctly, breaking the above example.

In the case of `target data`, this patch fixes the latter behavior by
removing the `present` modifier from the map types Clang generates for
the runtime call at the end of the region.

In the case of `target`, we have not found a valid OpenMP program for
which such a fix would matter.  It appears that, if a program can
guarantee that data is present at the beginning of a `target` region
so that there's no error there, that data is also guaranteed to be
present at the end.  This patch adds a comment to the runtime to
document this case.

Reviewed By: grokos, RaviNarayanaswamy, ABataev

Differential Revision: https://reviews.llvm.org/D84422
2020-08-05 10:03:31 -04:00
Bruno Ricci f7a039de7a
[clang][NFC] DeclPrinter: use NamedDecl::getDeclName instead of NamedDecl::printName to print the name of enumerations, namespaces and template parameters.
NamedDecl::printName will print the pretty-printed name of the entity, which
is not what we want here (we should print "enum { e };" instead of "enum
(unnamed enum at input.cc:1:5) { e };").

For now only DecompositionDecl and MDGuidDecl have an overloaded printName so
this does not result in any functional change, but this change is needed since
I will be adding overloads to better handle unnamed entities in diagnostics.
2020-08-05 13:54:38 +01:00
Bruno Ricci 94b43118e2
[clang][NFCI] Get rid of ConstantMatrixTypeBitfields to avoid increasing the size of every type.
sizeof(ConstantMatrixTypeBitfields) > 8 which increases the size of every type.
This was not detected because no corresponding static_assert for its size was
added.

To prevent this from occuring again replace the various static_asserts for
the size of each of the bit-field classes by a single static_assert for the
size of Type.

I have left ConstantMatrixType::MaxElementsPerDimension unchanged since
the limit is exercised by multiple tests.
2020-08-05 13:54:37 +01:00
Bruno Ricci 19701458d4
[clang][nearly-NFC] Remove some superfluous uses of NamedDecl::getNameAsString
`OS << ND->getDeclName();` is equivalent to `OS << ND->getNameAsString();`
without the extra temporary string.

This is not quite a NFC since two uses of `getNameAsString` in a
diagnostic are replaced, which results in the named entity being
quoted with additional "'"s (ie: 'var' instead of var).
2020-08-05 13:54:37 +01:00
Bruno Ricci 00b89f66f9
[clang][NFC] Remove spurious +x flag on DeclTemplate.cpp and DeclTemplate.h 2020-08-05 13:54:30 +01:00