]> granicus.if.org Git - clang/log
clang
5 years ago[clang] adding explicit(bool) from c++2a
Nicolas Lesser [Sat, 4 May 2019 00:09:00 +0000 (00:09 +0000)]
[clang] adding explicit(bool) from c++2a

this patch adds support for the explicit bool specifier.

Changes:
- The parsing for the explicit(bool) specifier was added in ParseDecl.cpp.
- The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class.
- Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted.
- Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration.
- The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected.
- Test for Semantic and Serialization were added.

This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback.
Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky.

Patch by Tyker

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

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

5 years agoCWG issue 727: Fix numerous bugs in support for class-scope explicit
Richard Smith [Fri, 3 May 2019 23:51:38 +0000 (23:51 +0000)]
CWG issue 727: Fix numerous bugs in support for class-scope explicit
specializations for variable templates.

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

5 years ago[clang-format] Fix bug in block comment reflow that joins * and /
Owen Pan [Fri, 3 May 2019 23:15:40 +0000 (23:15 +0000)]
[clang-format] Fix bug in block comment reflow that joins * and /

Fixes PR41213

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

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

5 years ago[COFF, ARM64] Fix ABI implementation of struct returns
Mandeep Singh Grang [Fri, 3 May 2019 21:12:24 +0000 (21:12 +0000)]
[COFF, ARM64] Fix ABI implementation of struct returns

Summary:
Related llvm patch: D60348.
Patch co-authored by Sanjin Sijaric.

Reviewers: rnk, efriedma, TomTan, ssijaric, ostannard

Reviewed By: efriedma

Subscribers: dmajor, richard.townsend.arm, ostannard, javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

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

5 years agoEnsure there is stack usage in stack size warning test
Matt Arsenault [Fri, 3 May 2019 19:04:14 +0000 (19:04 +0000)]
Ensure there is stack usage in stack size warning test

r359906 broke this because the only stack usage was from a spill which
can be avoided since the only block is a return.

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

5 years agoAttempt to fix the clang-sphinx-docs bot after r358797
Nico Weber [Fri, 3 May 2019 18:54:18 +0000 (18:54 +0000)]
Attempt to fix the clang-sphinx-docs bot after r358797

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

5 years agoRemove else-after-return
David Blaikie [Fri, 3 May 2019 18:11:31 +0000 (18:11 +0000)]
Remove else-after-return

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

5 years ago[CUDA][Clang][Bugfix] Add missing CUDA 9.2 case
Gheorghe-Teodor Bercea [Fri, 3 May 2019 17:59:18 +0000 (17:59 +0000)]
[CUDA][Clang][Bugfix] Add missing CUDA 9.2 case

Summary:
The bug was reported on the OpenMP-dev list:

