Commit Graph

60687 Commits

Author SHA1 Message Date
mydeveloperday 8668eae2ad [clang-format] Add option for case sensitive regexes for sorted includes
I think the title says everything.

Reviewed By: MyDeveloperDay

Patch By:  HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D91507
2020-12-05 16:33:21 +00:00
Fangrui Song 1ab9327d1c [TargetMachine][CodeGenModule] Delete unneeded ppc32 special case from shouldAssumeDSOLocal
PPCMCInstLower does not actually call shouldAssumeDSOLocal for ppc32 so this is dead.
Actually Clang ppc32 does produce a pair of absolute relocations which match GCC.

This also fixes a comment (R_PPC_COPY and R_PPC64_COPY do exist).
2020-12-05 00:42:07 -08:00
Hsiangkai Wang 5e953a274b [RISCV] Define preprocessor definitions for 'V' extension.
Differential Revision: https://reviews.llvm.org/D92650
2020-12-05 08:34:32 +08:00
Alex Lorenz db226cdf4c [objc] diagnose protocol conformance in categories with direct members
in their corresponding class interfaces

Categories that add protocol conformances to classes with direct members should prohibit protocol
conformances when the methods/properties that the protocol expects are actually declared as 'direct' in the class.

Differential Revision: https://reviews.llvm.org/D92602
2020-12-04 15:55:34 -08:00
Alex Lorenz eddd1d192b [clang] add a `swift_async_name` attribute
The swift_async_name attribute provides a name for a function/method that can be used
to call the async overload of this method from Swift. This name specified in this attribute
assumes that the last parameter in the function/method its applied to is removed when
Swift invokes it, as the the Swift's await/async transformation implicitly constructs the callback.

Differential Revision: https://reviews.llvm.org/D92355
2020-12-04 15:55:29 -08:00
Alex Lorenz 03dcd57ecf [clang] add a new `swift_attr` attribute
The swift_attr attribute is a generic annotation attribute that's not used by clang,
but is used by the Swift compiler. The Swift compiler can use these annotations to provide
various syntactic and semantic sugars for the imported Objective-C API declarations.

Differential Revision: https://reviews.llvm.org/D92354
2020-12-04 15:53:24 -08:00
Duncan P. N. Exon Smith d126943251 Index: Remove unused internal header SimpleFormatContext.h, NFC
Looks like nothing has included this header since
d21485d2f5 / r286279 in 2016. Delete the
dead code.
2020-12-04 15:10:27 -08:00
shafik 6333871f85 Add diagnostic for for-range-declaration being specificed with thread_local
Currently we have a diagnostic that catches the other storage class specifies for the range based for loop declaration but we miss the thread_local case. This changes adds a diagnostic for that case as well.

Differential Revision: https://reviews.llvm.org/D92671
2020-12-04 15:06:35 -08:00
Duncan P. N. Exon Smith b4f4fc6872 ASTImporter: Migrate to the FileEntryRef overload of SourceManager::createFileID, NFC
Migrate `ASTImporter::Import` over to using the `FileEntryRef` overload
of `SourceManager::createFileID`. No functionality change here.

Differential Revision: https://reviews.llvm.org/D92529
2020-12-04 14:45:59 -08:00
Duncan P. N. Exon Smith 9ae0a46f2b ARCMigrate: Initialize fields in EditEntry inline, NFC
Initialize the fields inline instead of having to manually write out a
default constructor.

Differential Revision: https://reviews.llvm.org/D92597
2020-12-04 14:43:22 -08:00
Duncan P. N. Exon Smith 1b023f54b6 Frontend: Use translateLineCol instead of translateFileLineCol, NFC
`ParseDirective` in VerifyDiagnosticConsumer.cpp is already calling
`translateFile`, so use the `FileID` returned by that to call
`translateLineCol` instead of using the more heavyweight
`translateFileLineCol`.

No functionality change here.
2020-12-04 14:37:48 -08:00
Alexey Bataev d764ad72e5 [OPENMP]Fix PR48394: need to capture variables used in atomic constructs.
The variables used in atomic construct should be captured in outer
task-based regions implicitly. Otherwise, the compiler will crash trying
to find the address of the local variable.

Differential Revision: https://reviews.llvm.org/D92682
2020-12-04 13:08:54 -08:00
Sam McCall 650e04e179 [Tooling] JSONCompilationDatabase::loadFromBuffer retains the buffer, copy it.
This function doesn't seem to be used in-tree outside tests.
However clangd wants to use it soon, and having the CDB be self-contained seems
reasonable.

