Commit Graph

93782 Commits

Author SHA1 Message Date
Mitch Phillips 8aa1490513 [MTE] Add -fsanitize=memtag* and friends.
Currently, enablement of heap MTE on Android is specified by an ELF note, which
signals to the linker to enable heap MTE. This change allows
-fsanitize=memtag-heap to synthesize these notes, rather than adding them
through the build system. We need to extend this feature to also signal the
linker to do special work for MTE globals (in future) and MTE stack (currently
implemented in the toolchain, but not implemented in the loader).

Current Android uses a non-backwards-compatible ELF note, called
".note.android.memtag". Stack MTE is an ABI break anyway, so we don't mind that
we won't be able to run executables with stack MTE on Android 11/12 devices.

The current expectation is to support the verbiage used by Android, in
that "SYNC" means MTE Synchronous mode, and "ASYNC" effectively means
"fast", using the Kernel auto-upgrade feature that allows
hardware-specific and core-specific configuration as to whether "ASYNC"
would end up being Asynchronous, Asymmetric, or Synchronous on that
particular core, whichever has a reasonable performance delta. Of
course, this is platform and loader-specific.

Differential Revision: https://reviews.llvm.org/D118948
2022-04-08 12:13:15 -07:00
Jorge Gorbe Moya 7dcd698875 Use writable temporary file for test compiler output instead of hardcoded name. NFCI. 2022-04-08 10:57:27 -07:00
Chris Bieneman 9e3678e161 [Clang] [Docs] Add HLSLSupport page
This document is a first-stab at addressing some of the questions about
HLSL support in Clang.

Differential Revision: https://reviews.llvm.org/D123278
2022-04-08 12:17:45 -05:00
Siu Chi Chan 0f6cbdee57
[clang-offload-bundler] fix "no output file" issue with -outputs
Fix backward compatibility issue due to D120662.

Change-Id: I7cd0f704aabbaac7dcf59fd4b73b4f0e0cdfa69f

Reviewed By: yaxunl, saiislam