.../obj-release/lib/clang/9.0.0/include/__clang_cuda_intrinsics.h:173:35: error: '__nvvm_shfl_sync_idx_i32' needs target feature ptx60|ptx61|ptx63|ptx64
__MAKE_SYNC_SHUFFLES(__shfl_sync, __nvvm_shfl_sync_idx_i32,

This problem occurs when trying to compile a .cu file that requires a newer ptx version (>ptx60 in this case) than ptx42.

Reviewers: tra, ABataev, caomhin

Reviewed By: tra

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

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

5 years ago[CommandLine] Change help output to prefix long options with `--` instead of `-`...
Don Hinton [Fri, 3 May 2019 17:47:29 +0000 (17:47 +0000)]
[CommandLine] Change help output to prefix long options with `--` instead of `-`. NFC . Part 3 of 5

Summary:
By default, `parseCommandLineOptions()` will accept either a
`-` or `--` prefix for long options -- options with names longer than
a single character.

While this change does not affect behavior, it will be helpful with a
subsequent change that requires long options use the `--` prefix.

Reviewers: rnk, thopre

Reviewed By: thopre

Subscribers: thopre, cfe-commits, hiraditya, llvm-commits

Tags: #llvm, #clang

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

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

5 years agoAdded an AST matcher for declarations that are in the `std` namespace
Dmitri Gribenko [Fri, 3 May 2019 12:50:00 +0000 (12:50 +0000)]
Added an AST matcher for declarations that are in the `std` namespace

Reviewers: alexfh

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[Sema][ObjC] Disable -Wunused-parameter for ObjC methods
Akira Hatanaka [Fri, 3 May 2019 07:19:46 +0000 (07:19 +0000)]
[Sema][ObjC] Disable -Wunused-parameter for ObjC methods

The warning isn't very useful when the function is an ObjC method.

rdar://problem/41561853

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

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

5 years agoRevert "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"
Leonard Chan [Fri, 3 May 2019 03:28:06 +0000 (03:28 +0000)]
Revert "[Attribute/Diagnostics] Print macro if definition is an attribute declaration"

This reverts commit fc40cbd9d8c63e65eed3590ba925321afe782e1d.

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

5 years agoRevert r359814 "[Sema] Emit warning for visibility attribute on internal-linkage...
Nico Weber [Fri, 3 May 2019 03:16:07 +0000 (03:16 +0000)]
Revert r359814 "[Sema] Emit warning for visibility attribute on internal-linkage declaration"

See cfe-commits thread for r359814.

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

5 years agoSemaOverload: Complete candidates before emitting the error, to ensure diagnostics...
David Blaikie [Fri, 3 May 2019 00:44:50 +0000 (00:44 +0000)]
SemaOverload: Complete candidates before emitting the error, to ensure diagnostics emitted (or suppressed) during completion don't interfere with the overload notes

Because diagnostics and their notes are not connected at the API level,
if the error message for an overload is emitted, then the overload
candidates are completed - if a diagnostic is emitted during that work,
the notes related to overload candidates would be attached to the latter
diagnostic, not the original error. Sort of worse, if the latter
diagnostic was disabled, the notes are disabled.

Reviewers: rsmith

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

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

5 years agoFix -Wunsequenced false-positives in code controlled by a branch on
Richard Smith [Thu, 2 May 2019 23:21:28 +0000 (23:21 +0000)]
Fix -Wunsequenced false-positives in code controlled by a branch on
__builtin_constant_p.

If the operand of __builtin_constant_p is not constant and has
side-effects, then code controlled by a branch on it is unreachable and
we should not emit runtime behavior warnings in such code.

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

5 years ago[CUDA] Do not pass deprecated option fo fatbinary
Artem Belevich [Thu, 2 May 2019 22:37:19 +0000 (22:37 +0000)]
[CUDA] Do not pass deprecated option fo fatbinary

CUDA 10.1 tools deprecated some command line options.
fatbinary no longer needs --cuda.

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

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

5 years ago[Attribute/Diagnostics] Print macro if definition is an attribute declaration
Leonard Chan [Thu, 2 May 2019 20:38:14 +0000 (20:38 +0000)]
[Attribute/Diagnostics] Print macro if definition is an attribute declaration

If an address_space attribute is defined in a macro, print the macro instead
when diagnosing a warning or error for incompatible pointers with different
address_spaces.

We allow this for all attributes (not just address_space), and for multiple
attributes declared in the same macro.

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

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

5 years agoChange the metadata for heapallocsite calls when the type is cast.
Amy Huang [Thu, 2 May 2019 20:07:35 +0000 (20:07 +0000)]
Change the metadata for heapallocsite calls when the type is cast.

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

5 years agoAnother attempt to fix "could not find clang-check" lit warning in analyzer-less...
Nico Weber [Thu, 2 May 2019 19:47:05 +0000 (19:47 +0000)]
Another attempt to fix "could not find clang-check" lit warning in analyzer-less builds

r359717 added clang-check as a dep of check-clang unconditionally
because I had missed lit.local.cfg in test/Tooling.

Instead, only add clang-check to the tools if the analyzer is enabled,
since the build target only exists then, and since all tests using
clang-check are skipped when the analyzer is disabled.

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

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

5 years ago[Sema] Emit warning for visibility attribute on internal-linkage declaration
Scott Linder [Thu, 2 May 2019 19:03:57 +0000 (19:03 +0000)]
[Sema] Emit warning for visibility attribute on internal-linkage declaration

GCC warns on these cases, but we currently just silently ignore the attribute.

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

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

5 years agoUse primary template parameter names for variable template debug info
Reid Kleckner [Thu, 2 May 2019 17:45:54 +0000 (17:45 +0000)]
Use primary template parameter names for variable template debug info

Summary:
Fixes PR41677

Consider:
  template <typename LHS, typename RHS> constexpr bool is_same_v = false;
  template <typename T> constexpr bool is_same_v<T, T> = true;
  template constexpr bool is_same_v<int, int>;

Before this change, when emitting debug info for the
`is_same_v<int, int>` global variable, clang would crash because it
would try to use the template parameter list from the partial
specialization to give parameter names to template arguments. This
doesn't work in general, since a partial specialization can have fewer
arguments than the primary template. Therefore, always use the primary
template. Hypothetically we could try to use the parameter names from
the partial specialization when possible, but it's not clear this really
helps debugging in practice.

Reviewers: JDevlieghere, aprantl, ormris, dblaikie

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoDo not warn on switches over enums that do not use [[maybe_unused]] enumerators
David Blaikie [Thu, 2 May 2019 16:30:49 +0000 (16:30 +0000)]
Do not warn on switches over enums that do not use [[maybe_unused]] enumerators

PR36231, [dcl.attr.unused]p3

Reviewers: aaron.ballman

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

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

5 years ago[OpenCL] Fix initialisation of this via pointer.
Anastasia Stulova [Thu, 2 May 2019 16:10:50 +0000 (16:10 +0000)]
[OpenCL] Fix initialisation of this via pointer.

When the expression used to initialise 'this' has a pointer type,
check the address space of the pointee type instead of the pointer
type to decide whether an address space cast is required.
It is the pointee type that carries the address space qualifier.

Fixing PR41674.

Patch by kpet (Kevin Petit)!

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

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

5 years ago[OpenCL] Deduce static data members to __global addr space.
Anastasia Stulova [Thu, 2 May 2019 14:40:40 +0000 (14:40 +0000)]
[OpenCL] Deduce static data members to __global addr space.

Similarly to static variables in OpenCL, static class data
members should be deduced to __global addr space.

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

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

5 years agoFix typo in test case.
Akira Hatanaka [Thu, 2 May 2019 07:38:07 +0000 (07:38 +0000)]
Fix typo in test case.

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

5 years agoAdapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO
Stephan Bergmann [Thu, 2 May 2019 06:40:33 +0000 (06:40 +0000)]
Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO

This follows up after b7692bc3e9ad2691fc07261904b88fb15f30696b "[UBSan] Fix
isDerivedFromAtOffset on iOS ARM64" fixed the RTTI comparison in
isDerivedFromAtOffset on just one platform and then
a25a2c7c9a7e1e328a5bd8274d2d86b1fadc4692 "Always compare C++ typeinfo (based on
libstdc++ implementation)" extended that fix to more platforms.

But there is another RTTI comparison for -fsanitize=function generated in
clang's CodeGenFunction::EmitCall as just a pointer comparison.  For
SANITIZER_NON_UNIQUE_TYPEINFO platforms this needs to be extended to also do
string comparison.  For that, __ubsan_handle_function_type_mismatch[_abort]
takes the two std::type_info pointers as additional parameters now, checks them
internally for potential equivalence, and returns without reporting failure if
they turn out to be equivalent after all.  (NORETURN needed to be dropped from
the _abort variant for that.)  Also these functions depend on ABI-specific RTTI
now, so needed to be moved from plain UBSAN_SOURCES (ubsan_handlers.h/cc) to
UBSAN_CXXABI_SOURCES (ubsan_handlers_cxx.h/cc), but as -fsanitize=function is
only supported in C++ mode that's not a problem.

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

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

5 years agoReplace ad-hoc tracking of pattern for an instantiated class-scope
Richard Smith [Thu, 2 May 2019 00:49:14 +0000 (00:49 +0000)]
Replace ad-hoc tracking of pattern for an instantiated class-scope
explicit function specialization with the MemberSpecializationInfo used
everywhere else.

Not NFC: the ad-hoc pattern tracking was not being serialized /
deserialized properly. That's fixed here.

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

5 years agoDiagnose non-dependent qualified friend function template declarations
Richard Smith [Thu, 2 May 2019 00:49:05 +0000 (00:49 +0000)]
Diagnose non-dependent qualified friend function template declarations
that don't match any existing declaration. Don't get confused and treat
such declarations as template *specializations*.

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