Differential Revision: https://reviews.llvm.org/D92646
2020-12-04 21:54:55 +01:00
Duncan P. N. Exon Smith d10f9863a5 ADT: Migrate users of AlignedCharArrayUnion to std::aligned_union_t, NFC
Prepare to delete `AlignedCharArrayUnion` by migrating its users over to
`std::aligned_union_t`.

I will delete `AlignedCharArrayUnion` and its tests in a follow-up
commit so that it's easier to revert in isolation in case some
downstream wants to keep using it.

Differential Revision: https://reviews.llvm.org/D92516
2020-12-04 12:34:49 -08:00
Artem Belevich 4326792942 [CUDA] Another attempt to fix early inclusion of <new> from libstdc++
Previous patch (9a465057a6) did not fix the problem.
https://bugs.llvm.org/show_bug.cgi?id=48228

If the <new> is included too early, before CUDA-specific defines are available,
just include-next the standard <new> and undo the include guard.  CUDA-specific
variants of operator new/delete will be declared if/when <new> is used from the
CUDA source itself, when all CUDA-related macros are available.

Differential Revision: https://reviews.llvm.org/D91807
2020-12-04 12:03:35 -08:00
Duncan P. N. Exon Smith 5b267fb796 ADT: Stop peeking inside AlignedCharArrayUnion, NFC
Update all the users of `AlignedCharArrayUnion` to stop peeking inside
(to look at `buffer`) so that a follow-up patch can replace it with an
alias to `std::aligned_union_t`.

This was reviewed as part of https://reviews.llvm.org/D92512, but I'm
splitting this bit out to commit first to reduce churn in case the
change to `AlignedCharArrayUnion` needs to be reverted for some
unexpected reason.
2020-12-04 11:07:42 -08:00
Hafiz Abid Qadeer ca2888310b Don't use sysroot/include when sysroot is empty.
Baremetal toolchain add Driver.SysRoot/include to the system include
paths without checking if Driver.SysRoot is empty. This resulted in
"-internal-isystem" "include" in the command. This patch adds check for
empty sysroot.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D92176
2020-12-04 18:33:24 +00:00
mydeveloperday 840e651dc6 [clang-format] Improve clang-formats handling of concepts
This is a starting point to improve the handling of concepts in clang-format. There is currently no real formatting of concepts and this can lead to some odd formatting, e.g.

Reviewed By: mitchell-stellar, miscco, curdeius

Differential Revision: https://reviews.llvm.org/D79773
2020-12-04 17:45:50 +00:00
Alexey Bataev 2502f89954 [OPENMP]Fix PR48387: disable warning messages caused by internal conversions.
Compiler needs to convert some of the loop iteration
variables/conditions to different types for better codegen and it may
lead to spurious warning messages about implicit signed/unsigned
conversions.

Differential Revision: https://reviews.llvm.org/D92655
2020-12-04 07:44:36 -08:00
Erik Pilkington 090dd647d9 [Sema] Fold VLAs to constant arrays in a few more contexts
552c6c2 removed support for promoting VLAs to constant arrays when the bounds
isn't an ICE, since this can result in miscompiling a conforming program that
assumes that the array is a VLA. Promoting VLAs for fields is still supported,
since clang doesn't support VLAs in fields, so no conforming program could have
a field VLA.

This change is really disruptive, so this commit carves out two more cases
where we promote VLAs which can't miscompile a conforming program:

 - When the VLA appears in an ivar -- this seems like a corollary to the field thing
 - When the VLA has an initializer -- VLAs can't have an initializer

Differential revision: https://reviews.llvm.org/D90871
2020-12-04 10:03:23 -05:00
Yaxun (Sam) Liu 0519e1ddb3 [HIP] Fix bug in driver about wavefront size
The static variable causes it only initialized once and take
the same value for different GPU archs, whereas they
may be different for different GPU archs, e.g. when
there are both gfx900 and gfx1010.

Removing static fixes that.

