Commit Graph

86781 Commits

Author SHA1 Message Date
Raphael Isemann 3f6c856bb5 [ASTImporter] Import the default argument of TemplateTypeParmDecl
The test case isn't using the AST matchers for all checks as there doesn't seem to be support for
matching TemplateTypeParmDecl default arguments. Otherwise this is simply importing the
default arguments.

Also updates several LLDB tests that now as intended omit the default template
arguments of several std templates.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D92103
2020-11-26 18:01:30 +01:00
Jan Svoboda a325856686 [clang][cli] Port Target option flags to new option parsing system
Depends on D83697

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83698
2020-11-26 15:32:38 +01:00
Raphael Isemann 39a5dd164c [ASTImporter] Import the default argument of TemplateTemplateParmDecl
Same idea as in D92103 and D92106, but I realised after creating those reviews that there are
also TemplateTemplateParmDecls that can have default arguments, so here's hopefully the
last patch for default template arguments.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D92119
2020-11-26 15:12:45 +01:00
Hafiz Abid Qadeer 45ba2392d7 [clang][Driver] Handle risvc in Baremetal.cpp.
I am working on a baremetal riscv toolchain using LLVM runtime and
LLD linker. Baremetal.cpp provides most of the things needed for such
toolchain. So I have modified it to also handle riscv64/32-unknown-elf
 targets alongside arm-none-eabi.

Currently, targets like riscv64-unknown-elf are handled by RISCVToolChain
which mostly expects a gcc toolchain to be present. If you dont
want the dependency on gcc-toolchain/libgloss or want to use LLD, then
RISCVToolChain is not a good fit.

So in the toolchain selection code, I have made this dependency of
RISCVToolChain on gcc toolchain explicit. It is created if gcc-toolchain
option is present. Otherwise Baremetal toolchain is created. I will be
happy to hear if there is a better way to choose between these two
toolchains.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D91442
2020-11-26 11:43:17 +00:00
Richard Smith 7c327db3ef Part of C++ DR 39: a class member lookup is not ambiguous if it finds the
same type in multiple base classes.

Not even if the type is introduced by distinct declarations (for
example, two typedef declarations, or a typedef and a class definition).
2020-11-25 17:03:11 -08:00
Richard Smith 3fb0879867 Refactor and simplify class scope name lookup.
This is partly in preparation for an upcoming change that can change the
order in which DeclContext lookup results are presented.

In passing, fix some obvious errors where name lookup's notion of a
"static member function" missed static member function templates, and
where its notion of "same set of declarations" was confused by the same
declarations appearing in a different order.
2020-11-25 16:25:33 -08:00
Reid Kleckner 1e843a987d [MS] Add more 128bit cmpxchg intrinsics for AArch64
The MSVC STL for requires this on ARM64.
Requested in https://llvm.org/pr47099

Depends on D92061

Differential Revision: https://reviews.llvm.org/D92062
2020-11-25 12:07:28 -08:00
Reid Kleckner 3bd0672726 [MS] Fix double evaluation of MSVC builtin arguments
This code got quite twisted because we consider some MSVC builtins to be
target agnostic, and some to be target specific. Target specific
intrinsics have a pattern of doing up-front argument evaluation, while
general intrinsics do not evaluate their arguments up front. As we tried
to share codepaths between the target-specific and target-agnostic
handling, we ended up doing double evaluation.

Instead, have each target handle MSVC intrinsics consistently before up
front argument evaluation. This requires passing less data around and is
more consistent with target independent intrinsic handling.

See D50979 for past examples of this bug. I noticed this while looking
into adding some more intrinsics.

Differential Revision: https://reviews.llvm.org/D92061
2020-11-25 11:55:01 -08:00
Endre Fülöp dc96cc33c1 [clang][test] Fix prefix operator++ signature in iterators
Prefix operator++ should return the iterator incremented by reference.

Differential Revision: https://reviews.llvm.org/D89528
2020-11-25 18:05:11 +01:00
Mark Murray 2b6691894a [ARM][AArch64] Adding Neoverse N2 CPU support
Add support for the Neoverse N2 CPU to the ARM and AArch64 backends.

