[clang] [C++20] Destroying delete and deleted destructors (PR #118800)

2025-01-08 Thread Richard Smith via cfe-commits
@@ -2855,6 +2855,11 @@ class CXXDestructorDecl : public CXXMethodDecl { return getCanonicalDecl()->OperatorDeleteThisArg; } + /// Will this destructor ever be called when considering which deallocation + /// function is associated with the destructor? Can optionally be

[clang] [C++20] Destroying delete and deleted destructors (PR #118800)

2025-01-08 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. LG other than the function name. https://github.com/llvm/llvm-project/pull/118800 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit

[clang] [C++20] Destroying delete and deleted destructors (PR #118800)

2025-01-08 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/118800 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add "extend lifetime" flags and release note (PR #110000)

2025-01-08 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: New flag name LGTM. https://github.com/llvm/llvm-project/pull/11 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add "extend lifetime" flags and release note (PR #110000)

2025-01-08 Thread Richard Smith via cfe-commits
@@ -412,6 +412,20 @@ New Compiler Flags only for thread-local variables, and none (which corresponds to the existing ``-fno-c++-static-destructors`` flag) skips all static destructors registration. +- The ``-fextend-variable-liveness`` flag has been added to allow for imp

[clang] [Clang] Add "extend lifetime" flags and release note (PR #110000)

2025-01-08 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/11 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20] Destroying delete and deleted destructors (PR #118800)

2025-01-07 Thread Richard Smith via cfe-commits
@@ -1200,21 +1200,35 @@ CanThrowResult Sema::canThrow(const Stmt *S) { case Expr::CXXDeleteExprClass: { auto *DE = cast(S); -CanThrowResult CT; +CanThrowResult CT = CT_Cannot; QualType DTy = DE->getDestroyedType(); if (DTy.isNull() || DTy->isDependentTy

[clang] [C++20] Destroying delete and deleted destructors (PR #118800)

2025-01-07 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/118800 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20] Destroying delete and deleted destructors (PR #118800)

2025-01-07 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/118800 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Resolving issue #119101 (PR #119143)

2024-12-08 Thread Richard Smith via cfe-commits
zygoloid wrote: Did you mean a different issue than #119101? It's not clear to me what connection this PR has to that issue. It's not clear to me that there's an issue to be solved here. Under `-pedantic-errors`, clang [already produces an error](https://godbolt.org/z/h6oKarex9) on examples l

[clang] Switch builtin strings to use string tables (PR #118734)

2024-12-05 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. LGTM too. I do wonder if we can make tablegen generate the data directly in the desired format here (perhaps with some additional `.td` files to define exactly which files we want to include in which targets and to define the placeholder

[clang] [C++20] Destroying delete and deleted destructors (PR #118800)

2024-12-05 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/118800 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20] Destroying delete and deleted destructors (PR #118800)

2024-12-05 Thread Richard Smith via cfe-commits
@@ -3768,6 +3768,28 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName( ArrayForm ? OO_Array_Delete : OO_Delete); +// C++20 [expr.delete]p6: If

[clang] [C++20] Destroying delete and deleted destructors (PR #118800)

2024-12-05 Thread Richard Smith via cfe-commits
zygoloid wrote: As I just noted in #118687, I think we also need similar treatment for `noexcept(delete p)`. https://github.com/llvm/llvm-project/pull/118800 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailma

[clang] [C++20] Destroying delete can cause a type to be noexcept when deleting (PR #118687)

2024-12-05 Thread Richard Smith via cfe-commits
zygoloid wrote: Hm, the issue raised in #118800 is relevant here too, isn't it? If the destructor is virtual, we want to look at its exception specification, not the one on the destroying operator delete, because `delete p` actually invokes the virtual deleting destructor, not the statically s

[clang] [C++20] Destroying delete and deleted destructors (PR #118800)

2024-12-05 Thread Richard Smith via cfe-commits
@@ -3768,6 +3768,28 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName( ArrayForm ? OO_Array_Delete : OO_Delete); +// C++20 [expr.delete]p6: If

[clang] [C++20] Deleting destructors can be noexcept (PR #118687)

2024-12-04 Thread Richard Smith via cfe-commits
@@ -1206,15 +1206,16 @@ CanThrowResult Sema::canThrow(const Stmt *S) { CT = CT_Dependent; } else { const FunctionDecl *OperatorDelete = DE->getOperatorDelete(); - CT = canCalleeThrow(*this, DE, OperatorDelete); - if (const RecordType *RT = DTy->getAs()

[clang] [C++20] Deleting destructors can be noexcept (PR #118687)

2024-12-04 Thread Richard Smith via cfe-commits
@@ -1205,11 +1205,12 @@ CanThrowResult Sema::canThrow(const Stmt *S) { if (DTy.isNull() || DTy->isDependentType()) { CT = CT_Dependent; } else { - CT = canCalleeThrow(*this, DE, DE->getOperatorDelete()); + const FunctionDecl *OperatorDelete = DE->getOper

[clang] [C++20] Deleting destructors can be noexcept (PR #118687)

2024-12-04 Thread Richard Smith via cfe-commits
@@ -654,6 +654,9 @@ Bug Fixes in This Version - Fixed a crash when GNU statement expression contains invalid statement (#GH113468). - Fixed a failed assertion when using ``__attribute__((noderef))`` on an ``_Atomic``-qualified type (#GH116124). +- No longer return ``false``

[clang] [Clang] Add "extend lifetime" flags and release note (PR #110000)

2024-12-04 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/11 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add "extend lifetime" flags and release note (PR #110000)

2024-12-04 Thread Richard Smith via cfe-commits
zygoloid wrote: Looks like the tests in #110102 are named `extend-liveness-*.cpp`. Perhaps `-fextend-liveness` would be a good name for this flag? https://github.com/llvm/llvm-project/pull/11 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [Clang] Add "extend lifetime" flags and release note (PR #110000)

2024-12-04 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: I think this flag name is going to be extremely confusing. "lifetime" is a notion defined formally by the C++ language standard, and "lifetime extension" is again a process defined in C++ with a specific meaning. Those meanings have nothing to do with wha

[clang] [clang][ExprConst] Add diagnostics for invalid binary arithmetic (PR #118475)

2024-12-04 Thread Richard Smith via cfe-commits
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -14548,8 +14548,21 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { return Error(E); const Expr *LHSExpr = LHSValue.Base.dyn_cast(); const Expr *RHSExpr = RHSValue.Base.dyn_cast()

[clang] [clang][ExprConst] Add diagnostics for invalid binary arithmetic (PR #118475)

2024-12-03 Thread Richard Smith via cfe-commits
@@ -91,11 +91,15 @@ def note_constexpr_pointer_subtraction_zero_size : Note< "subtraction of pointers to type %0 of zero size">; def note_constexpr_pointer_comparison_unspecified : Note< "comparison between '%0' and '%1' has unspecified value">; +def note_constexpr_pointer_

[clang] [clang][ExprConst] Add diagnostics for invalid binary arithmetic (PR #118475)

2024-12-03 Thread Richard Smith via cfe-commits
@@ -14548,8 +14548,21 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { return Error(E); const Expr *LHSExpr = LHSValue.Base.dyn_cast(); const Expr *RHSExpr = RHSValue.Base.dyn_cast(); - if (!LHSExpr || !RHSExpr) -return

[clang] [clang][ExprConst] Add diagnostics for invalid binary arithmetic (PR #118475)

2024-12-03 Thread Richard Smith via cfe-commits
@@ -14548,8 +14548,21 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { return Error(E); const Expr *LHSExpr = LHSValue.Base.dyn_cast(); const Expr *RHSExpr = RHSValue.Base.dyn_cast(); - if (!LHSExpr || !RHSExpr) -return

[clang] [clang][ExprConst] Add diagnostics for invalid binary arithmetic (PR #118475)

2024-12-03 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/118475 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Add diagnostics for invalid binary arithmetic (PR #118475)

2024-12-03 Thread Richard Smith via cfe-commits
@@ -91,11 +91,15 @@ def note_constexpr_pointer_subtraction_zero_size : Note< "subtraction of pointers to type %0 of zero size">; def note_constexpr_pointer_comparison_unspecified : Note< "comparison between '%0' and '%1' has unspecified value">; +def note_constexpr_pointer_

[clang] [clang][ExprConst] Add diagnostics for invalid binary arithmetic (PR #118475)

2024-12-03 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Thanks! I think this is an improvement as-is, but while we're looking at this it'd be useful to make the existing diagnostics (and the new ones that are mirroring them) a little bit more precise about what the problem is. https://github.com/llvm/llvm-proj

[clang] Enable AST mutation in the constant evaluator (PR #115168)

2024-11-26 Thread Richard Smith via cfe-commits
zygoloid wrote: > @zygoloid would it be correct to say that you want the Standard to leave > idempotency of functions with side effects up to implementations, and, > consequently, you want the model of how side effects are integrated into > constant evaluation to work for both idempotent and n

[clang] Enable AST mutation in the constant evaluator (PR #115168)

2024-11-26 Thread Richard Smith via cfe-commits
zygoloid wrote: > Hey Richard - We added idempotency to `define_aggregate` in response to > concern from Clang maintainers that it could interact poorly with > `clang-repl`. The argument was that idempotency would provide a better > experience for a user that wanted to re-evaluate an expressio

[clang] Enable AST mutation in the constant evaluator (PR #115168)

2024-11-26 Thread Richard Smith via cfe-commits
zygoloid wrote: > I initially was of the same opinion as you, but I think we would have to > modify most call sites It seems to me that we'd need to modify those call sites that want to perform an evaluation of a "plainly constant-evaluated expression". Aren't those exactly the call sites we

[clang] Enable AST mutation in the constant evaluator (PR #115168)

2024-11-25 Thread Richard Smith via cfe-commits
zygoloid wrote: > I think there's a contradiction between what `define_aggregate` needs and > that hypothetical `write_char_to_file` needs from the same language construct > (which is currently called _plainly constant-evaluated expression_). If we > say that we're not going to guarantee idemp

[clang] Enable AST mutation in the constant evaluator (PR #115168)

2024-11-25 Thread Richard Smith via cfe-commits
zygoloid wrote: > > the special "the language rules say this is manifestly constant evaluated" > > cases that should be able to perform AST mutations, that we need to be > > extremely careful to invoke at exactly the right times and in exactly the > > right cases and to invoke only once > > C

[clang] Enable AST mutation in the constant evaluator (PR #115168)

2024-11-25 Thread Richard Smith via cfe-commits
zygoloid wrote: > 1. Asking users to pass additional parameter to every `Eval*()` function > makes a bad transition story for users that wish to upgrade to a version of > Clang that has changed the interface in this way. External callers of the `Eval*` functions in almost all cases should not

[clang] Enable AST mutation in the constant evaluator (PR #115168)

2024-11-25 Thread Richard Smith via cfe-commits
zygoloid wrote: If we do end up needing this (and it's looking increasingly likely that we will), I think the general approach of having a set of callbacks that gets passed into the constant evaluator is the right approach. I think the older approach in this PR (a callback object that is expli

[clang] [C23] Fixed the value of BOOL_WIDTH (PR #117364)

2024-11-25 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/117364 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C23] Fixed the value of BOOL_WIDTH (PR #117364)

2024-11-22 Thread Richard Smith via cfe-commits
@@ -1103,7 +1103,15 @@ static void InitializePredefinedMacros(const TargetInfo &TI, assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far"); Builder.defineMacro("__CHAR_BIT__", Twine(TI.getCharWidth())); - Builder.defineMacro("__BOOL_WIDTH__", Twine(TI.getBool

[clang] [C23] Fixed the value of BOOL_WIDTH (PR #117364)

2024-11-22 Thread Richard Smith via cfe-commits
@@ -1103,7 +1103,15 @@ static void InitializePredefinedMacros(const TargetInfo &TI, assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far"); Builder.defineMacro("__CHAR_BIT__", Twine(TI.getCharWidth())); - Builder.defineMacro("__BOOL_WIDTH__", Twine(TI.getBool

[clang] [clang][UBSan] Make sure that the implicit-conversion group is compatible with minimal runtime (PR #114865)

2024-11-20 Thread Richard Smith via cfe-commits
https://github.com/zygoloid closed https://github.com/llvm/llvm-project/pull/114865 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][UBSan] Make sure that the implicit-conversion group is compatible with minimal runtime (PR #114865)

2024-11-20 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/114865 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Reject field access with nullptr base (PR #113885)

2024-11-20 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. LG, thank you! https://github.com/llvm/llvm-project/pull/113885 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Reject field access with nullptr base (PR #113885)

2024-11-19 Thread Richard Smith via cfe-commits
zygoloid wrote: As mentioned in the comment thread, I'd prefer to see this addressed by reversing the order in which we call `addDecl` versus add an offset. While it's a corner case, I think this change would cause us to start rejecting things like [this example](https://godbolt.org/z/5Pae6Ghd

[clang] [clang][UBSan] Make sure that the implicit-conversion group is compatible with minimal runtime (PR #114865)

2024-11-19 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Please can you also add a test that we allow combining `-fsanitize=implicit-conversion` and `-fsanitize-minimal-runtime` so that this doesn't regress in a similar way in future? (It'd be great if the test covered all the sanitizer groups that are currentl

[clang] Document that the lifetime of the caller-side `trivial_abi` parameter ends before the call. (PR #116100)

2024-11-13 Thread Richard Smith via cfe-commits
https://github.com/zygoloid closed https://github.com/llvm/llvm-project/pull/116100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Document that the lifetime of the caller-side `trivial_abi` parameter ends before the call. (PR #116100)

2024-11-13 Thread Richard Smith via cfe-commits
https://github.com/zygoloid created https://github.com/llvm/llvm-project/pull/116100 Fixes #116096. >From 885c95fcf03f9ab89b7d445ee758c69c77333567 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 13 Nov 2024 12:09:01 -0800 Subject: [PATCH] Document that the lifetime of the caller-side `

[clang] Don't redundantly specify the default template argument to `BumpPtrAllocatorImpl` (PR #114857)

2024-11-06 Thread Richard Smith via cfe-commits
https://github.com/zygoloid closed https://github.com/llvm/llvm-project/pull/114857 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Don't redundantly specify the default template argument to `BumpPtrAllocatorImpl` (PR #114857)

2024-11-04 Thread Richard Smith via cfe-commits
https://github.com/zygoloid created https://github.com/llvm/llvm-project/pull/114857 None >From 25047a9f9b8b961451bef0d0c526944d17ffe9d7 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 4 Nov 2024 11:27:46 -0800 Subject: [PATCH 1/2] Don't redundantly specify the default template argumen

[clang] [clang][ExprConst] Reject field access with nullptr base (PR #113885)

2024-10-28 Thread Richard Smith via cfe-commits
@@ -1703,7 +1703,7 @@ namespace { bool checkNullPointerDiagnosingWith(const GenDiagType &GenDiag) { if (Designator.Invalid) return false; - if (IsNullPtr) { + if (getLValueBase().isNull()) { zygoloid wrote: Oh, I see. We're adjustin

[clang] [clang][ExprConst] Reject field access with nullptr base (PR #113885)

2024-10-28 Thread Richard Smith via cfe-commits
@@ -1703,7 +1703,7 @@ namespace { bool checkNullPointerDiagnosingWith(const GenDiagType &GenDiag) { if (Designator.Invalid) return false; - if (IsNullPtr) { + if (getLValueBase().isNull()) { zygoloid wrote: Why was the old check not

[clang] [clang] Make LazyOffsetPtr more portable (PR #112927)

2024-10-19 Thread Richard Smith via cfe-commits
zygoloid wrote: > Doesn't it change ABI, though? Only on platforms where it didn't work at all before. https://github.com/llvm/llvm-project/pull/112927 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/list

[clang] [llvm] [Clang] Match MSVC handling of duplicate header search paths in Microsoft compatibility modes. (PR #105738)

2024-10-18 Thread Richard Smith via cfe-commits
zygoloid wrote: I've been pondering this. On the one hand, people switching from the `cl.exe`-compatible driver to the GCC-compatible driver might want the MSVC interpretation of the path flags. On the other hand, people enabling `-fms-compatibility` to accept code written against MSVC in a di

[clang] Remove type-punning in LazyOffsetPtr. (PR #112806)

2024-10-18 Thread Richard Smith via cfe-commits
zygoloid wrote: Closing in favour of #112927. https://github.com/llvm/llvm-project/pull/112806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Remove type-punning in LazyOffsetPtr. (PR #112806)

2024-10-18 Thread Richard Smith via cfe-commits
https://github.com/zygoloid closed https://github.com/llvm/llvm-project/pull/112806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Make LazyOffsetPtr more portable (PR #112927)

2024-10-18 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/112927 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Make LazyOffsetPtr more portable (PR #112927)

2024-10-18 Thread Richard Smith via cfe-commits
@@ -326,45 +328,65 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + static constexpr size_t DataSize = std::max(sizeof(uint64_t), sizeof(T *))

[clang] [clang] Make LazyOffsetPtr more portable (PR #112927)

2024-10-18 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. One style nit, otherwise looks good, thanks! https://github.com/llvm/llvm-project/pull/112927 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinf

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-18 Thread Richard Smith via cfe-commits
zygoloid wrote: > But yes, the short answer is that the code as written should work on Morello > and CHERI-RISC-V. Great, thanks. > > > The std::launder may be unnecessary > > > > > > Formally I think it's correct and necessary for the pointer and integer > > case because an array element a

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-18 Thread Richard Smith via cfe-commits
zygoloid wrote: > How about: > [...] Yeah, I think that fixes it. For me that looks a lot less simple than using a union, but it is nice to have only a single implementation. I'd be fine with going in that direction. For CHERI, can we assume that the least-significant byte of the pointer rep

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-18 Thread Richard Smith via cfe-commits
zygoloid wrote: > > > #112806 should address this without narrowing the field to 32 bits. > > > > > > As does [#111995 > > (comment)](https://github.com/llvm/llvm-project/pull/111995#discussion_r1805329590), > > with less code and more generality > > I prefer this solution too. That solutio

[clang] Remove type-punning in LazyOffsetPtr. (PR #112806)

2024-10-18 Thread Richard Smith via cfe-commits
zygoloid wrote: > > This violates aliasing rules and doesn't work at all on big-endian 64-bit > > systems where the pointer is stored in the second four bytes of the > > uint64_t. > > Your sizes aren't correct in the description here. This issue occurs on big > endian 32-bit systems, Yeah, s

[clang] Remove type-punning in LazyOffsetPtr. (PR #112806)

2024-10-18 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/112806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Remove type-punning in LazyOffsetPtr. (PR #112806)

2024-10-17 Thread Richard Smith via cfe-commits
@@ -321,50 +322,87 @@ class ExternalASTSource : public RefCountedBase { /// external AST source itself. template struct LazyOffsetPtr { - /// Either a pointer to an AST node or the offset within the - /// external AST source where the AST node can be found. - /// - /// If

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Richard Smith via cfe-commits
zygoloid wrote: #112806 should address this without narrowing the field to 32 bits. https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Remove type-punning in LazyOffsetPtr. (PR #112806)

2024-10-17 Thread Richard Smith via cfe-commits
https://github.com/zygoloid created https://github.com/llvm/llvm-project/pull/112806 Don't try to read the `uint64_t` stored in `LazyOffsetPtr` as a `T*` via `getAddressOfPointer`. This violates aliasing rules and doesn't work at all on big-endian 64-bit systems where the pointer is stored in th

[clang] [llvm] [Clang] Match MSVC handling of duplicate header search paths in Microsoft compatibility modes. (PR #105738)

2024-10-17 Thread Richard Smith via cfe-commits
zygoloid wrote: This choice seems like a question of how the driver's command line is interpreted, rather than a language mode, so I wonder if it makes sense for it to consider `-fms-compatibility` at all or whether this should just be based on the driver mode. Do you have rationale for this a

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Richard Smith via cfe-commits
zygoloid wrote: > > Can we remove `getAddressOfPointer` instead?. Where is it being used? > > It is used in `VarDecl::getInitAddress()` in Decl.cpp. It looks like it is > used indirectly by the StmtIterator And that in turn is used in `StmtIterator`, and indeed we can end up *storing through*

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Richard Smith via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-15 Thread Richard Smith via cfe-commits
https://github.com/zygoloid closed https://github.com/llvm/llvm-project/pull/112047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-15 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Thanks, looks good to me too. https://github.com/llvm/llvm-project/pull/112047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-15 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Can we remove `getAddressOfPointer` instead?. Where is it being used? https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits
zygoloid wrote: > I expect that won't be caught, and you'll need to make a similar change to > `visitLocalsRetainedByInitializer` to handle it. Actually, maybe the best thing would be to change `visitFunctionCallArguments` to step over `CXXDefaultArgExpr` in `Args`. That should cover both case

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Please can you also add tests for the case where the default argument is a pointer, eg: ```c++ using T = int[]; int *f([[clang::lifetimebound]] int *p = T{1, 2, 3}); int *p = f(); ``` I expect that won't be caught, and you'll need to make a similar change t

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits
@@ -532,6 +533,11 @@ static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path, } } while (Init != Old); + if (auto *DAE = dyn_cast(Init)) { +Path.push_back({IndirectLocalPathEntry::DefaultArg, DAE, DAE->getParam()}); +Init = DAE->getExpr(); +

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/112047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Thanks, this seems reasonable. https://github.com/llvm/llvm-project/pull/112047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits
@@ -19,8 +19,10 @@ namespace usage_invalid { namespace usage_ok { struct IntRef { int *target; }; + const int *defaultparam(const int &def1 [[clang::lifetimebound]] = 0); // #def1 int &refparam(int ¶m [[clang::lifetimebound]]); int &classparam(IntRef param [[clang::l

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-10 Thread Richard Smith via cfe-commits
zygoloid wrote: @luxufan I think we may need changes on the LLVM side before we can make progress here -- either to clarify what `unnamed_addr` is intended to mean, or perhaps to split it into separate attributes for cloning and merging. But before we go down that path, this PR doesn't describ

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-10 Thread Richard Smith via cfe-commits
zygoloid wrote: > unnamed_addr doesn't allow cloning; there's no way to make it work in a > reasonable way even if we wanted it. See, for example, #32127 . OK. The LangRef is very vague on its semantics, would be nice to get that clarified by someone who knows the intent. Is the same true for

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-10 Thread Richard Smith via cfe-commits
@@ -4097,6 +4096,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo( // And the name. llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage); llvm::Constant *TypeNameField; + llvm::GlobalValue::UnnamedAddr Scope; zygoloid wrote: `Scope` isn

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-10 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Hmm. Looking at https://reviews.llvm.org/D20348 it seems like `unnamed_addr` and `local_unnamed_addr` don't just permit merging, but also cloning of the global (so that the same global could have different addresses in different modules). Cloning wouldn't

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-10 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/111343 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Add test for CWG110 "Can template functions and classes be declared in the same scope?" (PR #111446)

2024-10-08 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/111446 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-08 Thread Richard Smith via cfe-commits
zygoloid wrote: > But, I have a question: now that it has ensured the uniqueness of typeinfo's > address, why does the implementation still compare the type equality by the > address of type name string? The uniqueness of the address of the `type_info` object itself is not guaranteed. The rea

[clang] [clang] Add test for CWG110 "Can template functions and classes be declared in the same scope?" (PR #111446)

2024-10-07 Thread Richard Smith via cfe-commits
@@ -119,6 +119,16 @@ namespace cwg109 { // cwg109: yes }; } +namespace cwg110 { // cwg110: 2.8 +template +void f(); + +class f; + +template +void f(int); +} // namespace cwg110 zygoloid wrote: It'd be nice to also check that `class f` works here, and that

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-07 Thread Richard Smith via cfe-commits
zygoloid wrote: Specifically: we do perform address comparisons between these strings, so the address is significant. And we can have identical string content but different types: - for types whose name involves anything with internal linkage - for types with hidden visibility - when loading a

[clang] [ItaniumCXXABI] Mark RTTI type name as global unnamed_addr (PR #111343)

2024-10-07 Thread Richard Smith via cfe-commits
zygoloid wrote: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-rtti and https://itanium-cxx-abi.github.io/cxx-abi/abi.html#typeid in the ABI require the type name string to be globally unique, and some `std::type_info` implementations rely on that. You might be able to do this for so

[clang] [clang][Itanium Mangle] Enable mangling of enclosing class for member… (PR #110503)

2024-09-30 Thread Richard Smith via cfe-commits
@@ -693,7 +693,7 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const Decl *D) { if (VD->isExternC()) return getASTContext().getTranslationUnitDecl(); - if (const auto *FD = D->getAsFunction()) { + if (const auto *FD = dyn_cast(D)) { zygoloi

[clang] [clang][Itanium Mangle] Enable mangling of enclosing class for member… (PR #110503)

2024-09-30 Thread Richard Smith via cfe-commits
@@ -704,6 +704,15 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const Decl *D) { return D->getLexicalDeclContext()->getRedeclContext(); } + if (const auto *FTD = dyn_cast(D)) { +// Member-like constrained friends are mangled as if they were members of +

[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread Richard Smith via cfe-commits
zygoloid wrote: Should this have `-fclang-abi-compat` support? https://github.com/llvm/llvm-project/pull/110247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] implement current direction of CWG2765 for string literal comparisons in constant evaluation (PR #109208)

2024-09-27 Thread Richard Smith via cfe-commits
zygoloid wrote: I've filed a fmtlib bug: https://github.com/fmtlib/fmt/issues/4177 https://github.com/llvm/llvm-project/pull/109208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] implement current direction of CWG2765 for string literal comparisons in constant evaluation (PR #109208)

2024-09-27 Thread Richard Smith via cfe-commits
zygoloid wrote: I found this: https://fuchsia.googlesource.com/third_party/github.com/fmtlib/fmt/+/refs/heads/upstream/main/include/fmt/base.h#2664 Note that this is passing `s` separately both to `parse_format_string` and to `checker`. Here, `s` is a lambda that implicitly converts to a strin

[clang] [clang] implement current direction of CWG2765 for string literal comparisons in constant evaluation (PR #109208)

2024-09-27 Thread Richard Smith via cfe-commits
zygoloid wrote: That backtrace doesn't match the fmtlib code available from their official repository. Where can I find the code you're building? https://github.com/llvm/llvm-project/pull/109208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [ItaniumMangle] Use mangleType instead of mangleNameOrStandardSubstitution in mangleCXXCtorVTable function (PR #109970)

2024-09-26 Thread Richard Smith via cfe-commits
zygoloid wrote: > Do we need an ABI flag guarding against the change as well? Yeah, I think this change should respect `-fclang-abi-compat`. https://github.com/llvm/llvm-project/pull/109970 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https

[clang] [ItaniumMangle] Use mangleType instead of mangleNameOrStandardSubstitution in mangleCXXCtorVTable function (PR #109970)

2024-09-26 Thread Richard Smith via cfe-commits
@@ -1214,3 +1216,25 @@ namespace test61 { // CHECK-LABEL: @_ZN6test611fINS_1XEEEvNT_1Y1aENS3_1bE template void f(int, int); } + +namespace test62 { +namespace A { + +class VBase { + public: + virtual ~VBase() {}; +}; + +struct Wrap {}; + +template +class Impl : public vir

[clang] [clang] implement current direction of CWG2765 for string literal comparisons in constant evaluation (PR #109208)

2024-09-26 Thread Richard Smith via cfe-commits
https://github.com/zygoloid closed https://github.com/llvm/llvm-project/pull/109208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] implement current direction of CWG2765 for string literal comparisons in constant evaluation (PR #109208)

2024-09-25 Thread Richard Smith via cfe-commits
zygoloid wrote: I believe all the feedback has been addressed, and plan to merge in 24 hours if there are no further comments. https://github.com/llvm/llvm-project/pull/109208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.

[clang] [Clang][Sema] Refactor collection of multi-level template argument lists (PR #106585)

2024-09-24 Thread Richard Smith via cfe-commits
zygoloid wrote: In @sdkrystian's example, does the use of `A<1>::B` within `A<0>::B` cause an implicit instantiation to take place? I would have expected that no implicit instantiation takes place at that point because `A<1>::B` is a dependent type. I would expect that the specialization of `A

[clang] Clang tooling generated visibility macros for Clang (PR #109702)

2024-09-23 Thread Richard Smith via cfe-commits
zygoloid wrote: @fsfod Can you update the first comment to describe the overall purpose of this change? That seems pretty central to understanding whether we want this, and if so, whether this looks like the right set of annotations. https://github.com/llvm/llvm-project/pull/109702 ___

[clang] [clang] implement current direction of CWG2765 for string literal comparisons in constant evaluation (PR #109208)

2024-09-20 Thread Richard Smith via cfe-commits
https://github.com/zygoloid updated https://github.com/llvm/llvm-project/pull/109208 >From 81193568c17a89f6cf42f43a82fb1fbf0f90184d Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 18 Sep 2024 21:59:56 + Subject: [PATCH 01/15] Implement current CWG direction for string literal compa

  1   2   3   4   5   6   7   8   9   10   >