[clang] Fix spurious non-strict availability warning (PR #94377)

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

[clang] Fix spurious non-strict availability warning (PR #94377)

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

[clang] Fix spurious availability warning (PR #94377)

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

[clang] Fix spurious availability warning (PR #94377)

2024-06-06 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: Thos should fix the non-strict availability related repro from https://github.com/llvm/llvm-project/issues/40423 . It does not fix the strict case which is a separate codepath, so I did not mark this PR as fixing that bug report.

[clang] Fix spurious availability warning (PR #94377)

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

[clang] Fix spurious availability warning (PR #94377)

2024-06-04 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun created https://github.com/llvm/llvm-project/pull/94377 The availability attributes are stored on the function declarations. The code was looking for them in the function template declarations. This resulted in spuriously diagnosing availablity issues in contexts

[clang] [clang][dataflow] Propagate storage location of compound assignment operators. (PR #94332)

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

[clang] [clang][nullability] Propagate storage location / value of `++`/`--` operators. (PR #94217)

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

[clang] [analyzer] Fix a test issue in mingw configurations (PR #92737)

2024-05-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/92737 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][dataflow] Make `CNFFormula` externally accessible. (PR #92401)

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

[clang] [analyzer] MallocChecker: Recognize std::atomics in smart pointer suppression. (PR #90918)

2024-05-08 Thread Gábor Horváth via cfe-commits
@@ -3479,13 +3479,24 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N, // original reference count is positive, we should not report use-after-frees // on objects deleted in such destructors. This can probably be improved // through better

[clang] [clang][dataflow] Allow `DataflowAnalysisContext` to use a non-owned `Solver`. (PR #91316)

2024-05-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/91316 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Strengthen pointer comparison. (PR #75170)

2024-05-06 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > In summary, if the storage locations for two pointers are the same, we can > return a true literal for the comparison, but if the storage locations are > different, we need to return an atom. I am wondering, if it would make sense to "fix up" the state when we discover

[clang] [clang][dataflow] Strengthen pointer comparison. (PR #75170)

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

[clang] [clang][dataflow] Fix crash when `operator=` result type is not destination type. (PR #90898)

2024-05-05 Thread Gábor Horváth via cfe-commits
@@ -556,14 +556,23 @@ class TransferVisitor : public ConstStmtVisitor { copyRecord(*LocSrc, *LocDst, Env); - // If the expr is a glvalue, we can reasonably assume the operator is - // returning T& and thus we can assign it `LocDst`. - if

[clang] [clang][dataflow] Fix crash when `operator=` result type is not destination type. (PR #90898)

2024-05-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/90898 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker: Recognize std::atomics in smart pointer suppression. (PR #90918)

2024-05-02 Thread Gábor Horváth via cfe-commits
@@ -3479,13 +3479,24 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N, // original reference count is positive, we should not report use-after-frees // on objects deleted in such destructors. This can probably be improved // through better

[clang] [analyzer] MallocChecker: Recognize std::atomics in smart pointer suppression. (PR #90918)

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

[clang] [analyzer] MallocChecker: Recognize std::atomics in smart pointer suppression. (PR #90918)

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

[clang] [clang][dataflow] Don't propagate result objects in unevaluated contexts (PR #90438)

2024-04-30 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/90438 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Don't propagate result objects in unevaluated contexts (PR #90438)

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

[clang] [clang][dataflow] Don't propagate result objects in unevaluated contexts (PR #90438)

2024-04-30 Thread Gábor Horváth via cfe-commits
@@ -350,6 +350,13 @@ class ResultObjectVisitor : public RecursiveASTVisitor { return RecursiveASTVisitor::TraverseDecl(D); } + bool TraverseDecltypeTypeLoc(DecltypeTypeLoc Node) { Xazax-hun wrote: > It also turns out that, even though the operand of

[clang] [clang][dataflow] Don't propagate result objects inside `decltype`. (PR #90438)

2024-04-29 Thread Gábor Horváth via cfe-commits
@@ -350,6 +350,13 @@ class ResultObjectVisitor : public RecursiveASTVisitor { return RecursiveASTVisitor::TraverseDecl(D); } + bool TraverseDecltypeTypeLoc(DecltypeTypeLoc Node) { Xazax-hun wrote: There are other instances in the language that are

[clang] [clang][dataflow] Fix crash when `ConstantExpr` is used in conditional operator. (PR #90112)

2024-04-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/90112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Don't propagate result objects in nested declarations. (PR #89903)

2024-04-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/89903 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Crash fix for `widenDistinctValues()`. (PR #89895)

2024-04-24 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. LGTM! Do we want to open tickets to track these FIXMEs? https://github.com/llvm/llvm-project/pull/89895 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [analyzer] Fix performance of getTaintedSymbolsImpl() (PR #89606)

2024-04-22 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > @Xazax-hun WDYT? If it really takes over an hour to analyze a file in clang-18, I'd agree that this has similar severity to a crash, and I support backporting the fix. https://github.com/llvm/llvm-project/pull/89606 ___

[clang] Reapply "[clang][dataflow] Model conditional operator correctly." with fixes (PR #89596)

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

[clang] [clang][dataflow] Model conditional operator correctly. (PR #89213)

2024-04-19 Thread Gábor Horváth via cfe-commits
@@ -657,17 +658,22 @@ class TransferVisitor : public ConstStmtVisitor { } void VisitConditionalOperator(const ConditionalOperator *S) { -// FIXME: Revisit this once flow conditions are added to the framework. For -// `a = b ? c : d` we can add `b => a == c && !b

[clang] [clang][dataflow] Model conditional operator correctly. (PR #89213)

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

[clang] [clang][dataflow] Model conditional operator correctly. (PR #89213)

2024-04-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/89213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][nullability] Remove `RecordValue`. (PR #89052)

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

[clang] [clang][dataflow] Model conditional operator correctly. (PR #89213)

2024-04-18 Thread Gábor Horváth via cfe-commits
@@ -657,17 +658,22 @@ class TransferVisitor : public ConstStmtVisitor { } void VisitConditionalOperator(const ConditionalOperator *S) { -// FIXME: Revisit this once flow conditions are added to the framework. For -// `a = b ? c : d` we can add `b => a == c && !b

[clang] [clang][dataflow] Model conditional operator correctly. (PR #89213)

2024-04-18 Thread Gábor Horváth via cfe-commits
@@ -657,17 +658,25 @@ class TransferVisitor : public ConstStmtVisitor { } void VisitConditionalOperator(const ConditionalOperator *S) { -// FIXME: Revisit this once flow conditions are added to the framework. For -// `a = b ? c : d` we can add `b => a == c && !b

[clang] [clang][dataflow] Refactor `PropagateResultObject()` with a switch statement. (PR #88865)

2024-04-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/88865 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Support `StmtExpr` in `PropagateResultObject()`. (PR #88872)

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

[clang] [clang][dataflow] Treat `BuiltinBitCastExpr` correctly in `PropagateResultObject()`. (PR #88875)

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

[clang] [clang][dataflow] Refactor `PropagateResultObject()` with a switch statement. (PR #88865)

2024-04-16 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > It's unfortunate that the enum syntax is so bulky (the need for `Stmt::` and > the `Class` suffix). Once we can use C++20, it could get a bit better thanks to https://en.cppreference.com/w/cpp/language/enum#Using-enum-declaration. > I'm making this a non-draft PR and will

[clang] [clang][dataflow] Reland #87320: Propagate locations from result objects to initializers. (PR #88316)

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

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-10 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/87320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-09 Thread Gábor Horváth via cfe-commits
@@ -6830,50 +6932,6 @@ TEST(TransferTest, LambdaCaptureThis) { }); } -TEST(TransferTest, DifferentReferenceLocInJoin) { Xazax-hun wrote: What is the main reason for removing this test? https://github.com/llvm/llvm-project/pull/87320

[clang] Add handling of the `-nostdlibinc` option to ccc-analyzer (PR #88017)

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

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
@@ -385,6 +390,187 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
@@ -556,6 +763,10 @@ void Environment::pushCallInternal(const FunctionDecl *FuncDecl, const VarDecl *Param = *ParamIt; setStorageLocation(*Param, createObject(*Param, Args[ArgIndex])); } + + ResultObjectMap = std::make_shared( Xazax-hun wrote: I

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: I know it is not exactly what we need, but I found `Expr::skipRValueSubobjectAdjustments` in the compiler. I think it might be a good idea to take a look just in case there is something we forgot to cover, and maybe in the future we could look for

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
@@ -385,6 +390,187 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

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

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-08 Thread Gábor Horváth via cfe-commits
@@ -688,22 +689,45 @@ class Environment { /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body. void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl); + static PrValueToResultObject + buildResultObjectMap(DataflowAnalysisContext *DACtx, +

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
@@ -385,6 +388,185 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
@@ -688,22 +689,45 @@ class Environment { /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body. void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl); + static PrValueToResultObject + buildResultObjectMap(DataflowAnalysisContext *DACtx, +

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
@@ -688,22 +689,45 @@ class Environment { /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body. void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl); + static PrValueToResultObject + buildResultObjectMap(DataflowAnalysisContext *DACtx, +

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
@@ -385,6 +388,185 @@ getFieldsGlobalsAndFuncs(const Stmt , FieldSet , } } +namespace { + +// Visitor that builds a map from record prvalues to result objects. +// This traverses the body of the function to be analyzed; for each result +// object that it encounters, it

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

2024-04-05 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun commented: I did not finish reviewing this, but wanted to send a couple of questions early to parallelize the process a bit. https://github.com/llvm/llvm-project/pull/87320 ___ cfe-commits mailing list

[clang] [clang][dataflow] Propagate locations from result objects to initializers. (PR #87320)

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

[clang] [analyzer] Make recognition of hardened __FOO_chk functions explicit (PR #86536)

2024-04-04 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Sorry for the delay. Nothing jumps out to me, feel free to merge it. https://github.com/llvm/llvm-project/pull/86536 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

2024-03-18 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Thanks! At this point all of my comments are addressed, and I am happy with the patch. https://github.com/llvm/llvm-project/pull/85064 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

2024-03-18 Thread Gábor Horváth via cfe-commits
@@ -212,8 +212,23 @@ TEST(TransferTest, CopyRecordFromDerivedToBase) { // [[p]] } )"; + auto SyntheticFieldCallback = [](QualType Ty) -> llvm::StringMap { +CXXRecordDecl *ADecl = nullptr; +if (Ty.getAsString() == "A") + ADecl =

[clang] [clang][dataflow][NFC] Rename `ControlFlowContext` to `AdornedCFG`. (PR #85640)

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

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

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

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

2024-03-18 Thread Gábor Horváth via cfe-commits
@@ -212,8 +212,23 @@ TEST(TransferTest, CopyRecordFromDerivedToBase) { // [[p]] } )"; + auto SyntheticFieldCallback = [](QualType Ty) -> llvm::StringMap { +CXXRecordDecl *ADecl = nullptr; +if (Ty.getAsString() == "A") + ADecl =

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

2024-03-18 Thread Gábor Horváth via cfe-commits
@@ -35,45 +69,27 @@ void clang::dataflow::copyRecord(RecordStorageLocation , }); assert(compatibleTypes); - for (auto [Field, DstFieldLoc] : Dst.children()) { -StorageLocation *SrcFieldLoc = Src.getChild(*Field); - -assert(Field->getType()->isReferenceType() || -

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

2024-03-18 Thread Gábor Horváth via cfe-commits
@@ -14,18 +14,52 @@ #define DEBUG_TYPE "dataflow" -void clang::dataflow::copyRecord(RecordStorageLocation , - RecordStorageLocation , Environment ) { +namespace clang::dataflow { + +static void copyField(const ValueDecl *Field,

[clang] [clang][dataflow] Fix `getResultObjectLocation()` on `CXXDefaultArgExpr`. (PR #85072)

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

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

2024-03-13 Thread Gábor Horváth via cfe-commits
@@ -14,18 +14,52 @@ #define DEBUG_TYPE "dataflow" -void clang::dataflow::copyRecord(RecordStorageLocation , - RecordStorageLocation , Environment ) { +namespace clang::dataflow { + +static void copyField(const ValueDecl *Field,

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

2024-03-13 Thread Gábor Horváth via cfe-commits
@@ -35,45 +69,27 @@ void clang::dataflow::copyRecord(RecordStorageLocation , }); assert(compatibleTypes); - for (auto [Field, DstFieldLoc] : Dst.children()) { -StorageLocation *SrcFieldLoc = Src.getChild(*Field); - -assert(Field->getType()->isReferenceType() || -

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

2024-03-13 Thread Gábor Horváth via cfe-commits
@@ -35,45 +69,27 @@ void clang::dataflow::copyRecord(RecordStorageLocation , }); assert(compatibleTypes); - for (auto [Field, DstFieldLoc] : Dst.children()) { -StorageLocation *SrcFieldLoc = Src.getChild(*Field); - -assert(Field->getType()->isReferenceType() || -

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

2024-03-13 Thread Gábor Horváth via cfe-commits
@@ -14,18 +14,52 @@ #define DEBUG_TYPE "dataflow" -void clang::dataflow::copyRecord(RecordStorageLocation , - RecordStorageLocation , Environment ) { +namespace clang::dataflow { + +static void copyField(const ValueDecl *Field,

[clang] [clang][dataflow] Model assignment to derived class from base. (PR #85064)

2024-03-13 Thread Gábor Horváth via cfe-commits
@@ -212,8 +212,23 @@ TEST(TransferTest, CopyRecordFromDerivedToBase) { // [[p]] } )"; + auto SyntheticFieldCallback = [](QualType Ty) -> llvm::StringMap { +CXXRecordDecl *ADecl = nullptr; +if (Ty.getAsString() == "A") + ADecl =

[clang] [clang][dataflow] Refactor processing of terminator element (PR #84499)

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

[clang] [analyzer] Accept C library functions from the `std` namespace (PR #84469)

2024-03-08 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: Once the other reviewers are happy, this looks good to me! https://github.com/llvm/llvm-project/pull/84469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Add context-sensitive test for returning a record by value. (PR #84317)

2024-03-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/84317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][nullability] Don't discard expression state before end of full-expression. (PR #82611)

2024-03-07 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > Do you happen to know any references to similar work, maybe in CSA? CSA will also remove dead symbols from the path constraints (which is akin to the flow condition in path-sensitive analysis). But this definitely introduced some challenges, there was a recent discussion

[clang] [clang][dataflow] When analyzing ctors, don't initialize fields of `*this` with values. (PR #84164)

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

[clang] [clang][nullability] Don't discard expression state before end of full-expression. (PR #82611)

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

[clang] [clang][nullability] Don't discard expression state before end of full-expression. (PR #82611)

2024-03-06 Thread Gábor Horváth via cfe-commits
@@ -94,6 +94,38 @@ static llvm::BitVector findReachableBlocks(const CFG ) { return BlockReachable; } +static llvm::DenseSet +buildContainsExprConsumedInDifferentBlock( +const CFG , +const llvm::DenseMap ) { + llvm::DenseSet Result; + + auto CheckChildExprs = [,

[clang] [clang][nullability] Don't discard expression state before end of full-expression. (PR #82611)

2024-03-06 Thread Gábor Horváth via cfe-commits
@@ -94,6 +94,38 @@ static llvm::BitVector findReachableBlocks(const CFG ) { return BlockReachable; } +static llvm::DenseSet +buildContainsExprConsumedInDifferentBlock( +const CFG , +const llvm::DenseMap ) { + llvm::DenseSet Result; Xazax-hun wrote:

[clang] [clang][nullability] Don't discard expression state before end of full-expression. (PR #82611)

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

[clang] [clang][nullability] Don't discard expression state before end of full-expression. (PR #82611)

2024-03-06 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: > Yes, significantly faster, and fewer SAT solver timeouts. The Clang Static Analyzer is going one step further. It is pruning the analysis state really aggressively, it is relying on liveness analysis, and whenever the value of a variable is dead (would not be read in future

[clang] [clang][dataflow] Make optional checker work for types derived from optional. (PR #84138)

2024-03-06 Thread Gábor Horváth via cfe-commits
@@ -64,38 +64,53 @@ static bool hasOptionalClassName(const CXXRecordDecl ) { return false; } +static const CXXRecordDecl *getOptionalBaseClass(const CXXRecordDecl *RD) { + if (RD == nullptr) +return nullptr; + if (hasOptionalClassName(*RD)) +return RD; + + if

[clang] [clang][dataflow] Correctly treat empty initializer lists for unions. (PR #82986)

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

[clang] [clang][dataflow] Correctly treat empty initializer lists for unions. (PR #82986)

2024-02-26 Thread Gábor Horváth via cfe-commits
@@ -685,9 +685,22 @@ class TransferVisitor : public ConstStmtVisitor { // `S->inits()` contains all the initializer expressions, including the // ones for direct base classes. -auto Inits = S->inits(); +ArrayRef Inits = S->inits(); size_t InitIdx = 0;

[clang] [clang][dataflow] Correctly treat empty initializer lists for unions. (PR #82986)

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

[clang] [clang][dataflow] Remove deprecated `ValueModel::merge()` function. (PR #82602)

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

[clang] [clang][dataflow] Fix inaccuracies in `buildStmtToBasicBlockMap()`. (PR #82496)

2024-02-21 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. This is horrifying. It makes me think that we might want to revamp the CfgBlock interface at some point. https://github.com/llvm/llvm-project/pull/82496 ___ cfe-commits mailing list

[clang] [clang][dataflow] Correctly handle `InitListExpr` of union type. (PR #82348)

2024-02-20 Thread Gábor Horváth via cfe-commits
@@ -1104,12 +1104,22 @@ RecordStorageLocation *getBaseObjectLocation(const MemberExpr , return Env.get(*Base); } -std::vector getFieldsForInitListExpr(const RecordDecl *RD) { +std::vector +getFieldsForInitListExpr(const InitListExpr *InitList) { + const RecordDecl *RD =

[clang] [clang][dataflow] Correctly handle `InitListExpr` of union type. (PR #82348)

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

[clang] [clang][dataflow] Correctly handle `InitListExpr` of union type. (PR #82348)

2024-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/82348 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Correctly handle `InitListExpr` of union type. (PR #82348)

2024-02-20 Thread Gábor Horváth via cfe-commits
@@ -731,6 +723,18 @@ class TransferVisitor : public ConstStmtVisitor { FieldLocs.insert({Field, }); } +// In the case of a union, we don't in general have initializers for all +// of the fields. Create storage locations for the remaining fields (but +//

[clang] [clang][dataflow][NFC] Add a FIXME to handling of union initialization. (PR #82239)

2024-02-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/82239 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Add `Environment::initializeFieldsWithValues()`. (PR #81239)

2024-02-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/81239 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][dataflow] Add `Environment::initializeFieldsWithValues()`. (PR #81239)

2024-02-12 Thread Gábor Horváth via cfe-commits
@@ -943,6 +919,50 @@ Environment::createLocAndMaybeValue(QualType Ty, return Loc; } +void Environment::initializeFieldsWithValues(RecordStorageLocation , + llvm::DenseSet , + int Depth,

[clang] [clang][dataflow] Add `Environment::initializeFieldsWithValues()`. (PR #81239)

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

[clang] [clang][dataflow] Add support for `CXXRewrittenBinaryOperator`. (PR #81086)

2024-02-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/81086 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Model Microsoft "__assume" in the same way as clang "__builtin_assume" (PR #80456)

2024-02-05 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/80456 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Teach analzer about ms __analyzer_assume(bool) and friends (PR #80456)

2024-02-02 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: Hey! Thanks for looking into this! Did you actually encounter this call in the wild? The reason I ask, because their definition looks like this in the current version of `sal.h`: ``` #ifndef __analysis_assume // [ #ifdef _PREFAST_ // [ #define __analysis_assume(expr)

[clang] [clang][dataflow] Add new `join` API and replace existing `merge` implementations. (PR #80361)

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

[clang] [clang][dataflow][NFC] Rename a confusingly named variable. (PR #80182)

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

[clang] [clang][dataflow] Display line numbers in the HTML logger timeline. (PR #80130)

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

[clang] [clang][dataflow] In the CFG visualization, mark converged blocks. (PR #79999)

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

[clang] [clang][dataflow] In the CFG visualization, mark converged blocks. (PR #79999)

2024-01-30 Thread Gábor Horváth via cfe-commits
@@ -158,13 +158,17 @@ class HTMLLogger : public Logger { StreamFactory Streams; std::unique_ptr OS; - std::optional JOS; + std::string JSON; + llvm::raw_string_ostream JStringStream{JSON}; + llvm::json::OStream JOS{JStringStream, /*Indent=*/2}; const

  1   2   3   4   5   >