Differential Revision: https://reviews.llvm.org/D91695
2020-11-25 11:42:54 +00:00
Simon Pilgrim 88bb265670 SemaExpr.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.
castAs<> will assert the correct cast type instead of just returning null, which we then try to dereference immediately.
2020-11-25 11:38:30 +00:00
Simon Pilgrim 9d996c01aa TargetInfo.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.
castAs<> will assert the correct cast type instead of just returning null, which we then try to dereference immediately.
2020-11-25 11:38:29 +00:00
Simon Pilgrim eb7ea5aa1a CGCall.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.
castAs<> will assert the correct cast type instead of just returning null, which we then try to dereference immediately in the setUsedBits call.
2020-11-25 11:38:29 +00:00
Simon Pilgrim 6d56823116 SemaExpr.cpp - use castAs<> instead of getAs<> as we dereference the pointer directly. NFCI.
castAs<> will assert the correct cast type instead of just returning null, which we then try to dereference immediately.
2020-11-25 11:38:29 +00:00
Sven van Haastregt 633cae3059 [OpenCL] Move kernel arg type tests into one file
Keep all kernel parameter type diagnostic tests in
invalid-kernel-parameters.cl .

Differential Revision: https://reviews.llvm.org/D92033
2020-11-25 10:20:30 +00:00
Francesco Petrogalli e592dde688 [clang][SVE] Activate macro `__ARM_FEATURE_SVE_VECTOR_OPERATORS`.
The macro is emitted when wargeting SVE code generation with the additional command line option `-msve-vector-bits=<N>`.

The behavior implied by the macro is described in sections "3.7.3.3. Behavior specific to SVE vectors" of the SVE ACLE (Version 00bet6) that can be found at https://developer.arm.com/documentation/100987/latest

Reviewed By: rengolin, rsandifo-arm

Differential Revision: https://reviews.llvm.org/D90956
2020-11-25 10:16:43 +00:00
Nico Weber a9eaf8435d Try to fix tests after e16c0a9a68 with CLANG_DEFAULT_LINKER=lld
Tests that pass -mlinker-version=old version and that then don't
expect new flags to be passed need to explicitly request the system
linker now.
2020-11-24 22:34:12 -05:00
Richard Smith e0f4dea0d0 Don't assume the clang binary name contains the string "clang".
Also ensure the -cc1 argument is actually part of the clang -cc1 command
line rather than some unrelated command line.
2020-11-24 18:52:46 -08:00
Reid Kleckner 09ba2063dc Fix compilation issue reported by MSVC user on cfe-dev
MSVC seems to think this `friend class TrailingObjects;` declaration is
declaring a TrailingObjects class instead of naming the injected base
class. Remove `class` so it does the right thing.
2020-11-24 17:31:25 -08:00
Richard Smith 23dc04981b Treat a placeholder type for class template argument deduction as
substitutable for the deduced template.

As agreed in https://github.com/itanium-cxx-abi/cxx-abi/issues/109.
2020-11-24 16:59:06 -08:00
Richard Smith c2cb61bed3 Fix mangling of substitutions for template-prefixes.
Previously we only considered using a substitution for a template-name
after already having mangled its prefix, so we'd produce nonsense
manglings like NS3_S4_IiEE where we should simply produce NS4_IiEE.

This is not ABI-compatible with previous Clang versions, and the old
behavior is restored by -fclang-abi-compat=11.0 or earlier.
2020-11-24 16:25:18 -08:00
Zarko Todorovski c92f29b05e [AIX] Add mabi=vec-extabi options to enable the AIX extended and default vector ABIs.
Added support for the options mabi=vec-extabi and mabi=vec-default which are analogous to qvecnvol and qnovecnvol when using XL on AIX.
The extended Altivec ABI on AIX is enabled using mabi=vec-extabi in clang and vec-extabi in llc.

Reviewed By: Xiangling_L, DiggerLin

Differential Revision: https://reviews.llvm.org/D89684
2020-11-24 18:17:53 -05:00
Luís Marques 28de0fb486 [RISCV] Set __GCC_HAVE_SYNC_COMPARE_AND_SWAP_x defines
The RISCV target did not set the GCC atomic compare and swap defines,
unlike other targets. This broke builds for things like glib on RISCV.

Patch by Kristof Provost (kprovost)

Differential Revision: https://reviews.llvm.org/D91784
2020-11-24 22:50:28 +00:00
Raphael Isemann 0c926e6d24 [ASTImporter] Make the Import() return value consistent with the map of imported decls when merging ClassTemplateSpecializationDecls
When importing a `ClassTemplateSpecializationDecl` definition into a TU with a matching
`ClassTemplateSpecializationDecl` definition and a more recent forward decl, the ASTImporter
currently will call `MapImported()` for the definitions, but will return the forward declaration
from the `ASTImporter::Import()` call.