Differential Revision: https://reviews.llvm.org/D123387
2022-04-08 17:11:27 +00:00
Daniel Grumberg 80ae366592 [clang][extract-api] Emit "navigator" property of "name" in SymbolGraph
Differential Revision: https://reviews.llvm.org/D123391
2022-04-08 17:29:00 +01:00
Aaron Ballman be93716593 Clarify language option default value behavior; NFC
The LANGOPT macro allows you to specify a default value for the
langauge option. However, it's expected that these values be constant
rather than depending on other language options (because the
constructor setting the default values does not know the language mode
at the time it's being constructed).

Some of our language options were abusing this and passing in other
language mode options which were then set correctly by other parts of
frontend initialization. This removes the default values for the
language options, and then ensures they're consistently set from the
same place when setting language standard defaults.
2022-04-08 10:26:16 -04:00
Joseph Huber ae377575b2 [OpenMP] Remove help and documentation for old flag
Summary:
The `-fopenmp-target-new-runtime` flag has not been used for awhile. It
was present in a previous release so we shouldn't remove it for
backwards compatibility, but we shouldn't have documentation or a help
message for it.
2022-04-08 10:16:33 -04:00
Nikita Popov 692a147bf4 [CGCall] Make findDominatingStoreToReturnValue() more robust
This was skipping specific lifetime + bitcast patterns, but with
opaque pointers the bitcast will not be present, and we did not
perform this fold.

Instead skip over lifetime.end and bitcasts generally, without
trying to correlate them.
2022-04-08 15:18:12 +02:00
Sven van Haastregt 1331ad22c3 [OpenCL] Add generic addrspace guards for get_fence
Align guards of these builtins with opencl-c.h.
2022-04-08 12:08:10 +01:00
Kito Cheng f922dbb792 Revert "Reland "[RISCV][NFC] Moving RVV intrinsic type related util to llvm/Support""
This reverts commit fc2d8326ae.
2022-04-08 16:20:19 +08:00
Kristóf Umann fd8e5762f8 [analyzer] Don't track function calls as control dependencies
I recently evaluated ~150 of bug reports on open source projects relating to my
GSoC'19 project, which was about tracking control dependencies that were
relevant to a bug report.

Here is what I found: when the condition is a function call, the extra notes
were almost always unimportant, and often times intrusive:

void f(int *x) {
  x = nullptr;
  if (alwaysTrue()) // We don't need a whole lot of explanation
                    // here, the function name is good enough.
    *x = 5;
}
It almost always boiled down to a few "Returning null pointer, which participates
in a condition later", or similar notes. I struggled to find a single case
where the notes revealed anything interesting or some previously hidden
correlation, which is kind of the point of condition tracking.

This patch checks whether the condition is a function call, and if so, bails
out.

The argument against the patch is the popular feedback we hear from some of our
users, namely that they can never have too much information. I was specifically
fishing for examples that display best that my contribution did more good than
harm, so admittedly I set the bar high, and one can argue that there can be
non-trivial trickery inside functions, and function names may not be that
descriptive.

My argument for the patch is all those reports that got longer without any
notable improvement in the report intelligibility. I think the few exceptional
cases where this patch would remove notable information are an acceptable
sacrifice in favor of more reports being leaner.

Differential Revision: https://reviews.llvm.org/D116597
2022-04-08 10:16:58 +02:00
Iain Sandoe f60dc3caa6 [C++20][Modules] Adjust handling of exports of namespaces and using-decls.
This adjusts the handling for:

export module  M;

export namespace {};

export namespace N {};
export using namespace N;

In the first case, we were allowing empty anonymous namespaces
as part of an extension allowing empty top-level entities, but that seems
inappropriate in this case, since the linkage would be internal for the
anonymous namespace.  We now report an error for this.

The second case was producing a warning diagnostic that this was
accepted as an extension - however the C++20 standard does allow this
as well-formed.

In the third case we keep the current practice that this is accepted with a
warning (as an extension). The C++20 standard says it's an error.

We also ensure that using decls are only applied to items with external linkage.

This adjusts error messages for exports involving redeclarations in modules to
be more specific about the reason that the decl has been rejected.

Differential Revision: https://reviews.llvm.org/D122119
2022-04-08 08:57:37 +01:00
serge-sans-paille 301e0d9135 [Clang][Fortify] drop inline decls when redeclared
When an inline builtin declaration is shadowed by an actual declaration, we must
reference the actual declaration, even if it's not the last, following GCC
behavior.

This fixes #54715

Differential Revision: https://reviews.llvm.org/D123308
2022-04-08 09:31:51 +02:00
Jan Svoboda b672638dbc [clang][deps] Ensure deterministic filename case
The dependency scanner can reuse single FileManager instance across multiple translation units. This may lead to non-deterministic output depending on which TU gets processed first.

One of the problems is that Clang uses DirectoryEntry::getName in the header search algorithm. This function returns the path that was first used to construct the (shared) entry in FileManager. Using DirectoryEntryRef::getName instead preserves the case as it was spelled out for the current "get directory entry" request.

rdar://90647508

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D123229
2022-04-08 09:18:00 +02:00
Kito Cheng fc2d8326ae Reland "[RISCV][NFC] Moving RVV intrinsic type related util to llvm/Support"
Reland Note: We've resolve the circular dependency issue on llvm/lib/Support and
llvm/TableGen.

Differential Revision: https://reviews.llvm.org/D121984
2022-04-08 15:09:03 +08:00
Chuanqi Xu 74b56e02bd [NFC] Remove unused variable in CodeGenModules
This eliminates an unused-variable warning
2022-04-08 11:52:31 +08:00
David Blaikie 1cee3d9db7 DebugInfo: Consider the type of NTTP when simplifying template names
Since the NTTP may need to be cast to the type when rebuilding the name,
check that the type can be rebuilt when determining whether a template
name can be simplified.
2022-04-08 00:00:46 +00:00
Quinn Pham fef56f79ac Revert "[PowerPC] Fix EmitPPCBuiltinExpr to emit arguments once"
This reverts commit 2aae5b1fac. Because it
breaks tests on windows.
2022-04-07 16:45:19 -05:00
Quinn Pham 2aae5b1fac [PowerPC] Fix EmitPPCBuiltinExpr to emit arguments once
This patch changes `EmitPPCBuiltinExpr` in `CGBuiltin.cpp` to remove
the loop at the beginning of the function that emits the arguments and
to delay emitting the arguments until inside the switch statement. These
changes will put `EmitPPCBuiltinExpr` in line with the strategy of the
target independent function `EmitBuiltinExpr`. Also, this patch
ensures that arguments are only emitted once.

Tests that included builtins affected by these changes have been
modified to match expected behaviour.

Reviewed By: #powerpc, nemanjai, amyk

Differential Revision: https://reviews.llvm.org/D121637
2022-04-07 16:00:12 -05:00
Emil Kieri da1fc3ae95 [Driver][NFC] Simplify handling of flags in Options.td
We aim at improving the readability and maintainability of Options.td,
and in particular its handling of 'Flags', by
 - limiting the extent of 'let Flags = [...] in {'s, and
 - adding closing comments to matching '}'s.
 - being more consistent about empty lines around 'let Flags' and '}'.

More concretely,
 - we do not let a 'let Flags' span across several headline comments.
   When all 'def's in two consecutive headlines share the same flags,
   we stil close and start a new 'let Flags' at the intermediate
   headline.
 - when a 'let Flags' span just one or two 'def's, set 'Flags' within
   the 'def's instead.
 - we remove nested 'let Flags'.

Note that nested 'let Flags' can be quite confusing, especially when
the outer was started long before the inner. Moving a 'def' out of the
inner 'let Flags' and setting 'Flags' within the 'def' will not have the
intended effect, as those flags will be overridden by the outer
'let Flags'.

Reviewed By: awarzynski, jansvoboda11, hans

Differential Revision: https://reviews.llvm.org/D123070
2022-04-07 20:38:51 +02:00
Alex Brachet 50de659adc [clang] Use -triple, not -target for %clang_cc1 2022-04-07 18:19:54 +00:00
Alex Brachet 3329dae5cb [clang] Fix macos build broken after D120989 2022-04-07 18:17:29 +00:00
Daniel Grumberg 1015592251 [clang][extract-api][NFC] Use dedicated API to check for macro equality
Differential Revision: https://reviews.llvm.org/D123295
2022-04-07 19:08:17 +01:00
Pavel Samolysov b4ac84901e [clang][NFC] Extract EmitAssemblyHelper::shouldEmitRegularLTOSummary
The code to check if the regular LTO summary should be emitted and to
add the corresponding module flags was duplicated in the
'EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager' and
'EmitAssemblyHelper::RunOptimizationPipeline' methods.

In order to eliminate these code duplications, the
'EmitAssemblyHelper::shouldEmitRegularLTOSummary' method has been
extracted. The method returns a bool value, the value is 'true' if the
module summary should be emitted. The patch keeps the setting of the
module flags inline.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D123026
2022-04-07 10:38:46 -07:00
Zixu Wang 4048aad85a [clang][ExtractAPI] Fix declaration fragments for ObjC methods
Objective-C methods selector parts should be considered as identifiers.

Depends on D123259

Differential Revision: https://reviews.llvm.org/D123261
2022-04-07 10:22:41 -07:00
Daniel Grumberg aebe5fc6e7 [clang][extract-api] Process only APIs declared in inputs
We should only process APIs declared in the command line inputs to avoid
drowning the ExtractAPI output with symbols the user doesn't care about.
This is achieved by keeping track of the provided input files and
checking that the associated Decl or Macro is declared in one of those files.

Differential Revision: https://reviews.llvm.org/D123148
2022-04-07 17:49:05 +01:00
Zixu Wang fe2c77a006 [clang][ExtractAPI] Fix appendSpace in DeclarationFragments
There is a bug in `DeclarationFragments::appendSpace` where the space
character is added to a local copy of the last fragment.

Differential Revision: https://reviews.llvm.org/D123259
2022-04-07 09:17:30 -07:00
Sam McCall b2a7f1c390 Remove a few effectively-unused FileEntry APIs. NFC
- isValid: FileManager only ever returns valid FileEntries (see next point)

- construction from outside FileManager (both FileEntry and DirectoryEntry).
  It's not possible to create a useful FileEntry this way, there are no setters.
  This was only used in FileEntryTest, added a friend to enable this.
  A real constructor is cleaner but requires larger changes to FileManager.

Differential Revision: https://reviews.llvm.org/D123197
2022-04-07 16:45:47 +02:00
Nico Weber e22a60b1c8 Revert "Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON"""
This reverts commit 2aca33baf1.
Broke tests on several bots, see comments on https://reviews.llvm.org/D120305
2022-04-07 10:07:07 -04:00
Nathan Sidwell 9eda5fc0c6 [clang] Verify internal entity module mangling
Internal symbol mangling is implementation-defined.  We do not mangle
any module attachment, and this adds a test to verify that.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D123220
2022-04-07 05:40:57 -07:00
Antonio Frighetto 7c3d8c8977 Fix warnings when `-Wdeprecated-enum-enum-conversion` is enabled
clang may throw the following warning:
include/clang/AST/DeclarationName.h:210:52: error: arithmetic between
different enumeration types ('clang::DeclarationName::StoredNameKind'
and 'clang::detail::DeclarationNameExtra::ExtraKind') is deprecated
when flags -Werror,-Wdeprecated-enum-enum-conversion are on.

This adds the `addEnumValues()` helper function to STLExtras.h to hide
the details of adding enumeration values together from two different
enumerations.
2022-04-07 08:20:54 -04:00
Nikita Popov 82d0f7bdb5 [Clang] Remove redundant -no-opaque-pointers flag in test (NFC)
This was accidentally caught in an automated replacement. This
test is testing the -opaque-pointers flag itself, so we shouldn't
add -no-opaque-pointers here (though it doesn't hurt either).

Also drop the line testing the default, as the default is now
determined by a cmake option.
2022-04-07 13:53:37 +02:00
Kavitha Natarajan b1ea0191a4 [clang][DebugInfo] Support debug info for alias variable
clang to emit DWARF information for global alias variable as
DW_TAG_imported_declaration. This change also handles nested
(recursive) imported declarations.

Reviewed by: dblaikie, aprantl

Differential Revision: https://reviews.llvm.org/D120989
2022-04-07 17:15:40 +05:30
Nikita Popov b16a3b4f3b [Clang] Add -no-opaque-pointers to more tests (NFC)
This adds the flag to more tests that were not caught by the
mass-migration in 532dc62b90.
2022-04-07 12:53:29 +02:00
Nikita Popov 532dc62b90 [OpaquePtrs][Clang] Add -no-opaque-pointers to tests (NFC)
This adds -no-opaque-pointers to clang tests whose output will
change when opaque pointers are enabled by default. This is
intended to be part of the migration approach described in
https://discourse.llvm.org/t/enabling-opaque-pointers-by-default/61322/9.

The patch has been produced by replacing %clang_cc1 with
%clang_cc1 -no-opaque-pointers for tests that fail with opaque
pointers enabled. Worth noting that this doesn't cover all tests,
there's a remaining ~40 tests not using %clang_cc1 that will need
a followup change.

Differential Revision: https://reviews.llvm.org/D123115
2022-04-07 12:09:47 +02:00
Balázs Kéri 5479174071 [clang][ASTImporter] Not using consumeError at failed import of in-class initializer.
The error can be returned from the function, the problem written in comment before
does not exist. The same is done already in ASTImporter at various import failures.

After a declaration is created in an `ASTNodeImporter` import function
with `GetImportedOrCreateDecl`, that function registers it with
`MapImported`. At many places import errors can happen after this
and the error is returned. The same can be done in the place where
the in-class initializer is imported.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D122528
2022-04-07 11:07:15 +02:00
Nikita Popov 5390606aa9 [OpaquePtr][Clang] Add CLANG_ENABLE_OPAQUE_POINTERS cmake option
This option controls whether -opaque-pointers or -no-opaque-pointers
is the default. Once opaque pointers are enabled by default, this
will provide a simple way to temporarily opt-out of the change.

Differential Revision: https://reviews.llvm.org/D123122
2022-04-07 10:14:56 +02:00
Petr Hosek ff78d25b8e [CMake][Fuchsia] Include bolt
We would like to use bolt with Fuchsia toolchain.

Differential Revision: https://reviews.llvm.org/D123280
2022-04-06 22:48:17 -07:00
Fangrui Song 6c9b363cf6 [Driver][test] Fix csky-toolchain.c to be CLANG_DEFAULT_PIE_ON_LINUX agnostic 2022-04-06 21:14:24 -07:00
Fangrui Song e3dcef355f [Driver][test] Fix csky-toolchain.c to be CLANG_DEFAULT_PIE_ON_LINUX agnostic 2022-04-06 20:41:39 -07:00
Fangrui Song 2aca33baf1 Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""
(The upgrade of the ppc64le bot and D121257 have fixed compiler-rt failures. Tested by nemanjai.)

Default the option introduced in D113372 to ON to match all(?) major Linux
distros. This matches GCC and improves consistency with Android and linux-musl
which always default to PIE.
Note: CLANG_DEFAULT_PIE_ON_LINUX may be removed in the future.

Differential Revision: https://reviews.llvm.org/D120305
2022-04-06 20:19:07 -07:00
Krystian Kuzniarek 1cd4346409 [clang-format][docs] Fix incorrect 'clang-format 11' option markers
Differential Revision: https://reviews.llvm.org/D122064
2022-04-06 18:38:30 -07:00
Sam McCall 69f7210657 Remove unused FileEntry::operator<. NFC 2022-04-06 23:39:17 +02:00
Paul Robinson 375d93465b [PS4] Fix a buggy cast 2022-04-06 12:28:50 -07:00
Zixu Wang 178aad9b94 [clang][extract-api] Add Objective-C Category support
Add (partial) support for Objective-C category records in ExtractAPI.
The current ExtractAPI collects everything for an Objective-C category,
but not fully serialized in the SymbolGraphSerializer. Categories
extending external interfaces are disgarded during serialization, and
categories extending known interfaces are merged (all members surfaced)
into the interfaces.

Differential Revision: https://reviews.llvm.org/D122774
2022-04-06 12:00:12 -07:00
David Blaikie 6b306233f7 DebugInfo: Make the simplified template names prefix more unique 2022-04-06 18:25:46 +00:00
Daniel Grumberg 9fc45ca00a [clang][extract-api] Add support for typedefs
Typedef records consist of the symbol associated with the underlying
TypedefDecl and a SymbolReference to the underlying type. Additionally
typedefs for anonymous TagTypes use the typedef'd name as the symbol
name in their respective records and USRs. As a result the declaration
fragments for the anonymous TagType are those for the associated
typedef. This means that when the user is defining a typedef to a
typedef to a anonymous type, we use a reference the anonymous TagType
itself and do not emit the typedef to the anonymous type in the
generated symbol graph, including in the type destination of further
typedef symbol records.

Differential Revision: https://reviews.llvm.org/D123019
2022-04-06 19:14:05 +01:00
Nathan Sidwell 482fad4a3f [clang][DOC] Document module mangler changes
Note that the mangling has changed and the demangler's learnt a new
trick.  Obviously dependent upon the mangler and demangler patches.

Reviewed By: bruno

Differential Revision: https://reviews.llvm.org/D123141
2022-04-06 11:13:32 -07:00
Daniel Grumberg 28d793144f [clang][extract-api] Fix small issues with SymbolGraphSerializer
This includes:
- replacing "relationhips" with "relationships"
- emitting the "pathComponents" property on symbols
- emitting the "accessLevel" property on symbols

Differential Revision: https://reviews.llvm.org/D123045
2022-04-06 18:42:55 +01:00
Paul Robinson 31c971145f [PS4] clang-format PS4CPU.cpp/.h 2022-04-06 06:52:29 -07:00