[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-21 Thread Ilya Biryukov via cfe-commits
@@ -0,0 +1,226 @@ +// RUN: %clang_cc1 %s -verify +template struct TypeList; + +// === Check results of the builtin. +template +struct TemplateWrapper { + static_assert(__is_same( // expected-error {{static assertion contains an unexpanded parameter pack}} +TypeList<__built

[clang] 26d4e56 - [Clang] Fix dedup-types-builtin.cpp test when -std=c++20

2025-08-21 Thread Ilya Biryukov via cfe-commits
Author: Ilya Biryukov Date: 2025-08-21T11:05:02+02:00 New Revision: 26d4e56be81adbaa8aeed7f5cde39b779d959fc3 URL: https://github.com/llvm/llvm-project/commit/26d4e56be81adbaa8aeed7f5cde39b779d959fc3 DIFF: https://github.com/llvm/llvm-project/commit/26d4e56be81adbaa8aeed7f5cde39b779d959fc3.diff

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-21 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > @ilya-biryukov I've addressed these warnings with #154606. Thanks a lot! And sorry for not spotting this earlier, I do not have LLDB build configured locally. It would be great to add this to presubmits at some point in order to spot those problems. https://github.com/l

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-20 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Thanks a lot for the review, everyone! I will create the concrete issues for the follow-ups required tomorrow and will start tackling them after that. https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-20 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov closed https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][timers][modules] Fix a timer being started when it's running (PR #154231)