This is triggering some assertions in LLDB when we try to fully import some DeclContexts
before we delete the 'From' AST. The returned 'To' Decl before this patch is just the most recent
forward decl but that's not the Decl with the definition to which the ASTImporter will import
the child declarations.

This patch just changes that the ASTImporter returns the definition that the imported Decl was
merged with instead of the found forward declaration.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D92016
2020-11-24 23:46:18 +01:00
cchen 77e98eaee2 [OpenMP50][DOCS] Mark target data non-contiguous as done, NFC. 2020-11-24 16:07:39 -06:00
Teresa Johnson 0768b0576a Avoid redundant work when computing vtable vcall visibility
Add a Visited set to avoid repeatedly processing the same base classes
in complex class hierarchies. This cut down the compile time of one
source file from >12min to ~1min.

Differential Revision: https://reviews.llvm.org/D91676
2020-11-24 12:06:24 -08:00
Fangrui Song 8f8bbf98da [test] Clean up ppc-features.cpp and improve tests
And add ppc-cpus.cpp for -mcpu= specific tests.
2020-11-24 11:59:15 -08:00
Fangrui Song f96fef89b5 [Driver] Default Generic_GCC aarch64 to -fasynchronous-unwind-tables
In GCC, `aarch64-*-linux` and `aarch64-*-freebsd` made the switch in 2018
(https://gcc.gnu.org/pipermail/gcc-patches/2018-March/495549.html).
In Clang, FreeBSD/Fuchsia/NetBSD/MinGW aarch64 default to -fasynchronous-unwind-tables.

This patch defaults Generic_GCC aarch64 (which affects Linux) to use -fasynchronous-unwind-tables.

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D91760
2020-11-24 09:51:32 -08:00
Teresa Johnson 6e4c1cf293 [ThinLTO/WPD] Enable -wholeprogramdevirt-skip in ThinLTO backends
Previously this option could be used to skip devirtualizations of the
given functions in regular LTO and in the ThinLTO indexing step. This
change allows them to be skipped in the backend as well, which is useful
when debugging WPD in a distributed ThinLTO backend.

Differential Revision: https://reviews.llvm.org/D91812
2020-11-24 09:35:07 -08:00
Hubert Tong 44174b3d51 [NFC][tests] Replace non-portable grep with FileCheck
After commit 2482648a79, a GNU grep option
is just passed unconditionally to `grep` in general. This patch fixes
the test for platforms where `grep` is not GNU grep.
2020-11-24 12:15:07 -05:00
Nico Weber 9a8386dba8 clang: Pass -platform-version to new MachO LLD
New MachO LLD doesn't implement the old -macos_version_min (etc)
flags, but it understands the modern platform_version flag.
So make the clang driver pass that when using new MachO LLD.

Also, while here, don't pass -lto_library to LLD, since it
links in LTO libraries statically (which it can because it's
versioned alongside clang).

Differential Revision: https://reviews.llvm.org/D92037
2020-11-24 11:16:03 -05:00
Sergey Dmitriev 1b0ca81a6c [clang-offload-bundler] use std::forward_list for storing temp file names [NFC]
Use a different container that preserves existing elements on modification
for storing temporary file names. Current container can make StringRefs
returned earlier invalid on reallocation.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D92010
2020-11-24 08:07:31 -08:00
Nico Weber 5ce85e6635 Fix driver test from e16c0a9a68
The test failed silently if lld wasn't built alongside clang.
But the test uses -###, so the "invalid linker name in -fuse-ld=lld"
diag didn't make clang fail, and something else happened to match
"-demangle", so the test passed.

To fix, pass -B to a directory with two empty +x files (which works
on non-Windows), and look for `"-demangle"` instead of just `-demangle`.
Also force linker_version to 0 and pass a darwin triple.

Differential Revision: https://reviews.llvm.org/D92028
2020-11-24 10:51:08 -05:00
Nico Weber e16c0a9a68 clang+lld: Improve clang+ld.darwinnew.lld interaction, pass -demangle
This patch:
- adds an ld64.lld.darwinnew symlink for lld, to go with f2710d4b57,
  so that `clang -fuse-ld=lld.darwinnew` can be used to test new
  Mach-O lld while it's in bring-up. (The expectation is that we'll
  remove this again once new Mach-O lld is the defauld and only Mach-O
  lld.)