5 years ago[COFF, ARM64] Align global symbol by size for ARM64 MSVC ABI
Tom Tan [Thu, 2 May 2019 00:38:14 +0000 (00:38 +0000)]
[COFF, ARM64] Align global symbol by size for ARM64 MSVC ABI

According to alignment section in below ARM64 ABI document, MSVC could increase
alignment of global data based on its total size. Clang doesn't do this. Compile
the same symbol into different alignments by Clang and MSVC could cause link
error because some instruction encodings, like 64-bit LDR/STR with immediate,
require the target to be 8 bytes aligned, and linker could choose code stream
with such LDR/STR instruction from MSVC and 4 bytes aligned data from Clang into
final image, which actually cannot be linked together
(see https://bugs.llvm.org/show_bug.cgi?id=41506 for more details).

https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=vs-2019#alignment

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

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

5 years agoConsume unexpected "template" keywords after "using"
Richard Trieu [Wed, 1 May 2019 23:33:49 +0000 (23:33 +0000)]
Consume unexpected "template" keywords after "using"

The parser was dealing with unexpected "template" keywords after "using"
keywords too late and putting the parser into the wrong state, which could
lead to a crash down the line.  This change allows the parser to consume the
bad "template" keywords earlier, and continue parsing as if "template" was
never there to begin with for better error recovery.

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

5 years agoRevert r359717, "Make check-clang depend on the clang-check binary always"
Nico Weber [Wed, 1 May 2019 23:32:38 +0000 (23:32 +0000)]
Revert r359717, "Make check-clang depend on the clang-check binary always"

The Tooling tests do have a lit.local.cfg with

    if not config.root.clang_staticanalyzer:
        config.unsupported = True

so what's wrong isn't the missing dep, but that lit prints a warning for
the binary missing. This will need a different kind of fix.

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

5 years ago[analyzer] Fix buildbot failures caused by a forgotten initialization
Kristof Umann [Wed, 1 May 2019 21:09:32 +0000 (21:09 +0000)]
[analyzer] Fix buildbot failures caused by a forgotten initialization

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

5 years agoMake clang/utils/creduce-clang-crash.py executable
Reid Kleckner [Wed, 1 May 2019 20:15:39 +0000 (20:15 +0000)]
Make clang/utils/creduce-clang-crash.py executable

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

5 years ago[analyzer] Don't display implementation checkers under -analyzer-checker-help, but...
Kristof Umann [Wed, 1 May 2019 19:56:47 +0000 (19:56 +0000)]
[analyzer] Don't display implementation checkers under -analyzer-checker-help, but do under the new flag -analyzer-checker-help-hidden

During my work on analyzer dependencies, I created a great amount of new
checkers that emitted no diagnostics at all, and were purely modeling some
function or another.

However, the user shouldn't really disable/enable these by hand, hence this
patch, which hides these by default. I intentionally chose not to hide alpha
checkers, because they have a scary enough name, in my opinion, to cause no
surprise when they emit false positives or cause crashes.

The patch introduces the Hidden bit into the TableGen files (you may remember
it before I removed it in D53995), and checkers that are either marked as
hidden, or are in a package that is marked hidden won't be displayed under
-analyzer-checker-help. -analyzer-checker-help-hidden, a new flag meant for
developers only, displays the full list.

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

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

5 years agoMake check-clang depend on the clang-check binary always
Nico Weber [Wed, 1 May 2019 19:34:00 +0000 (19:34 +0000)]
Make check-clang depend on the clang-check binary always

check-clang (the target that runs all clang tests) used to
only depend on clang-check (a binary like clang-tidy,
clang-refactor, etc) if the static analyzer is enabled.
However, several lit tests call clang-check unconditionally,
so always depend on it.

Fixes a "could not find clang-check" lit warning in clean builds with
the static analyzer disabled.

Also sort the deps in the CMake file and put just one dep on each line.

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

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

5 years ago[Parser] Avoid correcting delayed typos in array subscript multiple times.
Volodymyr Sapsai [Wed, 1 May 2019 19:24:50 +0000 (19:24 +0000)]
[Parser] Avoid correcting delayed typos in array subscript multiple times.

We correct some typos in `ActOnArraySubscriptExpr` and
`ActOnOMPArraySectionExpr`, so when their result is `ExprError`, we can
end up correcting delayed typos in the same expressions again. In
general it is OK but when `NumTypos` is incorrect, we can hit the
assertion

> Assertion failed: (Entry != DelayedTypos.end() && "Failed to get the state for a TypoExpr!"), function getTypoExprState, file clang/lib/Sema/SemaLookup.cpp, line 5219.

Fix by replacing some subscript `ExprResult` with typo-corrected expressions
instead of keeping the original expressions. Thus if original expressions
contained `TypoExpr`, we'll use corrected expressions instead of trying to
correct them again.

rdar://problem/47403222

Reviewers: rsmith, erik.pilkington, majnemer

Reviewed By: erik.pilkington

Subscribers: jkorous, dexonsmith, cfe-commits

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

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

5 years ago[clang-format] Fix a bug in AlignConsecutiveDeclarations.
Owen Pan [Wed, 1 May 2019 18:23:44 +0000 (18:23 +0000)]
[clang-format] Fix a bug in AlignConsecutiveDeclarations.

Fixes PR37175

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

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

5 years ago[Driver] Explicitly request platform rtlib in the Driver pic test
Petr Hosek [Wed, 1 May 2019 16:52:45 +0000 (16:52 +0000)]
[Driver] Explicitly request platform rtlib in the Driver pic test

This test checks whether crtbegin.o and crtend.o appear on the link
line, but names of these files may be affected by the choice of the
rtlib, specifically when compiler-rt is used as the default rtlib
the names will be clang_rt.crtbegin.o and clang_rt.crtend.o instead
of crtbeginS.o and crtendS.o. To avoid the test failure, explicitly
request to use the platform rtlib.

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

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

5 years agoBump DIAG_SIZE_SEMA, as we've hit it.
Scott Linder [Wed, 1 May 2019 16:45:49 +0000 (16:45 +0000)]
Bump DIAG_SIZE_SEMA, as we've hit it.

$ grep 'DIAG_SIZE_SEMA          =' include/clang/Basic/DiagnosticIDs.h
      DIAG_SIZE_SEMA          = 4000,
$ grep DIAG $(build)/tools/clang/include/clang/Basic/DiagnosticSemaKinds.inc | wc -l
3499

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

5 years ago[analyzer][tests][NFC] Add EOF newlines, normalize reference expected files
Hubert Tong [Wed, 1 May 2019 15:57:00 +0000 (15:57 +0000)]
[analyzer][tests][NFC] Add EOF newlines, normalize reference expected files

Reference expected files not ending with a newline are normalized to
have said newlines. Additionally `plist-macros-with-expansion.cpp.plist`
is modified to add a line that is ignored by `%diff_plist`, but not by
the more sensitive pattern proposed by
http://lists.llvm.org/pipermail/cfe-dev/2019-April/061904.html for
`%normalize_plist`.

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

5 years ago[analyzer][tests] Use diff_plist, correct order of arguments for missed cases; NFC
Hubert Tong [Wed, 1 May 2019 15:53:56 +0000 (15:53 +0000)]
[analyzer][tests] Use diff_plist, correct order of arguments for missed cases; NFC

For various files under `clang/test/Analysis`, D52036 applied
`%diff_plist` to replace `diff` invocations with certain options and
D56340 swapped the order of the arguments so that the reference file
comes first. The tests that used `tail` to filter the test output were
not modified accordingly. This patch applies the corresponding update
to those tests.

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

5 years ago[clang-format] Fix bug that misses some function-like macro usages
Owen Pan [Wed, 1 May 2019 15:03:41 +0000 (15:03 +0000)]
[clang-format] Fix bug that misses some function-like macro usages

Fixes PR41483

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

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

5 years agoChange llvm-{objdump,readobj} -long-option to --long-option or well-known short optio...
Fangrui Song [Wed, 1 May 2019 09:30:45 +0000 (09:30 +0000)]
Change llvm-{objdump,readobj} -long-option to --long-option or well-known short options in tests. NFC

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

5 years agolib/Header: Fix Visual Studio builds try #2
Tom Stellard [Wed, 1 May 2019 06:18:03 +0000 (06:18 +0000)]
lib/Header: Fix Visual Studio builds try #2

Summary:
This is a follow up to r355253 and a better fix than the first attempt
which was r359257.

We can't install anything from ${CMAKE_CFG_INTDIR}, because this value
is only defined at build time, but we still must make sure to copy the
headers into ${CMAKE_CFG_INTDIR}/lib/clang/$VERSION/include, because the lit
tests look for headers there.  So for this fix we revert to the
old behavior of copying the headers to ${CMAKE_CFG_INTDIR}/lib/clang/$VERSION/include
during the build and then installing them from the source tree.

Reviewers: smeenai, vzakhari, phosek

Reviewed By: smeenai, vzakhari

Subscribers: mgorny, cfe-commits

Tags: #clang

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

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

5 years agoFix auto-init test
JF Bastien [Tue, 30 Apr 2019 23:27:28 +0000 (23:27 +0000)]
Fix auto-init test

r359628 changed the initialization of padding to follow C, but I didn't update the C++ tests.

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

5 years ago[WebAssembly] Use the "wasm32-wasi" triple in tests
Dan Gohman [Tue, 30 Apr 2019 23:06:07 +0000 (23:06 +0000)]
[WebAssembly] Use the "wasm32-wasi" triple in tests

Similar to https://reviews.llvm.org/D61334, update clang tests to use the
"wasm32-wasi" triple, removing the "-musl" environment and omitting the
"-unknown" vendor.

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

Reviewer: sbc100

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

5 years agoVariable auto-init: don't initialize aggregate padding of all aggregates
JF Bastien [Tue, 30 Apr 2019 22:56:53 +0000 (22:56 +0000)]
Variable auto-init: don't initialize aggregate padding of all aggregates

Summary:
C guarantees that brace-init with fewer initializers than members in the
aggregate will initialize the rest of the aggregate as-if it were static
initialization. In turn static initialization guarantees that padding is
initialized to zero bits.

Quoth the Standard:

C17 6.7.9 Initialization ❡21

If there are fewer initializers in a brace-enclosed list than there are elements
or members of an aggregate, or fewer characters in a string literal used to
initialize an array of known size than there are elements in the array, the
remainder of the aggregate shall be initialized implicitly the same as objects
that have static storage duration.

C17 6.7.9 Initialization ❡10

If an object that has automatic storage duration is not initialized explicitly,
its value is indeterminate. If an object that has static or thread storage
duration is not initialized explicitly, then:

 * if it has pointer type, it is initialized to a null pointer;
 * if it has arithmetic type, it is initialized to (positive or unsigned) zero;
 * if it is an aggregate, every member is initialized (recursively) according to
   these rules, and any padding is initialized to zero bits;
 * if it is a union, the first named member is initialized (recursively)
   according to these rules, and any padding is initialized to zero bits;

<rdar://problem/50188861>

Reviewers: glider, pcc, kcc, rjmccall, erik.pilkington

Subscribers: jkorous, dexonsmith, cfe-commits

Tags: #clang

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

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

5 years agoRemove two unnecessary wrappers of canPassInRegisters
Reid Kleckner [Tue, 30 Apr 2019 22:23:20 +0000 (22:23 +0000)]
Remove two unnecessary wrappers of canPassInRegisters

These extra layers aren't necessary.

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

5 years agoSet LoopInterleaved in the PassManagerBuilder.
Alina Sbirlea [Tue, 30 Apr 2019 21:29:23 +0000 (21:29 +0000)]
Set LoopInterleaved in the PassManagerBuilder.

Summary: Corresponds to D61030.

Subscribers: jlebar, cfe-commits, llvm-commits

Tags: #clang

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

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

5 years ago[Driver] Support compiler-rt crtbegin.o/crtend.o for Linux
Petr Hosek [Tue, 30 Apr 2019 19:35:14 +0000 (19:35 +0000)]
[Driver] Support compiler-rt crtbegin.o/crtend.o for Linux

When compiler-rt is selected as the runtime library for Linux targets
use its crtbegin.o/crtend.o implemenetation rather than platform one
if available.

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

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

5 years agoAdd requires amdgpu-registered-target for amdgpu-float16.cpp
Yaxun Liu [Tue, 30 Apr 2019 19:06:15 +0000 (19:06 +0000)]
Add requires amdgpu-registered-target for amdgpu-float16.cpp

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

5 years agoAMDGPU: Enable _Float16
Yaxun Liu [Tue, 30 Apr 2019 18:35:37 +0000 (18:35 +0000)]
AMDGPU: Enable _Float16

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

5 years ago[LibTooling] Fix broken test after r359574.
Yitzhak Mandelbaum [Tue, 30 Apr 2019 17:24:36 +0000 (17:24 +0000)]
[LibTooling] Fix broken test after r359574.

r359574 changed the way that failures are reported, which broke the test TransformerTest.NodePartNameDeclRefFailure which detects a faiure.

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

5 years ago[LibTooling] Change Transformer's TextGenerator to a partial function.
Yitzhak Mandelbaum [Tue, 30 Apr 2019 16:48:33 +0000 (16:48 +0000)]
[LibTooling] Change Transformer's TextGenerator to a partial function.

Summary:
Changes the signature of the TextGenerator std::function to return an Expected<std::string>
instead of std::string to allow for (non-fatal) failures.  Previously, we
expected that any failures would be expressed with assertions. However, that's
unfriendly to running the code in servers or other places that don't want their
library calls to crash the program.

Correspondingly, updates Transformer's handling of failures in TextGenerators
and the signature of `ChangeConsumer`.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoFix inconsistency in calculating DIAG_START_ values.
Russell Gallop [Tue, 30 Apr 2019 12:53:19 +0000 (12:53 +0000)]
Fix inconsistency in calculating DIAG_START_ values.

This was introduced at r313975. As DIAG_SIZE_CROSSTU and
DIAG_SIZE_COMMENT are both 100 this should be NFC.

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

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

5 years agoFix gcc "-Wdangling-else" warning. NFCI.
Simon Pilgrim [Tue, 30 Apr 2019 10:57:37 +0000 (10:57 +0000)]
Fix gcc "-Wdangling-else" warning. NFCI.

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

5 years agoFix gcc "-Wdangling-else" warnings. NFCI.
Simon Pilgrim [Tue, 30 Apr 2019 10:57:02 +0000 (10:57 +0000)]
Fix gcc "-Wdangling-else" warnings. NFCI.

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

5 years ago[analyzer][UninitializedObjectChecker] PR41611: Regard vector types as primitive
Kristof Umann [Tue, 30 Apr 2019 08:47:56 +0000 (08:47 +0000)]
[analyzer][UninitializedObjectChecker] PR41611: Regard vector types as primitive

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

Similarly to D61106, the checker ran over an llvm_unreachable for vector types:

struct VectorSizeLong {
  VectorSizeLong() {}
  __attribute__((__vector_size__(16))) long x;
};

void __vector_size__LongTest() {
  VectorSizeLong v;
}
Since, according to my short research,

"The vector_size attribute is only applicable to integral and float scalars,
although arrays, pointers, and function return values are allowed in conjunction
with this construct."
[src: https://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Vector-Extensions.html#Vector-Extensions]

vector types are safe to regard as primitive.

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

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

5 years ago[analyzer] Treat functions without run-time branches as "small".
Artem Dergachev [Tue, 30 Apr 2019 03:01:02 +0000 (03:01 +0000)]
[analyzer] Treat functions without run-time branches as "small".

Currently we always inline functions that have no branches, i.e. have exactly
three CFG blocks: ENTRY, some code, EXIT. This makes sense because when there
are no branches, it means that there's no exponential complexity introduced
by inlining such function. Such functions also don't trigger various fundamental
problems with our inlining mechanism, such as the problem of inlined
defensive checks.

Sometimes the CFG may contain more blocks, but in practice it still has
linear structure because all directions (except, at most, one) of all branches
turned out to be unreachable. When this happens, still treat the function
as "small". This is useful, in particular, for dealing with C++17 if constexpr.

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

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

5 years ago[analyzer] SmartPtrModeling: Fix a null dereference.
Artem Dergachev [Tue, 30 Apr 2019 03:00:57 +0000 (03:00 +0000)]
[analyzer] SmartPtrModeling: Fix a null dereference.

Don't crash when trying to model a call in which the callee is unknown
in compile time, eg. a pointer-to-member call.

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

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

5 years ago[NFC] typo
JF Bastien [Tue, 30 Apr 2019 00:19:43 +0000 (00:19 +0000)]
[NFC] typo

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

5 years ago[NFC] typo
JF Bastien [Tue, 30 Apr 2019 00:11:53 +0000 (00:11 +0000)]
[NFC] typo

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

5 years agoAdd __builtin_dcbf support for PPC
Ahsan Saghir [Mon, 29 Apr 2019 23:25:33 +0000 (23:25 +0000)]
Add __builtin_dcbf support for PPC

Summary:
This patch adds support for __builtin_dcbf for PPC.

__builtin_dcbf copies the contents of a modified block from the data cache
to main memory and flushes the copy from the data cache.

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

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

5 years ago[Diagnostics] Support -Wtype-limits for GCC compatibility
David Bolvansky [Mon, 29 Apr 2019 23:24:00 +0000 (23:24 +0000)]
[Diagnostics] Support -Wtype-limits for GCC compatibility

Summary:
GCC's  -Wtype-limits (part of -Wextra):
Warn if a comparison is always true or always false due to the limited range of the data type

Reviewers: rsmith, aaron.ballman, lebedev.ri, thakis

Reviewed By: rsmith

Subscribers: lebedev.ri, jdoerfert, cfe-commits

Tags: #clang

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

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

5 years agoRe-land r359250, [COFF] Statically link certain runtime library functions
Reid Kleckner [Mon, 29 Apr 2019 23:05:47 +0000 (23:05 +0000)]
Re-land r359250, [COFF] Statically link certain runtime library functions

Reverts the revert of r359251, this time with fixed tests.

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

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

5 years agoMake test more robust by writing stdout/stderr to different files.
Douglas Yung [Mon, 29 Apr 2019 22:57:15 +0000 (22:57 +0000)]
Make test more robust by writing stdout/stderr to different files.

Our internal build bots were failing this test randomly as the stderr
output was emitted to the file in the middle of the stdout output
line that the test was checking.

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

5 years agoSimplify exclusion of nested classes from extern template instantiation, NFC
Reid Kleckner [Mon, 29 Apr 2019 21:32:05 +0000 (21:32 +0000)]
Simplify exclusion of nested classes from extern template instantiation, NFC

Summary:
This simplifies three checks for MS ABI, Win Itanium, or Win GNU to just
"is Windows".

The question remains, however, if this is really the correct thing to
do. We could, for example, only not consider inner classes to be
externally available if the outer class has a dllexport annotation.
However, I will leave that as future work.

Reviewers: hans, mstorsjo

Subscribers: cfe-commits

Tags: #clang

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

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

5 years agoWhen skipping code at the start of a file during PCH use, Preprocessor::Lex
Mike Rice [Mon, 29 Apr 2019 21:21:17 +0000 (21:21 +0000)]
When skipping code at the start of a file during PCH use, Preprocessor::Lex
is not used since it consumes all preprocessor directives until it returns
a real token. Using the specific Lexer (i.e. CurLexer->Lex) makes it
possible to stop skipping after an #include or #pragma hdrstop. Previously
the skipping code was only handling CurLexer, now all will be handled
correctly.

Fixes: llvm.org/PR41585
Differential Revision: https://reviews.llvm.org/D61217

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

5 years ago[ASTImporter] Add an ImportImpl method to allow customizing Import behavior.
Raphael Isemann [Mon, 29 Apr 2019 21:02:35 +0000 (21:02 +0000)]
[ASTImporter] Add an ImportImpl method to allow customizing Import behavior.

Summary:
We are currently implementing support in LLDB that reconstructs the STL templates from
the target program in the expression evaluator. This reconstruction happens during the
import process from our debug info AST into the expression evaluation AST, which means
we need a way to intercept the ASTImporter import process.

This patch adds an protected ImportImpl method that we can overwrite in LLDB to implement
our special importing logic (which is essentially just looking into a C++ module that is attached to
the target context). Because ImportImpl has to call MapImported/AddToLookup for the decls it
creates, this patch also exposes those via a new unified method and checks that we call it when
importing decls.

Reviewers: martong, balazske, a.sidorin, shafik, a_sidorin

Reviewed By: martong, a_sidorin

Subscribers: rnkovacs, cfe-commits, lldb-commits, aprantl

Tags: #clang

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

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

5 years ago[LibTooling] Fix unneeded use of unique_ptr where shared_ptr is expected.
Yitzhak Mandelbaum [Mon, 29 Apr 2019 16:57:40 +0000 (16:57 +0000)]
[LibTooling] Fix unneeded use of unique_ptr where shared_ptr is expected.

Summary: This fixes a few places in the Stencil implementation where a unique_ptr is created at a callsite that expects shared_ptr. Since the former implicitly converts to the latter, the code compiles and runs correctly as is.  But, there's no reason to involve unique_ptr -- the current code was leftover from a previous version in which unique_ptr was the expected type.

Reviewers: sbenza

Subscribers: cfe-commits

Tags: #clang

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

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

5 years ago[OPENMP]Fix PR41617: crash on template instantiation.
Alexey Bataev [Mon, 29 Apr 2019 15:51:36 +0000 (15:51 +0000)]
[OPENMP]Fix PR41617: crash on template instantiation.

Fixed the crash on the template instantiation when trying to check the
data locality in the current instantiation scope.

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

5 years ago[libclang] Add missing export for clang_Cursor_isAnonymousRecordDecl
Ivan Donchevskii [Mon, 29 Apr 2019 14:13:11 +0000 (14:13 +0000)]
[libclang] Add missing export for clang_Cursor_isAnonymousRecordDecl

Follow up for D61232 to fix build.

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

5 years ago[libclang] Restore old clang_Cursor_isAnonymous behaviour
Ivan Donchevskii [Mon, 29 Apr 2019 13:44:07 +0000 (13:44 +0000)]
[libclang] Restore old clang_Cursor_isAnonymous behaviour

D54996 Changed the behaviour of clang_Cursor_isAnonymous, but there is no alternative available to get the old behaviour in some cases, which is essential for determining if a record is syntactically accessible, e.g.

struct {
  int x;
  int y;
} foo;

struct {
  struct {
    int x;
    int y;
  };
} bar;

void fun(struct { int x; int y; } *param);
The only 'anonymous' struct here is the one nested in bar, since there is
no way to reference the struct itself, only the fields within. Though the
anonymity applies to the instance itself, not the type.

To avoid confusion, I have added a new function called clang_Cursor_isAnonymousRecordDecl
which has the old behaviour of clang_Cursor_isAnonymous (and updated the doc
for the latter as well, which was seemingly forgotten).

Patch by Jorn Vernee.

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

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

5 years ago[PowerPC][Clang] Add tests for PowerPC MMX intrinsics
Qiu Chaofan [Sun, 28 Apr 2019 06:27:33 +0000 (06:27 +0000)]
[PowerPC][Clang] Add tests for PowerPC MMX intrinsics

Add the rest of test cases covering functions defined in mmintrin.h on PowerPC.

Reviewed By: Jinsong Ji

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

5 years agoReinstate r359059, reverted in r359361, with a fix to properly prevent
Richard Smith [Sat, 27 Apr 2019 02:58:17 +0000 (02:58 +0000)]
Reinstate r359059, reverted in r359361, with a fix to properly prevent
us emitting the operand of __builtin_constant_p if it has side-effects.

Original commit message:

Fix interactions between __builtin_constant_p and constexpr to match
current trunk GCC.

GCC permits information from outside the operand of
__builtin_constant_p (but in the same constant evaluation context) to be
used within that operand; clang now does so too. A few other minor
deviations from GCC's behavior showed up in my testing and are also
fixed (matching GCC):
  * Clang now supports nullptr_t as the argument type for
    __builtin_constant_p
    * Clang now returns true from __builtin_constant_p if called with a
    null pointer
    * Clang now returns true from __builtin_constant_p if called with an
    integer cast to pointer type

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

5 years ago[AArch64] Initialize HasMTE
Vitaly Buka [Sat, 27 Apr 2019 02:40:01 +0000 (02:40 +0000)]
[AArch64] Initialize HasMTE

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

5 years agoRevert Fix interactions between __builtin_constant_p and constexpr to match current...
Jorge Gorbe Moya [Sat, 27 Apr 2019 00:32:04 +0000 (00:32 +0000)]
Revert Fix interactions between __builtin_constant_p and constexpr to match current trunk GCC.

This reverts r359059 (git commit 0b098754b73f3b96d00ecb1c7605760b11c90298)

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

5 years ago[Fuchsia] Support multilib for -fsanitize=address and -fno-exceptions
Petr Hosek [Sat, 27 Apr 2019 00:25:13 +0000 (00:25 +0000)]
[Fuchsia] Support multilib for -fsanitize=address and -fno-exceptions

This introduces a support for multilibs to Fuchsia driver. Unlike the
existing multilibs that are used primarily for handling different
architecture variants, we use multilibs to handle different variants
of Clang runtime libraries: -fsanitize=address and -fno-exceptions
are the two we support initially. This replaces the existing support
for sanitized runtimes libraries that was only used by Fuchsia driver
and it also refactors some of the logic to allow sharing between GNU
and Fuchsia drivers.

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

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

5 years ago[Driver] Support priority for multilibs
Petr Hosek [Sat, 27 Apr 2019 00:25:11 +0000 (00:25 +0000)]
[Driver] Support priority for multilibs

When more than one multilib flag matches, try to select the best
possible match based on priority. When two different multilibs with
the same same priority match, we still throw an error matching the
existing behavior.

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

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

5 years ago[clang][driver] Weaken the test from 359353 to appease Windows bots
Alex Lorenz [Fri, 26 Apr 2019 22:58:31 +0000 (22:58 +0000)]
[clang][driver] Weaken the test from 359353 to appease Windows bots

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

5 years ago[driver][macOS] Link libarclite from the default toolchain when clang
Alex Lorenz [Fri, 26 Apr 2019 22:40:47 +0000 (22:40 +0000)]
[driver][macOS] Link libarclite from the default toolchain when clang
is running in a toolchain outside of xcode

'libarclite' usually lives in the same toolchain as 'clang'. However, the
Swift open source toolchains for macOS distribute Clang without 'libarclite'.
In that case, to allow the linker to find 'libarclite', we point to the
'libarclite' that should be in the XcodeDefault toolchain instead. The
path to the toolchain is inferred from the SDK path if it's specified.

https://bugs.swift.org/browse/SR-9972
rdar://49947573

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

5 years agoAdd to the release notes the fact that UninitializedObject checker is now
Sylvestre Ledru [Fri, 26 Apr 2019 21:46:33 +0000 (21:46 +0000)]
Add to the release notes the fact that UninitializedObject checker is now
considered as stable

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

5 years ago[AArch64] Add support for MTE intrinsics
Javed Absar [Fri, 26 Apr 2019 21:08:11 +0000 (21:08 +0000)]
[AArch64] Add support for MTE intrinsics
This provides intrinsics support for Memory Tagging Extension (MTE),
which was introduced with the Armv8.5-a architecture.
These intrinsics are available when __ARM_FEATURE_MEMORY_TAGGING is defined.
Each intrinsic is described in detail in the ACLE Q1 2019 documentation:
https://developer.arm.com/docs/101028/latest
Reviewed By: Tim Nortover, David Spickett
Differential Revision: https://reviews.llvm.org/D60485

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

5 years ago[MinGW] Always emit local typeinfo
Martin Storsjo [Fri, 26 Apr 2019 19:31:51 +0000 (19:31 +0000)]
[MinGW] Always emit local typeinfo

This makes sure that code built with headers for a statically linked
libc++ also works when linking to the DLL version, when the DLL
hasn't been built with --export-all-symbols.

This matches what GCC for MinGW does for this test case.

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

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

5 years ago[HIP] Fix visibility of `__constant__` variables.
Michael Liao [Fri, 26 Apr 2019 19:31:48 +0000 (19:31 +0000)]
[HIP] Fix visibility of `__constant__` variables.

Summary:
- `__constant__` variables should not be `hidden` as the linker may turn
  them into `LOCAL` symbols.

Reviewers: yaxunl

Subscribers: jvesely, nhaehnle, cfe-commits

Tags: #clang

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

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

5 years ago[MinGW] Do dllexport inline methods in template instantiation
Martin Storsjo [Fri, 26 Apr 2019 19:31:46 +0000 (19:31 +0000)]
[MinGW] Do dllexport inline methods in template instantiation

Normally, in MinGW mode, inline methods aren't dllexported.

However, in the case of a dllimported template instantiation,
the inline methods aren't instantiated locally, but referenced
from the instantiation. Therefore, those methods also need to
be dllexported, in the case of an instantiation.

GCC suffers from the same issue, reported at [1], but the issue
is still unresolved there.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89088

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

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

5 years ago[MinGW] Don't let template instantiation declarations cover nested classes
Martin Storsjo [Fri, 26 Apr 2019 19:31:39 +0000 (19:31 +0000)]
[MinGW] Don't let template instantiation declarations cover nested classes

An explicit template instantiation declaration used to let
callers assume both outer and nested classes instantiations were
defined in a different translation unit.

If the instantiation is marked dllexport, only the outer class
is exported, but the caller will try to reference the instantiation
of both outer and inner classes.

This makes MinGW mode match both MSVC and Windows Itanium, by
having instantations only cover the outer class, and locally emitting
definitions of the nested classes. Windows Itanium was changed to
use this behavious in SVN r300804.

This deviates from what GCC does, but should be safe (and only
inflate the object file size a bit, but MSVC and Windows Itanium
modes do the same), and fixes cases where inner classes aren't
dllexported.

This fixes missing references in combination with dllexported/imported
template intantiations.

GCC suffers from the same issue, reported at [1], but the issue
is still unresolved there. The issue can probably be solved either
by making dllexport cover all nested classes as well, or this
way (matching MSVC).

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89087

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

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

5 years ago[OPENMP]Added check for non-random access types for the dependent loop
Alexey Bataev [Fri, 26 Apr 2019 19:28:37 +0000 (19:28 +0000)]
[OPENMP]Added check for non-random access types for the dependent loop
counters.

According to the OpenMP 5.0, For any associated loop where the b or lb
expression is not loop invariant with respect to the outermost loop, the
var-outer that appears in the expression may not have a random access
iterator type.

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

5 years ago[ASTImporter] Copy Argument Passing Restrictions setting when importing a CXXRecordDe...
Shafik Yaghmour [Fri, 26 Apr 2019 18:51:28 +0000 (18:51 +0000)]
[ASTImporter] Copy Argument Passing Restrictions setting when importing a CXXRecordDecl definition

Summary:
For a CXXRecordDecl the RecordDeclBits are stored in the DeclContext. Currently when we import the definition of a CXXRecordDecl via the ASTImporter we do not copy over this data.
This change will add support for copying the ArgPassingRestrictions from RecordDeclBits to fix an LLDB expression parsing bug where we would set it to not pass in registers.
Note, we did not copy over any other of the RecordDeclBits since we don't have tests for those. We know that copying over LoadedFieldsFromExternalStorage would be a error and that may be the case for others as well.

The companion LLDB review: https://reviews.llvm.org/D61146

Differential Review: https://reviews.llvm.org/D61140

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

5 years ago[BPF] do not generate predefined macro bpf
Yonghong Song [Fri, 26 Apr 2019 15:35:51 +0000 (15:35 +0000)]
[BPF] do not generate predefined macro bpf

"DefineStd(Builder, "bpf", Opts)" generates the following three
macros:
  bpf
  __bpf
  __bpf__
and the macro "bpf" is due to the fact that the target language
is C which allows GNU extensions.

The name "bpf" could be easily used as variable name or type
field name. For example, in current linux kernel, there are
four places where bpf is used as a field name. If the corresponding
types are included in bpf program, the compilation error will
occur.

This patch removed predefined macro "bpf" as well as "__bpf" which
is rarely used if used at all.

Signed-off-by: Yonghong Song <yhs@fb.com>
Differential Revision: https://reviews.llvm.org/D61173

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

5 years ago[MinGW] Fix dllexport of explicit template instantiation
Martin Storsjo [Fri, 26 Apr 2019 08:09:51 +0000 (08:09 +0000)]
[MinGW] Fix dllexport of explicit template instantiation

Contrary to MSVC, GCC/MinGW needs to have the dllexport attribute
on the template instantiation declaration, not on the definition.

Previously clang never marked explicit template instantiations as
dllexport in MinGW mode, if the instantiation had a previous
declaration, regardless of where the attribute was placed. This
makes Clang behave like GCC in this regard, and allows using the
same attribute form for both MinGW compilers.

This fixes PR40256.

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

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

5 years ago[Analyzer] Iterator Checkers - Do an early return after handling calls
Adam Balogh [Fri, 26 Apr 2019 07:30:07 +0000 (07:30 +0000)]
[Analyzer] Iterator Checkers - Do an early return after handling calls

This patch is more of a fix than a real improvement: in checkPostCall()
we should return immediately after finding the right call and handling
it. This both saves unnecessary processing and double-handling calls by
mistake.

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

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

5 years ago[clang-format] Fix documentation for FixNamespaceComments
Owen Pan [Fri, 26 Apr 2019 07:05:47 +0000 (07:05 +0000)]
[clang-format] Fix documentation for FixNamespaceComments

Fixes PR40409

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

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

5 years agoPR41607: Don't forget to substitute outer template arguments into a
Richard Smith [Fri, 26 Apr 2019 02:11:23 +0000 (02:11 +0000)]
PR41607: Don't forget to substitute outer template arguments into a
class-scope explicit specialization of a class template.

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

5 years ago[analyzer] RetainCount: Add a suppression for "the Matching rule".
Artem Dergachev [Fri, 26 Apr 2019 02:05:18 +0000 (02:05 +0000)]
[analyzer] RetainCount: Add a suppression for "the Matching rule".

In the OSObject universe there appears to be another slightly popular contract,
apart from "create" and "get", which is "matching". It optionally consumes
a "table" parameter and if a table is passed, it fills in the table and
returns it at +0; otherwise, it creates a new table, fills it in and
returns it at +1.

For now suppress false positives by doing a conservative escape on all functions
that end with "Matching", which is the naming convention that seems to be
followed by all such methods.

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

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

5 years ago[analyzer] RetainCount: Allow offsets in return values.
Artem Dergachev [Fri, 26 Apr 2019 02:05:15 +0000 (02:05 +0000)]
[analyzer] RetainCount: Allow offsets in return values.

Because RetainCountChecker has custom "local" reasoning about escapes,
it has a separate facility to deal with tracked symbols at end of analysis
and check them for leaks regardless of whether they're dead or not.
This facility iterates over the list of tracked symbols and reports
them as leaks, but it needs to treat the return value specially.

Some custom allocators tend to return the value with an offset, storing
extra metadata at the beginning of the buffer. In this case the return value
would be a non-base region. In order to avoid false positives, we still need to
find the original symbol within the return value, otherwise it'll be unable
to match it to the item in the list of tracked symbols.

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

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

5 years ago[analyzer] Fix crash when returning C++ objects from ObjC messages-to-nil.
Artem Dergachev [Fri, 26 Apr 2019 02:05:12 +0000 (02:05 +0000)]
[analyzer] Fix crash when returning C++ objects from ObjC messages-to-nil.

the assertion is in fact incorrect: there is a cornercase in Objective-C++
in which a C++ object is not constructed with a constructor, but merely
zero-initialized. Namely, this happens when an Objective-C message is sent
to a nil and it is supposed to return a C++ object.

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

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

5 years ago[www] Rebuild cxx_dr_status.
Richard Smith [Fri, 26 Apr 2019 01:51:08 +0000 (01:51 +0000)]
[www] Rebuild cxx_dr_status.

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

5 years agoC++ DR2387: a variable template declared wtih (or instantiated with) a
Richard Smith [Fri, 26 Apr 2019 01:51:08 +0000 (01:51 +0000)]
C++ DR2387: a variable template declared wtih (or instantiated with) a
const-qualified type is not implicitly given internal linkage. But a
variable template declared 'static' is.

This reinstates part of r359048, reverted in r359076.

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

5 years agoAdd missing diagnostic for explicit instantiation declarations naming
Richard Smith [Fri, 26 Apr 2019 01:51:07 +0000 (01:51 +0000)]
Add missing diagnostic for explicit instantiation declarations naming
internal linkage entities.

Such constructs are ill-formed by [temp.explicit]p13. We make a special
exception to permit an invalid construct used by libc++ in some build
modes: its <valarray> header declares some functions with the
internal_linkage attribute and then (meaninglessly) provides explicit
instantiation declarations for them. Luckily, Clang happens to
effectively ignore the explicit instantiation declaration when
generating code in this case, and this change codifies that behavior.

This reinstates part of r359048, reverted in r359076. (The libc++ issue
triggering the rollback has been addressed.)

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