Commit Graph

16110 Commits

Author SHA1 Message Date
John McCall 36b12a861c Rename TypeNodes.def to TypeNodes.inc for consistency across all
our autogenerated files.  NFC.

As requested by Nico Weber.

llvm-svn: 373425
2019-10-02 06:35:23 +00:00
Richard Trieu e388725316 Revert r368237 - Update fix-it hints for std::move warnings.
r368237 attempted to improve fix-its for move warnings, but introduced some
regressions to -Wpessimizing-move.  Revert that change and add the missing
test cases to the pessimizing move test to prevent future regressions.

llvm-svn: 373421
2019-10-02 02:32:15 +00:00
Alexey Bataev 658ad4d4d2 [OPENMP]Fix PR43516: Compiler crash with collapse(2) on non-rectangular
loop.

Missed check if the condition is also dependent when building final
expressions for the collapsed loop directives.

llvm-svn: 373348
2019-10-01 16:19:10 +00:00
Kadir Cetinkaya fd019ed54e [clang] Make handling of unnamed template params similar to function params
Summary:
Clang uses the location identifier should be inserted for declarator
decls when a decl is unnamed. But for type template and template template
paramaters it uses the location of "typename/class" keyword, which makes it hard
for tooling to insert/change parameter names.

This change tries to unify these two cases by making template parameter
parsing and sourcerange operations similar to function params/declarator decls.

Reviewers: ilya-biryukov

Subscribers: arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 373340
2019-10-01 14:08:51 +00:00
David Bolvansky 471910d754 [Diagnostics] Warn if enumeration type mismatch in conditional expression
Summary:
- Useful warning
- GCC compatibility (GCC warns in C++ mode)

Reviewers: rsmith, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 373252
2019-09-30 19:55:50 +00:00
Alexey Bataev 218bea9703 [OPENMP50]Do not emit warning for the function with the currently
defined body.

If the function is currently defined, we should not emit a warning that
it might be emitted already because it was not really emitted.

llvm-svn: 373243
2019-09-30 18:24:35 +00:00
Alexey Bataev d1caf93957 [OPENMP] Fix comment, NFC.
llvm-svn: 373210
2019-09-30 14:05:26 +00:00
Richard Smith 00966d1791 Don't crash if a variable with a constexpr destructor has a
value-dependent initializer.

llvm-svn: 373173
2019-09-29 20:30:13 +00:00
Richard Smith 2b4fa5348e For P0784R7: compute whether a variable has constant destruction if it
has a constexpr destructor.

For constexpr variables, reject if the variable does not have constant
destruction. In all cases, do not emit runtime calls to the destructor
for variables with constant destruction.

llvm-svn: 373159
2019-09-29 05:08:46 +00:00
Simon Pilgrim 6891c72d0f SemaExpr - silence static analyzer getAs<> null dereference warnings. NFCI.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us.

