Commit Graph

2567 Commits

Author SHA1 Message Date
YangZhihui 1d1c382ed2 Fix typos in ASTMatchers.h; NFC 2020-09-23 09:09:11 -04:00
Jan Korous 8a64689e26 [Analyzer][WebKit] UncountedLocalVarsChecker
Differential Review: https://reviews.llvm.org/D83259
2020-09-22 11:05:04 -07:00
Joachim Meyer f64903fd81 Add -Wno-error=unknown flag to clang-format.
Currently newer clang-format options cannot be included in .clang-format files, if not all users can be forced to use an updated version.
This patch tries to solve this by adding an option to clang-format, enabling to ignore unknown (newer) options.

Differential Revision: https://reviews.llvm.org/D86137
2020-09-19 10:17:57 +02:00
mydeveloperday 2e7add812e [clang-format] Add a option for the position of Java static import
Some Java style guides and IDEs group Java static imports after
 non-static imports. This patch allows clang-format to control
 the location of static imports.

Patch by: @bc-lee

Reviewed By: MyDeveloperDay, JakeMerdichAMD

Differential Revision: https://reviews.llvm.org/D87201
2020-09-18 18:12:21 +01:00
Jessica Clarke 788c7d2ec1 [clang][docs] Fix documentation of -O
D79916 changed the behaviour from -O2 to -O1 but the documentation was
not updated to reflect this.
2020-09-17 13:44:01 +01:00
mydeveloperday 4dd9c709ef [clang-format] [NFC] Fix spelling mistake in the documentation
Ensure ClangFormatStyleOptions.rst can be regenerated from Format.h

Patch By: YangZhihui

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D87352
2020-09-16 13:46:34 +01:00
Jonas Toth 69f98311ca [ASTMatchers] extract public matchers from const-analysis into own patch
The analysis for const-ness of local variables required a view generally useful
matchers that are extracted into its own patch.

They are decompositionDecl and forEachArgumentWithParamType, that works
for calls through function pointers as well.