2025-08-19 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov requested changes to this pull request. https://github.com/llvm/llvm-project/pull/154231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-19 Thread Ilya Biryukov via cfe-commits
@@ -1598,6 +1599,18 @@ BuiltinTemplateDecl::BuiltinTemplateDecl(const ASTContext &C, DeclContext *DC, createBuiltinTemplateParameterList(C, DC, BTK)), BTK(BTK) {} +bool BuiltinTemplateDecl::isPackProducingBuiltinTemplate() const { + return getBuiltin

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-19 Thread Ilya Biryukov via cfe-commits
@@ -1598,6 +1599,18 @@ BuiltinTemplateDecl::BuiltinTemplateDecl(const ASTContext &C, DeclContext *DC, createBuiltinTemplateParameterList(C, DC, BTK)), BTK(BTK) {} +bool BuiltinTemplateDecl::isPackProducingBuiltinTemplate() const { + return getBuiltin

[clang] [clang][timers][modules] Fix a timer being started when it's running (PR #154231)

2025-08-19 Thread Ilya Biryukov via cfe-commits
@@ -11003,8 +11003,9 @@ void ASTReader::diagnoseOdrViolations() { } void ASTReader::StartedDeserializing() { - if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get()) -ReadTimer->startTimer(); + if (llvm::Timer *T = ReadTimer.get(); ilya-biryukov

[clang] [clang][timers][modules] Fix a timer being started when it's running (PR #154231)

2025-08-19 Thread Ilya Biryukov via cfe-commits
@@ -11003,8 +11003,9 @@ void ASTReader::diagnoseOdrViolations() { } void ASTReader::StartedDeserializing() { - if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get()) -ReadTimer->startTimer(); + if (llvm::Timer *T = ReadTimer.get(); + ++NumCurrentElementsDese

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-18 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Friendly ping for another round / final approves. https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-14 Thread Ilya Biryukov via cfe-commits
@@ -1700,6 +1717,21 @@ namespace { return inherited::TransformTemplateArgument(Input, Output, Uneval); } +using TreeTransform::TransformTemplateSpecializationType; +QualType +TransformTemplateSpecializationType(TypeLocBuilder &TLB, +

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-14 Thread Ilya Biryukov via cfe-commits
@@ -0,0 +1,226 @@ +// RUN: %clang_cc1 %s -verify +template struct TypeList; + +// === Check results of the builtin. +template +struct TemplateWrapper { + static_assert(__is_same( // expected-error {{static assertion contains an unexpanded parameter pack}} +TypeList<__built

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-14 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > Can you add a release note and some documentation in LanguageExtensions.rst, > in the [Type Trait > Primitives](https://clang.llvm.org/docs/LanguageExtensions.html#type-trait-primitives) > section? I have added both, PTAL. I opted for the "builtin type aliases" section

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-14 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -6654,6 +6658,56 @@ class SubstTemplateTypeParmType final } }; +/// Represents the result of substituting a set of types as a template argument +/// that needs to be expanded later. +/// +/// These types are always dependent and produced depending on the situations: +///

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -316,6 +330,13 @@ TemplateNameKind Sema::isTemplateName(Scope *S, } } + if (isPackProducingBuiltinTemplateName(Template) && + S->getTemplateParamParent() == nullptr) { +Diag(Name.getBeginLoc(), diag::err_builtin_pack_outside_template); +// Recover by ret

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -36,6 +40,7 @@ #include "clang/Sema/TemplateDeduction.h" #include "clang/Sema/TemplateInstCallback.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Casting.h" ilya-biryukov wrote: Done. https://github.com/llvm/llvm-project/pull/106730

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -1,5 +1,4 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -// XFAIL: asserts ilya-biryukov wrote: Yes, I managed to hit a similar case in the new testsuite and fixing it also fixed the corresponding assertion. I was going to follow up with checking all ex

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -5857,6 +5900,29 @@ bool Sema::CheckTemplateArgumentList( } } +// Check for builtins producing template packs at this position, we do not +// support them yet. ilya-biryukov wrote: Done. https://github.com/llvm/llvm-project/pull/106730 _

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -17,30 +17,44 @@ #include "clang/AST/DynamicRecursiveASTVisitor.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" +#include "clang/AST/Mangle.h" +#include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/TemplateBase.h" #include "clang/AST/TemplateName.h"

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -1914,7 +1914,8 @@ Decl *TemplateDeclInstantiator::VisitFriendDecl(FriendDecl *D) { UnsignedOrNone NumExpansions = std::nullopt; if (SemaRef.CheckParameterPacksForExpansion( D->getEllipsisLoc(), D->getSourceRange(), Unexpanded, -

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -5154,6 +5177,84 @@ bool TreeTransform::TransformTemplateArguments( } +template +bool TreeTransform::PreparePackForExpansion(TemplateArgumentLoc In, + bool Uneval, + Te

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -71,12 +73,17 @@ inline std::pair getDepthAndIndex(const NamedDecl *ND) { } /// Retrieve the depth and index of an unexpanded parameter pack. -inline std::pair +/// Returns nullopt when the unexpanded packs do not correspond to template +/// parameters, e.g. __builtin_dedu

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -228,7 +228,9 @@ void threadSafetyCleanup(BeforeSet *Cache); // FIXME: No way to easily map from TemplateTypeParmTypes to // TemplateTypeParmDecls, so we have this horrible PointerUnion. -typedef std::pair, +typedef std::pair, ilya-biryukov wrote: When we

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -6414,11 +6410,9 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New, bool RetainExpansion = false; UnsignedOrNone NumExpansions = std::nullopt; if (CheckParameterPacksForExpansion(Init->getEllipsisLoc(), - B

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -5063,60 +5115,30 @@ bool TreeTransform::TransformTemplateArguments( } if (In.getArgument().isPackExpansion()) { - // We have a pack expansion, for which we will be substituting into - // the pattern. - SourceLocation Ellipsis; - UnsignedOrNone O

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -307,7 +307,7 @@ static UnsignedOrNone EvaluateFoldExpandedConstraintSize( UnsignedOrNone NumExpansions = FE->getNumExpansions(); if (S.CheckParameterPacksForExpansion( FE->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded, MLTAL, - Expand, Retai

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -777,12 +844,32 @@ bool Sema::CheckParameterPacksForExpansion( IdentifierInfo *Name; bool IsVarDeclPack = false; FunctionParmPackExpr *BindingPack = nullptr; +std::optional NumPrecomputedArguments; -if (const TemplateTypeParmType *TTP = -Par

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -25,6 +25,7 @@ #include "clang/AST/RawCommentList.h" #include "clang/AST/SYCLKernelInfo.h" #include "clang/AST/TemplateName.h" +#include "clang/AST/Type.h" ilya-biryukov wrote: I believe Clangd added it for `SubstBuiltinTemplatePackType` and it seems reaso

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -1510,6 +1517,21 @@ namespace { } } +MultiLevelTemplateArgumentList ForgetSubstitution() { + MultiLevelTemplateArgumentList New; + New.addOuterRetainedLevels(this->TemplateArgs.getNumLevels()); + + MultiLevelTemplateArgumentList Old = +

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -3331,6 +3343,65 @@ checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, QualType HasNoTypeMember = Converted[2].getAsType(); return HasNoTypeMember; } + case BTK__builtin_dedup_pack: { +assert(Converted.size() == 1 && "__builtin_dedup_pack sho

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -935,15 +938,18 @@ class PackDeductionScope { S.collectUnexpandedParameterPacks(Pattern, Unexpanded); for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) { unsigned Depth, Index; -std::tie(Depth, Index) = getDepthAndIndex(Unexpanded[I]); +

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -4393,17 +4393,47 @@ void SubstTemplateTypeParmType::Profile(llvm::FoldingSetNodeID &ID, ID.AddBoolean(Final); } +SubstPackType::SubstPackType(TypeClass Derived, QualType Canon, + const TemplateArgument &ArgPack) +: Type(Derived, Canon, +

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -133,7 +133,7 @@ static void instantiateDependentAlignedAttr( // FIXME: Use the actual location of the ellipsis. SourceLocation EllipsisLoc = Aligned->getLocation(); if (S.CheckParameterPacksForExpansion(EllipsisLoc, Aligned->getRange(), -

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -17992,7 +17992,12 @@ DeclResult Sema::ActOnTemplatedFriendTag( collectUnexpandedParameterPacks(QualifierLoc, Unexpanded); unsigned FriendDeclDepth = TempParamLists.front()->getDepth(); for (UnexpandedParameterPack &U : Unexpanded) { -if (getDepthAndIndex(U).first

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-11 Thread Ilya Biryukov via cfe-commits
@@ -4014,8 +4010,8 @@ Decl *TemplateDeclInstantiator::instantiateUnresolvedUsingDecl( bool RetainExpansion = false; UnsignedOrNone NumExpansions = std::nullopt; if (SemaRef.CheckParameterPacksForExpansion( - D->getEllipsisLoc(), D->getSourceRange(), Unexpa

[clang] [clang-tools-extra] [Clang] Add a builtin that deduplicate types into a pack (PR #106730)

2025-08-05 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [Clang] Add builtin that sorts types (PR #152118)

2025-08-05 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: I will rebase this and move out of draft state after #106730 lands. Currently the change also includes commit from that PR. Also left to do: add a builtin to compare types by mangled names. https://github.com/llvm/llvm-project/pull/152118 ___

[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

2025-08-04 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov closed https://github.com/llvm/llvm-project/pull/151666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

2025-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/151666 >From d1c95d8babda9665310773acc66ead6ba5797649 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 1 Aug 2025 09:14:46 +0200 Subject: [PATCH 1/3] [Clang] Handle C++20 export declarations in -dump-mini

[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

2025-08-01 Thread Ilya Biryukov via cfe-commits
@@ -205,12 +204,37 @@ class DeserializedDeclsSourceRangePrinter : public ASTConsumer, private: std::vector PendingDecls; - llvm::DenseSet ProcessedNamespaces; + llvm::DenseSet ProcessedDeclContexts; bool IsCollectingDecls = true; const SourceManager &SM; std::uni

[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

2025-08-01 Thread Ilya Biryukov via cfe-commits
@@ -188,10 +204,64 @@ class DeserializedDeclsSourceRangePrinter : public ASTConsumer, private: std::vector PendingDecls; + llvm::DenseSet ProcessedDeclContexts; bool IsCollectingDecls = true; const SourceManager &SM; std::unique_ptr OS; + static bool shouldIncl

[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

2025-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/151666 >From d1c95d8babda9665310773acc66ead6ba5797649 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 1 Aug 2025 09:14:46 +0200 Subject: [PATCH 1/2] [Clang] Handle C++20 export declarations in -dump-mini

[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

2025-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/151666 >From d1c95d8babda9665310773acc66ead6ba5797649 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 1 Aug 2025 09:14:46 +0200 Subject: [PATCH] [Clang] Handle C++20 export declarations in -dump-minimiza

[clang] [Clang] Dump minimization hints for namespaces (PR #151534)

2025-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov closed https://github.com/llvm/llvm-project/pull/151534 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Dump minimization hints for namespaces (PR #151534)

2025-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/151534 >From ac646c60e0b323eeab7dfa6e1b8965fa7fa78796 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 31 Jul 2025 16:35:50 +0200 Subject: [PATCH 1/2] [Clang] Dump minimization hints for namespaces Unlike

[clang] [Clang] Dump minimization hints for namespaces (PR #151534)

2025-08-01 Thread Ilya Biryukov via cfe-commits
@@ -188,10 +205,49 @@ class DeserializedDeclsSourceRangePrinter : public ASTConsumer, private: std::vector PendingDecls; + llvm::DenseSet ProcessedNamespaces; ilya-biryukov wrote: There is a misunderstanding. The documentation says: > DenseSet is a simple

[clang] [Clang] Dump minimization hints for namespaces (PR #151534)

2025-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/151534 >From ac646c60e0b323eeab7dfa6e1b8965fa7fa78796 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 31 Jul 2025 16:35:50 +0200 Subject: [PATCH 1/2] [Clang] Dump minimization hints for namespaces Unlike

[clang] [Clang] Flush minimization hints after writing (PR #151522)

2025-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov closed https://github.com/llvm/llvm-project/pull/151522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

2025-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/151666 >From ac646c60e0b323eeab7dfa6e1b8965fa7fa78796 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 31 Jul 2025 16:35:50 +0200 Subject: [PATCH 1/2] [Clang] Dump minimization hints for namespaces Unlike

[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

2025-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/151666 >From ac646c60e0b323eeab7dfa6e1b8965fa7fa78796 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 31 Jul 2025 16:35:50 +0200 Subject: [PATCH 1/2] [Clang] Dump minimization hints for namespaces Unlike

[clang] [Clang] Dump minimization hints for namespaces (PR #151534)

2025-08-01 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: @JustinStitt thanks for bringing this up. Export declarations were actually handled well before either, I now have another PR that fixes it #151666. It also sets the ground for handling `LinkageSpecDecl`, which we overlooked until now, but that would be yet another follow-

[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

2025-08-01 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: This also includes changes from #151534, I will rebase it after the relevant PR lands. https://github.com/llvm/llvm-project/pull/151666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

2025-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/151666 Thanks to Justin Stitt for bringing this up, providing test cases and a direction for the fix! >From ac646c60e0b323eeab7dfa6e1b8965fa7fa78796 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 31 Jul

[clang] [Clang] Dump minimization hints for namespaces (PR #151534)

2025-07-31 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/151534 >From ac646c60e0b323eeab7dfa6e1b8965fa7fa78796 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 31 Jul 2025 16:35:50 +0200 Subject: [PATCH] [Clang] Dump minimization hints for namespaces Unlike oth

[clang] [Clang] Dump minimization hints for namespaces (PR #151534)

2025-07-31 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/151534 Unlike other declarations, these cover two ranges: - from `namespace/inline namespace` to the opening `{`, - the closing `}`. This allows to mark the declarations inside the namespace itself independently.

[clang] [Clang] Flush minimization hints after writing (PR #151522)

2025-07-31 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/151522 This helps to get well-formed output if Clang crashes after that point. >From b922a24f7647e47dd8148e8cf980f66cce58282e Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Thu, 31 Jul 2025 15:32:59 +0200 Su

[clang] 311b291 - [Clang] Test that -dump-minimization-hints do not report unused decls. NFC

2025-07-31 Thread Ilya Biryukov via cfe-commits
Author: Ilya Biryukov Date: 2025-07-31T15:47:19+02:00 New Revision: 311b2918129192b9171793406b0c53d9bdd9240b URL: https://github.com/llvm/llvm-project/commit/311b2918129192b9171793406b0c53d9bdd9240b DIFF: https://github.com/llvm/llvm-project/commit/311b2918129192b9171793406b0c53d9bdd9240b.diff

[clang] Reland "[Modules] Record whether VarDecl initializers contain side effects" (PR #145447)

2025-07-07 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Here's a small repro: ```cpp export module Foo; export template struct Wrapper { double value; }; export constexpr Wrapper Compute() { return Wrapper{1.0}; } export template Wrapper ComputeInFloat() { const Wrapper a = Compute(); return a; } ``` it fails when as

[clang] [clang][CompundLiteralExpr] Don't defer evaluation for CLEs (PR #137163)

2025-07-07 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/137163 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Sema] Avoid deep recursion in AnalyzeImplicitConversions (PR #145734)

2025-06-26 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > My first thought is that this has tried to use more stack than its allowed. that's probably the case, the test is a complete overkill, I just wanted to make sure we do hit the issue with upstream Clang when adding it. The buildbot in question is using asan for sure (based

[clang] [clang] NFC: Add alias for std::pair used in SourceLocation (PR #145711)

2025-06-26 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. LG from my side, but I would wait for another approval just to make sure people are on board with a relatively-large NFC refactoring. Code style is a subjective matter, so having a little more backing from @AaronBallman or someone el

[clang] [Sema] Avoid deep recursion in AnalyzeImplicitConversions (PR #145734)

2025-06-26 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov closed https://github.com/llvm/llvm-project/pull/145734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Sema] Avoid deep recursion in AnalyzeImplicitConversions (PR #145734)

2025-06-25 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/145734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Sema] Avoid deep recursion in AnalyzeImplicitConversion (PR #145734)

2025-06-25 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/145734 The function already exposes a work list to avoid deep recursion, this commit starts utilizing it in a helper that could also lead to a deep recursion. We have observed this crash on `clang/test/C/C99/n59

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-06-23 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: I have started picking this back up after a break, sorry for the delays. I will address the comments in the coming days and send an updated version. #139730 also didn't really pick up, so I'm going to abandon the simpler attempt and double down on this PR. https://github.

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-06-23 Thread Ilya Biryukov via cfe-commits
@@ -6484,6 +6499,57 @@ class SubstTemplateTypeParmType final } }; +/// Represents the result of substituting a set of types as a template argument +/// that needs to be expanded later. +/// +/// These types are always dependent and produced depending on the situations: +///

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-06-23 Thread Ilya Biryukov via cfe-commits
@@ -5054,95 +5089,128 @@ bool TreeTransform::TransformTemplateArguments( } if (In.getArgument().isPackExpansion()) { - // We have a pack expansion, for which we will be substituting into - // the pattern. - SourceLocation Ellipsis; - UnsignedOrNone

[clang] [clang] ODR hashes depth+index and not name of TemplateTypeParm (PR #144796)

2025-06-23 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov requested changes to this pull request. Thanks, I believe we've seen some related breakages in the past and had to workaround the module structure because of this. It would definitely save some cycles for us in the future! My only request is to keep this change

[clang] [clang] ODR hashes depth+index and not name of TemplateTypeParm (PR #144796)

2025-06-23 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/144796 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] ODR hashes depth+index and not name of TemplateTypeParm (PR #144796)

2025-06-23 Thread Ilya Biryukov via cfe-commits
@@ -828,7 +828,23 @@ void ODRHash::AddDecl(const Decl *D) { return; } - AddDeclarationName(ND->getDeclName()); + // For template parameters, use depth+index instead of name, because type + // canonicalization can change the name of the template parameter. + if (auto

[clang] [clang] ODR hashes depth+index and not name of TemplateTypeParm (PR #144796)

2025-06-23 Thread Ilya Biryukov via cfe-commits
@@ -5164,6 +5164,29 @@ namespace A { A::X x; #endif +namespace TemplateDecltypeOperator { + +#if defined(FIRST) || defined(SECOND) +template +T6 func(); +#endif + +#if defined(SECOND) +template +using UnrelatedAlias = decltype(func())(); +#endif + +#if defined(FIRST) || defi

[clang] [clang] ODR hashes depth+index and not name of TemplateTypeParm (PR #144796)

2025-06-23 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > It's just that a canonical template parameter type doesn't refer to a > particular template parameter declaration. The particular statement is that Clang canonicalizes `decltype(func())` to `decltype(func())`. If we don't change that, we end up with spurious false posi

[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)

2025-06-04 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > So far we are still aiming for a more principled solution. For example, if > support of a header in multiple modules is a supported feature, then some > kind of a spec with a more comprehensive testing would be appropriate. It is > up to you but personally I feel like th

[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)

2025-06-02 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > I'm sorry that my replies came across as hostile and snarky, I didn't mean it > that way. Though I'll admit I'm not thrilled about your current approach, > that's what I was communicating. But that's what you have right now and there > is no easy way to change it fast.

[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)

2025-05-28 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Many thanks for engaging in this discussion and sorry for the delays in my responses too. https://github.com/llvm/llvm-project/pull/138227 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)

2025-05-28 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > In general, though, I share the same concern as @vsapsai about leaving this > patch reverted for too long. I have a concrete proposal to move forward, #141792. I have checked that the failure we've seen in our infrastructure goes away with both changes applied. Given t

[clang] [Module] Prefer precompiled module even when header is private (PR #141792)

2025-05-28 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: This change will fix the breakages we've had internally with #138227, unblocking it. https://github.com/llvm/llvm-project/pull/141792 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

[clang] [Module] Prefer precompiled module even when header is private (PR #141792)

2025-05-28 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/141792 Currently, Clang picks a module where the header is non-private even when the header is textual and the other is modular. This change makes it prefer a module where the header is modular instead. Access c

[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)

2025-05-28 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > Can you clarify, are you saying this pattern of having a header in two > different modules has to keep working indefinitely, or are you willing to > migrate off of it? > I don't understand what the reason is for the header to be in two different > modules in the first pl

[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)

2025-05-23 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Back to the original issue. > I'm willing to help figure out how to achieve the desired result in a > different way. But for that need to know what is the desired result. We would need to example I shared above to keep working. We rely on an optimization that picks a modu

[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)

2025-05-23 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > Ok, I'm going to revert the change to help you out. But I'm going to re-land > it in a week or when you are ready, whichever comes first. > > There was no indication there is anything wrong with the change or if the > issue is wide-spread. And if a single company relies o

[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)

2025-05-22 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > And I'm not sure such a use case is worth supporting. > But I understand that is only my own interpretation which can be incorrect. > And I want to believe you have a better use case that doesn't rely on > accessing private headers The code I shared compiles with no er

[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)

2025-05-21 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > What is your timeframe for stopping putting the same header ("wrap_foo.h") > into multiple modules? If you do that it was never guaranteed which module > would be used for a header. I'm willing to unblock you but I'd like to know > if you are committed to fixing the issu

[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)

2025-05-20 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Here's a reproducer for our breakage: ```cpp // RUN: rm -rf %t // RUN: split-file %s %t // // First, build a module with a header. // // RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/modules1.map -fmodule-name=a -emit-module -xc++ -fmodules-embed-all-files -o %t/a.pcm %t/mo

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-19 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: I can confirm that we routinely rely on the same header being part of multiple modules and results of that being combined in all kinds of ways imaginable. Moreover, the same header can be a modular header in some modules, textual in others and the resulting PCMs may also b

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-14 Thread Ilya Biryukov via cfe-commits
@@ -1666,6 +1685,21 @@ namespace { return inherited::TransformTemplateArgument(Input, Output, Uneval); } +using TreeTransform::TransformTemplateSpecializationType; +QualType +TransformTemplateSpecializationType(TypeLocBuilder &TLB, +

[clang] [Clang] Add a builtin for efficient type deduplication (PR #139730)

2025-05-14 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > Because this isn't for correctness but is for performance, I think there > isn't a pressing need to land something ASAP from the community perspective > (or is the performance truly bad enough that you think the feature is not > really usable without doing something?). S

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-14 Thread Ilya Biryukov via cfe-commits
@@ -6484,6 +6499,57 @@ class SubstTemplateTypeParmType final } }; +/// Represents the result of substituting a set of types as a template argument +/// that needs to be expanded later. +/// +/// These types are always dependent and produced depending on the situations: +///

[clang] [clang-tools-extra] [Clang] Add __builtin_type_pack_dedup template to deduplicate types in template arguments (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits
@@ -1666,6 +1685,21 @@ namespace { return inherited::TransformTemplateArgument(Input, Output, Uneval); } +using TreeTransform::TransformTemplateSpecializationType; +QualType +TransformTemplateSpecializationType(TypeLocBuilder &TLB, +

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits
@@ -5054,95 +5089,128 @@ bool TreeTransform::TransformTemplateArguments( } if (In.getArgument().isPackExpansion()) { - // We have a pack expansion, for which we will be substituting into - // the pattern. - SourceLocation Ellipsis; - UnsignedOrNone

[clang] [Clang] Add a builtin for efficient type deduplication (PR #139730)

2025-05-13 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/139730 Deduplicating types via standard C++ can be a huge compile-time hog, we have observed that on some of the large targets we have internally this can be up to 25%. This builtin can be used to improve compi

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Note to people reviewing this: please ensure you "hide whitespace" via `git diff -w` or the corresponding setting on GitHub. For your own sanity when looking at changes in `TreeTransform.h`, which are otherwise really complicated to validate. I've deliberately kept the cod

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/106730 >From e2d345d490d73f46d969b9a5945d9bfe11e148f9 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 23 Aug 2024 17:27:26 +0200 Subject: [PATCH 1/2] [Clang] Add builtins that deduplicate and sort types

[clang] [clang-tools-extra] [Clang] Add builtins that deduplicate and sort types (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add a builtin for efficient type deduplication (PR #139730)

2025-05-13 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: This is a simple initial version of a builtin in #106730 that does **not** introduce new kind of packs that can be produced by builtins rather than variadic template parameters and instead relies on features already available in C++. This makes the implementation much sim

[clang] [clang-tools-extra] [Clang] Add __builtin_type_pack_dedup template to deduplicate types in template arguments (PR #106730)

2025-05-13 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: I have made quite a bit of progress here, but we also need the deduplication builting urgently to help ease the pain for some of the big compilations that started hitting our infrastructure limits internally. I have created #139730 with the initial and simple version of th

  1   2   3   4   5   6   7   8   9   10   >