[clang] [C++20][Modules] Load function body from the module that gives canonical decl (PR #111992)

2025-01-10 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Some code got rearranged after our initial testing and we started seeing some new errors after this landed. I have filed #122493 to track it, let's continue the discussion there. https://github.com/llvm/llvm-project/pull/111992 __

[clang] [clang] Refactor attr diagnostics to use %select (PR #122473)

2025-01-10 Thread Ilya Biryukov via cfe-commits
@@ -3708,9 +3709,9 @@ void Parser::ParseDeclarationSpecifiers( continue; if (PA.getKind() == ParsedAttr::AT_LifetimeBound) -Diag(PA.getLoc(), diag::err_attribute_wrong_decl_type_str) ilya-biryukov wrote: Do we have any instan

[clang] [clang] Refactor attr diagnostics to use %select (PR #122473)

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

[clang] [ASTWriter] Do not allocate source location space for module maps used only for textual headers (PR #116374)

2025-02-12 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: @jansvoboda11 No worries at all, thanks for getting back to me. https://github.com/llvm/llvm-project/pull/116374 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-03-15 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: We are aiming to land this on Monday, but let us know if @jkorous-apple, @malavikasamak, @dtarditi or other reviewers have potential concerns and need more time. https://github.com/llvm/llvm-project/pull/125492 ___ cfe-commits ma

[clang] [clang] Do not infer lifetimebound for functions with void return type (PR #131997)

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

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-03-17 Thread Ilya Biryukov via cfe-commits
@@ -2382,14 +2382,20 @@ size_t SourceManager::getDataStructureSizes() const { SourceManagerForFile::SourceManagerForFile(StringRef FileName, StringRef Content) { + // We copy to `std::string` for Context instead of StringRef because

[clang] [NFC] [ASTMatchers] Share code of `forEachArgumentWithParamType` with UnsafeBufferUsage (PR #132387)

2025-03-21 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/132387 This changes exposes a low-level helper that is used to implement `forEachArgumentWithParamType` but can also be used without matchers, e.g. if performance is a concern. Commit f5ee10538b68835112323c241c

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-03-18 Thread Ilya Biryukov via cfe-commits
@@ -2382,14 +2382,20 @@ size_t SourceManager::getDataStructureSizes() const { SourceManagerForFile::SourceManagerForFile(StringRef FileName, StringRef Content) { + // We copy to `std::string` for Context instead of StringRef because

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-03-18 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/131299 >From 1acb9b0717c0f55e59abca104bbb710375a67610 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 14 Mar 2025 10:53:09 +0100 Subject: [PATCH 1/2] [Format] Do not crash on non-null terminated strings

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-03-18 Thread Ilya Biryukov via cfe-commits
@@ -2382,14 +2382,20 @@ size_t SourceManager::getDataStructureSizes() const { SourceManagerForFile::SourceManagerForFile(StringRef FileName, StringRef Content) { + // We copy to `std::string` for Context instead of StringRef because

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-03-17 Thread Ilya Biryukov via cfe-commits
@@ -2031,6 +2031,7 @@ class SourceManagerForFile { // The order of these fields are important - they should be in the same order // as they are created in `createSourceManagerForFile` so that they can be // deleted in the reverse order as they are created. + std::string

[clang] [clang] Do not infer lifetimebound for functions with void return type (PR #131997)

2025-03-19 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov requested changes to this pull request. There seem to be some errors missing the attribute tests now (see buildkythe failures) https://github.com/llvm/llvm-project/pull/131997 ___ cfe-commits mailing list cfe-commits@l

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

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

[clang] [clang] Do not infer lifetimebound for functions with void return type (PR #131997)

2025-03-19 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: LGTM! I second the suggestion to add a test. Also see the suggestion to turn this into a warning in the first place: https://github.com/llvm/llvm-project/issues/126231#issuecomment-2735876367 I am not sure why lifetimebound needs to be an error while other attributes like

[clang] [clang] Do not infer lifetimebound for functions with void return type (PR #131997)

2025-03-19 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: @usx95 I struggled to come up with a reproducer and couldn't understand why at first. I think we infer the attribute **after** we check for this error. This is obviously something we need to fix, but you can get a reproducer like this: https://gcc.godbolt.org/z/e66MY1nn5

[clang] [clang] Do not infer lifetimebound for functions with void return type (PR #131997)

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

[clang] [NFC] [ASTMatchers] Share code of `forEachArgumentWithParamType` with UnsafeBufferUsage (PR #132387)

2025-04-04 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/132387 >From ef63166c24f7328af8177220be706a573d97009e Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 21 Mar 2025 11:42:32 +0100 Subject: [PATCH 1/3] [NFC] [ASTMatchers] Share code of `forEachArgumentWit

[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)

2025-04-05 Thread Ilya Biryukov via cfe-commits
@@ -49,6 +51,135 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// Dumps deserialized declarations. +class DeserializedDeclsLineRangePrinter : public DelegatingDeserializationListener, public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePr

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-04-05 Thread Ilya Biryukov via cfe-commits
@@ -29096,6 +29096,17 @@ TEST_F(FormatTest, BreakBeforeClassName) { "ArenaSafeUniquePtr {};"); } +TEST_F(FormatTest, DoesNotCrashOnNonNullTerminatedStringRefs) { + llvm::StringRef TwoLines = "namespace foo {}\n" + "namespace bar

[clang] [WIP] Implement `print-deserialized-declarations` flag to dump source… (PR #133910)

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

[clang] [Sema] Handle AttributedType in template deduction with derived-to-base conversions (PR #134361)

2025-04-05 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/134361 Fix #134356. We accidentally skipped checking derived-to-base conversions because deduction did not strip sugar in the relevant code. This caused deduction failures when a parameter type had an attribute

[clang] [Tooling] Handle AttributedType in getFullyQualifiedType (PR #134228)

2025-04-05 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/134228 Before this change the code used to add extra qualifiers, e.g. `std::unique_ptr _Nonnull` became `::std::std::unique_ptr _Nonnull` when adding a global namespace qualifier was requested. >From 7edb987104cf

[clang] [NFC] [ASTMatchers] Share code of `forEachArgumentWithParamType` with UnsafeBufferUsage (PR #132387)

2025-04-05 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/132387 >From ef63166c24f7328af8177220be706a573d97009e Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 21 Mar 2025 11:42:32 +0100 Subject: [PATCH 1/2] [NFC] [ASTMatchers] Share code of `forEachArgumentWit

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

2025-03-26 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > @ilya-biryukov, would you mind giving this PR a test on your infrastructure > and if it works maybe share some performance results? Sure, let me try kicking it off. Note that our infrastructure is much better at detecting the compilations timing out than providing proper

[clang] [NFC] [ASTMatchers] Share code of `forEachArgumentWithParamType` with UnsafeBufferUsage (PR #132387)

2025-03-26 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: cc @ivanaivanovska FYI https://github.com/llvm/llvm-project/pull/132387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)

2025-03-28 Thread Ilya Biryukov via cfe-commits
@@ -57,6 +59,8 @@ class ASTDeserializationListener { /// A module import was read from the AST file. virtual void ModuleImportRead(serialization::SubmoduleID ID, SourceLocation ImportLoc) {} + /// The deserialization of the AST file was fini

[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)

2025-03-28 Thread Ilya Biryukov via cfe-commits
@@ -103,15 +120,30 @@ class DeserializedDeclsDumper : public DelegatingDeserializationListener { : DelegatingDeserializationListener(Previous, DeletePrevious) {} void DeclRead(GlobalDeclID ID, const Decl *D) override { -llvm::outs() << "PCH DECL: " << D->getDeclKi

[clang] [clang] Implement some missing interfaces for DelegatingDeserializationListener (PR #133424)

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

[clang] [clang] Fix the crash when dumping deserialized decls (PR #133395)

2025-03-28 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > I'm happy to split the patch. I agree that (2) requires more thought and > careful consideration. I'm not sure I'll have time to finish it before my > leave, so I might have to leave it to you. But I can take care of (1). Yeah, I feel it makes sense to abandon this until

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

2025-03-28 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: The small-scale benchmarks we had show 10% improvement in CPU and 23% improvement in memory usage for some compilations! We did hit one compiler error that does not reproduce without modules, however: ```error: use of overloaded operator '=' is ambiguous``` We're in the pr

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-03-14 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: > It would be useful to have a repro or a stack trace here. In particular, in > `SourceManagerForFile`, `RequiresNullTerminator` is `false`, so the assert > should _not_ fire on a non-null terminated file The repro is attached to the commit. Here is the full stack trace:

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-03-14 Thread Ilya Biryukov via cfe-commits
@@ -2382,14 +2382,20 @@ size_t SourceManager::getDataStructureSizes() const { SourceManagerForFile::SourceManagerForFile(StringRef FileName, StringRef Content) { + // We copy to `std::string` for Context instead of StringRef because

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-03-14 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov created https://github.com/llvm/llvm-project/pull/131299 The `format` API receives a StringRef, but crashes whenever it is non-null-terminated with the corresponding assertion: ``` FormatTests: llvm/lib/Support/MemoryBuffer.cpp:53: void llvm::MemoryBuffer::init

[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-03-15 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: I am going with the path of least resistance in this change and I would welcome any concerns or alternative suggestions. It definitely has trade-offs as we now incur an extra copy, but this seems acceptable for a convenience API that `SourceManagerForFile` aims to be. htt

[clang] [clang] Fix a use-after-free in expression evaluation (PR #118480)

2025-04-22 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: @kadircet let's team up tomorrow and poke at what's happening with the smaller reproducer to figure out if this is the right fix? @AaronBallman I was initially concerned that it would be incorrect to consider the compound literal expression a full expression even if it fix

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

2025-04-28 Thread Ilya Biryukov via cfe-commits
@@ -9125,9 +9126,25 @@ bool LValueExprEvaluator::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) { assert((!Info.getLangOpts().CPlusPlus || E->isFileScope()) && "lvalue compound literal in c++?"); - // Defer visiting the literal until the lvalue-to-rvalue con

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

2025-04-28 Thread Ilya Biryukov via cfe-commits
@@ -4522,6 +4523,38 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E, BaseVal = MTE->getOrCreateValue(false); assert(BaseVal && "got reference to unevaluated temporary"); + } else if (const CompoundLiteralExpr *CLE = +

[clang] [clang] Fix a use-after-free in expression evaluation (PR #118480)

2025-04-23 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: @kadircet and I have spent some time on this. The `LValueExprEvaluator` decides to "defer" the evaluation of compound literals to conversions, but does this in a way that assumes the evaluation happens inside the same expression. https://github.com/llvm/llvm-project/blob/

[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)

2025-05-05 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. Approving to land this and unblock our internal releases. Obviously, I encourage to address the issues raised by other reviewers in the follow-ups. In particular, the most easily actionable one is about the naming of the getter from

[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)

2025-05-05 Thread Ilya Biryukov via cfe-commits
@@ -3602,6 +3602,10 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { } NestedNameSpecifier *getQualifier() const { return Qualifier; } + CXXRecordDecl *getCXXRecordDecl() const; ilya-biryukov wrote: Could you make this private for

[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)

2025-05-05 Thread Ilya Biryukov via cfe-commits
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { } void Profile(llvm::FoldingSetNodeID &ID) { -Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl()); +Profile(ID, getPointeeType(), getQualifier(), ge

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-03-07 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. LGTM from my side, but please give some time for the owners to chime in. https://github.com/llvm/llvm-project/pull/125492 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists

[clang] [llvm] [Clang][C++23] Core language changes from P1467R9 extended floating-point types and standard names. (PR #78503)

2025-03-07 Thread Ilya Biryukov via cfe-commits
@@ -4446,6 +4455,73 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc, ? ImplicitConversionSequence::Better : ImplicitConversionSequence::Worse; + // C++23 [over.ics.rank]p4b3: + // A conversion in either direction between float

[clang-tools-extra] [clangd] Explicitly block until async task completes (PR #130077)

2025-03-06 Thread Ilya Biryukov via cfe-commits
@@ -460,18 +460,24 @@ void ClangdServer::codeComplete(PathRef File, Position Pos, CodeCompleteResult Result = clangd::codeComplete( File, Pos, IP->Preamble, ParseInput, CodeCompleteOpts, SpecFuzzyFind ? &*SpecFuzzyFind : nullptr); +// We don't want `cod

[clang-tools-extra] [clangd] Explicitly block until async task completes (PR #130077)

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

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-10 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: (please note the update comment above, I did not read the change history and didn't realize the original patch was touching the common default style, not Google's style) https://github.com/llvm/llvm-project/pull/130346 ___ cfe-co

[clang] Improve the -Wundefined-func-template diagnostic note for invisible template functions (PR #129031)

2025-03-10 Thread Ilya Biryukov via cfe-commits
@@ -759,13 +759,11 @@ Sema::BuildDependentDeclRefExpr(const CXXScopeSpec &SS, TemplateArgs); } -bool Sema::DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, - NamedDecl *Instantiation, -

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-11 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Google C++ Style Guide and Abseil go hand-in-hand from Google's perspective. We are the stewards of both and we would prefer to keep the two in sync. We have opted to have the Google Style available as builtin in `clang-format` and have been sticking to that decision until

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-11 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: >From the Google's perspective, we are happy with any change that makes those >macros available in `-style=google`. It seems that either of the options gives us that, so up to the rest of the folks in the thread. https://github.com/llvm/llvm-project/pull/130346 __

[clang-tools-extra] [clangd] Explicitly block until async task completes (PR #130077)

2025-03-11 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov approved this pull request. LGTM. PS it would've probably not been my first choice to fix this at the use site rather than at the declaration of the type itself. I am worried that someone else using this elsewhere may end up running into the same problem. Howe

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

2025-02-28 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov updated https://github.com/llvm/llvm-project/pull/106730 >From a6788c3ba0b00c7b935cbb764c25e12f30d2fe80 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Fri, 23 Aug 2024 17:27:26 +0200 Subject: [PATCH] [Clang] Add builtin templates to deduplicate and sort type

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

2025-02-28 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: @cor3ntin and everyone else, would you mind taking another look? I wanted to bring this up again and tried to do all the proposed changes: - we now have a builtin to sort types by mangled name. - the builtins now expand directly into a list of template arguments. - the built

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-28 Thread Ilya Biryukov via cfe-commits
@@ -1986,112 +2360,119 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { } }; -/// Scan the function and return a list of gadgets found with provided kits. -static void findGadgets(const Stmt *S, ASTContext &Ctx, -const UnsafeBufferU

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-28 Thread Ilya Biryukov via cfe-commits
@@ -1986,112 +2360,119 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { } }; -/// Scan the function and return a list of gadgets found with provided kits. -static void findGadgets(const Stmt *S, ASTContext &Ctx, -const UnsafeBufferU

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-28 Thread Ilya Biryukov via cfe-commits
@@ -1986,112 +2360,119 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { } }; -/// Scan the function and return a list of gadgets found with provided kits. -static void findGadgets(const Stmt *S, ASTContext &Ctx, -const UnsafeBufferU

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-28 Thread Ilya Biryukov via cfe-commits
@@ -2672,7 +3053,7 @@ static inline std::optional createDataFixit(const ASTContext &Ctx, // `DRE.data()` std::optional UPCStandalonePointerGadget::getFixits(const FixitStrategy &S) const { - const auto VD = cast(Node->getDecl()); ilya-biryukov wrote: NIT: we

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-28 Thread Ilya Biryukov via cfe-commits
@@ -1948,31 +2294,59 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { const IntegerLiteral *Offset = nullptr; public: - DerefSimplePtrArithFixableGadget(const MatchFinder::MatchResult &Result) + DerefSimplePtrArithFixableGadget(const MatchResult &Result)

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-28 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov commented: @ivanaivanovska I only have NITs so far, could you address them? I will make sure to finish the few other functions I have left "note to self" for, but I don't actually expect much to pop up there. As soon as the comments are addressed, I think we are

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-28 Thread Ilya Biryukov via cfe-commits
@@ -1948,31 +2294,59 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { const IntegerLiteral *Offset = nullptr; public: - DerefSimplePtrArithFixableGadget(const MatchFinder::MatchResult &Result) + DerefSimplePtrArithFixableGadget(const MatchResult &Result)

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

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

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-28 Thread Ilya Biryukov via cfe-commits
@@ -1986,112 +2360,119 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { } }; -/// Scan the function and return a list of gadgets found with provided kits. -static void findGadgets(const Stmt *S, ASTContext &Ctx, -const UnsafeBufferU

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

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

[clang] WIP: Improve the -Wundefined-func-template diagnostic note for invisible template functions (PR #129031)

2025-02-28 Thread Ilya Biryukov via cfe-commits
@@ -5654,6 +5654,8 @@ def warn_func_template_missing : Warning<"instantiation of function %q0 " InGroup, DefaultIgnore; def note_forward_template_decl : Note< "forward declaration of template entity is here">; +def note_unreachable_template_decl +: Note<"declaration of

[clang] WIP: Improve the -Wundefined-func-template diagnostic note for invisible template functions (PR #129031)

2025-02-28 Thread Ilya Biryukov via cfe-commits
@@ -5082,11 +5085,16 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() && !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc())) { Diag(PointOfInstantiation,

[clang] [clang] Fix ASTWriter crash after merging named enums (PR #114240)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -2551,18 +2551,7 @@ void Sema::MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New, // Make the old tag definition visible. makeMergedDefinitionVisible(Hidden); - // If this was an unscoped enumeration, yank all of its enumerators - // out of the scop

[clang] [clang] Fix ASTWriter crash after merging named enums (PR #114240)

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

[clang] [clang] Fix ASTWriter crash after merging named enums (PR #114240)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -2551,18 +2551,7 @@ void Sema::MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New, // Make the old tag definition visible. makeMergedDefinitionVisible(Hidden); - // If this was an unscoped enumeration, yank all of its enumerators - // out of the scop

[clang] [-Wunsafe-buffer-usage] Add absl::{Span,string_view} to UnsafeBufferUsage analysis (PR #127698)

2025-02-24 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov requested changes to this pull request. This makes sense, although I suspect it doesn't work because the code checks for `std` namespace. It would be nice to get a signal from the code owners that they're happy with adding Abseil as a special case in addition

[clang] [-Wunsafe-buffer-usage] Add absl::{Span,string_view} to UnsafeBufferUsage analysis (PR #127698)

2025-02-24 Thread Ilya Biryukov via cfe-commits
@@ -891,7 +891,9 @@ AST_MATCHER(CallExpr, hasUnsafeSnprintfBuffer) { // Pattern 1: static StringRef SizedObjs[] = {"span", "array", "vector", - "basic_string_view", "basic_string"}; + "basic_string_view", "b

[clang] [-Wunsafe-buffer-usage] Add absl::{Span,string_view} to UnsafeBufferUsage analysis (PR #127698)

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

[clang] [clang] Fix ASTWriter crash after merging named enums (PR #114240)

2025-02-24 Thread Ilya Biryukov via cfe-commits
@@ -2551,18 +2551,7 @@ void Sema::MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New, // Make the old tag definition visible. makeMergedDefinitionVisible(Hidden); - // If this was an unscoped enumeration, yank all of its enumerators - // out of the scop

[clang] Thread Safety Analysis: Improved pointer handling (PR #127396)

2025-02-25 Thread Ilya Biryukov via cfe-commits
@@ -143,6 +143,11 @@ Improvements to Clang's diagnostics - A statement attribute applied to a ``case`` label no longer suppresses 'bypassing variable initialization' diagnostics (#84072). +- The :doc:`ThreadSafetyAnalysis` now supports ``-Wthread-safety-pointer`` ---

[clang] Thread Safety Analysis: Improved pointer handling (PR #127396)

2025-02-25 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov commented: I only have a few comments about documenting the caveats (no alias analysis). The actual code changes look very simple and this looks like a clear improvement that would catch many useful cases. I don't have much experience with this code and would s

[clang] Thread Safety Analysis: Improved pointer handling (PR #127396)

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

[clang] Thread Safety Analysis: Improved pointer handling (PR #127396)

2025-02-25 Thread Ilya Biryukov via cfe-commits
@@ -6087,9 +6215,37 @@ class Return { const Foo &returns_constref_shared_locks_required() SHARED_LOCKS_REQUIRED(mu) { return foo; } + + Foo *returns_ptr_exclusive_locks_required() EXCLUSIVE_LOCKS_REQUIRED(mu) { +return &foo; + } + + Foo *returns_pt_ptr_exclusive

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov commented: I had another round, left a few more comments, mostly NITs. I feel we should definitely get rid of `getQualifiedNameAsString` calls, though. There's a few more lines left, I'll get to them soon. https://github.com/llvm/llvm-project/pull/125492 ___

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1505,23 +1741,51 @@ class DataInvocationGadget : public WarningGadget { const ExplicitCastExpr *Op; public: - DataInvocationGadget(const MatchFinder::MatchResult &Result) + DataInvocationGadget(const MatchResult &Result) : WarningGadget(Kind::DataInvocation), -

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1561,56 +1825,70 @@ class UnsafeLibcFunctionCallGadget : public WarningGadget { } WarnedFunKind = OTHERS; public: - UnsafeLibcFunctionCallGadget(const MatchFinder::MatchResult &Result) + UnsafeLibcFunctionCallGadget(const MatchResult &Result) : WarningGadget(Ki

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1505,23 +1741,51 @@ class DataInvocationGadget : public WarningGadget { const ExplicitCastExpr *Op; public: - DataInvocationGadget(const MatchFinder::MatchResult &Result) + DataInvocationGadget(const MatchResult &Result) : WarningGadget(Kind::DataInvocation), -

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1711,25 +2008,38 @@ class PointerDereferenceGadget : public FixableGadget { const UnaryOperator *Op = nullptr; public: - PointerDereferenceGadget(const MatchFinder::MatchResult &Result) + PointerDereferenceGadget(const MatchResult &Result) : FixableGadget(Kind::

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1505,23 +1741,51 @@ class DataInvocationGadget : public WarningGadget { const ExplicitCastExpr *Op; public: - DataInvocationGadget(const MatchFinder::MatchResult &Result) + DataInvocationGadget(const MatchResult &Result) : WarningGadget(Kind::DataInvocation), -

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1636,24 +1914,33 @@ class ULCArraySubscriptGadget : public FixableGadget { const ArraySubscriptExpr *Node; public: - ULCArraySubscriptGadget(const MatchFinder::MatchResult &Result) + ULCArraySubscriptGadget(const MatchResult &Result) : FixableGadget(Kind::ULCArr

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1505,23 +1741,51 @@ class DataInvocationGadget : public WarningGadget { const ExplicitCastExpr *Op; public: - DataInvocationGadget(const MatchFinder::MatchResult &Result) + DataInvocationGadget(const MatchResult &Result) : WarningGadget(Kind::DataInvocation), -

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1460,30 +1694,32 @@ class UnsafeBufferUsageAttrGadget : public WarningGadget { DeclUseList getClaimedVarUseSites() const override { return {}; } }; -/// A call of a constructor that performs unchecked buffer operations -/// over one of its pointer parameters, or constru

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1460,30 +1694,32 @@ class UnsafeBufferUsageAttrGadget : public WarningGadget { DeclUseList getClaimedVarUseSites() const override { return {}; } }; -/// A call of a constructor that performs unchecked buffer operations -/// over one of its pointer parameters, or constru

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1238,27 +1413,36 @@ class SpanTwoParamConstructorGadget : public WarningGadget { const CXXConstructExpr *Ctor; // the span constructor expression public: - SpanTwoParamConstructorGadget(const MatchFinder::MatchResult &Result) + SpanTwoParamConstructorGadget(const Matc

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

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

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1901,28 +2238,37 @@ class UUCAddAssignGadget : public FixableGadget { const Expr *Offset = nullptr; public: - UUCAddAssignGadget(const MatchFinder::MatchResult &Result) + UUCAddAssignGadget(const MatchResult &Result) : FixableGadget(Kind::UUCAddAssign), -

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
https://github.com/ilya-biryukov deleted https://github.com/llvm/llvm-project/pull/125492 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1636,24 +1914,33 @@ class ULCArraySubscriptGadget : public FixableGadget { const ArraySubscriptExpr *Node; public: - ULCArraySubscriptGadget(const MatchFinder::MatchResult &Result) + ULCArraySubscriptGadget(const MatchResult &Result) : FixableGadget(Kind::ULCArr

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-02-27 Thread Ilya Biryukov via cfe-commits
@@ -1460,30 +1694,32 @@ class UnsafeBufferUsageAttrGadget : public WarningGadget { DeclUseList getClaimedVarUseSites() const override { return {}; } }; -/// A call of a constructor that performs unchecked buffer operations -/// over one of its pointer parameters, or constru

[clang] [NFC] [ASTMatchers] Share code of `forEachArgumentWithParamType` with UnsafeBufferUsage (PR #132387)

2025-04-04 Thread Ilya Biryukov via cfe-commits
ilya-biryukov wrote: Friendly ping @AaronBallman to take a look. And also add @usx95 to get another pair of eyes and faster review in case Aaron is busy. https://github.com/llvm/llvm-project/pull/132387 ___ cfe-commits mailing list cfe-commits@lists.l

[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)

2025-04-04 Thread Ilya Biryukov via cfe-commits
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so tha

[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)

2025-04-04 Thread Ilya Biryukov via cfe-commits
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so tha

[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)

2025-04-04 Thread Ilya Biryukov via cfe-commits
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so tha

[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)

2025-04-04 Thread Ilya Biryukov via cfe-commits
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so tha

[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)

2025-04-04 Thread Ilya Biryukov via cfe-commits
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so tha

[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)

2025-04-04 Thread Ilya Biryukov via cfe-commits
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so tha

[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)

2025-04-04 Thread Ilya Biryukov via cfe-commits
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so tha

<    9   10   11   12   13   14   15   >