[all-commits] [llvm/llvm-project] b1867e: [Attributes] Support Attributes being declared as ...
Dan Liew via All-commits
all-commits at lists.llvm.org
Mon Apr 29 18:38:08 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b1867e18c346e9621e14270bea2d1acb7d2a9ce0
https://github.com/llvm/llvm-project/commit/b1867e18c346e9621e14270bea2d1acb7d2a9ce0
Author: Dan Liew <delcypher at gmail.com>
Date: 2024-04-29 (Mon, 29 Apr 2024)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/Attr.td
M clang/include/clang/Basic/LangOptions.def
M clang/include/clang/Driver/Options.td
M clang/include/clang/Parse/Parser.h
M clang/lib/Driver/ToolChains/Clang.cpp
M clang/lib/Parse/ParseDecl.cpp
A clang/test/Driver/experimental-late-parse-attributes.c
M clang/utils/TableGen/ClangAttrEmitter.cpp
Log Message:
-----------
[Attributes] Support Attributes being declared as supporting an experimental late parsing mode "extension" (#88596)
This patch changes the `LateParsed` field of `Attr` in `Attr.td` to be
an instantiation of the new `LateAttrParseKind` class. The instation can be one of the following:
* `LateAttrParsingNever` - Corresponds with the false value of `LateParsed` prior to this patch (the default for an attribute).
* `LateAttrParseStandard` - Corresponds with the true value of `LateParsed` prior to this patch.
* `LateAttrParseExperimentalExt` - A new mode described below.
`LateAttrParseExperimentalExt` is an experimental extension to
`LateAttrParseStandard`. Essentially this allows
`Parser::ParseGNUAttributes(...)` to distinguish between these cases:
1. Only `LateAttrParseExperimentalExt` attributes should be late parsed.
2. Both `LateAttrParseExperimentalExt` and `LateAttrParseStandard`
attributes should be late parsed.
Callers (and indirect callers) of `Parser::ParseGNUAttributes(...)`
indicate the desired behavior by setting a flag in the
`LateParsedAttrList` object that is passed to the function.
In addition to the above, a new driver and frontend flag
(`-fexperimental-late-parse-attributes`) with a corresponding LangOpt
(`ExperimentalLateParseAttributes`) is added that changes how
`LateAttrParseExperimentalExt` attributes are parsed.
* When the flag is disabled (default), in cases where only
`LateAttrParsingExperimentalOnly` late parsing is requested, the
attribute will be parsed immediately (i.e. **NOT** late parsed). This
allows the attribute to act just like a `LateAttrParseStandard`
attribute when the flag is disabled.
* When the flag is enabled, in cases where only
`LateAttrParsingExperimentalOnly` late parsing is requested, the
attribute will be late parsed.
The motivation behind this change is to allow the new `counted_by`
attribute (part of `-fbounds-safety`) to support late parsing but
**only** when `-fexperimental-late-parse-attributes` is enabled. This
attribute needs to support late parsing to allow it to refer to fields
later in a struct definition (or function parameters declared later).
However, there isn't a precedent for supporting late attribute parsing
in C so this flag allows the new behavior to exist in Clang but not be
on by default. This behavior was requested as part of the
`-fbounds-safety` RFC process
(https://discourse.llvm.org/t/rfc-enforcing-bounds-safety-in-c-fbounds-safety/70854/68).
This patch doesn't introduce any uses of `LateAttrParseExperimentalExt`.
This will be added for the `counted_by` attribute in a future patch
(https://github.com/llvm/llvm-project/pull/87596). A consequence is the
new behavior added in this patch is not yet testable. Hence, the lack of
tests covering the new behavior.
rdar://125400257
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list