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

2024-09-18 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: I have also left a few comments in the parallel discussion on the RFC. 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-com

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

2024-09-18 Thread Ilya Biryukov via cfe-commits
@@ -3158,6 +3161,33 @@ checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, int64_t N = Index.getExtValue(); return Ts.getPackAsArray()[N].getAsType(); } + case BTK__type_pack_dedup: { +assert(Converted.size() == 2 && "__builtin_type_pack_dedup sh

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

2024-09-17 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Friendly ping for another round of review. 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] [llvm] [Clang] Add __builtin_type_pack_dedup template to deduplicate types in template arguments (PR #106730)

2024-09-17 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] [llvm] [Clang] Add __builin_type_pack_dedup template to deduplicate types in template arguments (PR #106730)

2024-09-17 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] [llvm] [Clang] Add __builint_type_pack_dedup template to deduplicate types in template arguments (PR #106730)

2024-09-17 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] Propagate lifetimebound from formal parameters to those in the canonical declaration and use that for analysis (PR #107627)

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -266,6 +262,20 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) { LifetimeBoundAttr::CreateImplicit(Context, FD->getLocation())); } } + } else if (auto *CanonDecl = FD->getCanonicalDecl(); FD != CanonDecl) { +// Propagate the lifetimeb

[clang] Propagate lifetimebound from formal parameters to those in the canonical declaration and use that for analysis (PR #107627)

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -462,14 +462,16 @@ static void visitFunctionCallArguments(IndirectLocalPath &Path, Expr *Call, } } - for (unsigned I = 0, -N = std::min(Callee->getNumParams(), Args.size()); - I != N; ++I) { -if (CheckCoroCall || Callee->getParamDecl(I)->ha

[clang] [Modules] Add -cc1 -flate-module-map-file to load module maps after PCMs (PR #88893)

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

[clang] [Modules] Add -cc1 -flate-module-map-file to load module maps after PCMs (PR #88893)

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

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

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -3158,6 +3161,33 @@ checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, int64_t N = Index.getExtValue(); return Ts.getPackAsArray()[N].getAsType(); } + case BTK__type_pack_dedup: { +assert(Converted.size() == 2 && "__builtin_type_pack_dedup sh

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > I don't think the rfc has reached its conclusion yet, and consensus has not > been called (for example, i still need to think about whether my questions > were addressed) so we should wait for the RFC process before continuing with > that PR. > > Thanks Thanks for expl

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

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -3158,6 +3161,33 @@ checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD, int64_t N = Index.getExtValue(); return Ts.getPackAsArray()[N].getAsType(); } + case BTK__type_list_dedup: { +assert(Converted.size() == 2 && + "__type_list_dedu

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

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -0,0 +1,57 @@ +// RUN: %clang_cc1 %s -verify ilya-biryukov wrote: Done. I have also added a few tests with arrays and pointers, which should also exhibit a few more combinations of types that subsume qualifiers and could be different when canonical/non-canon

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

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -309,7 +309,10 @@ enum BuiltinTemplateKind : int { BTK__make_integer_seq, /// This names the __type_pack_element BuiltinTemplateDecl. - BTK__type_pack_element + BTK__type_pack_element, + + /// This names the __type_list_dedup BuiltinTemplateDecl. ily

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

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -309,7 +309,10 @@ enum BuiltinTemplateKind : int { BTK__make_integer_seq, /// This names the __type_pack_element BuiltinTemplateDecl. - BTK__type_pack_element + BTK__type_pack_element, + + /// This names the __type_list_dedup BuiltinTemplateDecl. + BTK__type_list_de

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: @AaronBallman @cor3ntin I believe we are getting close to finalizing this PR. Would you be okay with this feature landing and myself approving this when it's ready? There was some discussion here and in the RFC, but I don't think there was explicit approval (or objection)

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -743,6 +743,12 @@ void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field, ILE->updateInit(SemaRef.Context, Init, Filler); return; } + +if (Field->hasAttr()) { + SemaRef.Diag(ILE->getExprLoc(), diag::warn_field_requires_expli

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -1472,3 +1472,49 @@ template struct Outer { }; }; Outer::Inner outerinner; + +void aggregate() { + struct S { +[[clang::requires_explicit_initialization]] int x; +int y; +int z = 12; +[[clang::requires_explicit_initialization]] int q = 100; +static voi

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -2148,6 +2158,19 @@ void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) { for (conversion_iterator I = conversion_begin(), E = conversion_end(); I != E; ++I) I.setAccess((*I)->getAccess()); + + ASTContext &Context = getASTContext(); +

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -743,6 +743,12 @@ void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field, ILE->updateInit(SemaRef.Context, Init, Filler); return; } + +if (Field->hasAttr()) { + SemaRef.Diag(ILE->getExprLoc(), diag::warn_field_requires_expli

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits
@@ -119,6 +119,14 @@ FIELD(HasInitMethod, 1, NO_MERGE) /// within anonymous unions or structs. FIELD(HasInClassInitializer, 1, NO_MERGE) +/// Custom attribute that is True if any field is marked as explicit in a type ilya-biryukov wrote: Suggestion: could we

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov commented: See my comment about `VerifyOnly` and duplicate diagnostics. The rest are small NITs. https://github.com/llvm/llvm-project/pull/102040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llv

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

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

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. LGTM from my side if all other tests pass. Given that it's a small change and bugfix, I think it should be okay to land this without waiting for other reviewers. We could always follow up with more fixes if they have additional commen

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Ilya Biryukov via cfe-commits
@@ -113,9 +113,11 @@ class TreeTransform { class ForgetPartiallySubstitutedPackRAII { Derived &Self; TemplateArgument Old; +Sema::ArgumentPackSubstitutionIndexRAII ResetPackSubstIndex; ilya-biryukov wrote: Could you add a short comment mentioning

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: I have spent some time poking at the code and looking at the debugger and came up with a smaller repro, see https://gcc.godbolt.org/z/6ccPPd6hz: ```cpp int bar(...); template struct Int {}; template constexpr auto foo(T... x) -> decltype(bar(T(x)...)) { return 1; } temp

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Other than the test, the idea of the change does seem correct, here's the relevant comment from `Sema.h`: ```cpp /// The current index into pack expansion arguments that will be /// used for substitution of parameter packs. /// /// The pack expansion index will be -1 to indi

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-11 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov commented: Sorry for not looking closer yet, but could we get a test case? It would make it much easier to review this change. https://github.com/llvm/llvm-project/pull/108197 ___ cfe-commits mailing list cfe-commits@li

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

2024-09-10 Thread Ilya Biryukov via cfe-commits
@@ -38,9 +40,11 @@ #include "clang/Sema/Template.h" #include "clang/Sema/TemplateDeduction.h" #include "llvm/ADT/BitVector.h" +#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" +#include "

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

2024-09-10 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/106730 >From a46885df62ff64f355abb010f778d84309acd10f Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 23 Aug 2024 17:27:26 +0200 Subject: [PATCH 1/5] [Clang] Add __type_list_dedup builtin to deduplicate

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

2024-09-10 Thread Ilya Biryukov via cfe-commits
@@ -309,7 +309,10 @@ enum BuiltinTemplateKind : int { BTK__make_integer_seq, /// This names the __type_pack_element BuiltinTemplateDecl. - BTK__type_pack_element + BTK__type_pack_element, + + /// This names the __type_list_dedup BuiltinTemplateDecl. + BTK__type_list_de

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

2024-09-10 Thread Ilya Biryukov via cfe-commits
@@ -309,7 +309,10 @@ enum BuiltinTemplateKind : int { BTK__make_integer_seq, /// This names the __type_pack_element BuiltinTemplateDecl. - BTK__type_pack_element + BTK__type_pack_element, + + /// This names the __type_list_dedup BuiltinTemplateDecl. + BTK__type_list_de

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-09 Thread Ilya Biryukov via cfe-commits
@@ -2133,6 +2142,18 @@ void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) { for (conversion_iterator I = conversion_begin(), E = conversion_end(); I != E; ++I) I.setAccess((*I)->getAccess()); + + ASTContext &Context = getASTContext(); +

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-09 Thread Ilya Biryukov via cfe-commits
@@ -1472,3 +1472,25 @@ template struct Outer { }; }; Outer::Inner outerinner; + +void aggregate() { ilya-biryukov wrote: Could we add examples from @AaronBallman's [RFC comment](https://discourse.llvm.org/t/rfc-add-clang-attribute-to-ensure-that-fields-are-

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-09 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov commented: I think there are some good parallel disscussions happening in the RFC, but despite their outcomes, we could probably update the PR to capture current behavior in those interesting cases. I left a few comments along those lines, PTAL. https://githu

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

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

[clang] [Modules] Add -cc1 -flate-module-map-file to load module maps after PCMs (PR #88893)

2024-09-06 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > To better understand the motivation, I have two questions: > > * Why do you give Clang module maps describing modules that are already > described in PCM files? Unless the module map describes some other top-level > module that's yet to be built, the information it provi

[clang] [Modules] Add -cc1 -flate-module-map-file to load module maps after PCMs (PR #88893)

2024-09-06 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: @ChuanqiXu9 thanks for taking a look! Makes sense to give others a chance to chime in, I will wait for more comments. https://github.com/llvm/llvm-project/pull/88893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://

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

2024-09-04 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: I still need to add code that preserves source locations for template arguments and tests for it, but otherwise this is ready for review and I would like to get some initial feedback. The RFC did not get any comments so far, but also happy to discuss the general design th

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

2024-09-04 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 __type_list_dedup builtin to deduplicate types in template arguments (PR #106730)

2024-09-04 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 __type_list_dedup builtin to deduplicate types in template arguments (PR #106730)

2024-09-04 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 __type_list_dedup builtin to deduplicate types in templat… (PR #106730)

2024-09-04 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov ready_for_review 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 __type_list_dedup builtin to deduplicate types in templat… (PR #106730)

2024-09-04 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/106730 >From a46885df62ff64f355abb010f778d84309acd10f Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 23 Aug 2024 17:27:26 +0200 Subject: [PATCH 1/3] [Clang] Add __type_list_dedup builtin to deduplicate

[clang] [clang-tools-extra] [Clang] Add __type_list_dedup builtin to deduplicate types in templat… (PR #106730)

2024-09-04 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/106730 >From a46885df62ff64f355abb010f778d84309acd10f Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 23 Aug 2024 17:27:26 +0200 Subject: [PATCH 1/3] [Clang] Add __type_list_dedup builtin to deduplicate

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-04 Thread Ilya Biryukov via cfe-commits
@@ -1472,3 +1472,25 @@ template struct Outer { }; }; Outer::Inner outerinner; + +void aggregate() { + struct B { +[[clang::explicit_init]] int f1; + }; + + struct S : B { // expected-warning {{uninitialized}} +int f2; +int f3 [[clang::explicit_init]]; + }; + +

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-04 Thread Ilya Biryukov via cfe-commits
@@ -1419,6 +1419,28 @@ is not specified. }]; } +def ExplicitInitDocs : Documentation { + let Category = DocCatField; + let Content = [{ +The ``clang::explicit_init`` attribute indicates that the field must be +initialized explicitly by the caller when the class is construc

[clang-tools-extra] [include-cleaner] Report refs for enum constants used through namespace aliases (PR #106706)

2024-09-02 Thread Ilya Biryukov via cfe-commits
@@ -146,9 +148,24 @@ class ASTWalker : public RecursiveASTVisitor { // // If it's an enum constant, it must be due to prior decl. Report references // to it when qualifier isn't a type. -if (llvm::isa(FD)) { - if (!DRE->getQualifier() || DRE->getQualifier(

[clang] [clang-tools-extra] [Clang] Add __type_list_dedup builtin to deduplicate types in templat… (PR #106730)

2024-08-30 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: RFC for this change: https://discourse.llvm.org/t/rfc-adding-builtin-for-deduplicating-type-lists/80986 https://github.com/llvm/llvm-project/pull/106730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.or

[clang-tools-extra] [include-cleaner] Report refs for enum constants used through namespace aliases (PR #106706)

2024-08-30 Thread Ilya Biryukov via cfe-commits
@@ -146,9 +148,24 @@ class ASTWalker : public RecursiveASTVisitor { // // If it's an enum constant, it must be due to prior decl. Report references // to it when qualifier isn't a type. -if (llvm::isa(FD)) { - if (!DRE->getQualifier() || DRE->getQualifier(

[clang-tools-extra] [include-cleaner] Report refs for enum constants used through namespace aliases (PR #106706)

2024-08-30 Thread Ilya Biryukov via cfe-commits
@@ -534,6 +534,8 @@ TEST(WalkAST, Enums) { testWalk(R"(namespace ns { enum E { A = 42 }; } struct S { using ns::E::A; };)", "int e = S::^A;"); + testWalk(R"(namespace ns { enum E { $explicit^A = 42 }; })", + "namespace z = ns; int e = z::^A

[clang-tools-extra] [include-cleaner] Report refs for enum constants used through namespace aliases (PR #106706)

2024-08-30 Thread Ilya Biryukov via cfe-commits
@@ -146,9 +148,24 @@ class ASTWalker : public RecursiveASTVisitor { // // If it's an enum constant, it must be due to prior decl. Report references // to it when qualifier isn't a type. -if (llvm::isa(FD)) { - if (!DRE->getQualifier() || DRE->getQualifier(

[clang-tools-extra] [include-cleaner] Report refs for enum constants used through namespace aliases (PR #106706)

2024-08-30 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. Still LGTM. See one minor comment about the code style, but up to you if you want to apply it or not. https://github.com/llvm/llvm-project/pull/106706 ___ cfe-commits mailing list cfe-commit

[clang-tools-extra] [include-cleaner] Report refs for enum constants used through namespace aliases (PR #106706)

2024-08-30 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov edited https://github.com/llvm/llvm-project/pull/106706 ___ 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 __type_list_dedup builtin to deduplicate types in templat… (PR #106730)

2024-08-30 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/106730 >From 0151fbf9a8cea2d1c60dc399f088258dd94ad562 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 __type_list_dedup builtin to deduplicate

[clang] [clang-tools-extra] [Clang] Add __type_list_dedup builtin to deduplicate types in templat… (PR #106730)

2024-08-30 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/106730 …e arguments This allows to deduplicate the type lists efficiently in C++. It is possible to achieve the same effect via template metaprogramming, but performance of the resulting code is much lower than

[clang-tools-extra] [include-cleaner] Report refs for enum constants used through namespace aliases (PR #106706)

2024-08-30 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. LGTM. See a small suggestion about adding another test too. https://github.com/llvm/llvm-project/pull/106706 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi

[clang-tools-extra] [include-cleaner] Report refs for enum constants used through namespace aliases (PR #106706)

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

[clang-tools-extra] [include-cleaner] Report refs for enum constants used through namespace aliases (PR #106706)

2024-08-30 Thread Ilya Biryukov via cfe-commits
@@ -534,6 +534,8 @@ TEST(WalkAST, Enums) { testWalk(R"(namespace ns { enum E { A = 42 }; } struct S { using ns::E::A; };)", "int e = S::^A;"); + testWalk(R"(namespace ns { enum E { $explicit^A = 42 }; })", + "namespace z = ns; int e = z::^A

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-08-30 Thread Ilya Biryukov via cfe-commits
@@ -1419,6 +1419,28 @@ is not specified. }]; } +def ExplicitInitDocs : Documentation { + let Category = DocCatField; + let Content = [{ +The ``clang::explicit_init`` attribute indicates that the field must be +initialized explicitly by the caller when the class is construc

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-08-30 Thread Ilya Biryukov via cfe-commits
@@ -1472,3 +1472,25 @@ template struct Outer { }; }; Outer::Inner outerinner; + +void aggregate() { + struct B { +[[clang::explicit_init]] int f1; + }; + + struct S : B { // expected-warning {{uninitialized}} +int f2; +int f3 [[clang::explicit_init]]; + }; + +

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-08-30 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov commented: I hope folks are ok with me chiming in as a reviewer for this. I've left quite a few comments in the RFC and is also supportive of landing this change and happy to invest into supporting it going forward inside our team. https://github.com/llvm/llvm-

[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

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

[clang] [clang] Cleanup IncludeLocMap (PR #106241)

2024-08-30 Thread Ilya Biryukov via cfe-commits
@@ -453,6 +454,61 @@ TEST_F(SourceManagerTest, loadedSLocEntryIsInTheSameTranslationUnit) { #if defined(LLVM_ON_UNIX) +TEST_F(SourceManagerTest, ResetsIncludeLocMap) { ilya-biryukov wrote: Suggestion: add a comment explaining what this aims to test at a mor

[clang] [clang] Cleanup IncludeLocMap (PR #106241)

2024-08-30 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. LGMT with a small suggestion. Thanks for getting the test in! https://github.com/llvm/llvm-project/pull/106241 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/

[clang] [clang] Cleanup IncludeLocMap (PR #106241)

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

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Ilya Biryukov via cfe-commits
@@ -194,13 +236,15 @@ struct llvm::TimeTraceProfiler { J.attribute("pid", Pid); J.attribute("tid", int64_t(Tid)); J.attribute("ts", StartUs); -if (E.AsyncEvent) { +if (TimeTraceEventType::AsyncEvent == E.EventType) { J.attribut

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Ilya Biryukov via cfe-commits
@@ -406,34 +450,50 @@ TimeTraceProfilerEntry *llvm::timeTraceProfilerBegin(StringRef Name, StringRef Detail) { if (TimeTraceProfilerInstance != nullptr) return TimeTraceProfilerInstance->begin( -std::string(Nam

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Ilya Biryukov via cfe-commits
@@ -104,6 +105,23 @@ struct llvm::TimeTraceProfilerEntry { } }; +struct InProgressEntry { + std::unique_ptr Event; + std::vector InstantEvents; + + InProgressEntry(TimePointType &&S, TimePointType &&E, std::string &&N, ilya-biryukov wrote: Suggestion: re

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Ilya Biryukov via cfe-commits
@@ -83,6 +83,8 @@ namespace llvm { class raw_pwrite_stream; +enum class TimeTraceEventType { CompleteEvent, InstantEvent, AsyncEvent }; ilya-biryukov wrote: It would be useful to add a comment explaining what different event types are about (e.g. it would m

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Ilya Biryukov via cfe-commits
@@ -104,6 +105,23 @@ struct llvm::TimeTraceProfilerEntry { } }; +struct InProgressEntry { + std::unique_ptr Event; + std::vector InstantEvents; + + InProgressEntry(TimePointType &&S, TimePointType &&E, std::string &&N, + std::string &&Dt, TimeTraceEventTy

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Ilya Biryukov via cfe-commits
@@ -75,18 +76,18 @@ struct llvm::TimeTraceProfilerEntry { const std::string Name; TimeTraceMetadata Metadata; - const bool AsyncEvent = false; + TimeTraceEventType EventType; ilya-biryukov wrote: Let's assign the default to avoid accidentally having uni

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

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

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov commented: I have left quite a few comments, but they are mostly about the code style. I think this looks really good overall and almost ready to land. Could you split the change to Sema into a separate PR so that we have time profiler changes separately? https

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-29 Thread Ilya Biryukov via cfe-commits
@@ -104,6 +105,23 @@ struct llvm::TimeTraceProfilerEntry { } }; +struct InProgressEntry { + std::unique_ptr Event; ilya-biryukov wrote: Could we store it directly as `TimeTraceProfilerEntry` without unique_ptr? We are already creating `InProgressEntry` in

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-28 Thread Ilya Biryukov via cfe-commits
@@ -92,13 +94,17 @@ struct TimeTraceMetadata { bool isEmpty() const { return Detail.empty() && File.empty(); } }; +struct TimeTraceProfilerEntry; ilya-biryukov wrote: The idea of sharing most code and configuring only the relevant bits we need to write for

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

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

[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)

2024-08-28 Thread Ilya Biryukov via cfe-commits
@@ -1255,8 +1256,12 @@ Parser::DeclGroupPtrTy Parser::ParseDeclarationOrFunctionDefinition( // Add an enclosing time trace scope for a bunch of small scopes with // "EvaluateAsConstExpr". llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition", [&]() { -

[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)

2024-08-28 Thread Ilya Biryukov via cfe-commits
@@ -223,15 +223,15 @@ Frontend (test.cc) | | | | EvaluateAsRValue () | | | EvaluateAsBooleanCondition () | | | | EvaluateAsRValue () -| ParseDeclarationOrFunctionDefinition (test.cc:16:1) +| ParseDeclarationOrFunctionDefinition (test.cc:16) | | ParseFunctionDefinition (slow_te

[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)

2024-08-28 Thread Ilya Biryukov via cfe-commits
@@ -1255,8 +1256,12 @@ Parser::DeclGroupPtrTy Parser::ParseDeclarationOrFunctionDefinition( // Add an enclosing time trace scope for a bunch of small scopes with // "EvaluateAsConstExpr". llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition", [&]() { -

[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)

2024-08-28 Thread Ilya Biryukov via cfe-commits
@@ -1255,8 +1256,12 @@ Parser::DeclGroupPtrTy Parser::ParseDeclarationOrFunctionDefinition( // Add an enclosing time trace scope for a bunch of small scopes with // "EvaluateAsConstExpr". llvm::TimeTraceScope TimeScope("ParseDeclarationOrFunctionDefinition", [&]() { -

[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)

2024-08-28 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov commented: Suggestion: could we update the PR title to say something like "Output location in separate fields of `-ftime-trace`"? "properly" is open to interpretation and requires reading the full change description. https://github.com/llvm/llvm-project/pull/1

[clang] [clang] Properly set file and line info for -ftime-trace (PR #106277)

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

[clang] [clang] Cleanup IncludeLocMap (PR #106241)

2024-08-28 Thread Ilya Biryukov via cfe-commits
@@ -350,6 +350,7 @@ void SourceManager::clearIDTables() { LastLineNoContentCache = nullptr; LastFileIDLookup = FileID(); + IncludedLocMap.clear(); ilya-biryukov wrote: Is there a way to write a unit test checking this behavior? SourceManager should be r

[clang] [clang] Cleanup IncludeLocMap (PR #106241)

2024-08-28 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov requested changes to this pull request. This looks good, but I wanted to explore if we could write a unit test for this... https://github.com/llvm/llvm-project/pull/106241 ___ cfe-commits mailing list cfe-commits@lists

[clang] [clang] Cleanup IncludeLocMap (PR #106241)

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

[clang-tools-extra] [include-cleaner] Turn new/delete usages to ambiguous references (PR #105844)

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

[clang] [llvm] Added instant events and marking defered templated instantiation. (PR #103039)

2024-08-13 Thread Ilya Biryukov via cfe-commits
@@ -181,9 +187,18 @@ class TimeTraceScope { Entry = timeTraceProfilerBegin(Name, Detail); } TimeTraceScope(StringRef Name, ilya-biryukov wrote: We should not use the `TimeTraceScope` for instant events at all. It does not make much sense to deal with

[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)

2024-08-06 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > r3 is in 2 weeks and we have to be more conservatives in our backports, so it > really depends on how long it took you and @ilya-biryukov to address these > issues and the complexity of the patches. > > In particular, I would be surprised if the attribute case impacts ma

[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

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

[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-02 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/100985 >From d35544d971f073f98fba047cfcbe3cfe92dd78c4 Mon Sep 17 00:00:00 2001 From: Ivana Ivanovska Date: Mon, 29 Jul 2024 08:08:00 + Subject: [PATCH 1/4] Surface error for plain return statement in coroutin

[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-02 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. Thanks! The changes LG, I'll wait until premerge checks finish and merge it into mainline. https://github.com/llvm/llvm-project/pull/100985 ___ cfe-commits mailing list cfe-commits@lists.llv

[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

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

[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits
@@ -684,6 +684,19 @@ bool Sema::checkFinalSuspendNoThrow(const Stmt *FinalSuspend) { return ThrowingDecls.empty(); } +// [stmt.return.coroutine]p1: +// A coroutine shall not enclose a return statement ([stmt.return]). +static void checkReturnStmtInCoroutine(Sema &S, Funct

[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov requested changes to this pull request. The `assert` condition seems wrong, otherwise this should be good to go. I've also left one more suggestion to leave a comment that I missed in the original review since we need another round anyway. https://github.com/ll

[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits
@@ -694,6 +707,9 @@ bool Sema::ActOnCoroutineBodyStart(Scope *SC, SourceLocation KWLoc, auto *ScopeInfo = getCurFunction(); assert(ScopeInfo->CoroutinePromise); + if (ScopeInfo->FirstCoroutineStmtLoc == KWLoc) ilya-biryukov wrote: NIT: add a comment exp

[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits
@@ -291,6 +318,50 @@ void mixed_coreturn_template2(bool b, T) { return; // expected-error {{not allowed in coroutine}} } +struct promise_handle; + +struct Handle : std::coroutine_handle { // expected-note 4{{not viable}} +// expected-note@-1 4{{not viable}} +using

  1   2   3   4   5   6   7   8   9   10   >