llvm-svn: 373150
2019-09-28 14:01:52 +00:00
Martin Storsjo 71decf841c [clang] [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode
This matches how GCC handles it, see e.g. https://gcc.godbolt.org/z/HPplnl.
GCC documents the gnu_inline attribute with "In C++, this attribute does
not depend on extern in any way, but it still requires the inline keyword
to enable its special behavior."

The previous behaviour of gnu_inline in C++, without the extern
keyword, can be traced back to the original commit that added
support for gnu_inline, SVN r69045.

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

llvm-svn: 373078
2019-09-27 12:25:19 +00:00
Richard Smith da1b4347e4 For P0784R7: Add support for dynamic allocation with new / delete during
constant evaluation.

llvm-svn: 373036
2019-09-27 01:26:47 +00:00
Michael Kruse 945249b5a9 [OpenMP 5.0] Fix user-defined mapper lookup in sema
This patches fixes the case when a user-defined mapper is attached to
the elements of an array, and to report error when a mapper is used for
types other than struct, class, and union.

Patch by Lingda Li <lildmh@gmail.com>

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

llvm-svn: 373023
2019-09-26 22:53:01 +00:00
Richard Smith bf322b7cdd Always rebuild a DeclRefExpr if its FoundDecl would change.
Fixes a regression introduced by r369999.

llvm-svn: 373022
2019-09-26 22:28:32 +00:00
Alexey Bataev 1202614d16 [OPENMP50]Emit warnings if the functions was defined/used before marked
declare variant.

We can use the original function if it was used/emitted already. So,
just use warnings for these cases, not errors.

llvm-svn: 373010
2019-09-26 20:04:15 +00:00
Alexey Bataev 9ff34745a2 [OPENMP50]Parsing/sema support for 'implementation/vendor' context
selector.

Added basic parsing/semantic support for
'implementation={vendor(<vendor>)}' context selector.

llvm-svn: 372917
2019-09-25 19:43:37 +00:00
Vedant Kumar f6bc251274 [Mangle] Add flag to asm labels to disable '\01' prefixing
LLDB synthesizes decls using asm labels. These decls cannot have a mangle
different than the one specified in the label name. I.e., the '\01' prefix
should not be added.

Fixes an expression evaluation failure in lldb's TestVirtual.py on iOS.

rdar://45827323

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

llvm-svn: 372903
2019-09-25 18:00:31 +00:00
Michael Liao 24337db616 [CUDA][HIP] Enable kernel function return type deduction.
Summary:
- Even though only `void` is still accepted as the deduced return type,
  enabling deduction/instantiation on the return type allows more
  consistent coding.

Reviewers: tra, jlebar

Subscribers: cfe-commits, yaxunl

Tags: #clang

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

llvm-svn: 372898
2019-09-25 16:51:45 +00:00
Sven van Haastregt 2a69ed0bc8 [OpenCL] Add image query builtin functions
Add the image query builtin functions from the OpenCL C specification.

Patch by Pierre Gondois and Sven van Haastregt.

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

llvm-svn: 372833
2019-09-25 09:12:59 +00:00
David Bolvansky e52ed1e80c [NFC] Strenghten preconditions for warning
llvm-svn: 372775
2019-09-24 20:10:57 +00:00
Yaxun Liu 1282889347 [HIP] Support new kernel launching API
Differential Revision: https://reviews.llvm.org/D67947

llvm-svn: 372773
2019-09-24 19:16:40 +00:00
David Bolvansky 275e4df115 [Diagnostics] Handle tautological left shifts in boolean context
llvm-svn: 372749
2019-09-24 13:14:18 +00:00
David Bolvansky 849fd28cf0 [Diagnostics] Do not diagnose unsigned shifts in boolean context (-Wint-in-bool-context)
I was looking at old GCC's patch. Current "trunk" version avoids warning for unsigned case, GCC warns only for signed shifts.

llvm-svn: 372708
2019-09-24 09:14:33 +00:00
Adrian Prantl 350de4f05d Support for DWARF-5 C++ language tags.
This patch provides support for DW_LANG_C_plus_plus_11,
DW_LANG_C_plus_plus_14 tags in the Clang C++ frontend.

Patch by Sourabh Singh Tomar!
Differential Revision: https://reviews.llvm.org/D67613

Reapplies r372663 after adapting a failing test in the LLDB testsuite.

llvm-svn: 372681
2019-09-24 00:38:49 +00:00
Jonas Devlieghere 5c49c26714 Revert "Support for DWARF-5 C++ language tags."
This reverts commit bf9c8ffb54.

llvm-svn: 372672
2019-09-23 23:49:36 +00:00
David Bolvansky 28b38c277a [Diagnostics] Warn for enum constants in bool context (-Wint-in-bool-context; GCC compatibility)
Extracted from D63082.

llvm-svn: 372664
2019-09-23 22:09:49 +00:00
Adrian Prantl bf9c8ffb54 Support for DWARF-5 C++ language tags.
This patch provides support for DW_LANG_C_plus_plus_11,
DW_LANG_C_plus_plus_14 tags in the Clang C++ frontend.

Patch by Sourabh Singh Tomar!
Differential Revision: https://reviews.llvm.org/D67613

llvm-svn: 372663
2019-09-23 22:01:49 +00:00
Michael Liao 566b3164c5 [Sema] Fix the atomic expr rebuilding order.
Summary:
- Rearrange the atomic expr order to the API order when rebuilding
  atomic expr during template instantiation.

Reviewers: erichkeane

Subscribers: jfb, cfe-commits

Tags: #clang

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

llvm-svn: 372640
2019-09-23 18:48:06 +00:00
Alexey Bataev dba792c522 [OPENMP]Use standard parsing for 'match' clause, NFC.
Reused standard clauses parsing scheme for parsing/matching 'match'
clause in 'declare variant' directive.

llvm-svn: 372635
2019-09-23 18:13:31 +00:00
Zoe Carver 511dbd83d6 Fix __is_signed builtin
Summary: This patch fixes the __is_signed builtin type trait to work with floating point types and enums. Now, the builtin will return true if it is passed a floating point type and false for an enum type.

    Reviewers: EricWF, rsmith, erichkeane, craig.topper, efriedma

    Subscribers: cfe-commits

    Tags: #clang

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

llvm-svn: 372621
2019-09-23 15:41:20 +00:00
David Bolvansky 84ea41fd17 [Diagnostics] Warn if '<<' in bool context with -Wint-in-bool-context (GCC compatibility)
Extracted from D63082, addressed review comments related to a warning message.

llvm-svn: 372612
2019-09-23 14:21:08 +00:00
David Bolvansky 116e6cf36e [Diagnostics] Avoid -Wsizeof-array-div when dividing the size of a nested array by the size of the deepest base type
llvm-svn: 372600
2019-09-23 12:54:35 +00:00
Richard Smith 457226e02a For P0784R7: add support for constexpr destructors, and call them as
appropriate during constant evaluation.

Note that the evaluator is sometimes invoked on incomplete expressions.
In such cases, if an object is constructed but we never reach the point
where it would be destroyed (and it has non-trivial destruction), we
treat the expression as having an unmodeled side-effect.

llvm-svn: 372538
2019-09-23 03:48:44 +00:00
David Bolvansky fb218170b4 [Diagnostics] Warn if ?: with integer constants always evaluates to true
Extracted from D63082. GCC has this warning under -Wint-in-bool-context, but as noted in the D63082's review, we should put it under TautologicalConstantCompare.

llvm-svn: 372531
2019-09-22 22:00:48 +00:00
Yonghong Song 91d5c2a035 [CLANG][BPF] permit any argument type for __builtin_preserve_access_index()
Commit c15aa241f8 ("[CLANG][BPF] change __builtin_preserve_access_index()
signature") changed the builtin function signature to
  PointerT __builtin_preserve_access_index(PointerT ptr)
with a pointer type as the argument/return type, where argument and
return types must be the same.

There is really no reason for this constraint. The builtin just
presented a code region so that IR builtins
  __builtin_{array, struct, union}_preserve_access_index
can be applied.

This patch removed the pointer type restriction to permit any
argument type as long as it is permitted by the compiler.

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

llvm-svn: 372516
2019-09-22 17:33:48 +00:00
James Y Knight c2ca003baf NFC: Change ObjCQualified*TypesAreCompatible to take
ObjCObjectPointerType arguments.

All callers already had one, just creating a QualType to pass, after
which the function cast it right back.

llvm-svn: 372492
2019-09-21 22:31:28 +00:00
Richard Trieu 4c05de8c1d Merge and improve code that detects same value in comparisons.
-Wtautological-overlap-compare and self-comparison from -Wtautological-compare
relay on detecting the same operand in different locations.  Previously, each
warning had it's own operand checker.  Now, both are merged together into
one function that each can call.  The function also now looks through member
access and array accesses.

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

llvm-svn: 372453
2019-09-21 03:02:26 +00:00
Yaxun Liu 27a8039171 Revert assertion added by r372394
The assertion added by r372394 causes CUDA test in test-suite to assert.

The assertion was not there originally, so revert it.

llvm-svn: 372452
2019-09-21 02:51:44 +00:00
Erich Keane 830909b97a Ensure AtomicExpr goes through SEMA checking after TreeTransform
RebuildAtomicExpr was skipping doing semantic analysis which broke in
the cases where the expressions were not dependent. This resulted in the
ImplicitCastExpr from an array to a pointer being lost, causing a crash
in IR CodeGen.

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

llvm-svn: 372422
2019-09-20 19:17:31 +00:00
Yaxun Liu e5d17c511f [CUDA][HIP] Fix hostness of defaulted constructor
Clang does not respect the explicit device host attributes of defaulted special members.
Also clang does not respect the hostness of special members determined by their
first declarations.
Clang also adds duplicate implicit device or host attributes in certain cases.
This patch fixes that.
Differential Revision: https://reviews.llvm.org/D67509

llvm-svn: 372394
2019-09-20 14:28:09 +00:00
Richard Smith 4aef105b43 Finish building the full-expression for a static_assert expression
before evaluating it rather than afterwards.

This is groundwork for C++20's P0784R7, where non-trivial destructors
can be constexpr, so we need ExprWithCleanups markers in constant
expressions.

No significant functionality change intended (though this fixes a bug
only visible through libclang / -ast-dump / tooling: we now store the
converted condition on the StaticAssertDecl rather than the original).

llvm-svn: 372368
2019-09-20 03:29:19 +00:00
Richard Smith 40c3d6e335 Model converted constant expressions as full-expressions.
This is groundwork for C++20's P0784R7, where non-trivial destructors
can be constexpr, so we need ExprWithCleanups markers in constant
expressions.

No functionality change intended.

llvm-svn: 372359
2019-09-19 22:00:16 +00:00
Michael Liao b8fc6a9116 [CUDA][HIP] Re-apply part of r372318.
- r372318 causes violation of `use-of-uninitialized-value` detected by
  MemorySanitizer. Once `Viable` field is set to false, `FailureKind`
  needs setting as well as it will be checked during destruction if
  `Viable` is not true.
- Revert the part trying to skip `std::vector` erasing.

llvm-svn: 372356
2019-09-19 21:26:18 +00:00
Mitch Phillips 08f938bd1a Revert "[CUDA][HIP] Fix typo in `BestViableFunction`"
Broke the msan buildbots (see comments on rL372318 for more details).

This reverts commit eb231d1582.

llvm-svn: 372353
2019-09-19 21:11:28 +00:00
Sven van Haastregt ed69faa01b [OpenCL] Add version handling and add vector ld/st builtins
Allow setting a MinVersion, stating from which OpenCL version a
builtin function is available, and a MaxVersion, stating from which
OpenCL version a builtin function should not be available anymore.

Guard some definitions of the "work-item" builtin functions according
to the OpenCL versions from which they are available.

Add the "vector data load and store" builtin functions (e.g.
vload/vstore), whose signatures differ before and after OpenCL 2.0 in
the pointer argument address spaces.

Patch by Pierre Gondois and Sven van Haastregt.

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

llvm-svn: 372321
2019-09-19 13:41:51 +00:00
Michael Liao eb231d1582 [CUDA][HIP] Fix typo in `BestViableFunction`
Summary:
- Should consider viable ones only when checking SameSide candidates.
- Replace erasing with clearing viable flag to reduce data
  moving/copying.
- Add one and revise another one as the diagnostic message are more
  relevant compared to previous one.

Reviewers: tra

Subscribers: cfe-commits, yaxunl

Tags: #clang

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

llvm-svn: 372318
2019-09-19 13:14:03 +00:00
Yonghong Song c15aa241f8 [CLANG][BPF] change __builtin_preserve_access_index() signature
The clang intrinsic __builtin_preserve_access_index() currently
has signature:
  const void * __builtin_preserve_access_index(const void * ptr)

This may cause compiler warning when:
  - parameter type is "volatile void *" or "const volatile void *", or
  - the assign-to type of the intrinsic does not have "const" qualifier.
Further, this signature does not allow dereference of the
builtin result pointer as it is a "const void *" type, which
adds extra step for the user to do type casting.

Let us change the signature to:
  PointerT __builtin_preserve_access_index(PointerT ptr)
such that the result and argument types are the same.
With this, directly dereferencing the builtin return value
becomes possible.

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

llvm-svn: 372294
2019-09-19 02:59:43 +00:00
Erik Pilkington 5741d19f04 [Sema] Suppress -Wformat diagnostics for bool types when printed using %hhd
Also, add a diagnostic under -Wformat for printing a boolean value as a
character.

rdar://54579473

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

llvm-svn: 372247
2019-09-18 19:05:14 +00:00
Richard Smith c667cdc850 [c++20] P1331R2: Allow transient use of uninitialized objects in
constant evaluation.

llvm-svn: 372237
2019-09-18 17:37:44 +00:00
Alexey Bataev 0736f7f5d7 [OPENMP5.0]Allow multiple context selectors in the context selector
sets.

According to OpenMP 5.0, context selector set might include several
context selectors, separated with commas. Patch fixes this problem.

llvm-svn: 372235
2019-09-18 16:24:31 +00:00