Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5 |
|
#
8bdf13b1 |
| 19-Nov-2024 |
apple-fcloutier <75502309+apple-fcloutier@users.noreply.github.com> |
[ObjC] Name lookup in methods shouldn't allow shadowing types (#116683)
Arguably as a bug, Clang has previously not mixed up Objective-C
parameter names with types. This allows developers to write
[ObjC] Name lookup in methods shouldn't allow shadowing types (#116683)
Arguably as a bug, Clang has previously not mixed up Objective-C
parameter names with types. This allows developers to write parameter
names that _should_ shadow type names, but don't. For instance:
@interface Foo
-(void)foo:(int)id bar:(id)name; // OK
@end
Commit 97788089988a2ace63d717cadbcfe3443f380f9c changed the way that
parameters are parsed to bring it more in line with how C parameters are
parsed, but it breaks the example above. Given an expectation that the
change wouldn't introduce source breaks, this is not something we can go
forward with.
97788089988a2ace63d717cadbcfe3443f380f9c did this so that late-parsed
attributes could reference Objective-C parameters. This change buffers
Objective-C parameter info until after all parameters are parsed and
turns them into parameter declarations before realizing late-parsed
attributes instead.
Radar-ID: 139996306
show more ...
|
Revision tags: llvmorg-19.1.4 |
|
#
834dfd23 |
| 18-Nov-2024 |
Kazu Hirata <kazu@google.com> |
[Parse] Remove ParseDiagnostic.h (#116496)
This patch removes clang/Parse/ParseDiagnostic.h because it just
forwards to clang/Basic/DiagnosticParse.h.
|
#
97788089 |
| 31-Oct-2024 |
apple-fcloutier <75502309+apple-fcloutier@users.noreply.github.com> |
[ObjC] Insert method parameters in scope as they are parsed (#113745)
Before this change, ParseObjc would call the closing
`MaybeParseAttributes` before it had created Objective-C `ParmVarDecl`
ob
[ObjC] Insert method parameters in scope as they are parsed (#113745)
Before this change, ParseObjc would call the closing
`MaybeParseAttributes` before it had created Objective-C `ParmVarDecl`
objects (and associated name lookup entries), meaning that you could not
reference Objective-C method parameters in
`__attribute__((diagnose_if))`. This change moves the creation of the
`ParmVarDecl` objects ahead of calling `Sema::ActOnMethodDeclaration` so
that `MaybeParseAttributes` can find them. This is already how it works
for C parameters hanging off of the selector.
This change alone is insufficient to enable `diagnose_if` for
Objective-C methods and effectively is NFC. There will be a follow-up PR
for diagnose_if. This change is still useful for any other work that may
need attributes to reference Objective-C parameters.
rdar://138596211
show more ...
|
Revision tags: llvmorg-19.1.3 |
|
#
4dd55c56 |
| 24-Oct-2024 |
Jay Foad <jay.foad@amd.com> |
[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)
Follow up to #109133.
|
Revision tags: llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3 |
|
#
27d37ee4 |
| 17-Aug-2024 |
Vlad Serebrennikov <serebrennikov.vladislav@gmail.com> |
[clang][NFC] Clean up `Sema` headers
When various `Sema*.h` and `Sema*.cpp` files were created, cleanup of `Sema.h` includes and forward declarations was left for the later. Now's the time. This com
[clang][NFC] Clean up `Sema` headers
When various `Sema*.h` and `Sema*.cpp` files were created, cleanup of `Sema.h` includes and forward declarations was left for the later. Now's the time. This commit touches `Sema.h` and Sema components: 1. Unused includes are removed. 2. Unused forward declarations are removed. 3. Missing includes are added (those files are largely IWYU-clean now). 4. Includes were converted into forward declarations where possible.
As this commit focuses on headers, all changes to `.cpp` files were minimal, and were aiming at keeping everything buildable.
show more ...
|
Revision tags: llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7 |
|
#
29189738 |
| 24-May-2024 |
Dan Liew <dan@su-root.co.uk> |
Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (#93121)
[BoundsSafety] Reland #93121 Allow 'counted_by' attribute on pointers in structs in C (#93121)
Fix
Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (#93121)
[BoundsSafety] Reland #93121 Allow 'counted_by' attribute on pointers in structs in C (#93121)
Fixes #92687.
Previously the attribute was only allowed on flexible array members.
This patch patch changes this to also allow the attribute on pointer
fields in structs and also allows late parsing of the attribute in some
contexts.
For example this previously wasn't allowed:
```
struct BufferTypeDeclAttributePosition {
size_t count;
char* buffer __counted_by(count); // Now allowed
}
```
Note the attribute is prevented on pointee types where the size isn't
known at compile time. In particular pointee types that are:
* Incomplete (e.g. `void`) and sizeless types
* Function types (e.g. the pointee of a function pointer)
* Struct types with a flexible array member
This patch also introduces late parsing of the attribute when used in
the declaration attribute position. For example
```
struct BufferTypeDeclAttributePosition {
char* buffer __counted_by(count); // Now allowed
size_t count;
}
```
is now allowed but **only** when passing
`-fexperimental-late-parse-attributes`. The motivation for using late
parsing here is to avoid breaking the data layout of structs in existing
code that want to use the `counted_by` attribute. This patch is the
first use of `LateAttrParseExperimentalExt` in `Attr.td` that was
introduced in a previous patch.
Note by allowing the attribute on struct member pointers this now allows
the possiblity of writing the attribute in the type attribute position.
For example:
```
struct BufferTypeAttributePosition {
size_t count;
char *__counted_by(count) buffer; // Now allowed
}
```
However, the attribute in this position is still currently parsed
immediately rather than late parsed. So this will not parse currently:
```
struct BufferTypeAttributePosition {
char *__counted_by(count) buffer; // Fails to parse
size_t count;
}
```
The intention is to lift this restriction in future patches. It has not
been done in this patch to keep this size of this commit small.
There are also several other follow up changes that will need to be
addressed in future patches:
* Make late parsing working with anonymous structs (see
`on_pointer_anon_buf` in `attr-counted-by-late-parsed-struct-ptrs.c`).
* Allow `counted_by` on more subjects (e.g. parameters, returns types)
when `-fbounds-safety` is enabled.
* Make use of the attribute on pointer types in code gen (e.g. for
`_builtin_dynamic_object_size` and UBSan's array-bounds checks).
This work is heavily based on a patch originally written by Yeoul Na.
** Differences between #93121 and this patch **
* The memory leak that caused #93121 to be reverted (see #92687) should
now be fixed. See "The Memory Leak".
* The fix to `pragma-attribute-supported-attributes-list.test`
(originally in cef6387) has been incorporated into this patch.
* A relaxation of counted_by semantics (originally in 112eadd) has been
incorporated into this patch.
* The assert in `Parser::DistributeCLateParsedAttrs` has been removed
because that broke downstream code.
* The switch statement in `Parser::ParseLexedCAttribute` has been
removed in favor of using `Parser::ParseGNUAttributeArgs` which does
the same thing but is more feature complete.
* The `EnterScope` parameter has been plumbed through
`Parser::ParseLexedCAttribute` and `Parser::ParseLexedCAttributeList`.
It currently doesn't do anything but it will be needed in future
commits.
** The Memory Leak **
The problem was that these lines parsed the attributes but then did nothing to free the memory
```
assert(!getLangOpts().CPlusPlus);
for (auto *LateAttr : LateFieldAttrs)
ParseLexedCAttribute(*LateAttr);
```
To fix this this a new `Parser::ParseLexedCAttributeList` method has been
added (based on `Parser::ParseLexedAttributeList`) which does the
necessary memory management. The intention is to merge these two
methods together so there is just one implementation in a future patch
(#93263).
A more principled fixed here would be to fix the ownership of the
`LateParsedAttribute` objects. In principle `LateParsedAttrList` should own
its pointers exclusively and be responsible for deallocating them.
Unfortunately this is complicated by `LateParsedAttribute` objects also
being stored in another data structure (`LateParsedDeclarations`) as
can be seen below (`LA` gets stored in two places).
```
// Handle attributes with arguments that require late parsing.
LateParsedAttribute *LA =
new LateParsedAttribute(this, *AttrName, AttrNameLoc);
LateAttrs->push_back(LA);
// Attributes in a class are parsed at the end of the class, along
// with other late-parsed declarations.
if (!ClassStack.empty() && !LateAttrs->parseSoon())
getCurrentClass().LateParsedDeclarations.push_back(LA);
```
this means the ownership of LateParsedAttribute objects isn't very
clear.
rdar://125400257
show more ...
|
#
6447abe0 |
| 19-May-2024 |
Vitaly Buka <vitalybuka@google.com> |
Revert "[BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (#90786)"
Memory leak: https://lab.llvm.org/buildbot/#/builders/5/builds/43403
Issue #92687
This reverts commit 0ec3
Revert "[BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (#90786)"
Memory leak: https://lab.llvm.org/buildbot/#/builders/5/builds/43403
Issue #92687
This reverts commit 0ec3b972e58bcbcdc1bebe1696ea37f2931287c3.
show more ...
|
Revision tags: llvmorg-18.1.6 |
|
#
0ec3b972 |
| 17-May-2024 |
Dan Liew <delcypher@gmail.com> |
[BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (#90786)
Previously the attribute was only allowed on flexible array members.
This patch patch changes this to also allow the
[BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (#90786)
Previously the attribute was only allowed on flexible array members.
This patch patch changes this to also allow the attribute on pointer
fields in structs and also allows late parsing of the attribute in some
contexts.
For example this previously wasn't allowed:
```
struct BufferTypeDeclAttributePosition {
size_t count;
char* buffer __counted_by(count); // Now allowed
}
```
Note the attribute is prevented on pointee types where the size isn't
known at compile time. In particular pointee types that are:
* Incomplete (e.g. `void`) and sizeless types
* Function types (e.g. the pointee of a function pointer)
* Struct types with a flexible array member
This patch also introduces late parsing of the attribute when used in
the declaration attribute position. For example
```
struct BufferTypeDeclAttributePosition {
char* buffer __counted_by(count); // Now allowed
size_t count;
}
```
is now allowed but **only** when passing
`-fexperimental-late-parse-attributes`. The motivation for using late
parsing here is to avoid breaking the data layout of structs in existing
code that want to use the `counted_by` attribute. This patch is the
first use of `LateAttrParseExperimentalExt` in `Attr.td` that was
introduced in a previous patch.
Note by allowing the attribute on struct member pointers this now allows
the possiblity of writing the attribute in the type attribute position.
For example:
```
struct BufferTypeAttributePosition {
size_t count;
char *__counted_by(count) buffer; // Now allowed
}
```
However, the attribute in this position is still currently parsed
immediately rather than late parsed. So this will not parse currently:
```
struct BufferTypeAttributePosition {
char *__counted_by(count) buffer; // Fails to parse
size_t count;
}
```
The intention is to lift this restriction in future patches. It has not
been done in this patch to keep this size of this commit small.
There are also several other follow up changes that will need to be
addressed in future patches:
* Make late parsing working with anonymous structs (see
`on_pointer_anon_buf` in `attr-counted-by-late-parsed-struct-ptrs.c`).
* Allow `counted_by` on more subjects (e.g. parameters, returns types)
when `-fbounds-safety` is enabled.
* Make use of the attribute on pointer types in code gen (e.g. for
`_builtin_dynamic_object_size` and UBSan's array-bounds checks).
This work is heavily based on a patch originally written by Yeoul Na.
rdar://125400257
Co-authored-by: Dan Liew <dan@su-root.co.uk>
show more ...
|
#
874f511a |
| 17-May-2024 |
Vlad Serebrennikov <serebrennikov.vladislav@gmail.com> |
[clang] Introduce `SemaCodeCompletion` (#92311)
This patch continues previous efforts to split `Sema` up, this time
covering code completion.
Context can be found in #84184.
Dropping `Code` prefi
[clang] Introduce `SemaCodeCompletion` (#92311)
This patch continues previous efforts to split `Sema` up, this time
covering code completion.
Context can be found in #84184.
Dropping `Code` prefix from function names in `SemaCodeCompletion` would
make sense, but I think this PR has enough changes already.
As usual, formatting changes are done as a separate commit. Hopefully
this helps with the review.
show more ...
|
#
d3d5a300 |
| 17-May-2024 |
Vlad Serebrennikov <serebrennikov.vladislav@gmail.com> |
[clang][NFC] Remove `const_cast` from `ParseClassSpecifier`
|
#
31a203fa |
| 13-May-2024 |
Vlad Serebrennikov <serebrennikov.vladislav@gmail.com> |
[clang] Introduce `SemaObjC` (#89086)
This is continuation of efforts to split `Sema` up, following the
example of OpenMP, OpenACC, etc. Context can be found in
https://github.com/llvm/llvm-projec
[clang] Introduce `SemaObjC` (#89086)
This is continuation of efforts to split `Sema` up, following the
example of OpenMP, OpenACC, etc. Context can be found in
https://github.com/llvm/llvm-project/pull/82217 and
https://github.com/llvm/llvm-project/pull/84184.
I split formatting changes into a separate commit to help reviewing the
actual changes.
show more ...
|
Revision tags: llvmorg-18.1.5 |
|
#
a0462420 |
| 23-Apr-2024 |
Serge Pavlov <sepavloff@gmail.com> |
[clang] Set correct FPOptions if attribute 'optnone' presents (#85605)
Attribute `optnone` must turn off all optimizations including fast-math
ones. Actually AST nodes in the 'optnone' function sti
[clang] Set correct FPOptions if attribute 'optnone' presents (#85605)
Attribute `optnone` must turn off all optimizations including fast-math
ones. Actually AST nodes in the 'optnone' function still had fast-math
flags. This change implements fixing FP options before function body is
parsed.
show more ...
|
#
64c64958 |
| 17-Apr-2024 |
Vlad Serebrennikov <serebrennikov.vladislav@gmail.com> |
[clang][NFC] Move `Sema::SkipBodyInfo` into namespace scope
This makes it forward-declarable, and needed from splitting `Sema` up.
|
Revision tags: llvmorg-18.1.4 |
|
#
fca51911 |
| 11-Apr-2024 |
Bill Wendling <5993918+bwendling@users.noreply.github.com> |
[NFC][Clang] Improve const correctness for IdentifierInfo (#79365)
The IdentifierInfo isn't typically modified. Use 'const' wherever
possible.
|
Revision tags: llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2 |
|
#
a8279a8b |
| 01-Feb-2024 |
Owen Pan <owenpiano@gmail.com> |
[clang][NFC] Move isSimpleTypeSpecifier() from Sema to Token (#80101)
So that it can be used by clang-format.
|
#
b4d832c7 |
| 31-Jan-2024 |
Carl Peto <carl.peto@me.com> |
[clang] Improved isSimpleTypeSpecifier (#79037)
- Sema::isSimpleTypeSpecifier return true for _Bool in c99 (currently
returns false for _Bool, regardless of C dialect). (Fixes #72203)
- replace th
[clang] Improved isSimpleTypeSpecifier (#79037)
- Sema::isSimpleTypeSpecifier return true for _Bool in c99 (currently
returns false for _Bool, regardless of C dialect). (Fixes #72203)
- replace the logic with a check for simple types and a proper check for
a valid keyword in the appropriate dialect
Co-authored-by: Carl Peto <CPeto@becrypt.com>
show more ...
|
Revision tags: llvmorg-18.1.0-rc1, llvmorg-19-init |
|
#
68ae1e49 |
| 17-Jan-2024 |
Krystian Stasiowski <sdkrystian@gmail.com> |
[Clang][Sema][NFC] Remove unused Scope* parameter from Sema::GetTypeForDeclarator and Sema::ActOnTypeName (#78325)
Split from #78274
|
Revision tags: llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4 |
|
#
27bba42f |
| 04-Sep-2023 |
Kazu Hirata <kazu@google.com> |
[clang] Use range-based for loops (NFC)
|
Revision tags: llvmorg-17.0.0-rc3 |
|
#
851c248d |
| 18-Aug-2023 |
Kadir Cetinkaya <kadircet@google.com> |
[clang] Prevent possible use-after-free
This prevents further parsing of tokens (that'll be freed) inside method body by propagating EOF emitted by reaching code completion token up the parsing stac
[clang] Prevent possible use-after-free
This prevents further parsing of tokens (that'll be freed) inside method body by propagating EOF emitted by reaching code completion token up the parsing stack.
Differential Revision: https://reviews.llvm.org/D158269
show more ...
|
Revision tags: llvmorg-17.0.0-rc2 |
|
#
1f3c1cba |
| 03-Aug-2023 |
dingfei <fding@feysh.com> |
[Parser][ObjC] Fix crash on nested top-level block with better recovery path
Delay consuming tokens until we are certain that the next token is not top level block. Otherwise we bail out as if we sa
[Parser][ObjC] Fix crash on nested top-level block with better recovery path
Delay consuming tokens until we are certain that the next token is not top level block. Otherwise we bail out as if we saw an @end for better diagnostic and recovery.
Fixes https://github.com/llvm/llvm-project/issues/64065.
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D156277.
show more ...
|
Revision tags: llvmorg-17.0.0-rc1, llvmorg-18-init |
|
#
a42ce094 |
| 27-Jun-2023 |
David Goldman <davg@google.com> |
[clang][Sema] Add CodeCompletionContext::CCC_ObjCClassForwardDecl
- Use this new context in Sema to limit completions to seen ObjC class names
- Use this new context in clangd to disable include
[clang][Sema] Add CodeCompletionContext::CCC_ObjCClassForwardDecl
- Use this new context in Sema to limit completions to seen ObjC class names
- Use this new context in clangd to disable include insertions when completing ObjC forward decls
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D150978
show more ...
|
Revision tags: llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2 |
|
#
aec3f951 |
| 11-Apr-2023 |
Richard Sandiford <richard.sandiford@arm.com> |
[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 (cur
[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
show more ...
|
Revision tags: llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7 |
|
#
ed7a46a8 |
| 14-Dec-2022 |
Volodymyr Sapsai <vsapsai@apple.com> |
[modules] Allow parsing a duplicate Obj-C interface if a previous one comes from a hidden [sub]module.
Instead of emitting a redefinition error, check that definitions are equivalent and allow such
[modules] Allow parsing a duplicate Obj-C interface if a previous one comes from a hidden [sub]module.
Instead of emitting a redefinition error, check that definitions are equivalent and allow such scenario.
A few non-obvious implementation details: * to avoid multiple definitions in the redeclaration chain we just drop the new definition after checking for equivalence; * for checking definition equivalence use ODR hash instead of ASTStructuralEquivalence because it avoids excessive recursive deserialization. Though after detecting a mismatch we do deserialize multiple entities to provide a better error message.
rdar://82908223
Differential Revision: https://reviews.llvm.org/D124286
show more ...
|
#
5891420e |
| 03-Dec-2022 |
Kazu Hirata <kazu@google.com> |
[clang] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of m
[clang] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional.
This is part of an effort to migrate from llvm::Optional to std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
show more ...
|
Revision tags: llvmorg-15.0.6, llvmorg-15.0.5 |
|
#
b78d5380 |
| 15-Nov-2022 |
Saleem Abdulrasool <compnerd@compnerd.org> |
parse: process GNU and standard attributes on top-level decls
We would previously reject valid input where GNU attributes preceded the standard attributes on top-level declarations. A previous attri
parse: process GNU and standard attributes on top-level decls
We would previously reject valid input where GNU attributes preceded the standard attributes on top-level declarations. A previous attribute handling change had begun rejecting this whilst GCC does honour this layout. In practice, this breaks use of `extern "C"` attributed functions which use both standard and GNU attributes as experienced by the Swift runtime.
Objective-C deserves an honourable mention for requiring some additional special casing. Because attributes on declarations and definitions differ in semantics, we need to replicate some of the logic for detecting attributes to declarations to which they appertain cannot be attributed. This should match the existing case for the application of GNU attributes to interfaces, protocols, and implementations.
Take the opportunity to split out the tooling tests into two cases: ones which process macros and ones which do not.
Special thanks to Aaron Ballman for the many hints and extensive rubber ducking that was involved in identifying the various places where we accidentally dropped attributes.
Differential Revision: https://reviews.llvm.org/D137979 Fixes: #58229 Reviewed By: aaron.ballman, arphaman
show more ...
|