Differential Revision: https://reviews.llvm.org/D92628
2020-12-04 08:36:52 -05:00
Martin Storsjö c17fdca188 [clang] [Headers] Use the corresponding _aligned_free or __mingw_aligned_free in _mm_free
Differential Revision: https://reviews.llvm.org/D92570
2020-12-04 11:34:12 +02:00
David Blaikie c4af1c8d93 PR48383: Disallow decltype(auto) in pseudodestructor calls 2020-12-03 20:41:06 -08:00
Duncan P. N. Exon Smith 99b823c2eb Frontend: Remove redundant call to CompilerInstance::setFileManager, NFC
`ASTUnit::Parse` sets up the `FileManager` earlier in the same function,
ensuring `ASTUnit::getFileManager()` matches `Clang->getFileManager()`.
Remove the later call to `setFileManager(getFileManager())` since it
does nothing.

Differential Revision: https://reviews.llvm.org/D90888
2020-12-03 16:10:59 -08:00
Richard Smith eccc734a69 P0857R0: Parse a requires-clause after an explicit
template-parameter-list in a lambda.

This implements one of the missing parts of P0857R0. Mark it as not done
on the cxx_status page given that it's still incomplete.
2020-12-03 15:54:16 -08:00
Richard Smith be162f4c0e PR45699: Fix crash if an unexpanded parameter pack appears in a
requires-clause.
2020-12-03 15:26:06 -08:00
Aaron En Ye Shi ba2612ce01 [HIP] cmath demote long double args to double
Since there is no ROCm Device Library support for
long double, demote them to double, and use the fp64
math functions.

