[all-commits] [llvm/llvm-project] e841d5: [clang] Ensure that Attr::Create(Implicit) chooses...
rsandifo-arm via All-commits
all-commits at lists.llvm.org
Thu Apr 13 02:16:05 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e841d50926347c3596009dd4fbc4cbd1a1a2e0b8
https://github.com/llvm/llvm-project/commit/e841d50926347c3596009dd4fbc4cbd1a1a2e0b8
Author: Richard Sandiford <richard.sandiford at arm.com>
Date: 2023-04-13 (Thu, 13 Apr 2023)
Changed paths:
M clang/include/clang/Basic/Attr.td
M clang/include/clang/Basic/AttributeCommonInfo.h
M clang/lib/Sema/SemaDecl.cpp
M clang/lib/Sema/SemaDeclCXX.cpp
M clang/lib/Serialization/ASTReaderDecl.cpp
M clang/unittests/AST/DeclTest.cpp
M clang/utils/TableGen/ClangAttrEmitter.cpp
Log Message:
-----------
[clang] Ensure that Attr::Create(Implicit) chooses a valid syntax
The purpose of this patch and follow-on patches is to ensure that
AttributeCommonInfos always have a syntax that is appropriate for
their kind (i.e. that it matches one of the entries in Attr.td).
The attribute-specific Create and CreateImplicit methods had four
overloads, based on their tail arguments:
(1) no extra arguments
(2) an AttributeCommonInfo
(3) a SourceRange
(4) a SourceRange, a syntax, and (where necessary) a spelling
When (4) had a spelling argument, it defaulted to
SpellingNotCalculated.
One disadvantage of this was that (1) and (3) zero-initialized
the syntax field of the AttributeCommonInfo, which corresponds
to AS_GNU. But AS_GNU isn't always listed as a possibility
in Attr.td.
This patch therefore removes (1) and (3) and instead provides
the same functionality using default arguments on (4) (a bit
like the existing default argument for the spelling).
The default syntax is taken from the attribute's first valid
spelling.
Doing that raises the question: what should happen for attributes
like AlignNatural and CUDAInvalidTarget that are only ever created
implicitly, and so have no source-code manifestation at all?
The patch adds a new AS_Implicit "syntax" for that case.
The patch also removes the syntax argument for these attributes,
since the syntax must always be AS_Implicit.
For similar reasons, the patch removes the syntax argument if
there is exactly one valid spelling.
Doing this means that AttributeCommonInfo no longer needs the
single-argument constructors. It is always given a syntax instead.
Differential Revision: https://reviews.llvm.org/D148101
Commit: b6d4d51f8f5aab311df34c753b925760578729bd
https://github.com/llvm/llvm-project/commit/b6d4d51f8f5aab311df34c753b925760578729bd
Author: Richard Sandiford <richard.sandiford at arm.com>
Date: 2023-04-13 (Thu, 13 Apr 2023)
Changed paths:
M clang/include/clang/Basic/AttributeCommonInfo.h
M clang/include/clang/Parse/Parser.h
M clang/include/clang/Sema/ParsedAttr.h
M clang/lib/AST/ASTImporter.cpp
M clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
M clang/lib/Parse/ParseDecl.cpp
M clang/lib/Sema/HLSLExternalSemaSource.cpp
M clang/lib/Sema/SemaAttr.cpp
M clang/lib/Sema/SemaDecl.cpp
M clang/lib/Sema/SemaDeclAttr.cpp
M clang/lib/Sema/SemaDeclCXX.cpp
M clang/lib/Sema/SemaObjCProperty.cpp
M clang/lib/Sema/SemaOpenMP.cpp
M clang/lib/Sema/SemaType.cpp
M clang/lib/Serialization/ASTReaderDecl.cpp
M clang/utils/TableGen/ClangAttrEmitter.cpp
Log Message:
-----------
[clang] Specify attribute syntax & spelling with a single argument
When constructing an attribute, the syntactic form was specified
using two arguments: an attribute-independent syntax type and an
attribute-specific spelling index. This patch replaces them with
a single argument.
In most cases, that's done using a new Form class that combines the
syntax and spelling into a single object. This has the minor benefit
of removing a couple of constructors. But the main purpose is to allow
additional information to be stored as well, beyond just the syntax and
spelling enums.
In the case of the attribute-specific Create and CreateImplicit
functions, the patch instead uses the attribute-specific spelling
enum. This helps to ensure that the syntax and spelling are
consistent with each other and with the Attr.td definition.
If a Create or CreateImplicit caller specified a syntax and
a spelling, the patch drops the syntax argument and keeps the
spelling. If the caller instead specified only a syntax
(so that the spelling was SpellingNotCalculated), the patch
simply drops the syntax argument.
There were two cases of the latter: TargetVersion and Weak.
TargetVersionAttrs were created with GNU syntax, which matches
their definition in Attr.td, but which is also the default.
WeakAttrs were created with Pragma syntax, which does not match
their definition in Attr.td. Dropping the argument switches
them to AS_GNU too (to match [GCC<"weak">]).
Differential Revision: https://reviews.llvm.org/D148102
Commit: 265d87e46535bef2b718759ba39bb9fa30b1ef48
https://github.com/llvm/llvm-project/commit/265d87e46535bef2b718759ba39bb9fa30b1ef48
Author: Richard Sandiford <richard.sandiford at arm.com>
Date: 2023-04-13 (Thu, 13 Apr 2023)
Changed paths:
M clang/include/clang/Basic/AttributeCommonInfo.h
M clang/lib/Parse/ParseDecl.cpp
M clang/lib/Parse/ParseDeclCXX.cpp
M clang/lib/Parse/ParseExprCXX.cpp
Log Message:
-----------
[clang] Allow attributes to be constructed from keyword tokens
This patch adds an extra AttributeCommonInfo::Form constructor
for keywords, represented by their TokenKind. This isn't a
win on its own, but it helps with later patches.
No functional change intended.
Differential Revision: https://reviews.llvm.org/D148103
Commit: aec3f951bf368d45b441554dac6e027678f9f3ee
https://github.com/llvm/llvm-project/commit/aec3f951bf368d45b441554dac6e027678f9f3ee
Author: Richard Sandiford <richard.sandiford at arm.com>
Date: 2023-04-13 (Thu, 13 Apr 2023)
Changed paths:
M clang/include/clang/Basic/AttributeCommonInfo.h
M clang/lib/Parse/ParseCXXInlineMethods.cpp
M clang/lib/Parse/ParseDecl.cpp
M clang/lib/Parse/ParseDeclCXX.cpp
M clang/lib/Parse/ParseHLSL.cpp
M clang/lib/Parse/ParseObjc.cpp
M clang/lib/Parse/ParsePragma.cpp
M clang/lib/Parse/ParseStmt.cpp
M clang/lib/Sema/SemaAttr.cpp
M clang/lib/Sema/SemaDecl.cpp
M clang/lib/Sema/SemaType.cpp
M clang/utils/TableGen/ClangAttrEmitter.cpp
Log Message:
-----------
[clang] Type safety tweak for AttributeCommonInfo::Form
This patch adds static functions for constructing most
AttributeCommonInfo::Forms. Direct construction is only retained where
all fields (currently the syntax and spelling) are specified explicitly.
This is a wash on its own. The purpose is to allow extra fields
to be added to Form without disrupting all callers. In particular,
it allows extra information to be stored about keywords without
affecting non-keyword uses.
No functional change intended.
Differential Revision: https://reviews.llvm.org/D148104
Commit: bd41371be02f6f5713459a2f6fe109cd3c01b4a4
https://github.com/llvm/llvm-project/commit/bd41371be02f6f5713459a2f6fe109cd3c01b4a4
Author: Richard Sandiford <richard.sandiford at arm.com>
Date: 2023-04-13 (Thu, 13 Apr 2023)
Changed paths:
M clang/include/clang/Basic/AttributeCommonInfo.h
M clang/lib/Sema/SemaType.cpp
M clang/lib/Serialization/ASTReaderDecl.cpp
M clang/utils/TableGen/ClangAttrEmitter.cpp
Log Message:
-----------
[clang] Fix FIXME in isAlignasAttribute()
AttributeCommonInfo::isAlignasAttribute() was used in one place:
isCXX11Attribute(). The intention was for isAlignasAttribute()
to return true for the C++ alignas keyword. However, as a FIXME
noted, the function also returned true for the C _Alignas keyword.
This meant that isCXX11Attribute() returned true for _Alignas as
well as for alignas.
AttributeCommonInfos are now always constructed with an
AttributeCommonInfo::Form. We can use that Form to convey whether
a keyword is alignas or not.
The patch uses 1 bit of an 8-bit hole in the current layout
of AttributeCommonInfo. This might not be the best long-term design,
but it should be easy to adapt the layout if necessary (that is,
if other uses are found for the spare bits).
I don't know of a way of testing this (other than grep -c FIXME)
Differential Revision: https://reviews.llvm.org/D148105
Commit: 053bdb77b0ce4506d15ed381b6db0dddafe52c3e
https://github.com/llvm/llvm-project/commit/053bdb77b0ce4506d15ed381b6db0dddafe52c3e
Author: Richard Sandiford <richard.sandiford at arm.com>
Date: 2023-04-13 (Thu, 13 Apr 2023)
Changed paths:
M clang/include/clang/Basic/AttributeCommonInfo.h
Log Message:
-----------
[clang] Bump AS_GNU to 1
Following a suggestion from Erich in https://reviews.llvm.org/D148101,
this patch bumps AS_GNU to 1 so that syntax 0 is invalid. It also
asserts that the syntax is in range.
Differential Revision: https://reviews.llvm.org/D148148
Compare: https://github.com/llvm/llvm-project/compare/cafefe01604c...053bdb77b0ce
More information about the All-commits
mailing list