Commit Graph

3460 Commits

Author SHA1 Message Date
Jonas Devlieghere d4d47e574e
Revert "Deferred Concept Instantiation Implementation"
This reverts commit 2f20743952 because it
triggers an assertion when building an LLDB test program:

  Assertion failed: (InstantiatingSpecializations.empty() && "failed to
  clean up an InstantiatingTemplate?"), function ~Sema, file
  /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Sema/Sema.cpp,
  line 458.

More details in https://reviews.llvm.org/D126907.
2022-06-30 11:43:10 -07:00
Erich Keane 2f20743952 Deferred Concept Instantiation Implementation
This is a continuation of D119544.  Based on @rsmith 's feed back
showing me https://eel.is/c++draft/temp#friend-9, We should properly
handle friend functions now.

Differential Revision: https://reviews.llvm.org/D126907
2022-06-30 06:47:11 -07:00
Prathit Aswar cde1df4ca4 Correct -Winfinite-recursion warning on potentially-unevaluated operand
Fixing issue "incorrect -Winfinite-recursion warning on potentially-
unevaluated operand".

We add a dedicated visit function (VisitCXXTypeidExpr) for typeid,
instead of using the default (VisitStmt). In this new function we skip
over building the CFG for unevaluated operands of typeid.

Fixes #21668

Differential Revision: https://reviews.llvm.org/D128747
2022-06-30 09:09:28 -04:00
Phoebe Wang abeeae570e [X86] Support `_Float16` on SSE2 and up
This is split from D113107 to address #56204 and https://discourse.llvm.org/t/how-to-build-compiler-rt-for-new-x86-half-float-abi/63366

Reviewed By: zahiraam, rjmccall, bkramer, MaskRay

Differential Revision: https://reviews.llvm.org/D128571
2022-06-30 17:21:37 +08:00
Sam Estep 6a97be27a1 [clang][dataflow] Delete SourceLocationsLattice
This patch deletes the now-unused `SourceLocationsLattice` class, along with its containing files and surrounding helper functions and tests.

Reviewed By: xazax.hun, ymandel, sgatev, gribozavr2

Differential Revision: https://reviews.llvm.org/D128448
2022-06-29 20:14:07 +00:00
Sam Estep cf1f978d31 [clang][dataflow] Use NoopLattice in optional model
Followup to D128352. This patch pulls the `NoopLattice` class out from the `NoopAnalysis.h` test file into its own `NoopLattice.h` source file, and uses it to replace usage of `SourceLocationsLattice` in `UncheckedOptionalAccessModel`.

Reviewed By: ymandel, sgatev, gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D128356
2022-06-29 20:10:42 +00:00
Sam Estep 8361877b10 Revert "[clang][dataflow] Use NoopLattice in optional model"
This reverts commit 335c05f5d1.
2022-06-29 19:34:30 +00:00
Sam Estep 335c05f5d1 [clang][dataflow] Use NoopLattice in optional model
Followup to D128352. This patch pulls the `NoopLattice` class out from the `NoopAnalysis.h` test file into its own `NoopLattice.h` source file, and uses it to replace usage of `SourceLocationsLattice` in `UncheckedOptionalAccessModel`.

Reviewed By: ymandel, sgatev, gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D128356
2022-06-29 19:20:58 +00:00
Corentin Jabot 64ab2b1dcc Improve handling of static assert messages.
Instead of dumping the string literal (which
quotes it and escape every non-ascii symbol),
we can use the content of the string when it is a
8 byte string.

Wide, UTF-8/UTF-16/32 strings are still completely
escaped, until we clarify how these entities should
behave (cf https://wg21.link/p2361).

`FormatDiagnostic` is modified to escape
non printable characters and invalid UTF-8.

This ensures that unicode characters, spaces and new
lines are properly rendered in static messages.
This make clang more consistent with other implementation
and fixes this tweet
https://twitter.com/jfbastien/status/1298307325443231744 :)

Of note, `PaddingChecker` did print out new lines that were
later removed by the diagnostic printing code.
To be consistent with its tests, the new lines are removed
from the diagnostic.

Unicode tables updated to both use the Unicode definitions
and the Unicode 14.0 data.

U+00AD SOFT HYPHEN is still considered a print character
to match existing practices in terminals, in addition of
being considered a formatting character as per Unicode.

Reviewed By: aaron.ballman, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D108469
2022-06-29 14:57:35 +02:00
Corentin Jabot a774ba7f60 Revert "Improve handling of static assert messages."
This reverts commit 870b6d2183.

This seems to break some libc++ tests, reverting while investigating
2022-06-29 00:03:23 +02:00
Corentin Jabot 870b6d2183 Improve handling of static assert messages.
Instead of dumping the string literal (which
quotes it and escape every non-ascii symbol),
we can use the content of the string when it is a
8 byte string.

Wide, UTF-8/UTF-16/32 strings are still completely
escaped, until we clarify how these entities should
behave (cf https://wg21.link/p2361).

`FormatDiagnostic` is modified to escape
non printable characters and invalid UTF-8.

This ensures that unicode characters, spaces and new
lines are properly rendered in static messages.
This make clang more consistent with other implementation
and fixes this tweet
https://twitter.com/jfbastien/status/1298307325443231744 :)

Of note, `PaddingChecker` did print out new lines that were
later removed by the diagnostic printing code.
To be consistent with its tests, the new lines are removed
from the diagnostic.

Unicode tables updated to both use the Unicode definitions
and the Unicode 14.0 data.

U+00AD SOFT HYPHEN is still considered a print character
to match existing practices in terminals, in addition of
being considered a formatting character as per Unicode.

Reviewed By: aaron.ballman, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D108469
2022-06-28 22:26:00 +02:00
Ben Langmuir eab2a06f0f Revert "Reland "[X86] Support `_Float16` on SSE2 and up""
Broke compiler-rt on Darwin: https://green.lab.llvm.org/green/job/clang-stage1-RA/29920/

This reverts commit 527ef8ca98.
2022-06-28 10:59:03 -07:00
Phoebe Wang 527ef8ca98 Reland "[X86] Support `_Float16` on SSE2 and up"
Enable `COMPILER_RT_HAS_FLOAT16` to solve the lit fail.

This is split from D113107 to address #56204 and https://discourse.llvm.org/t/how-to-build-compiler-rt-for-new-x86-half-float-abi/63366

Reviewed By: zahiraam, rjmccall, bkramer

Differential Revision: https://reviews.llvm.org/D128571
2022-06-28 14:38:56 +08:00
Joel E. Denny 0103d4da74 [Clang][OpenMP] Don't overload "extension" in status doc
In Clang's OpenMPSupport.rst, "extension" is currently overloaded to
describe both:

1. Standard OpenMP features that appear only in recent versions of the
   OpenMP spec.
2. Non-standard features supported by Clang.  This usage appears in
   the final table on the page.

Last fall, we discussed this issue in the OpenMP in LLVM call and
agreed it should be corrected.  This patch takes the simple approach
of dropping the word "extension" for all occurrences of the first
usage.  The result seems to read well.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D126549
2022-06-27 18:41:17 -04:00
Vitaly Buka df18167ac5 [docs] Restore missing blank line
Lost in resolving conflicts for cdfa15da94.
2022-06-27 14:21:08 -07:00
Vitaly Buka cdfa15da94 Revert "[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible arrays"
This reverts D126864 and related fixes.

This reverts commit 572b08790a.
This reverts commit 886715af96.
2022-06-27 14:03:09 -07:00
Vitaly Buka 8f7cca90af Revert "[X86] Support `_Float16` on SSE2 and up"
Breaks buildbot
https://lab.llvm.org/buildbot/#/builders/37/builds/14334

This reverts commit f5d781d627.
2022-06-27 12:43:29 -07:00
Chris Bieneman ee0dd2ec11 [Docs] Update clang & llvm release notes for HLSL
Adding release note entries for LLVM & Clang to introduce the HLSL &
DirectX support that is being added.

Reviewed By: aaron.ballman, MaskRay

Differential Revision: https://reviews.llvm.org/D127890
2022-06-27 12:41:14 -05:00
Chi Chun Chen 92fd2eb74f [Clang][OpenMP] Claim nowait clause on taskwait 2022-06-27 11:02:39 -05:00
Phoebe Wang f5d781d627 [X86] Support `_Float16` on SSE2 and up
This is split from D113107 to address #56204 and https://discourse.llvm.org/t/how-to-build-compiler-rt-for-new-x86-half-float-abi/63366

Reviewed By: zahiraam, rjmccall, bkramer

Differential Revision: https://reviews.llvm.org/D128571
2022-06-27 21:37:30 +08:00
Aaron Ballman 4588b6fd26 Fix clang docs build; NFC
This should address the break from:
https://lab.llvm.org/buildbot/#/builders/92/builds/28769
2022-06-27 07:12:36 -04:00
Shivam 282059b44d
Update LibASTImporter.rst
As my last commit changed the name of ImportError to ASTImportError , this section also needs to be updated so changed it.
2022-06-26 19:22:52 +05:30
sstwcw 9ed2e68c9a [clang-format] Parse Verilog if statements
This patch mainly handles treating `begin` as block openers.

While and for statements will be handled in another patch.

Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D123450
2022-06-26 01:52:15 +00:00
David Blaikie 4821508d4d Revert "DebugInfo: Fully integrate ctor type homing into 'limited' debug info"
Reverting to simplify some Google-internal rollout issues. Will recommit
in a week or two.

This reverts commit 517bbc64db.
2022-06-24 17:07:47 +00:00
Stephen Long 186bea3750 [MSVC] Add initial support for MSVC pragma optimize
MSVC's pragma optimize turns optimizations on or off based on the list
passed. At the moment, we only support an empty optimization list.

i.e. `#pragma optimize("", on | off)`

From MSVC's docs:

| Parameter | Type of optimization                             |
|-----------|--------------------------------------------------|
| g         | Enable global optimizations. Deprecated          |
| s or t    | Specify short or fast sequences of machine code  |
| y         | Generate frame pointers on the program stack     |

https://docs.microsoft.com/en-us/cpp/preprocessor/optimize?view=msvc-170

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D125723
2022-06-24 08:03:42 -07:00
serge-sans-paille 886715af96 [clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible arrays
Some code [0] consider that trailing arrays are flexible, whatever their size.
Support for these legacy code has been introduced in
f8f6324983 but it prevents evaluation of
__builtin_object_size and __builtin_dynamic_object_size in some legit cases.

Introduce -fstrict-flex-arrays=<n> to have stricter conformance when it is
desirable.

n = 0: current behavior, any trailing array member is a flexible array. The default.
n = 1: any trailing array member of undefined, 0 or 1 size is a flexible array member
n = 2: any trailing array member of undefined or 0 size is a flexible array member
n = 3: any trailing array member of undefined size is a flexible array member (strict c99 conformance)

Similar patch for gcc discuss here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836

[0] https://docs.freebsd.org/en/books/developers-handbook/sockets/#sockets-essential-functions
2022-06-24 16:13:29 +02:00
David Blaikie 517bbc64db DebugInfo: Fully integrate ctor type homing into 'limited' debug info
Simplify debug info back to just "limited" or "full" by rolling the ctor
type homing fully into the "limited" debug info.

Also fix a bug I found along the way that was causing ctor type homing
to kick in even when something could be vtable homed (where vtable
homing is stronger/more effective than ctor homing) - fixing at the same
time as it keeps the tests (that were testing only "limited non ctor"
homing and now test ctor homing) passing.
2022-06-23 20:15:00 +00:00
James Y Knight 17e2702528 Clang AttributeReference: emit entries for "Undocumented" attributes.
Almost all attributes currently marked `Undocumented` are user-facing
attributes which _ought_ to be documented, but nobody has written it
yet. This change ensures that we at least acknowledge that these
attributes exist in the documentation, even if we have no description
of their semantics.

A new category, `InternalOnly` has been added for those few attributes
which are not user-facing, and should remain omitted from the docs.
2022-06-22 09:55:05 -04:00
Balázs Kéri 60f3b07118 [clang][analyzer] Add checker for bad use of 'errno'.
Extend checker 'ErrnoModeling' with a state of 'errno' to indicate
the importance of the 'errno' value and how it should be used.
Add a new checker 'ErrnoChecker' that observes use of 'errno' and
finds possible wrong uses, based on the "errno state".
The "errno state" should be set (together with value of 'errno')
by other checkers (that perform modeling of the given function)
in the future. Currently only a test function can set this value.
The new checker has no user-observable effect yet.

Reviewed By: martong, steakhal

Differential Revision: https://reviews.llvm.org/D122150
2022-06-20 10:07:31 +02:00
Roy Jacobson 21eb1af469 [Concepts] Implement overload resolution for destructors (P0848)
This patch implements a necessary part of P0848, the overload resolution for destructors.
It is now possible to overload destructors based on constraints, and the eligible destructor
will be selected at the end of the class.

The approach this patch takes is to perform the overload resolution in Sema::ActOnFields
and to mark the selected destructor using a new property in FunctionDeclBitfields.

CXXRecordDecl::getDestructor is then modified to use this property to return the correct
destructor.

This closes https://github.com/llvm/llvm-project/issues/45614.

Reviewed By: #clang-language-wg, erichkeane

Differential Revision: https://reviews.llvm.org/D126194
2022-06-19 00:30:37 +03:00
Fangrui Song af6d2a0b68 [docs] Re-generate ClangCommandLineReference.rst 2022-06-18 11:01:54 -07:00
Jolanta Jensen c80c57674e [Clang] Allow 'Complex float __attribute__((mode(HC)))'
Adding half float to types that can be represented by __attribute__((mode(xx))).
Original implementation authored by George Steed.

Differential Revision: https://reviews.llvm.org/D126479
2022-06-17 12:39:52 +01:00
Javier Alvarez 5ea341d7c4 [clang] Fix trivially copyable for copy constructor and copy assignment operator
From [class.copy.ctor]:

```
A non-template constructor for class X is a copy constructor if its first
parameter is of type X&, const X&, volatile X& or const volatile X&, and
either there are no other parameters or else all other parameters have
default arguments (9.3.4.7).

A copy/move constructor for class X is trivial if it is not user-provided and if:
- class X has no virtual functions (11.7.3) and no virtual base classes (11.7.2), and
- the constructor selected to copy/move each direct base class subobject is trivial, and
- or each non-static data member of X that is of class type (or array thereof),
  the constructor selected to copy/move that member is trivial;

otherwise the copy/move constructor is non-trivial.
```

So `T(T&) = default`; should be trivial assuming that the previous
provisions are met.

This works in GCC, but not in Clang at the moment:
https://godbolt.org/z/fTGe71b6P

Reviewed By: royjacobson

Differential Revision: https://reviews.llvm.org/D127593
2022-06-17 10:35:01 +03:00
Fangrui Song 0e182469ee [sanitizer] Delete empty sanitizer_openbsd.cpp after D89759 2022-06-16 16:38:01 -07:00
Mitch Phillips 011e0604eb Add DWARF string debug to clang release notes.
D12353 added inline strings to the DWARF info produced by clang. This
turns out to break some debugging software that assumes that a
DW_TAG_variable *must* come with a DW_AT_name. Add a release note to
broadcast this change.

Reviewed By: paulkirth

Differential Revision: https://reviews.llvm.org/D126224
2022-06-16 14:54:12 -07:00
Arthur Eubanks a70b39abff [clang] Don't emit type test/assume for virtual classes that should never participate in WPD
Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D127876
2022-06-16 09:38:14 -07:00
Timm Bäder c149fa1f5f [clang][sema] Provide better diagnostic for missing template arguments
Instead of just complaining that "x is not a class, namespace or
enumeration", mention that using x requires template arguments.

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

Fixes https://github.com/llvm/llvm-project/issues/55962
2022-06-15 16:06:06 +02:00
Martin Boehme 665da187cc [Clang] Add the `annotate_type` attribute
This is an analog to the `annotate` attribute but for types. The intent is to allow adding arbitrary annotations to types for use in static analysis tools.

For details, see this RFC:

https://discourse.llvm.org/t/rfc-new-attribute-annotate-type-iteration-2/61378

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D111548
2022-06-15 09:47:28 +02:00
Anders Waldenborg 657e954939 [clang] Add tests for statement expression in initializers
The commit 683e83c5
  [Clang][C++2b] P2242R3: Non-literal variables [...] in constexpr
fixed a code generation bug when using (C-extension) statement
expressions inside initializer expressions.

Before that commit a nested static initializer inside the statement
expression would not be emitted, causing it to be zero initialized.

It is a bit surprising (at least to me) that a commit implementing a new
C++ feature would fix this code generation bug. Zooming in it is the
change done in ExprConstant.cpp that helps. That changes so that
"ESR_Failed" is returned in more cases, causing the expression to not be
deemed constant. This fixes the code generation as instead the compiler
has to resort to generating a dynamic initializer.

That commit also meant that some statement expressions (in particular
the ones using static variables) that previously were accepted now are
errors due to not being constant (matching GCC behavior).

Given how a seemingly unrelated change caused this behavior to change,
it is probably a good thing to add at least some rudimentary tests for
these kind expressions.

Differential Revision: https://reviews.llvm.org/D127201
2022-06-14 23:16:41 +02:00
Shivam Gupta 48e1829874 [Diagnostics] Fix inconsistent shift-overflow warnings in C++20
This fixes https://github.com/llvm/llvm-project/issues/52873.
Don't warn in C++2A mode (and newer), as signed left shifts
always wrap and never overflow. Ref. -
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1236r1.html.
2022-06-14 20:19:46 +05:30
Balazs Benics 9da697e1bc Reland "[analyzer] Deprecate the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag"
It was previously reverted by 8406839d19.

---

This flag was introduced by
6818991d71
    commit 6818991d71
    Author: Ted Kremenek <kremenek@apple.com>
    Date:   Mon Dec 7 22:06:12 2009 +0000

  Add clang-cc option '-analyzer-opt-analyze-nested-blocks' to treat
  block literals as an entry point for analyzer checks.

The last reference was removed by this commit:
5c32dfc5fb

    commit 5c32dfc5fb
    Author: Anna Zaks <ganna@apple.com>
    Date:   Fri Dec 21 01:19:15 2012 +0000

  [analyzer] Add blocks and ObjC messages to the call graph.
  This paves the road for constructing a better function dependency graph.
  If we analyze a function before the functions it calls and inlines,
  there is more opportunity for optimization.
  Note, we add call edges to the called methods that correspond to
  function definitions (declarations with bodies).

Consequently, we should remove this dead flag.
However, this arises a couple of burning questions.
 - Should the `cc1` frontend still accept this flag - to keep
   tools/users passing this flag directly to `cc1` (which is unsupported,
   unadvertised) working.
 - If we should remain backward compatible, how long?
 - How can we get rid of deprecated and obsolete flags at some point?

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126067
2022-06-14 10:22:37 +02:00
Balazs Benics ffe7950ebc Reland "[analyzer] Deprecate `-analyzer-store region` flag"
I'm trying to remove unused options from the `Analyses.def` file, then
merge the rest of the useful options into the `AnalyzerOptions.def`.
Then make sure one can set these by an `-analyzer-config XXX=YYY` style
flag.
Then surface the `-analyzer-config` to the `clang` frontend;

After all of this, we can pursue the tablegen approach described
https://discourse.llvm.org/t/rfc-tablegen-clang-static-analyzer-engine-options-for-better-documentation/61488

In this patch, I'm proposing flag deprecations.
We should support deprecated analyzer flags for exactly one release. In
this case I'm planning to drop this flag in `clang-16`.

In the clang frontend, now we won't pass this option to the cc1
frontend, rather emit a warning diagnostic reminding the users about
this deprecated flag, which will be turned into error in clang-16.

Unfortunately, I had to remove all the tests referring to this flag,
causing a mass change. I've also added a test for checking this warning.

I've seen that `scan-build` also uses this flag, but I think we should
remove that part only after we turn this into a hard error.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126215
2022-06-14 09:20:41 +02:00
David Tenty 6a8673038b Reland [clang][AIX] add option mdefault-visibility-export-mapping
The option mdefault-visibility-export-mapping is created to allow
mapping default visibility to an explicit shared library export
(e.g. dllexport). Exactly how and if this is manifested is target
dependent (since it depends on how they map dllexport in the IR).

Three values are provided for the option:

* none: the default and behavior without the option, no additional export linkage information is created.
* explicit: add the export for entities with explict default visibility from the source, including RTTI
* all: add the export for all entities with default visibility

This option is useful for targets which do not export symbols as part of
their usual default linkage behaviour (e.g. AIX), such targets
traditionally specified such information in external files (e.g. export
lists), but this mapping allows them to use the visibility information
typically used for this purpose on other (e.g. ELF) platforms.

This relands commit: 8c8a2679a2

with fixes for the compile time and assert problems that were reported
by:

* making shouldMapVisibilityToDLLExport inline and provide an early return
in the case where no mapping is in effect (aka non-AIX platforms)
* don't try to export RTTI types which we will give internal linkage to

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D126340
2022-06-13 13:43:46 -04:00
owenca b1c300fe68 [clang-format] Handle deprecated options in dump_format_style.py
Also add two deprecated options as comments back to Format.h.
2022-06-12 23:35:48 -07:00
Yuki Okushi e43a85a363
[docs][clang] Fix a broken link on the APINotes doc
This patch replaces a link with a GitHub one.

Fixes llvm#55748

Differential Revision: https://reviews.llvm.org/D126599
2022-06-12 22:53:32 +09:00
ksyx 45b278f195 [Clang][Doc][SafeStack] Fix deadlink (NFC) 2022-06-11 10:59:51 -04:00
Simon Pilgrim 781dc344f5 [clang][docs] Fix typo in code-block declaration 2022-06-11 09:28:38 +01:00
Christopher Di Bella f21187eb2d [clang][tablegen] adds human documentation to `WarningOption`
Building on D126796, this commit adds the infrastructure for being able
to print out descriptions of what each warning does.

Differential Revision: https://reviews.llvm.org/D126832
2022-06-10 17:23:00 +00:00
Simon Tatham 9073b53e5d [Clang,ARM] Add release note for D127197.
I should have put that in the original commit, but @lenary only just
reminded me that it needed to be there.
2022-06-10 15:19:33 +01:00
Guillaume Chatelet 38637ee477 [clang] Add support for __builtin_memset_inline
In the same spirit as D73543 and in reply to https://reviews.llvm.org/D126768#3549920 this patch is adding support for `__builtin_memset_inline`.

The idea is to get support from the compiler to easily write efficient memory function implementations.

This patch could be split in two:
 - one for the LLVM part adding the `llvm.memset.inline.*` intrinsics.
 - and another one for the Clang part providing the instrinsic as a builtin.

Differential Revision: https://reviews.llvm.org/D126903
2022-06-10 13:13:59 +00:00
Nico Weber 8406839d19 Revert "[analyzer] Deprecate `-analyzer-store region` flag"
This reverts commit d50d9946d1.
Broke check-clang, see comments on https://reviews.llvm.org/D126067

Also revert dependent change "[analyzer] Deprecate the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag"
This reverts commit 07b4a6d046.

Also revert "[analyzer] Fix buildbots after introducing a new frontend warning"
This reverts commit 90374df15d.
(See https://reviews.llvm.org/rG90374df15ddc58d823ca42326a76f58e748f20eb)
2022-06-10 08:50:13 -04:00
Balazs Benics 07b4a6d046 [analyzer] Deprecate the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag
This flag was introduced by
6818991d71
    commit 6818991d71
    Author: Ted Kremenek <kremenek@apple.com>
    Date:   Mon Dec 7 22:06:12 2009 +0000

  Add clang-cc option '-analyzer-opt-analyze-nested-blocks' to treat
  block literals as an entry point for analyzer checks.

The last reference was removed by this commit:
5c32dfc5fb

    commit 5c32dfc5fb
    Author: Anna Zaks <ganna@apple.com>
    Date:   Fri Dec 21 01:19:15 2012 +0000

  [analyzer] Add blocks and ObjC messages to the call graph.
  This paves the road for constructing a better function dependency graph.
  If we analyze a function before the functions it calls and inlines,
  there is more opportunity for optimization.
  Note, we add call edges to the called methods that correspond to
  function definitions (declarations with bodies).

Consequently, we should remove this dead flag.
However, this arises a couple of burning questions.
 - Should the `cc1` frontend still accept this flag - to keep
   tools/users passing this flag directly to `cc1` (which is unsupported,
   unadvertised) working.
 - If we should remain backward compatible, how long?
 - How can we get rid of deprecated and obsolete flags at some point?

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126067
2022-06-10 13:09:37 +02:00
Balazs Benics d50d9946d1 [analyzer] Deprecate `-analyzer-store region` flag
I'm trying to remove unused options from the `Analyses.def` file, then
merge the rest of the useful options into the `AnalyzerOptions.def`.
Then make sure one can set these by an `-analyzer-config XXX=YYY` style
flag.
Then surface the `-analyzer-config` to the `clang` frontend;

After all of this, we can pursue the tablegen approach described
https://discourse.llvm.org/t/rfc-tablegen-clang-static-analyzer-engine-options-for-better-documentation/61488

In this patch, I'm proposing flag deprecations.
We should support deprecated analyzer flags for exactly one release. In
this case I'm planning to drop this flag in `clang-16`.

In the clang frontend, now we won't pass this option to the cc1
frontend, rather emit a warning diagnostic reminding the users about
this deprecated flag, which will be turned into error in clang-16.

Unfortunately, I had to remove all the tests referring to this flag,
causing a mass change. I've also added a test for checking this warning.

I've seen that `scan-build` also uses this flag, but I think we should
remove that part only after we turn this into a hard error.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D126215
2022-06-10 12:57:15 +02:00
isuckatcs 1d3d5ecea5 [Documentation] Fixed typos in LibASTMatchers tutorial
There was one missing parenthesis and a typo in the mentioned
part of the documentation.

Differential Revision: https://reviews.llvm.org/D124738
2022-06-10 10:22:36 +02:00
Yuki Okushi cedfb5462c
[docs] Update supported language standards list for C++
Differential Revision: https://reviews.llvm.org/D127065
2022-06-09 22:14:08 +09:00
Matthias Gehre 7e17e15c9f clang: Introduce -fexperimental-max-bitint-width
This splits of the introduction of -fexperimental-max-bitint-width
from https://reviews.llvm.org/D122234
because that PR is still blocked on discussions on the backend side.

I was asked [0] to upstream at least the flag.

[0] 09854f2af3 (commitcomment-75116619)

Differential Revision: https://reviews.llvm.org/D127287
2022-06-09 07:15:03 +01:00
Jose Manuel Monsalve Diaz d6f6cd5cd5 [docs][clang] Fixing minor typo
Changing "tot the" to "to the"
2022-06-08 23:35:11 +00:00
Jose Manuel Monsalve Diaz 28aa7d1884 [docs][clang] Minor typo fix
Changing "iamge" to "image"
2022-06-08 17:41:04 +00:00
Andrew Browne c7689fd552 [Clang] Fix memory leak due to TemplateArgumentListInfo used in AST node.
It looks like the leak is rooted at the allocation here:
1a155ee7de/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (L3857)

The VarTemplateSpecializationDecl is allocated using placement new which uses the AST structure for ownership: 1a155ee7de/clang/lib/AST/DeclBase.cpp (L99)

The problem is the TemplateArgumentListInfo inside 1a155ee7de/clang/include/clang/AST/DeclTemplate.h (L2721)
This object contains a vector which does not use placement new: 1a155ee7de/clang/include/clang/AST/TemplateBase.h (L564)

Apparently ASTTemplateArgumentListInfo should be used instead 1a155ee7de/clang/include/clang/AST/TemplateBase.h (L575)

https://reviews.llvm.org/D125802#3551305

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D126944
2022-06-08 09:58:25 -07:00
Martin Storsjö 20ca739701 [doc] Add release notes about SEH unwind information on ARM
Differential Revision: https://reviews.llvm.org/D127150
2022-06-08 11:32:17 +03:00
Evgeny Shulgin a4f8590247 [clang] Allow consteval functions in default arguments
We should not mark a function as "referenced" if we call it within a
ConstantExpr, because the expression will be folded to a value in LLVM
IR. To prevent emitting consteval function declarations, we should not "jump
over" a ConstantExpr when it is a top-level ParmVarDecl's subexpression.

Fixes https://github.com/llvm/llvm-project/issues/48230

Reviewed By: erichkeane, aaron.ballman, ChuanqiXu

Differenitial Revision: https://reviews.llvm.org/D119646
2022-06-07 10:54:37 +08:00
Aaron Ballman 881125ad91 Allow use of an elaborated type specifier in a _Generic association in C++
Currently, Clang accepts this code in C mode (where the tag is required
to be used) but rejects it in C++ mode thinking that the association is
defining a new type.

void foo(void) {
  struct S { int a; };
  _Generic(something, struct S : 1);
}
Clang thinks this in C++ because it sees struct S : when parsing the
class specifier and decides that must be a type definition (because the
colon signifies the presence of a base class type). This patch adds a
new declarator context to represent a _Generic association so that we
can distinguish these situations properly.

Fixes #55562

Differential Revision: https://reviews.llvm.org/D126969
2022-06-06 07:17:35 -04:00
Anders Waldenborg dd2362a8ba [clang] Allow const variables with weak attribute to be overridden
A variable with `weak` attribute signifies that it can be replaced with
a "strong" symbol link time. Therefore it must not emitted with
"weak_odr" linkage, as that allows the backend to use its value in
optimizations.

The frontend already considers weak const variables as
non-constant (note_constexpr_var_init_weak diagnostic) so this change
makes frontend and backend consistent.

This commit reverses the
  f49573d1 weak globals that are const should get weak_odr linkage.
commit from 2009-08-05 which introduced this behavior. Unfortunately
that commit doesn't provide any details on why the change was made.

This was discussed in
https://discourse.llvm.org/t/weak-attribute-semantics-on-const-variables/62311

Differential Revision: https://reviews.llvm.org/D126324
2022-06-03 23:44:15 +02:00
Hans Wennborg 166f9be330 Update old mailing list link in the nullability doc 2022-06-03 14:23:41 +02:00
Shilei Tian b917433835 [NFC][Doc] Finish atomic compare 2022-06-02 21:50:07 -04:00
Mike Rice 48d6a6c9ad [OpenMP][NFC] update status for 'omp_all_memory' directive to 'done' 2022-06-02 17:31:33 -07:00
Akira Hatanaka b64f6e5722 Add a release note for the scope enum initialization bug fix in
https://reviews.llvm.org/D126084
2022-06-02 17:13:05 -07:00
Hans Wennborg d42fe9aa84 Revert "[clang][AIX] add option mdefault-visibility-export-mapping"
This caused assertions, see comment on the code review:

llvm/clang/lib/AST/Decl.cpp:1510:
clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl *, clang::LVComputationKind):
Assertion `D->getCachedLinkage() == LV.getLinkage()' failed.

> The option mdefault-visibility-export-mapping is created to allow
> mapping default visibility to an explicit shared library export
> (e.g. dllexport). Exactly how and if this is manifested is target
> dependent (since it depends on how they map dllexport in the IR).
>
> Three values are provided for the option:
>
> * none: the default and behavior without the option, no additional export linkage information is created.
> * explicit: add the export for entities with explict default visibility from the source, including RTTI
> * all: add the export for all entities with default visibility
>
> This option is useful for targets which do not export symbols as part of
> their usual default linkage behaviour (e.g. AIX), such targets
> traditionally specified such information in external files (e.g. export
> lists), but this mapping allows them to use the visibility information
> typically used for this purpose on other (e.g. ELF) platforms.
>
> Reviewed By: MaskRay
>
> Differential Revision: https://reviews.llvm.org/D126340

This reverts commit 8c8a2679a2.
2022-06-02 15:09:39 +02:00
Aaron Ballman c745f2ce6c Revert "Drop qualifiers from return types in C (DR423)"
This reverts commit d374b65f2d.

The changes lose AST fidelity (reported in #55778), but also may be
improperly dropping _Atomic qualifiers. I am rolling the changes back
until I've finished discussions in WG14 about the proper resolution to
DR423.
2022-06-02 08:28:43 -04:00
David Tenty 8c8a2679a2 [clang][AIX] add option mdefault-visibility-export-mapping
The option mdefault-visibility-export-mapping is created to allow
mapping default visibility to an explicit shared library export
(e.g. dllexport). Exactly how and if this is manifested is target
dependent (since it depends on how they map dllexport in the IR).

Three values are provided for the option:

* none: the default and behavior without the option, no additional export linkage information is created.
* explicit: add the export for entities with explict default visibility from the source, including RTTI
* all: add the export for all entities with default visibility

This option is useful for targets which do not export symbols as part of
their usual default linkage behaviour (e.g. AIX), such targets
traditionally specified such information in external files (e.g. export
lists), but this mapping allows them to use the visibility information
typically used for this purpose on other (e.g. ELF) platforms.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D126340
2022-06-01 18:07:17 -04:00
Mital Ashok 872f74440f Fix std::has_unique_object_representations for _BitInt types with padding bits
"std::has_unique_object_representations<_BitInt(N)>" was always true,
even if the type has padding bits (since the trait assumes all integer
types have no padding bits). The standard has an explicit note that
this should not hold for types with padding bits.

Differential Revision: https://reviews.llvm.org/D125802
2022-06-01 11:34:40 -04:00
Luke Nihlen 1f6ea2a37c Expand definition deprecation warning to include constexpr statements.
Clang currently warns on definitions downgraded to declarations
with a const modifier, but not for a constexpr modifier. This patch
updates the warning logic to warn on both inputs, and adds a test to
check the additional case as well.

See also: https://bugs.chromium.org/p/chromium/issues/detail?id=1284718

Differential Revision: https://reviews.llvm.org/D126664
2022-06-01 11:31:07 -04:00
Phoebe Wang a2ea5b496b [X86] Add support for `-mharden-sls=[none|all|return|indirect-jmp]`
The patch addresses the feature request from https://github.com/ClangBuiltLinux/linux/issues/1633. The implementation borrows a lot from aarch64.

Reviewed By: nickdesaulniers, MaskRay

Differential Revision: https://reviews.llvm.org/D126137
2022-06-01 09:45:04 +08:00
Joseph Huber 259a9df963 [Clang][Docs] Fix typo in offload packager reference 2022-05-31 12:27:33 -04:00
Joseph Huber e22b02d9b4 [Clang][Docs] Document the clang-offload-packager better
Summary:
This patch adds more in-depth documentation to the
clang-offload-packacker's binary format. This format is used to create
fat binaries and link them.
2022-05-31 11:53:27 -04:00
Joel E. Denny 4a36813669 [OpenACC][OpenMP] Document atomic-in-teams extension
That is, put D126323 in the status doc and explain its relationship to
OpenACC support.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D126547
2022-05-27 18:53:19 -04:00
Anastasia Stulova 7df25978ef [Doc][OpenCL] Misc wording improvements for SPIR-V 2022-05-27 11:13:06 +01:00
Balazs Benics 3a7a465def [analyzer][docs] Fix typo in checker name
Fixes #55720
2022-05-27 10:07:06 +02:00
Anastasia Stulova 3087afb421 [OpenCL][Doc] Misc improvements related to SPIR-V support. 2022-05-26 15:54:33 +01:00
Joseph Huber b7c8c4d8cf [Clang] Introduce `--offload-link` option to perform offload device linking
The new driver uses an augmented linker wrapper to perform the device
linking phase, but to the user looks like a regular linker invocation.
Contrary to the old driver, the new driver contains all the information
necessary to produce a linked device image in the host object itself.
Currently, we infer the usage of the device linker by the user
specifying an offloading toolchain, e.g. (--offload-arch=...) or
(-fopenmp-targets=...), but this shouldn't be strictly necessary.
This patch introduces a new option `--offload-link` to tell
 the driver to use the offloading linker instead. So a compilation flow
 can now look like this,

```
clang foo.cu --offload-new-driver -fgpu-rdc --offload-arch=sm_70 -c
clang foo.o --offload-link -lcudart
```

I was considering if this could be merged into the `-fuse-ld` option,
but because the device linker wraps over the users linker it would
conflict with that. In the future it's possible to merge this into `lld`
completely or `gold` via a plugin and we would use this option to
enable the device linking feature. Let me know what you think for this.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D126398
2022-05-25 16:30:53 -04:00
James Y Knight 997b072e10 C++ DR2394: Const-default-constructible for members.
Const class members may be initialized with a defaulted default
constructor under the same conditions it would be allowed for a const
object elsewhere.

Differential Revision: https://reviews.llvm.org/D126170
2022-05-25 14:20:11 -04:00
Joseph Huber 8a1984c25e [Clang][Docs] Document `-Xoffload-linker` flag
Summary:
I added the `-Xoffload-linker` flag and did not provide additional
documentation. This patch adds it.
2022-05-25 13:33:10 -04:00
Anastasia Stulova 730dc4e9bc [Clang] Added options for integrated backend.
Following the new flow for external object code emission,
provide flags to switch between integrated and external
backend similar to the integrated assembler options.

SPIR-V target is the only user of this functionality at
this point.

This patch also updated SPIR-V documentation to clarify
that integrated object code emission for SPIR-V is an
experimental feature.

Differential Revision: https://reviews.llvm.org/D125679
2022-05-25 12:07:33 +01:00
David Blaikie e59f648d69 Move GCC-compatible pod-packing change to v15/old behavior available at v14 and below
Since this didn't make it into the v14 release - anyone requesting the
v14 ABI shouldn't get this GCC-compatible change that isn't backwards
compatible with v14 Clang.

Differential Revision: https://reviews.llvm.org/D126334
2022-05-25 03:03:27 +00:00
Chuanqi Xu a1ffba8d52 [C++20] [Coroutines] Conform the updates for CWG issue 2585
According to the updates in CWG issue 2585
https://cplusplus.github.io/CWG/issues/2585.html, we shouldn't find an
allocation function with (size, p0, …, pn) in global scope.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D126187
2022-05-25 10:31:26 +08:00
Anastasia Stulova d61ded1034 [OpenCL] Make -cl-ext a driver option.
For generic targets such as SPIR-V clang sets all OpenCL
extensions/features as supported by default. However
concrete targets are unlikely to support all extensions
features, which creates a problem when such generic SPIR-V
binary is compiled for a specific target later on.

To allow compile time diagnostics for unsupported features
this flag is now being exposed in the clang driver.

Differential Revision: https://reviews.llvm.org/D125243
2022-05-24 11:34:19 +01:00
David Blaikie 0b903ef6aa Re-add release notes for GCC ABI compatibility for non-POD in packed structs 2022-05-22 01:15:34 +00:00
Stephen Long ae80024fbe [clang] Honor __attribute__((no_builtin("foo"))) on functions
Support for `__attribute__((no_builtin("foo")))` was added in https://reviews.llvm.org/D68028,
but builtins were still being used even when the attribute was placed on a function.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D124701
2022-05-20 06:41:47 -07:00
Jennifer Yu 7aa9c39381 [Clang][[OpenMP5.1] Initial parser/sema for default(private) clause
This implements the default(private) clause as defined in OMP5.1

Differential Revision: https://reviews.llvm.org/D125912
2022-05-19 12:43:13 -07:00
Aaron Ballman d374b65f2d Drop qualifiers from return types in C (DR423)
WG14 DR423 (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_423),
resolved during the C11 time frame, changed the way qualifiers are
handled on function return types and in cast expressions after it was
noted that these types are now directly observable via generic
selection expressions. In C, the function declarator is adjusted to
ignore all qualifiers (including _Atomic qualifiers).

Clang already handles the cast expression case correctly (by performing
the lvalue conversion, which drops the qualifiers as well), but with
these changes it will now also handle function declarations
appropriately.

Fixes #39595

Differential Revision: https://reviews.llvm.org/D125919
2022-05-19 13:06:50 -04:00
Archibald Elliott 2321c36fbf [ARM] Don't Enable AES Pass for Generic Cores
This brings clang/llvm into line with GCC. The Pass is still enabled for
the affected cores, but is now opt-in when using `-march=`.

I also took the opportunity to add release notes for this change.

Reviewed By: john.brawn

Differential Revision: https://reviews.llvm.org/D125775
2022-05-18 13:10:31 +01:00
Gabor Marton 56b9b97c1e [clang][analyzer][ctu] Make CTU a two phase analysis
This new CTU implementation is the natural extension of the normal single TU
analysis. The approach consists of two analysis phases. During the first phase,
we do a normal single TU analysis. During this phase, if we find a foreign
function (that could be inlined from another TU) then we don’t inline that
immediately, we rather mark that to be analysed later.
When the first phase is finished then we start the second phase, the CTU phase.
In this phase, we continue the analysis from that point (exploded node)
which had been enqueued during the first phase. We gradually extend the
exploded graph of the single TU analysis with the new node that was
created by the inlining of the foreign function.

We count the number of analysis steps of the first phase and we limit the
second (ctu) phase with this number.

This new implementation makes it convenient for the users to run the
single-TU and the CTU analysis in one go, they don't need to run the two
analysis separately. Thus, we name this new implementation as "onego" CTU.

Discussion:
https://discourse.llvm.org/t/rfc-much-faster-cross-translation-unit-ctu-analysis-implementation/61728

Differential Revision: https://reviews.llvm.org/D123773
2022-05-18 10:35:52 +02:00
Erich Keane 2def74bef1 Fix release note typo from 6da3d66f 2022-05-17 06:35:06 -07:00
Erich Keane 6da3d66f03 [concepts] Implement dcl.decl.general p4: No constraints on non-template funcs
The standard says:
The optional requires-clause ([temp.pre]) in an init-declarator or
member-declarator shall be present only if the declarator declares a
templated function ([dcl.fct]).

This implements that limitation, and updates the tests to the best of my
ability to capture the intent of the original checks.

Differential Revision: https://reviews.llvm.org/D125711
2022-05-17 06:21:51 -07:00
Chuanqi Xu 452fac9534 [Frontend] [Coroutines] Emit error when we found incompatible allocation
function in promise_type

According to https://cplusplus.github.io/CWG/issues/2585.html, this
fixes https://github.com/llvm/llvm-project/issues/54881

Simply, the clang tried to found (do lookup and overload resolution. Is
there any better word to use than found?) allocation function in
promise_type and global scope. However, this is not consistent with the
standard. The standard behavior would be that the compiler shouldn't
lookup in global scope in case we lookup the allocation function name in
promise_type. In other words, the program is ill-formed if there is
incompatible allocation function in promise type.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D125517
2022-05-17 10:36:21 +08:00
Fangrui Song babbd96f23 [docs] Re-generate ClangCommandLineReference.rst 2022-05-16 10:34:01 -07:00
Stephen Long b147717bb3 [MSVC] Add support for pragma alloc_text
`#pragma alloc_text` is a MSVC pragma that names the code section where functions should be placed. It only
applies to functions with C linkage.

https://docs.microsoft.com/en-us/cpp/preprocessor/alloc-text?view=msvc-170

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D125011
2022-05-16 07:00:17 -07:00
Simon Pilgrim f66596c94f [clang][docs] Add escape code to fix missing '*' in reduction operation list 2022-05-15 12:32:11 +01:00
Stephen Long 3946de0456 [MSVC] Add support for pragma function
MSVC pragma function tells the compiler to generate calls to functions in the pragma function list, instead of using the builtin. Needs https://reviews.llvm.org/D124701

https://docs.microsoft.com/en-us/cpp/preprocessor/function-c-cpp?view=msvc-170

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D124702
2022-05-13 06:39:47 -07:00
Ken Matsui a247ba9d15 Suggest typo corrections for preprocessor directives
When a preprocessor directive is unknown outside of a skipped
conditional block, we give an error diagnostic because we don't know
how to proceed with preprocessing. But when the directive is in a
skipped conditional block, we would not diagnose it on the theory that
the directive may be known to an implementation other than Clang.

Now, for unknown directives inside a skipped conditional block, we
diagnose the unknown directive as a warning if it is sufficiently
similar to a directive specific to preprocessor conditional blocks. For
example, we'll warn about `#esle` and suggest `#else` but we won't warn
about `#progma` because it's not a directive specific to preprocessor
conditional blocks.

Fixes #51598

Differential Revision: https://reviews.llvm.org/D124726
2022-05-13 09:16:46 -04:00