[clang-format] Correctly annotate C compound literal braces (#173771)
Fixes https://github.com/llvm/llvm-project/issues/173583
clang-format mis-formats C compound literals used in macro bodies, e.g.
`#define getAddr(v, type) &(type){v}`, treating `{...}` as a
block/function body
and reflowing the macro with backslashes and spaces.
This change:
- Recognizes `&( ... ){ ... }` patterns in macro bodies and marks the
brace as a braced-init.
- Improves parsing stability for braced lists in macro bodies.
Tests:
- FormatTests
---------
Co-authored-by: owenca <owenpiano at gmail.com>
[flang] Changes to "unsafe Cray pointers" option (#175223)
Reserve "-funsafe-cray-pointers" (with "f") for the driver. In the
fir-alias-analysis use "-unsafe-cray-pointers" (without "f").
This prevents conflicts with how certain kinds of tools use the "unsafe
Cray pointers" options.
InstCombine: Add more tests for min/max SimplifyDemandedFPClass
Test some more refined cases, such as ordering with 0s and within
known positive and known negative cases.
InstCombine: Improve SimplifyDemandedFPClass min/max handling
Refine handling of minimum/maximum and minimumnum/maximumnum. The
previous folds to input were based on sign bit checks. This was too
conservative with 0s. This can now consider -0 as less than or equal
to +0 as appropriate, account for nsz. It additionally can handle
cases like one half is known positive normal and the other subnormal.
ADT: Add utility functions for comparing FPClassTest
Add utility functions for checking if less and greater queries
are known to not evaluate to true. This will permit more precise
folding of min/max intrinsics. The test is kind of a mess.
[clang] Add a valid begin source location for abbreviated function templates (#174723)
The begin source location for function templates is determined by the
source location of the template keyword.
Pure abbreviated function templates do not have the template keyword.
This results in an invalid begin source location for abbreviated
function templates.
Without a valid begin source location, comments cannot be attached to
the function template which leads to the bug described in
clangd/clangd#2565.
This patch introduces new begin locations for abbreviated function
templates (begin of the templated function) and generic lambdas (begin
of the introducer `[...]`) when creating the template parameter lists in
Sema.
Control spacing for attribute printing (#174197)
This was motivated by the decl printing for the alignas() keyword
attribute:
class alignas(1) Foo;
would be printed as:
class alignas(1) Foo;
with two spaces before class name.
Rather than trying to help `prettyPrintAttributes` guess what the caller
wants in terms of leading and trailing spaces, have it return an
`optional<string>` which is either the pretty-printed attributes for
Pos,
or `nullopt` if no attributes were found.
[3 lines not shown]
[MLIR][Python] Register `OpAttributeMap` as `Mapping` for `match` compatibility (#174292)
This is a continuation of the idea from #174091 to add `match` support
for MLIR containers. In this PR the `OpAttributeMap` container is
registered as a `Mapping`, so be mapped as a "dictionary" in `match`
statements.
For this to work the `get(key, default=None)` method had to be
implemented. Those are pretty much copys of `dunderGetItemNamed` and
`dunderGetItemIndexed` with an added argument and `nb::object` as return
type, because they can now return other types than just `PyAttribute`.
Was unsure if I should refactor this to make `dunderGetItem...` use the
new `getWithDefault...` or if a separate method is preferred. Kept it as
a copy for simplicitys sake for now.
Even though the `OpAttributeMap` supports indexing by `int` and `str`,
Python does not allow to register it as a `Sequence` and a `Mapping` at
the same time. If it is registered as a Sequence it only returns the
attribute names as string, not as `NamedAttribute`. It is technically
[62 lines not shown]