- lets the clang driver know if the linker is lld (currently
  only triggered if `-fuse-ld=lld` or `-fuse-ld=lld.darwinnew` is
  passed). Currently only used for the next point, but could be used
  to implement other features that need close coordination between
  compiler and linker, e.g. having a diag for calling `clang++` instead
  of `clang` when link errors are caused by a missing C++ stdlib.
- lets the clang driver pass `-demangle` to Mach-O lld (both old and
  new), in addition to ld64
- implements -demangle for new Mach-O lld
- changes demangleItanium() to accept _Z, __Z, ___Z, ____Z prefixes
  (and updates one test added in D68014). Mach-O has an extra
  underscore for symbols, and the three (or, on Mach-O, four)
  underscores are used for block names.

Differential Revision: https://reviews.llvm.org/D91884
2020-11-24 08:51:58 -05:00
Yaxun (Sam) Liu cb08558caa [HIP] Fix regressions due to fp contract change
Recently HIP toolchain made a change to use clang instead of opt/llc to do compilation
(https://reviews.llvm.org/D81861). The intention is to make HIP toolchain canonical like
other toolchains.

However, this change introduced an unintentional change regarding backend fp fuse
option, which caused regressions in some HIP applications.

Basically before the change, HIP toolchain used clang to generate bitcode, then use
opt/llc to optimize bitcode and generate ISA. As such, the amdgpu backend takes
the default fp fuse mode which is 'Standard'. This mode respect contract flag of
fmul/fadd instructions and do not fuse fmul/fadd instructions without contract flag.

However, after the change, HIP toolchain now use clang to generate IR, do optimization,
and generate ISA as one process. Now amdgpu backend fp fuse option is determined
by -ffp-contract option, which is 'fast' by default. And this -ffp-contract=fast language option
is translated to 'Fast' fp fuse option in backend. Suddenly backend starts to fuse fmul/fadd
instructions without contract flag.

This causes wrong result for some device library functions, e.g. tan(-1e20), which should
return 0.8446, now returns -0.933. What is worse is that since backend with 'Fast' fp fuse
option does not respect contract flag, there is no way to use #pragma clang fp contract
directive to enforce fp contract requirements.

This patch fixes the regression by introducing a new value 'fast-honor-pragmas' for -ffp-contract
and use it for HIP by default. 'fast-honor-pragmas' is equivalent to 'fast' in frontend but
let the backend to use 'Standard' fp fuse option. 'fast-honor-pragmas' is useful since 'Fast'
fp fuse option in backend does not honor contract flag, it is of little use to HIP
applications since all code with #pragma STDC FP_CONTRACT or any IR from a
source compiled with -ffp-contract=on is broken.

Differential Revision: https://reviews.llvm.org/D90174
2020-11-24 08:10:06 -05:00
Hans Wennborg 38236656ab [docs] Try to make this bullet list in ThinLTO.rst actually be a bullet list 2020-11-24 14:08:42 +01:00
John Paul Adrian Glaubitz c2fb114475 [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux
This fixes the Builtins-sparc-linux testsuite failures on Linux
SPARC which occur because clang cannot find the 32-bit runtime
libraries when -m32 is passed on the command line. The same
workaround is already being used on X86 and PPC.

Also, switch the CHECK-DEBIAN-SPARC tests to use debian_multiarch_tree
as both sparc and sparc64 are using the MultiArch mechanism on modern Debian
systems the same way as x86_64, powerpc64el and others. Thus, switch the
CHECK-DEBIAN-SPARC32 and CHECK-DEBIAN-SPARC64 tests to use the files from
the debian_multiarch_tree directory for the header and linker path tests.

Finally, rename CHECK-DEBIAN-SPARC32 to CHECK-DEBIAN-SPARC to match the naming
scheme of the Debian MultiArch checks for the other Debian architectures.

Reviewed By: MaskRay, phosek

Differential Revision: https://reviews.llvm.org/D90524
2020-11-23 19:25:36 -08:00
Ben Dunbobbin e42021d5cc [Clang][-fvisibility-from-dllstorageclass] Set DSO Locality from final visibility
Ensure that the DSO Locality of the globals in the IR is derived from
their final visibility when using -fvisibility-from-dllstorageclass.

To accomplish this we reset the DSO locality of globals (before
setting their visibility from their dllstorageclass) at the end of
IRGen in Clang. This removes any effects that visibility options or
annotations may have had on the DSO locality.

The resulting DSO locality of the globals will be pessimistic
w.r.t. to the normal compiler IRGen.

Differential Revision: https://reviews.llvm.org/D91779
2020-11-24 00:32:14 +00:00
Saleem Abdulrasool f6b02ecd02 APINotes: add property models for YAML attributes
This adds internal representation of the attributes in a more usable
form.  This is meant to allow programmatic access to the attributes that
are specified in the YAML data.

This is based upon the work contributed by Apple at
https://github.com/llvm/llvm-project-staging/tree/staging/swift/apinotes.

Differential Revision: https://reviews.llvm.org/D91104
Reviewed By: Gabor Marton
2020-11-23 21:29:17 +00:00
Reid Kleckner 64802d48d5 Make check-clang depend on the LLVM split-file utility
Fixes a recently added test that has this dependency. IMO this utility
is generally useful, so we should go ahead and take the new dependency.
2020-11-23 12:21:44 -08:00
Craig Topper b3f1b19c9c [AArch64] Update clang CodeGen tests I missed in 4252f7773a.
These tests invoke opt and llc even though they are in the frontend.

We now do a better job of generating commuted patterns for fma so
these tests now form fmls instead of fmla+fneg.
2020-11-23 11:10:27 -08:00
Nico Weber 47eb5ce19a [mac/arm] fix clang/test/Driver/darwin-ld-dedup.c
The test needs an object file, which it currenty gets with
`-target x86_64-apple-darwin10`.  Rather than adding `REQUIRES: X86`, create
the object file via yaml2obj. This way, the test runs and passes even if the
host arch isn't x86 and only the host arch is built.

Part of PR46644.
2020-11-23 13:32:29 -05:00
Nico Weber e0e334a9c1 [mac/arm] make clang/test/Driver/clang_f_opts.c pass consistently
Part of PR46644, see comment 7/8.
2020-11-23 12:56:52 -05:00
Stephen Kelly 5e1801813d Remove the IgnoreImplicitCastsAndParentheses traversal kind
Differential Revision: https://reviews.llvm.org/D91918
2020-11-23 14:27:48 +00:00
Stephen Kelly f052cf494f Update mode used in traverse() examples
traverse() predates the IgnoreUnlessSpelledInSource mode. Update example
and test code to use the newer mode.

Differential Revision: https://reviews.llvm.org/D91917
2020-11-23 14:27:48 +00:00
Stephen Kelly 72a9f365e9 Remove automatic traversal from forEach matcher
Differential Revision: https://reviews.llvm.org/D91916
2020-11-23 14:27:47 +00:00
Jann Horn 00dad9d028 Ignore noderef attribute in unevaluated context
The noderef attribute is for catching code that accesses pointers in
a different address space. Unevaluated code is always safe in that regard.
2020-11-23 08:10:35 -05:00
Joe Ellis 3c696a212b [AArch64][SVE] Allow lax conversion between VLATs and GNU vectors
Previously, lax conversions were only allowed between SVE vector-length
agnostic types and vector-length specific types. This meant that code
such as the following:

    #include <arm_sve.h>
    #define N __ARM_FEATURE_SVE_BITS
    #define FIXED_ATTR __attribute__ ((vector_size (N/8)))
    typedef float fixed_float32_t FIXED_ATTR;

    void foo() {
        fixed_float32_t fs32;
        svfloat64_t s64;
        fs32 = s64;
    }

was not allowed.

This patch makes a minor change to areLaxCompatibleSveTypes to allow for
lax conversions to be performed between SVE vector-length agnostic types
and GNU vectors.

Differential Revision: https://reviews.llvm.org/D91696
2020-11-23 10:47:17 +00:00
Haojian Wu b1444edbf4 [AST] Build recovery expression by default for all language.
The dependency mechanism for C has been implemented, and we have rolled out
this to all internal users, didn't see crashy issues, we consider it is stable
enough.

Differential Revision: https://reviews.llvm.org/D89046
2020-11-23 11:08:28 +01:00
Zequan Wu 15a3ae1ab1 [Clang] Add __STDCPP_THREADS__ to standard predefine macros
According to https://eel.is/c++draft/cpp.predefined#2.6, `__STDCPP_THREADS__` is a predefined macro.

Differential Revision: https://reviews.llvm.org/D91747
2020-11-22 16:05:53 -08:00