This is a reupload of https://reviews.llvm.org/D72505, that already landed,
but had to be reverted due to a GCC crash on powerpc
(https://reviews.llvm.org/rG4c48ea68e491cb42f1b5d43ffba89f6a7f0dadc4)

Because this took a long time to adress, i decided to redo this patch and
have a clean workflow.
I try to coordinate with someone that has a PPC to apply this patch and
test for the crash. If everything is fine, I intend to just commit.
If the crash is still happening, i hope to at least find the cause.

Differential Revision: https://reviews.llvm.org/D87588
2020-09-15 21:07:30 +02:00
Kristóf Umann dd1d5488e4 [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist
The summary and very short discussion in D82122 summarizes whats happening here.

In short, liveness talks about variables, or expressions, anything that
has a value. Well, statements just simply don't have a one.

Differential Revision: https://reviews.llvm.org/D82598
2020-09-15 17:43:02 +02:00
Kristóf Umann 7c6f5b7fbf [analyzer] Add documentation for alpha.fuchsia.Lock and alpha.core.C11Lock
Differential Revision: https://reviews.llvm.org/D86532
2020-09-15 16:55:44 +02:00
Rahman Lavaee 7841e21c98 Let -basic-block-sections=labels emit basicblock metadata in a new .bb_addr_map section, instead of emitting special unary-encoded symbols.
This patch introduces the new .bb_addr_map section feature which allows us to emit the bits needed for mapping binary profiles to basic blocks into a separate section.
The format of the emitted data is represented as follows. It includes a header for every function:

|  Address of the function                      |  -> 8 bytes (pointer size)
|  Number of basic blocks in this function (>0) |  -> ULEB128

The header is followed by a BB record for every basic block. These records are ordered in the same order as MachineBasicBlocks are placed in the function. Each BB Info is structured as follows:

|  Offset of the basic block relative to function begin |  -> ULEB128
|  Binary size of the basic block                       |  -> ULEB128
|  BB metadata                                          |  -> ULEB128  [ MBB.isReturn() OR MBB.hasTailCall() << 1  OR  MBB.isEHPad() << 2 ]

The new feature will replace the existing "BB labels" functionality with -basic-block-sections=labels.
The .bb_addr_map section scrubs the specially-encoded BB symbols from the binary and makes it friendly to profilers and debuggers.
Furthermore, the new feature reduces the binary size overhead from 70% bloat to only 12%.

For more information and results please refer to the RFC: https://lists.llvm.org/pipermail/llvm-dev/2020-July/143512.html

Reviewed By: MaskRay, snehasish

Differential Revision: https://reviews.llvm.org/D85408
2020-09-14 10:16:44 -07:00
Travis Finkenauer 0fb2203cd6 [Docs] Fix --print-supported-cpus option rendering
Adds link/code sample to avoid rendering two dashes as non-ASCII "en dash".
Also make wording a complete sentence.

Reviewed By: nickdesaulniers, tmfink

Differential Revision: https://reviews.llvm.org/D85596
2020-09-13 05:26:18 +00:00
Guillaume Chatelet b8ea47a380
Uncapitalize word in LanguageExtensions.rst 2020-09-11 10:08:02 +02:00
Guillaume Chatelet e38be7091e [Clang] Clarify __builtin_memcpy_inline documentation
This patch updates the documentation about `__builtin_memcpy_inline` and reorders the sections so it is more consitent and understandable.

Differential Revision: https://reviews.llvm.org/D87458
2020-09-11 07:20:39 +00:00
Guillaume Chatelet 05d02e5a4e Fix invalid link format in Clang LanguageExtension 2020-09-10 12:27:50 +00:00
Alex Richardson e7bd058c7e [clang-format] Allow configuring list of macros that map to attributes
This adds a `AttributeMacros` configuration option that causes certain
identifiers to be parsed like a __attribute__((foo)) annotation.
This is motivated by our CHERI C/C++ fork which adds a __capability
qualifier for pointer/reference. Without this change clang-format parses
many type declarations as multiplications/bitwise-and instead.
I initially considered adding "__capability" as a new clang-format keyword,
but having a list of macros that should be treated as attributes is more
flexible since it can be used e.g. for static analyzer annotations or other language
extensions.

Example: std::vector<foo * __capability> -> std::vector<foo *__capability>

Depends on D86775 (to apply cleanly)

Reviewed By: MyDeveloperDay, jrtc27

Differential Revision: https://reviews.llvm.org/D86782
2020-09-07 10:09:17 +01:00
Aaron Puchert bbb3baf620 Thread safety analysis: Improve documentation for scoped capabilities
They are for more powerful than the current documentation implies, this
adds

* adopting a lock,
* deferring a lock,
* manually unlocking the scoped capability,
* relocking the scoped capability, possibly in a different mode,
* try-relocking the scoped capability.

Also there is now a generic explanation how attributes on scoped
capabilities work. There has been confusion in the past about how to
annotate them (see e.g. PR33504), hopefully this clears things up.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D87066
2020-09-06 20:37:42 +02:00
Aaron Puchert cc6713a2c3 Thread safety analysis: Test and document release_generic_capability
The old locking attributes had a generic release, but as it turns out
the capability-based attributes have it as well.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D87064
2020-09-06 20:37:41 +02:00
Aaron Puchert 8544defdcb Thread safety analysis: Document how try-acquire is handled
I don't think this is obvious, since try-acquire seemingly contradicts
our usual requirements of "no conditional locking".

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D87065
2020-09-05 14:26:43 +02:00
Akira Hatanaka 64bb582f4a Fix the type of the invoke function in the block ABI documentation
rdar://problem/67892794
2020-09-04 10:29:09 -07:00
Jan Korous c9239b2bf5 [Analyzer][docs][NFC] Fix typo in code example 2020-09-03 09:28:34 -07:00
Julian Lettner 478eb98cd2 [Docs] Remove outdated OS limitation
Thread Sanitizer is supported on macOS.

rdar://68159753

Differential Revision: https://reviews.llvm.org/D86980
2020-09-01 14:44:17 -07:00
JF Bastien 82d29b397b Add an unsigned shift base sanitizer
It's not undefined behavior for an unsigned left shift to overflow (i.e. to
shift bits out), but it has been the source of bugs and exploits in certain
codebases in the past. As we do in other parts of UBSan, this patch adds a
dynamic checker which acts beyond UBSan and checks other sources of errors. The
option is enabled as part of -fsanitize=integer.

The flag is named: -fsanitize=unsigned-shift-base
This matches shift-base and shift-exponent flags.

<rdar://problem/46129047>

Differential Revision: https://reviews.llvm.org/D86000
2020-08-27 19:50:10 -07:00
Craig Topper 2d13693bfc [X86] Update release notes for -mtune support. 2020-08-26 16:16:56 -07:00
Teresa Johnson 72bdb41a06 [Docs] Document --lto-whole-program-visibility
Summary:
Documents interaction of linker option added in D71913 with LTO
visibility.

Reviewers: pcc

Subscribers: inglorion, hiraditya, steven_wu, dexonsmith, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75655
2020-08-25 19:44:54 -07:00
Craig Topper 01eb1233db [X86] Mention -march=sapphirerapids in the release notes.
This was just added in e02d081f2b.
2020-08-25 11:57:34 -07:00
Simon Pilgrim a1dc3d241b [X86] Enable constexpr on ROTL/ROTR intrinsics (PR31446)
This enables constexpr rotate intrinsics defined in ia32intrin.h, including the MS specific builtins.
2020-08-23 16:11:58 +01:00
Simon Pilgrim f76adc2603 [docs] Add an initial (non-exhaustive) list of intrinsics that can be used in constant expressions
As suggested by @rsmith on D86398 - we should try to document the intrinsics that can be used in constexpr
2020-08-23 10:55:14 +01:00
Simon Pilgrim f8e0e5db48 [X86] Enable constexpr on _cast fp<-> uint intrinsics (PR31446)
As suggested by @rsmith on PR47267, by replacing the builtin_memcpy bitcast pattern with builtin_bit_cast we can use _castf32_u32, _castu32_f32, _castf64_u64 and _castu64_f64 inside constant expresssions (constexpr). Although __builtin_bit_cast was added for c++20 it works on all clang c/c++ modes.

Differential Revision: https://reviews.llvm.org/D86398
2020-08-23 10:27:46 +01:00
Simon Pilgrim e7d9182a66 Enable constexpr on BITREVERSE builtin intrinsics (PR47249)
This enables us to use the __builtin_bitreverse 8/16/32/64 intrinsics inside constexpr code.

Differential Revision: https://reviews.llvm.org/D86339
2020-08-22 14:43:22 +01:00
Simon Pilgrim 2ceac91ec0 Enable constexpr on ROTATELEFT/ROTATERIGHT builtin intrinsics (PR47249)
This enables us to use the __builtin_rotateleft / __builtin_rotateright 8/16/32/64 intrinsics inside constexpr code.

Differential Revision: https://reviews.llvm.org/D86342
2020-08-22 14:43:21 +01:00
Simon Pilgrim 436a35a773 [docs] Replace "constexpr expressions" with "constant expressions".
Based off comment from @rsmith on D86339
2020-08-22 14:14:36 +01:00
Craig Topper c0ec37ee65 [docs] Move the label for __builtin_shufflevector below __builtin_dump_struct so the see also link in 'vector operations' will go to the right place and have the right name. 2020-08-21 11:51:15 -07:00
Simon Pilgrim 9ffc412e1a [X86] Enable constexpr on BITSCAN intrinsics (PR31446)
This enables constexpr BSF/BSR intrinsics defined in ia32intrin.h
2020-08-21 11:44:20 +01:00
Simon Pilgrim c8e6bf0a65 [X86] Enable constexpr on BSWAP intrinsics (PR31446)
This enables constexpr BSWAP intrinsics defined in ia32intrin.h
2020-08-21 10:55:15 +01:00
Simon Pilgrim c6863a4ab8 [X86] Enable constexpr on POPCNT intrinsics (PR31446)
Followup to D86229, this enables constexpr on the alternative (which fallback to generic code) POPCNT intrinsics defined in ia32intrin.h
2020-08-21 10:20:37 +01:00
Simon Pilgrim cff0db0876 [X86] Enable constexpr on POPCNT intrinsics (PR31446)
This is a first step patch to enable constexpr support and testing to a large number of x86 intrinsics.

All I've done here is provide a DEFAULT_FN_ATTRS_CONSTEXPR variant to our existing DEFAULT_FN_ATTRS tag approach that adds constexpr on c++ builds. The clang cuda headers do something similar.

I've started with POPCNT mainly as its tiny and are wrappers to generic __builtin_* intrinsics which already act as constexpr.

Differential Revision: https://reviews.llvm.org/D86229
2020-08-20 21:38:04 +01:00
Matt Morehouse e492f959e0 [docs] Add missing semicolon to example. 2020-08-14 13:46:05 -07:00
Nick Desaulniers 4f2ad15db5 [Clang] implement -fno-eliminate-unused-debug-types
Fixes pr/11710.
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Resubmit after breaking Windows and OSX builds.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D80242
2020-08-10 15:08:48 -07:00
Nathan Ridge b1c7f84643 [clang] Allow DynTypedNode to store a TemplateArgumentLoc
The patch also adds a templateArgumentLoc() AST matcher.

Differential Revision: https://reviews.llvm.org/D85621
2020-08-10 03:09:18 -04:00
Nick Desaulniers abb9bf4bcf Revert "[Clang] implement -fno-eliminate-unused-debug-types"
This reverts commit e486921fd6.

Breaks windows builds and osx builds.
2020-08-07 16:11:41 -07:00
Nick Desaulniers e486921fd6 [Clang] implement -fno-eliminate-unused-debug-types
Fixes pr/11710.
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D80242
2020-08-07 14:13:48 -07:00
Peter Smith 839d974ee0 [DOCS] Add more detail to stack protector documentation
The Clang -fstack-protector documentation mentions what functions are considered
vulnerable but does not mention the details of the implementation such as the use
of a global variable for the guard value. This brings the documentation more in
line with the GCC documentation at:
https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html
and gives someone using the option more idea about what is protected.

This partly addresses https://bugs.llvm.org/show_bug.cgi?id=42764

Differential Revision: https://reviews.llvm.org/D85239
2020-08-06 13:47:21 +01:00
Jan Korous 820e8d8656 [Analyzer][WebKit] UncountedLambdaCaptureChecker
Differential Revision: https://reviews.llvm.org/D82837
2020-08-05 15:23:55 -08:00
Joel E. Denny 03bb545b68 [OpenMP][Docs] Mark `present` map type modifier as done 2020-08-05 10:03:31 -04:00
Joel E. Denny 26cf9c1704 [OpenMP][Docs] Add map clause reordering status as unclaimed 2020-08-05 10:03:31 -04:00
Fangrui Song 7cf4603fae Reland D61689 Change -gz and -Wa,--compress-debug-sections to use gABI compression (SHF_COMPRESSED) with integrated assembler
This fixes an inconsistency: clang -c -gz -fno-integrated-as means SHF_COMPRESSED
while clang -c -gz -fintegrated-as means zlib-gnu.

---

Since July 15, 2015 (binutils-gdb commit
19a7fe52ae3d0971e67a134bcb1648899e21ae1c, included in 2.26), gas
--compress-debug-sections=zlib (gcc -gz) means zlib-gabi:
SHF_COMPRESSED. Before that GCC/binutils used zlib-gnu (.zdebug).

clang's -gz was introduced in rC306115 (Jun 2017) to indicate zlib-gnu. It
is 2020 now and it is not unreasonable to assume users of the new
feature to have new linkers (ld.bfd/gold >= 2.26, lld >= rLLD273661).

Change clang's default accordingly to improve standard conformance.
zlib-gnu becomes out of fashion and gets poorer toolchain support.
Its mangled names confuse tools and are more likely to cause problems.

Reviewed By: compnerd

Differential Revision: https://reviews.llvm.org/D61689
2020-08-03 15:12:01 -07:00
Andrei Lebedev 8dd4e3ceb8 Updated the -I option description. 2020-08-01 15:54:11 -07:00
Andrei Lebedev 731292e5f3 Updated the -I option description. 2020-07-31 15:39:12 -07:00
Michael Kruse 18eba165e7 [OpenMP][docs] Update loop tiling status. 2020-07-31 13:01:55 -05:00
Joel E. Denny 3d06fc0049 [OpenMP][Docs] Mark `present` motion modifier as done 2020-07-30 12:21:37 -04:00