[clang] [clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-03-11 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Overall looks good to me, some nits inline. https://github.com/llvm/llvm-project/pull/128150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listin

[clang] [clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-03-11 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/128150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-03-11 Thread Gábor Horváth via cfe-commits
@@ -91,6 +91,10 @@ Improvements to clang-query Improvements to clang-tidy -- +- It no longer processes declarations from system headers by default, greatly Xazax-hun wrote: I think we should mention somewhere that downstream users migh

[clang] [analyzer] Model [[assume]] attributes without side-ffects (PR #130418)

2025-03-11 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/130418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [StaticAnalyzer] Relax the pre-condition of 'setsockopt' (PR #130683)

2025-03-11 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/130683 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [StaticAnalyzer] Relax the pre-condition of 'setsockopt' (PR #130683)

2025-03-11 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: This change looks good to me. I think you could open PRs for the questions you brought up and we could sort them out in the review process. https://github.com/llvm/llvm-project/pull/130683 ___ cfe-commits mailing list cfe-commits@lis

[clang] [analyzer] Model [[assume]] attributes without side-ffects (PR #130418)

2025-03-11 Thread Gábor Horváth via cfe-commits
@@ -91,8 +91,29 @@ QualType getOverflowBuiltinResultType(const CallEvent &Call, CheckerContext &C, } } -class BuiltinFunctionChecker : public Checker { +class BuiltinFunctionChecker +: public Checker> { public: + void checkPostStmt(const AttributedStmt *A, CheckerCont

[clang] [analyzer] Model [[assume]] attributes without side-ffects (PR #130418)

2025-03-11 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. I have one question once that is resolved the rest looks good to me. https://github.com/llvm/llvm-project/pull/130418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.o

[clang] [NFC][analyzer] Remove CheckerNameRef::getName() (PR #130780)

2025-03-11 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/130780 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Fix RegionStore assertion failure after #127602 (PR #129224)

2025-02-28 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/129224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reapply "[analyzer] Handle [[assume(cond)]] as __builtin_assume(cond)" (PR #129234)

2025-03-05 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/129234 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reapply "[analyzer] Handle [[assume(cond)]] as __builtin_assume(cond)" (PR #129234)

2025-03-05 Thread Gábor Horváth via cfe-commits
@@ -443,21 +443,44 @@ class reverse_children { } // namespace -reverse_children::reverse_children(Stmt *S) { - if (CallExpr *CE = dyn_cast(S)) { -children = CE->getRawSubExprs(); +reverse_children::reverse_children(Stmt *S, ASTContext &Ctx) { + switch (S->getStmtClass()

[clang] Reapply "[analyzer] Handle [[assume(cond)]] as __builtin_assume(cond)" (PR #129234)

2025-03-05 Thread Gábor Horváth via cfe-commits
@@ -180,3 +183,58 @@ int test_reference_that_might_be_after_the_end(int idx) { return ref; } +// From: https://github.com/llvm/llvm-project/issues/100762 +extern int arrOf10[10]; +void using_builtin(int x) { + __builtin_assume(x > 101); // CallExpr + arrOf10[x] = 404; // e

[clang] [clang][cleanup] simplify ReachableCode scanFromBlock (PR #72257)

2025-03-05 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/72257 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reapply "[analyzer] Handle [[assume(cond)]] as __builtin_assume(cond)" (PR #129234)

2025-03-05 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LG, thanks! https://github.com/llvm/llvm-project/pull/129234 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][analyzer] Rename `CheckerBase::getCheckerName` to `getName` (PR #130953)

2025-03-12 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/130953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][analyzer] Rename `CheckerBase::getCheckerName` to `getName` (PR #130953)

2025-03-12 Thread Gábor Horváth via cfe-commits
@@ -41,19 +41,19 @@ class BugType { Checker(nullptr), SuppressOnSink(SuppressOnSink) {} BugType(const CheckerBase *Checker, StringRef Desc, StringRef Cat = categories::LogicError, bool SuppressOnSink = false) - : CheckerName(Checker->getCheckerName()),

[clang] [clang][analyzer] Fix false positive of BlockInCriticalSectionChecker (PR #127049)

2025-02-14 Thread Gábor Horváth via cfe-commits
@@ -315,16 +342,54 @@ bool BlockInCriticalSectionChecker::isBlockingInCritSection( void BlockInCriticalSectionChecker::checkPostCall(const CallEvent &Call, CheckerContext &C) const { if (isBlockingInCritSection(Call, C)) { +

[clang] [clang][analyzer] Teach the BlockInCriticalSectionChecker about O_NONBLOCK streams (PR #127049)

2025-02-17 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: Mostly looks good to me, I have one question inline. https://github.com/llvm/llvm-project/pull/127049 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

[clang] [nfc][analyzer] Add MemSpace trait to program state (PR #123003)

2025-02-17 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. I am fine going ahead with this. https://github.com/llvm/llvm-project/pull/123003 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-comm

[clang] [analyzer] Add hack in ArrayBound to cover up missing casts (PR #127117)

2025-02-17 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Looks good! Suppressing results for cases we do not model properly is the right thing to do. That being said, I wonder if we should record the presence of casts when we produce `ElementRegion`s to better help checks suppress potentially

[clang] [clang] Fix false positive regression for lifetime analysis warning. (PR #127460)

2025-02-17 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/127460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Delay the checker constructions after parsing (PR #127409)

2025-02-17 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > FYI: This may be a breaking change to some downstream users that may had some > means to attach different listeners and what not to e.g. the Preprocessor > inside their checker register functions. Since we delay the calls to these > register fns after parsing is already done

[clang] [analyzer] Delay the checker constructions after parsing (PR #127409)

2025-02-17 Thread Gábor Horváth via cfe-commits
@@ -73,6 +73,23 @@ Nullability getNullabilityAnnotation(QualType Type); /// returned. std::optional tryExpandAsInteger(StringRef Macro, const Preprocessor &PP); +class CachedMacroValue { Xazax-hun wrote: I think with the optional we cannot distinguish between

[clang] [clang][analyzer] Teach the BlockInCriticalSectionChecker about O_NONBLOCK streams (PR #127049)

2025-02-17 Thread Gábor Horváth via cfe-commits
@@ -337,6 +391,28 @@ void BlockInCriticalSectionChecker::reportBlockInCritSection( << "' inside of critical section"; auto R = std::make_unique(BlockInCritSectionBugType, os.str(), ErrNode); + // for 'read' and 'recv'

[clang] Please ignore this (PR #127807)

2025-02-19 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun closed https://github.com/llvm/llvm-project/pull/127807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WIP][clang]: Implement a conditional lifetimebound_if builtin. (PR #125520)

2025-02-21 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: A moved from object could be reinitalized: ``` void test() { std::vector abc; std::string b; add(abc, std::move(b)); b = std::string(); // now b can be used again. } That being said, maybe this is rare enough that we could have an opt-in warning. B

[clang] [analyzer] Clean up slightly the messed up ownership model of the analyzer (PR #128368)

2025-02-24 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/128368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][analyzer] replace Stmt* with ConstCFGElementRef in SymbolConjured (PR #128251)

2025-02-24 Thread Gábor Horváth via cfe-commits
@@ -171,19 +172,11 @@ class SValBuilder { // Forwarding methods to SymbolManager. - const SymbolConjured* conjureSymbol(const Stmt *stmt, - const LocationContext *LCtx, - QualType type, -

[clang] [Clang][analyzer] replace Stmt* with ConstCFGElementRef in SymbolConjured (PR #128251)

2025-02-24 Thread Gábor Horváth via cfe-commits
@@ -27,7 +27,8 @@ namespace ento { /// by the loop body in any iteration. ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState, const LocationContext *LCtx, -unsigned BlockCount, const Stmt *LoopSt

[clang] [Clang][analyzer] replace Stmt* with ConstCFGElementRef in SymbolConjured (PR #128251)

2025-02-24 Thread Gábor Horváth via cfe-commits
@@ -1515,7 +1515,8 @@ void CStringChecker::evalCopyCommon(CheckerContext &C, const CallEvent &Call, // conjure a return value for later. if (lastElement.isUnknown()) lastElement = C.getSValBuilder().conjureSymbolVal( -nullptr, Call.getOriginExpr

[clang] [Clang][analyzer] replace Stmt* with ConstCFGElementRef in SymbolConjured (PR #128251)

2025-02-24 Thread Gábor Horváth via cfe-commits
@@ -101,8 +103,10 @@ class SymbolConjured : public SymbolData { } public: - /// It might return null. - const Stmt *getStmt() const { return S; } Xazax-hun wrote: Would it make sense to keep `getStmt`? It could still return null but some callers might fi

[clang] [Sema][NFC] Move two misplaced uninit tests to clang/test/SemaCXX (PR #128013)

2025-02-20 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/128013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Sema][NFC] Move two misplaced uninit tests to clang/test/SemaCXX (PR #128013)

2025-02-20 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: Looks good! I wonder if we should rename the directory to something like `clang/test/StaticAnalyzer` to avoid confusion in the future. https://github.com/llvm/llvm-project/pull/128013 ___ cfe-commits mailing list cfe-commits@lists.llv

[clang] [clang] Add alternative email for steakhal (PR #128558)

2025-02-25 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/128558 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-03-24 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: I'd prefer to go ahead with this and continue the discussion once that PR landed. This would unbreak the checks/resolve the backward compatibility issues while providing some of the benefits (even if the perf gain is smaller). At least we will be in a state that does not break

[clang] [clang][analyzer] Fix crash caused by overload operator member function with explicit this (PR #132581)

2025-03-24 Thread Gábor Horváth via cfe-commits
@@ -157,8 +157,11 @@ void ContainerModeling::checkPostCall(const CallEvent &Call, if (Func->isOverloadedOperator()) { const auto Op = Func->getOverloadedOperator(); if (Op == OO_Equal) { - // Overloaded 'operator=' must be a non-static member function. - co

[clang] [clang][analyzer] Fix crash caused by overload operator member function with explicit this (PR #132581)

2025-03-24 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Looks good to me. https://github.com/llvm/llvm-project/pull/132581 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Introduce the check::BlockEntrance checker callback (PR #140924)

2025-05-21 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > What is the relationship of this new callback with the BranchCondition > callback +1, I am also interested to learn what is the main motivation behind the new callback. Do you have some example use cases in mind? I think users might get confused which one to use. https://

[clang] [analyzer] Ignore [[clang::flag_enum]] enums in the EnumCastOutOfRange checker (PR #141232)

2025-05-23 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: Should we still warn if we store a negative value or a value >= 2*last member? https://github.com/llvm/llvm-project/pull/141232 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-b

[clang] [analyzer] Ignore [[clang::flag_enum]] enums in the EnumCastOutOfRange checker (PR #141232)

2025-05-23 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/141232 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Draft] Summary Based Analysis Prototype (PR #144224)

2025-06-16 Thread Gábor Horváth via cfe-commits
@@ -611,6 +623,29 @@ class CompilerInstance : public ModuleLoader { /// the compiler instance takes ownership of \p Value. void setCodeCompletionConsumer(CodeCompleteConsumer *Value); + /// @} + /// @name Summary + /// @{ + + bool hasSummaryContext() { return (bool)Sum

[clang] [Draft] Summary Based Analysis Prototype (PR #144224)

2025-06-16 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/144224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Draft] Summary Based Analysis Prototype (PR #144224)

2025-06-16 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,60 @@ +#ifndef LLVM_CLANG_SUMMARY_SUMMARYCONTEXT_H +#define LLVM_CLANG_SUMMARY_SUMMARYCONTEXT_H + +#include "clang/Summary/SummaryAttribute.h" +#include "clang/Summary/SummaryConsumer.h" +#include + +namespace clang { +class FunctionSummary { + SmallVector ID; ---

[clang] [Draft] Summary Based Analysis Prototype (PR #144224)

2025-06-16 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: I did not have time to look at it properly, just some small drive by comments. https://github.com/llvm/llvm-project/pull/144224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-

[clang] [Draft] Summary Based Analysis Prototype (PR #144224)

2025-06-16 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,60 @@ +#ifndef LLVM_CLANG_SUMMARY_SUMMARYCONTEXT_H +#define LLVM_CLANG_SUMMARY_SUMMARYCONTEXT_H + +#include "clang/Summary/SummaryAttribute.h" +#include "clang/Summary/SummaryConsumer.h" +#include + +namespace clang { +class FunctionSummary { + SmallVector ID; + std:

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-16 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,753 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-16 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-16 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,753 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-16 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,753 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-16 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] [Draft] Summary Based Analysis Prototype (PR #144224)

2025-06-16 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,23 @@ +#include "clang/Summary/SummaryConsumer.h" +#include "clang/Summary/SummaryContext.h" + +namespace clang { +void JSONPrintingSummaryConsumer::ProcessFunctionSummary( +const FunctionSummary &Summary) { + JOS.object([&] { +JOS.attribute("id", llvm::json::V

[clang] [Clang][Sema] Allow qualified type names in `swift_name` attribute (PR #145947)

2025-06-27 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/145947 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC] [API Notes] [Documentation] Add documentation for SwiftReturnOwnership (PR #143545)

2025-06-11 Thread Gábor Horváth via cfe-commits
@@ -195,6 +195,52 @@ declaration kind), all of which are optional: SwiftReleaseOp: immortal SwiftRetainOp: immortal +:SwiftReturnOwnership: + + Specifies the ownership convention of a function or method returning a C++ type + that has been imported as a Swift re

[clang] [NFC] [API Notes] [Documentation] Add documentation for SwiftReturnOwnership (PR #143545)

2025-06-11 Thread Gábor Horváth via cfe-commits
@@ -195,6 +195,52 @@ declaration kind), all of which are optional: SwiftReleaseOp: immortal SwiftRetainOp: immortal +:SwiftReturnOwnership: + + Specifies the ownership convention of a function or method returning a C++ type + that has been imported as a Swift re

[clang] [NFC] [API Notes] [Documentation] Add documentation for SwiftReturnOwnership (PR #143545)

2025-06-11 Thread Gábor Horváth via cfe-commits
@@ -195,6 +195,52 @@ declaration kind), all of which are optional: SwiftReleaseOp: immortal SwiftRetainOp: immortal +:SwiftReturnOwnership: + + Specifies the ownership convention of a function or method returning a C++ type + that has been imported as a Swift re

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-11 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > implement a warning (maybe return-stack-addr) in this patch. This patch is already big enough. But I think a small comment of how reporting will work down the line might be useful. https://github.com/llvm/llvm-project/pull/142313

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/142313 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,362 @@ +// RUN: %clang_cc1 -mllvm -debug-only=ExperimentalLifetimeAnalysis,LifetimeFacts,LifetimeDataflow -Wreturn-stack-address-cfg %s 2>&1 | FileCheck %s + +struct MyObj { + int id; + ~MyObj() {} // Non-trivial destructor +}; + +// Simple Local Variable Address an

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: Overall, I don't have any major comments on the design, I have mostly some nits inline. https://github.com/llvm/llvm-project/pull/142313 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llv

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] Introduce intra-procedural lifetime analysis in Clang (PR #142313)

2025-06-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] [LifetimeSafety] Implement dataflow analysis for loan propagation (PR #148065)

2025-07-14 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/148065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [LifetimeSafety] Make the dataflow analysis generic (PR #148222)

2025-07-15 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/148222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [LifetimeSafety] Make the dataflow analysis generic (PR #148222)

2025-07-15 Thread Gábor Horváth via cfe-commits
@@ -596,143 +709,66 @@ struct LifetimeLattice { } }; -// = // -// The Transfer Function -// = // -clas

[clang] [LifetimeSafety] Make the dataflow analysis generic (PR #148222)

2025-07-15 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Overall looks good to me. One question for the future: sometimes it might be better to run certain analyses side by side in the same worklist rather than running them sequentially after each other. Do you think there are some analysis st

[clang] [LifetimeSafety] Add language option for experimental lifetime safety (PR #149592)

2025-07-19 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/149592 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,728 @@ +#include "clang/Analysis/Analyses/LifetimeSafety.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Expr.h" +#include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/AnalysisDeclContext.h" +#include "clang/Analysis/CFG.h" +#inc

[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/142313 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. There are some discussions open on this PR e.g., whether access paths need kinds. But I don't think those are blockers, this is exploratory work and it is expected that some design decisions might be revisited along the way when we learn

[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/142313 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-07 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,508 @@ +//===- LifetimeSafety.cpp - C++ Lifetime Safety Analysis -*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)

2025-07-07 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: Actually, before merging, did you manage to run this on any non-trivial projects to see if there are any false positives? I think this change is valuable and important but these sorts of changes can expose some false positives. If that is the case (or there are some noisy patt

[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)

2025-07-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/147221 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)

2025-07-07 Thread Gábor Horváth via cfe-commits
@@ -438,13 +438,10 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) { return; } bool isTrivialBody = hasTrivialBody(CE); - // If a value is passed by const pointer to a function, - // we should not assume that it is initialized by the call, and we - // conservativel

[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)

2025-07-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LGTM! I have a nit inline for your consideration. https://github.com/llvm/llvm-project/pull/147221 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/146859 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang]: Propagate `*noreturn` attributes in `CFG` (PR #146355)

2025-07-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/146355 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang]: Propagate `*noreturn` attributes in `CFG` (PR #146355)

2025-07-07 Thread Gábor Horváth via cfe-commits
@@ -6298,10 +6334,43 @@ static bool isImmediateSinkBlock(const CFGBlock *Blk) { // at least for now, but once we have better support for exceptions, // we'd need to carefully handle the case when the throw is being // immediately caught. - if (llvm::any_of(*Blk, [](const

[clang] [clang-tools-extra] [clang]: Propagate `*noreturn` attributes in `CFG` (PR #146355)

2025-07-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: I think this is a good change in general, but I wonder what is the performance impact. Note that clang CFGs have many clients and some of them might not need this information. If there is a measurable performance cost, we might want to put this behind a

[clang] [clang-tools-extra] [clang]: Propagate `*noreturn` attributes in `CFG` (PR #146355)

2025-07-07 Thread Gábor Horváth via cfe-commits
@@ -2833,8 +2834,37 @@ CFGBlock *CFGBuilder::VisitCallExpr(CallExpr *C, AddStmtChoice asc) { if (!FD->isVariadic()) findConstructionContextsForArguments(C); -if (FD->isNoReturn() || C->isBuiltinAssumeFalse(*Context)) - NoReturn = true; +if (!NoReturn) +

[clang] [clang-tools-extra] [clang]: Propagate `*noreturn` attributes in `CFG` (PR #146355)

2025-07-07 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/146355 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [LifetimeSafety] Introduce intra-procedural analysis in Clang (PR #142313)

2025-07-10 Thread Gábor Horváth via cfe-commits
@@ -0,0 +1,510 @@ +//===- LifetimeSafety.cpp - C++ Lifetime Safety Analysis -*- C++-*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [clang-tools-extra] [clang-tidy] `bugprone-unchecked-optional-access`: handle `BloombergLP::bdlb:NullableValue::makeValue` to prevent false-positives (PR #144313)

2025-07-14 Thread Gábor Horváth via cfe-commits
@@ -985,6 +985,20 @@ auto buildTransferMatchSwitch() { isOptionalMemberCallWithNameMatcher(hasName("isNull")), transferOptionalIsNullCall) + // NullableValue::makeValue, NullableValue::makeValueInplace + // Only NullableValue has these methods, bu

[clang] [LifetimeSafety] Implement dataflow analysis for loan propagation (PR #148065)

2025-07-14 Thread Gábor Horváth via cfe-commits
@@ -493,7 +496,247 @@ class FactGenerator : public ConstStmtVisitor { }; // = // -// TODO: Run dataflow analysis to propagate loans, analyse and error reporting. +// The Dat

[clang] [LifetimeSafety] Implement dataflow analysis for loan propagation (PR #148065)

2025-07-14 Thread Gábor Horváth via cfe-commits
@@ -493,7 +496,247 @@ class FactGenerator : public ConstStmtVisitor { }; // = // -// TODO: Run dataflow analysis to propagate loans, analyse and error reporting. +// The Dat

[clang] [LifetimeSafety] Implement dataflow analysis for loan propagation (PR #148065)

2025-07-14 Thread Gábor Horváth via cfe-commits
@@ -493,7 +496,247 @@ class FactGenerator : public ConstStmtVisitor { }; // = // -// TODO: Run dataflow analysis to propagate loans, analyse and error reporting. +// The Dat

[clang] [LifetimeSafety] Implement dataflow analysis for loan propagation (PR #148065)

2025-07-14 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Some minor things inline, overall looks good to me. https://github.com/llvm/llvm-project/pull/148065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailma

[clang] [LifetimeSafety] Implement dataflow analysis for loan propagation (PR #148065)

2025-07-14 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/148065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer][docs] Mention perfetto for visualizing trace JSONs (PR #145500)

2025-06-25 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/145500 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (PR #146859)

2025-07-03 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: Hey, could you add a LIT test that fails before your changes but passes after? https://github.com/llvm/llvm-project/pull/146859 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe

<    5   6   7   8   9   10   11   >