Revision tags: llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, 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, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4 |
|
#
c45466cd |
| 24-Oct-2023 |
Timm Baeder <tbaeder@redhat.com> |
[clang][Interp] Only emit function_param_value_unknown in C++11 (#67990)
This is also what the current interpreter does.
|
#
84a3aadf |
| 20-Oct-2023 |
Aaron Ballman <aaron@aaronballman.com> |
Diagnose use of VLAs in C++ by default
Reapplication of 7339c0f782d5c70e0928f8991b0c05338a90c84c with a fix for a crash involving arrays without a size expression.
Clang supports VLAs in C++ as an
Diagnose use of VLAs in C++ by default
Reapplication of 7339c0f782d5c70e0928f8991b0c05338a90c84c with a fix for a crash involving arrays without a size expression.
Clang supports VLAs in C++ as an extension, but we currently only warn on their use when you pass -Wvla, -Wvla-extension, or -pedantic. However, VLAs as they're expressed in C have been considered by WG21 and rejected, are easy to use accidentally to the surprise of users (e.g., https://ddanilov.me/default-non-standard-features/), and they have potential security implications beyond constant-size arrays (https://wiki.sei.cmu.edu/confluence/display/c/ARR32-C.+Ensure+size+arguments+for+variable+length+arrays+are+in+a+valid+range). C++ users should strongly consider using other functionality such as std::vector instead.
This seems like sufficiently compelling evidence to warn users about VLA use by default in C++ modes. This patch enables the -Wvla-extension diagnostic group in C++ language modes by default, and adds the warning group to -Wall in GNU++ language modes. The warning is still opt-in in C language modes, where support for VLAs is somewhat less surprising to users.
RFC: https://discourse.llvm.org/t/rfc-diagnosing-use-of-vlas-in-c/73109 Fixes https://github.com/llvm/llvm-project/issues/62836 Differential Revision: https://reviews.llvm.org/D156565
show more ...
|
#
f5043f46 |
| 20-Oct-2023 |
Aaron Ballman <aaron@aaronballman.com> |
Revert "Diagnose use of VLAs in C++ by default"
This reverts commit 7339c0f782d5c70e0928f8991b0c05338a90c84c.
Breaks bots: https://lab.llvm.org/buildbot/#/builders/139/builds/51875 https://lab.llvm
Revert "Diagnose use of VLAs in C++ by default"
This reverts commit 7339c0f782d5c70e0928f8991b0c05338a90c84c.
Breaks bots: https://lab.llvm.org/buildbot/#/builders/139/builds/51875 https://lab.llvm.org/buildbot/#/builders/164/builds/45262
show more ...
|
#
7339c0f7 |
| 20-Oct-2023 |
Aaron Ballman <aaron@aaronballman.com> |
Diagnose use of VLAs in C++ by default
Clang supports VLAs in C++ as an extension, but we currently only warn on their use when you pass -Wvla, -Wvla-extension, or -pedantic. However, VLAs as they'r
Diagnose use of VLAs in C++ by default
Clang supports VLAs in C++ as an extension, but we currently only warn on their use when you pass -Wvla, -Wvla-extension, or -pedantic. However, VLAs as they're expressed in C have been considered by WG21 and rejected, are easy to use accidentally to the surprise of users (e.g., https://ddanilov.me/default-non-standard-features/), and they have potential security implications beyond constant-size arrays (https://wiki.sei.cmu.edu/confluence/display/c/ARR32-C.+Ensure+size+arguments+for+variable+length+arrays+are+in+a+valid+range). C++ users should strongly consider using other functionality such as std::vector instead.
This seems like sufficiently compelling evidence to warn users about VLA use by default in C++ modes. This patch enables the -Wvla-extension diagnostic group in C++ language modes by default, and adds the warning group to -Wall in GNU++ language modes. The warning is still opt-in in C language modes, where support for VLAs is somewhat less surprising to users.
RFC: https://discourse.llvm.org/t/rfc-diagnosing-use-of-vlas-in-c/73109 Fixes https://github.com/llvm/llvm-project/issues/62836 Differential Revision: https://reviews.llvm.org/D156565
show more ...
|
Revision tags: llvmorg-17.0.3 |
|
#
5fa5ffeb |
| 10-Oct-2023 |
kasuga-fj <143047127+kasuga-fj@users.noreply.github.com> |
[Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (#65246)
Fixes #64619
Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated c
[Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (#65246)
Fixes #64619
Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
diagnostic if you use `offsetof` on non-standard layout types in any
other contexts
show more ...
|
Revision tags: llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1 |
|
#
87461d66 |
| 27-Jul-2023 |
Timm Bäder <tbaeder@redhat.com> |
[clang][Interp] Implement __builtin_offsetof
Differential Revision: https://reviews.llvm.org/D156400
|
Revision tags: llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, 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 |
|
#
e7300e75 |
| 18-Jan-2023 |
Aaron Ballman <aaron@aaronballman.com> |
Diagnose extensions in 'offsetof'
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm made very clear that it is an UB having type definitions with in offsetof. Clang supports defining a type
Diagnose extensions in 'offsetof'
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm made very clear that it is an UB having type definitions with in offsetof. Clang supports defining a type as the first argument as a conforming extension due to how many projects use the construct in C99 and earlier to calculate the alignment of a type. GCC also supports defining a type as the first argument.
This adds extension warnings and documentation for the functionality Clang explicitly supports.
Fixes #57065 Reverts the revert of 39da55e8f548a11f7dadefa73ea73d809a5f1729
Co-authored-by: Yingchi Long <i@lyc.dev> Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
Differential Revision: https://reviews.llvm.org/D133574
show more ...
|
#
39da55e8 |
| 18-Jan-2023 |
Arthur Eubanks <aeubanks@google.com> |
Revert "Diagnose extensions in 'offsetof'"
This reverts commit f1f0a0d8e8fdd2e534d9423b2e64c6b8aaa53aee.
Causes crashes on
$ echo 'typedef int a; void c() { __builtin_offsetof(struct {a b}, b); }'
Revert "Diagnose extensions in 'offsetof'"
This reverts commit f1f0a0d8e8fdd2e534d9423b2e64c6b8aaa53aee.
Causes crashes on
$ echo 'typedef int a; void c() { __builtin_offsetof(struct {a b}, b); }' | bin/clang -cc1 -emit-llvm -o /dev/null - -x c
show more ...
|
#
f1f0a0d8 |
| 17-Jan-2023 |
Aaron Ballman <aaron@aaronballman.com> |
Diagnose extensions in 'offsetof'
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm made very clear that it is an UB having type definitions with in offsetof. Clang supports defining a type
Diagnose extensions in 'offsetof'
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm made very clear that it is an UB having type definitions with in offsetof. Clang supports defining a type as the first argument as a conforming extension due to how many projects use the construct in C99 and earlier to calculate the alignment of a type. GCC also supports defining a type as the first argument.
This adds extension warnings and documentation for the functionality Clang explicitly supports.
Fixes #57065
Co-authored-by: Yingchi Long <i@lyc.dev> Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
show more ...
|
#
596f76a7 |
| 16-Jan-2023 |
Yingchi Long <i@lyc.dev> |
Revert "[C2x] reject type definitions in offsetof"
This reverts commit e327b52766ed497e4779f4e652b9ad237dfda8e6.
|
Revision tags: llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1 |
|
#
e327b527 |
| 16-Sep-2022 |
Yingchi Long <i@lyc.dev> |
[C2x] reject type definitions in offsetof
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm made very clear that it is an UB having type definitions with in offsetof. After this patch clang
[C2x] reject type definitions in offsetof
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm made very clear that it is an UB having type definitions with in offsetof. After this patch clang will reject any type definitions in __builtin_offsetof.
Fixes https://github.com/llvm/llvm-project/issues/57065
``` local/offsetof.c:10:38: error: 'struct S' cannot be defined in '__builtin_offsetof' return __builtin_offsetof(struct S{ int a, b;}, a); ^ ```
Reviewed By: aaron.ballman, #clang-language-wg
Differential Revision: https://reviews.llvm.org/D133574
show more ...
|
Revision tags: llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1, llvmorg-15-init, llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1, llvmorg-13.0.0, llvmorg-13.0.0-rc4, llvmorg-13.0.0-rc3, llvmorg-13.0.0-rc2, llvmorg-13.0.0-rc1, llvmorg-14-init, llvmorg-12.0.1, llvmorg-12.0.1-rc4, llvmorg-12.0.1-rc3, llvmorg-12.0.1-rc2, llvmorg-12.0.1-rc1, llvmorg-12.0.0, llvmorg-12.0.0-rc5, llvmorg-12.0.0-rc4, llvmorg-12.0.0-rc3, llvmorg-12.0.0-rc2, llvmorg-11.1.0, llvmorg-11.1.0-rc3, llvmorg-12.0.0-rc1, llvmorg-13-init, llvmorg-11.1.0-rc2, llvmorg-11.1.0-rc1, llvmorg-11.0.1, llvmorg-11.0.1-rc2, llvmorg-11.0.1-rc1, llvmorg-11.0.0, llvmorg-11.0.0-rc6, llvmorg-11.0.0-rc5, llvmorg-11.0.0-rc4, llvmorg-11.0.0-rc3, llvmorg-11.0.0-rc2, llvmorg-11.0.0-rc1, llvmorg-12-init, llvmorg-10.0.1, llvmorg-10.0.1-rc4, llvmorg-10.0.1-rc3, llvmorg-10.0.1-rc2, llvmorg-10.0.1-rc1, llvmorg-10.0.0, llvmorg-10.0.0-rc6, llvmorg-10.0.0-rc5, llvmorg-10.0.0-rc4, llvmorg-10.0.0-rc3, llvmorg-10.0.0-rc2, llvmorg-10.0.0-rc1, llvmorg-11-init, llvmorg-9.0.1, llvmorg-9.0.1-rc3, llvmorg-9.0.1-rc2, llvmorg-9.0.1-rc1, llvmorg-9.0.0, llvmorg-9.0.0-rc6, llvmorg-9.0.0-rc5, llvmorg-9.0.0-rc4, llvmorg-9.0.0-rc3, llvmorg-9.0.0-rc2, llvmorg-9.0.0-rc1, llvmorg-10-init, llvmorg-8.0.1, llvmorg-8.0.1-rc4, llvmorg-8.0.1-rc3, llvmorg-8.0.1-rc2, llvmorg-8.0.1-rc1, llvmorg-8.0.0, llvmorg-8.0.0-rc5, llvmorg-8.0.0-rc4, llvmorg-8.0.0-rc3, llvmorg-7.1.0, llvmorg-7.1.0-rc1, llvmorg-8.0.0-rc2, llvmorg-8.0.0-rc1, llvmorg-7.0.1, llvmorg-7.0.1-rc3, llvmorg-7.0.1-rc2, llvmorg-7.0.1-rc1, llvmorg-7.0.0, llvmorg-7.0.0-rc3, llvmorg-7.0.0-rc2, llvmorg-7.0.0-rc1, llvmorg-6.0.1, llvmorg-6.0.1-rc3, llvmorg-6.0.1-rc2, llvmorg-6.0.1-rc1, llvmorg-5.0.2, llvmorg-5.0.2-rc2, llvmorg-5.0.2-rc1, llvmorg-6.0.0, llvmorg-6.0.0-rc3, llvmorg-6.0.0-rc2, llvmorg-6.0.0-rc1, llvmorg-5.0.1, llvmorg-5.0.1-rc3, llvmorg-5.0.1-rc2, llvmorg-5.0.1-rc1, llvmorg-5.0.0, llvmorg-5.0.0-rc5, llvmorg-5.0.0-rc4, llvmorg-5.0.0-rc3, llvmorg-5.0.0-rc2, llvmorg-5.0.0-rc1, llvmorg-4.0.1, llvmorg-4.0.1-rc3, llvmorg-4.0.1-rc2, llvmorg-4.0.1-rc1, llvmorg-4.0.0, llvmorg-4.0.0-rc4, llvmorg-4.0.0-rc3, llvmorg-4.0.0-rc2, llvmorg-4.0.0-rc1, llvmorg-3.9.1, llvmorg-3.9.1-rc3, llvmorg-3.9.1-rc2, llvmorg-3.9.1-rc1, llvmorg-3.9.0, llvmorg-3.9.0-rc3, llvmorg-3.9.0-rc2, llvmorg-3.9.0-rc1, llvmorg-3.8.1, llvmorg-3.8.1-rc1, llvmorg-3.8.0, llvmorg-3.8.0-rc3, llvmorg-3.8.0-rc2, llvmorg-3.8.0-rc1, llvmorg-3.7.1, llvmorg-3.7.1-rc2, llvmorg-3.7.1-rc1 |
|
#
542f04cc |
| 11-Nov-2015 |
Charles Li <charles_li@playstation.sony.com> |
[Lit Test] Updated 26 Lit tests to be C++11 compatible.
Expected diagnostics have been expanded to vary by C++ dialect. RUN line has also been expanded to: default, C++98/03 and C++11.
llvm-svn: 25
[Lit Test] Updated 26 Lit tests to be C++11 compatible.
Expected diagnostics have been expanded to vary by C++ dialect. RUN line has also been expanded to: default, C++98/03 and C++11.
llvm-svn: 252785
show more ...
|
Revision tags: llvmorg-3.7.0, llvmorg-3.7.0-rc4, llvmorg-3.7.0-rc3, studio-1.4, llvmorg-3.7.0-rc2, llvmorg-3.7.0-rc1, llvmorg-3.6.2, llvmorg-3.6.2-rc1, llvmorg-3.6.1, llvmorg-3.6.1-rc1, llvmorg-3.5.2, llvmorg-3.5.2-rc1, llvmorg-3.6.0, llvmorg-3.6.0-rc4, llvmorg-3.6.0-rc3, llvmorg-3.6.0-rc2, llvmorg-3.6.0-rc1, llvmorg-3.5.1, llvmorg-3.5.1-rc2, llvmorg-3.5.1-rc1, llvmorg-3.5.0, llvmorg-3.5.0-rc4, llvmorg-3.5.0-rc3, llvmorg-3.5.0-rc2, llvmorg-3.5.0-rc1, llvmorg-3.4.2, llvmorg-3.4.2-rc1, llvmorg-3.4.1, llvmorg-3.4.1-rc2, llvmorg-3.4.1-rc1, llvmorg-3.4.0, llvmorg-3.4.0-rc3, llvmorg-3.4.0-rc2, llvmorg-3.4.0-rc1 |
|
#
ff17f836 |
| 15-Oct-2013 |
David Majnemer <david.majnemer@gmail.com> |
Sema: Consider it an error to apply __builtin_offsetof to a member in a virtual base
icc 13 and g++ 4.9 both reject this while we would crash.
Fixes PR17578.
llvm-svn: 192674
|
Revision tags: llvmorg-3.3.1-rc1, llvmorg-3.3.0, llvmorg-3.3.0-rc3, llvmorg-3.3.0-rc2, llvmorg-3.3.0-rc1, llvmorg-3.2.0, llvmorg-3.2.0-rc3, llvmorg-3.2.0-rc2, llvmorg-3.2.0-rc1, llvmorg-3.1.0, llvmorg-3.1.0-rc3, llvmorg-3.1.0-rc2, llvmorg-3.1.0-rc1, llvmorg-3.0.0, llvmorg-3.0.0-rc4, llvmorg-3.0.0-rc3, llvmorg-3.0.0-rc2 |
|
#
9fcc5c31 |
| 17-Oct-2011 |
Richard Smith <richard-llvm@metafoo.co.uk> |
Perform lvalue-to-rvalue conversions on __builtin_offsetof array argument index before typechecking, as suggested by John.
llvm-svn: 142308
|
Revision tags: llvmorg-3.0.0-rc1, llvmorg-2.9.0, llvmorg-2.9.0-rc3, llvmorg-2.9.0-rc2, llvmorg-2.9.0-rc1, llvmorg-2.8.0, llvmorg-2.8.0-rc3, llvmorg-2.8.0-rc2, llvmorg-2.8.0-rc1, llvmorg-2.8.0-rc0 |
|
#
74ef7cf1 |
| 05-Aug-2010 |
Eli Friedman <eli.friedman@gmail.com> |
PR7769: Fix references to anonymous structs/unions in base classes in offsetof expressions.
llvm-svn: 110327
|
#
959d5a0c |
| 22-May-2010 |
Douglas Gregor <dgregor@apple.com> |
Implement support for variable length arrays in C++. VLAs are limited in several important ways:
- VLAs of non-POD types are not permitted. - VLAs cannot be used in conjunction with C++ template
Implement support for variable length arrays in C++. VLAs are limited in several important ways:
- VLAs of non-POD types are not permitted. - VLAs cannot be used in conjunction with C++ templates.
These restrictions are intended to keep VLAs out of the parts of the C++ type system where they cause the most trouble. Fixes PR5678 and <rdar://problem/8013618>.
llvm-svn: 104443
show more ...
|
#
d1702067 |
| 29-Apr-2010 |
Douglas Gregor <dgregor@apple.com> |
Teach __builtin_offsetof to compute the offsets of members of base classes, since we only warn (not error) on offsetof() for non-POD types. We store the base path within the OffsetOfExpr itself, then
Teach __builtin_offsetof to compute the offsets of members of base classes, since we only warn (not error) on offsetof() for non-POD types. We store the base path within the OffsetOfExpr itself, then evaluate the offsets within the constant evaluator.
llvm-svn: 102571
show more ...
|
#
10982ea3 |
| 28-Apr-2010 |
Douglas Gregor <dgregor@apple.com> |
Diagnose __builtin_offsetof expressions that refer to bit-fields
llvm-svn: 102548
|
#
882211c1 |
| 28-Apr-2010 |
Douglas Gregor <dgregor@apple.com> |
Completely reimplement __builtin_offsetof, based on a patch by Roberto Amadini.
This change introduces a new expression node type, OffsetOfExpr, that describes __builtin_offsetof. Previously, __buil
Completely reimplement __builtin_offsetof, based on a patch by Roberto Amadini.
This change introduces a new expression node type, OffsetOfExpr, that describes __builtin_offsetof. Previously, __builtin_offsetof was implemented using a unary operator whose subexpression involved various synthesized array-subscript and member-reference expressions, which was ugly and made it very hard to instantiate as a template. OffsetOfExpr represents the AST more faithfully, with proper type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof expressions; it can be value-dependent, but will never be type-dependent (like sizeof or alignof). This commit introduces template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a constant expression, so it produces an error. So, to avoid regressing in C, we retain the old UnaryOperator-based __builtin_offsetof implementation in C while using the shiny new OffsetOfExpr implementation in C++. The old implementation can go away once we have proper CodeGen support for this case, which we expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types, particularly when the designated field is found within a base class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python tests.
llvm-svn: 102542
show more ...
|
Revision tags: llvmorg-2.7.0 |
|
#
85f90559 |
| 10-Mar-2010 |
John McCall <rjmccall@apple.com> |
When pretty-printing tag types, only print the tag if we're in C (and therefore not creating ElaboratedTypes, which are still pretty-printed with the written tag).
Most of these testcase changes wer
When pretty-printing tag types, only print the tag if we're in C (and therefore not creating ElaboratedTypes, which are still pretty-printed with the written tag).
Most of these testcase changes were done by script, so don't feel too sorry for my fingers.
llvm-svn: 98149
show more ...
|
#
8fbe78f6 |
| 15-Dec-2009 |
Daniel Dunbar <daniel@zuster.org> |
Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead o
Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'. - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target).
llvm-svn: 91446
show more ...
|
#
7ca84af4 |
| 12-Dec-2009 |
Douglas Gregor <dgregor@apple.com> |
Suppress warnings and errors about certain uses of non-POD types (in __builtin_offsetof, passing through an ellipsis) when we're in an unevaluated context. This is the first part of the fix to PR5761
Suppress warnings and errors about certain uses of non-POD types (in __builtin_offsetof, passing through an ellipsis) when we're in an unevaluated context. This is the first part of the fix to PR5761, which deals with the simple case of an unevaluated context.
llvm-svn: 91210
show more ...
|
#
78cde144 |
| 04-Dec-2009 |
Eli Friedman <eli.friedman@gmail.com> |
Make sure to call PerformObjectMemberConversion where necessary.
llvm-svn: 90555
|
Revision tags: llvmorg-2.6.0 |
|
#
8469bc7c |
| 03-May-2009 |
Eli Friedman <eli.friedman@gmail.com> |
Fix/re-enable test.
llvm-svn: 70800
|
#
110c800c |
| 03-May-2009 |
Daniel Dunbar <daniel@zuster.org> |
Disable this test case, I'm tired of seeing red. :)
llvm-svn: 70799
|