Differential Revision: https://reviews.llvm.org/D92130
2020-12-03 23:00:14 +00:00
Ahmed Bougacha f77c948d56 [Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth.
This also teaches MachO writers/readers about the MachO cpu subtype,
beyond the minimal subtype reader support present at the moment.

This also defines a preprocessor macro to allow users to distinguish
__arm64__ from __arm64e__.

arm64e defaults to an "apple-a12" CPU, which supports v8.3a, allowing
pointer-authentication codegen.
It also currently defaults to ios14 and macos11.

Differential Revision: https://reviews.llvm.org/D87095
2020-12-03 07:53:59 -08:00
Nathan James aa1155634f
[ASTMatchers][NFC] Made variadic operator funcs static
Fix naming style while were here too.
2020-12-03 15:47:54 +00:00
Nico Weber 0cbf61be8b [mac/arm] Fix rtti codegen tests when running on an arm mac
shouldRTTIBeUnique() returns false for iOS64CXXABI, which causes
RTTI objects to be emitted hidden. Update two tests that didn't
expect this to happen for the default triple.

Also rename iOS64CXXABI to AppleARM64CXXABI, since it's used for
arm64-apple-macos triples too.

Part of PR46644.

Differential Revision: https://reviews.llvm.org/D91904
2020-12-03 09:11:03 -05:00
Nico Weber 68f2ff59d1 clang/darwin: Don't use response files with ld64
This morally reverts D82777 -- turns out that ld64 crashes with many
response files, so we must stop passing them to it until the crash is
fixed.

Differential Revision: https://reviews.llvm.org/D92357
2020-12-03 09:00:10 -05:00
Kazushi (Jam) Marukawa 7d30df7b59 [VE] Add standard include path and library path for C++
We have a plan to add libcxx and libcxxabi for VE.  In order to do so,
we need to compile cxx source code with bootstarapped header files.
This patch adds such expected path to make clang++ work, at least
not crash at the startup.  Add regression test for that, also.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D92386
2020-12-03 22:22:56 +09:00
Tim Northover 152df3add1 arm64: count Triple::aarch64_32 as an aarch64 target and enable leaf frame pointers 2020-12-03 11:09:44 +00:00
Gabor Marton 1e14588d0f [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs
http://lists.llvm.org/pipermail/cfe-dev/2020-November/067252.html

Differential Revision: https://reviews.llvm.org/D92101
2020-12-03 11:35:47 +01:00
Marek Kurdej fe21c86ee7 [clang-format] De-duplicate includes with leading or trailing whitespace.
This fixes PR46555 (https://bugs.llvm.org/show_bug.cgi?id=46555).

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D88296
2020-12-03 10:59:46 +01:00
Marek Kurdej 6627a3c287 [c++2b] Add option -std=c++2b to enable support for potential C++2b features.
Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D92547
2020-12-03 10:27:47 +01:00
Richard Smith c4fb7720ce PR48339: Improve diagnostics for invalid dependent unqualified function calls.
Fix bogus diagnostics that would get confused and think a "no viable
fuctions" case was an "undeclared identifiers" case, resulting in an
incorrect diagnostic preceding the correct one. Use overload resolution
to determine which function we should select when we can find call
candidates from a dependent base class. Make the diagnostics for a call
that could call a function from a dependent base class more specific,
and use a different diagnostic message for the case where the call
target is instead declared later in the same class. Plus some minor
diagnostic wording improvements.
2020-12-02 17:54:55 -08:00
Duncan P. N. Exon Smith b346322019 Revert "Frontend: Sink named pipe logic from CompilerInstance down to FileManager"
This reverts commit 3b18a594c7, since
apparently this doesn't work everywhere. E.g.,
clang-x86_64-debian-fast/3889
(http://lab.llvm.org:8011/#/builders/109/builds/3889) gives me:
```
+ : 'RUN: at line 8'
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -x c /dev/fd/0 -E
+ cat /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Misc/dev-fd-fs.c
fatal error: file '/dev/fd/0' modified since it was first processed
1 error generated.
```
2020-12-02 17:36:20 -08:00
Hsiangkai Wang 432d05174e [RISCV] Handle zfh in the arch string.
Differential Revision: https://reviews.llvm.org/D91315
2020-12-03 09:16:44 +08:00
Duncan P. N. Exon Smith 3b18a594c7 Frontend: Sink named pipe logic from CompilerInstance down to FileManager
Remove compilicated logic from CompilerInstance::InitializeSourceManager
to deal with named pipes, updating FileManager::getBufferForFile to
handle it in a more straightforward way. The existing test at
clang/test/Misc/dev-fd-fs.c covers the new behaviour (just like it did
the old behaviour).

Differential Revision: https://reviews.llvm.org/D90733
2020-12-02 17:14:27 -08:00
Duncan P. N. Exon Smith dcc4f7f3c4 ARCMigrate: Stop abusing PreprocessorOptions for passing back file remappings, NFC
As part of reducing use of PreprocessorOptions::RemappedFileBuffers,
stop abusing it to pass information around remapped files in
`ARCMigrate`.  This simplifies an eventual follow-up to switch to using
an `InMemoryFileSystem` for this.

Differential Revision: https://reviews.llvm.org/D90887
2020-12-02 16:28:33 -08:00
Yaxun (Sam) Liu 3a781b912f Fix assertion in tryEmitAsConstant
due to cd95338ee3

Need to check if result is LValue before getLValueBase.
2020-12-02 19:10:01 -05:00
Duncan P. N. Exon Smith 32c501dd88 Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and DirectoryName, NFC
Push `FileEntryRef` and `DirectoryEntryRef` further, using it them
`Module::Umbrella`, `Module::Header::Entry`, and
`Module::DirectoryName::Entry`.

- Add `DirectoryEntryRef::operator const DirectoryEntry *` and
  `OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr`, to get the
  same "degrades to `DirectoryEntry*` behaviour `FileEntryRef` enjoys
  (this avoids a bunch of churn in various clang tools).
- Fix the `DirectoryEntryRef` constructor from `MapEntry` to take it by
  `const&`.

Note that we cannot get rid of the `...AsWritten` names leveraging the
new classes, since these need to be as written in the `ModuleMap` file
and the module directory path is preprended for the lookup in the
`FileManager`.

Differential Revision: https://reviews.llvm.org/D90497
2020-12-02 14:07:23 -08:00
Hongtao Yu 24d4291ca7 [CSSPGO] Pseudo probes for function calls.
An indirect call site needs to be probed for its potential call targets. With CSSPGO a direct call also needs a probe so that a calling context can be represented by a stack of callsite probes. Unlike pseudo probes for basic blocks that are in form of standalone intrinsic call instructions, pseudo probes for callsites have to be attached to the call instruction, thus a separate instruction would not work.

One possible way of attaching a probe to a call instruction is to use a special metadata that carries information about the probe. The special metadata will have to make its way through the optimization pipeline down to object emission. This requires additional efforts to maintain the metadata in various places. Given that the `!dbg` metadata is a first-class metadata and has all essential support in place , leveraging the `!dbg` metadata as a channel to encode pseudo probe information is probably the easiest solution.

With the requirement of not inflating `!dbg` metadata that is allocated for almost every instruction, we found that the 32-bit DWARF discriminator field which mainly serves AutoFDO can be reused for pseudo probes. DWARF discriminators distinguish identical source locations between instructions and with pseudo probes such support is not required. In this change we are using the discriminator field to encode the ID and type of a callsite probe and the encoded value will be unpacked and consumed right before object emission. When a callsite is inlined, the callsite discriminator field will go with the inlined instructions. The `!dbg` metadata of an inlined instruction is in form of a scope stack. The top of the stack is the instruction's original `!dbg` metadata and the bottom of the stack is for the original callsite of the top-level inliner. Except for the top of the stack, all other elements of the stack actually refer to the nested inlined callsites whose discriminator field (which actually represents a calliste probe) can be used together to represent the inline context of an inlined PseudoProbeInst or CallInst.

To avoid collision with the baseline AutoFDO in various places that handles dwarf discriminators where a check against  the `-pseudo-probe-for-profiling` switch is not available, a special encoding scheme is used to tell apart a pseudo probe discriminator from a regular discriminator. For the regular discriminator, if all lowest 3 bits are non-zero, it means the discriminator is basically empty and all higher 29 bits can be reversed for pseudo probe use.

Callsite pseudo probes are inserted in `SampleProfileProbePass` and a target-independent MIR pass `PseudoProbeInserter` is added to unpack the probe ID/type from `!dbg`.

Note that with this work the switch -debug-info-for-profiling will not work with -pseudo-probe-for-profiling anymore. They cannot be used at the same time.

Reviewed By: wmi

Differential Revision: https://reviews.llvm.org/D91756
2020-12-02 13:45:20 -08:00
Yaxun (Sam) Liu acb6f80d96 [CUDA][HIP] Fix overloading resolution
This patch implements correct hostness based overloading resolution
in isBetterOverloadCandidate.

Based on hostness, if one candidate is emittable whereas the other
candidate is not emittable, the emittable candidate is better.

If both candidates are emittable, or neither is emittable based on hostness, then
other rules should be used to determine which is better. This is because
hostness based overloading resolution is mostly for determining
viability of a function. If two functions are both viable, other factors
should take precedence in preference.

If other rules cannot determine which is better, CUDA preference will be
used again to determine which is better.

However, correct hostness based overloading resolution
requires overloading resolution diagnostics to be deferred,
which is not on by default. The rationale is that deferring
overloading resolution diagnostics may hide overloading reslolutions
issues in header files.

An option -fgpu-exclude-wrong-side-overloads is added, which is off by
default.

When -fgpu-exclude-wrong-side-overloads is off, keep the original behavior,
that is, exclude wrong side overloads only if there are same side overloads.
This may result in incorrect overloading resolution when there are no
same side candates, but is sufficient for most CUDA/HIP applications.

When -fgpu-exclude-wrong-side-overloads is on, enable deferring
overloading resolution diagnostics and enable correct hostness
based overloading resolution, i.e., always exclude wrong side overloads.

Differential Revision: https://reviews.llvm.org/D80450
2020-12-02 16:33:33 -05:00
Dan Albert 0849047860 Add a less ambiguous macro for Android version.
Android has a handful of API levels relevant to developers described
here: https://developer.android.com/studio/build#module-level.
`__ANDROID_API__` is too vague and confuses a lot of people. Introduce
a new macro name that is explicit about which one it represents. Keep
the old name around because code has been using it for a decade.
2020-12-02 13:26:28 -08:00
Richard Smith 2ac5880187 Update MS ABI mangling for union constants based on new information from
Jon Caves.
2020-12-02 12:17:52 -08:00
jasonliu a65d8c5d72 [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX
Summary:
AIX uses the existing EH infrastructure in clang and llvm.
The major differences would be
1. AIX do not have CFI instructions.
2. AIX uses a new personality routine, named __xlcxx_personality_v1.
   It doesn't use the GCC personality rountine, because the
   interoperability is not there yet on AIX.
3. AIX do not use eh_frame sections. Instead, it would use a eh_info
section (compat unwind section) to store the information about
personality routine and LSDA data address.

Reviewed By: daltenty, hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D91455
2020-12-02 18:42:44 +00:00
Gabor Marton b40b3196b3 [analyzer][StdLibraryFunctionsChecker] Add return value constraint to functions with BufferSize
Differential Revision: https://reviews.llvm.org/D92474
2020-12-02 17:54:48 +01:00
Michael Liao d8949a8ad3 [hip] Fix host object creation from fatbin
- `__hip_fatbin` should a symbol in `.hip_fatbin` section.

Differential Revision: https://reviews.llvm.org/D92418
2020-12-02 10:36:01 -05:00