[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-12-13 Thread Christian Holler via cfe-commits
choller wrote: I looked into Tom's bug report and I hit the following assertion in a debug build: ``` clang: /srv/repos/llvm-project/clang/lib/StaticAnalyzer/Core/DynamicType.cpp:134: clang::ento::ProgramStateRef clang::ento::setDynamicTypeAndCastInfo(clang::ento::ProgramStateRef, const cla

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-12-13 Thread Balazs Benics via cfe-commits
steakhal wrote: Thanks for the replies. I'll come back to this PR once I have some time; maybe during the holidays. Both assertions directly relate to this PR for sure. > I looked into Tom's bug report and I hit the following assertion in a debug > build: > > ``` > clang: > /srv/repos/llvm-pr

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-12-14 Thread Tom Ritter via cfe-commits
tomrittervg wrote: Hm, testing these patches on the original testcase in #62663 (the one where we use statements 1B and 2B) - I don't think this patchset solves that scenario... https://github.com/llvm/llvm-project/pull/69057 ___ cfe-commits mailing l

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-11-06 Thread Balazs Benics via cfe-commits
@@ -492,11 +492,13 @@ void check_required_cast() { void check_cast_behavior(OSObject *obj) { OSArray *arr1 = OSDynamicCast(OSArray, obj); - clang_analyzer_eval(arr1 == obj); // expected-warning{{TRUE}} -// expected-note@-1{{TRUE}} -

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-14 Thread Balazs Benics via cfe-commits
https://github.com/steakhal created https://github.com/llvm/llvm-project/pull/69057 When doing a base to derived cast, and we should add a cast info recording that fact. This information will be then used for example inside `CXXInstanceCall::getRuntimeDefinition` (CallEvent.cpp), where for vir

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-14 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Balazs Benics (steakhal) Changes When doing a base to derived cast, and we should add a cast info recording that fact. This information will be then used for example inside `CXXInstanceCall::getRuntimeDefinition` (CallEvent.cpp), where fo

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

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

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-15 Thread Gábor Horváth via cfe-commits
@@ -392,19 +393,26 @@ void DynamicTypePropagation::checkPostCall(const CallEvent &Call, } } -/// TODO: Handle explicit casts. -/// Handle C++ casts. -/// -/// Precondition: the cast is between ObjCObjectPointers. ExplodedNode *DynamicTypePropagation::dynamicTypePropa

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-15 Thread Gábor Horváth via cfe-commits
@@ -609,9 +617,13 @@ storeWhenMoreInformative(ProgramStateRef &State, SymbolRef Sym, /// symbol and the destination type of the cast are unrelated, report an error. void DynamicTypePropagation::checkPostStmt(const CastExpr *CE, Checke

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-15 Thread Gábor Horváth via cfe-commits
https://github.com/Xazax-hun approved this pull request. Added some nits inline, overall, it looks good to me. https://github.com/llvm/llvm-project/pull/69057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailma

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-15 Thread Gábor Horváth via cfe-commits
Xazax-hun wrote: This patch makes me think whether we actually respect final on methods/classes to avoid unnecessary bifurcation on virtual calls. We probably do not. https://github.com/llvm/llvm-project/pull/69057 ___ cfe-commits mailing list cfe-co

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread via cfe-commits
https://github.com/DonatNagyE edited https://github.com/llvm/llvm-project/pull/69057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread via cfe-commits
https://github.com/DonatNagyE commented: The only thing that I know about the dynamic type handling is that it's not too reliable; it would be great if you could improve it. https://github.com/llvm/llvm-project/pull/69057 ___ cfe-commits mailing list

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread via cfe-commits
@@ -0,0 +1,105 @@ +// RUN: %clang_analyze_cc1 %s -verify \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=alpha.security.taint.TaintPropagation \ +// RUN: -analyzer-checker=debug.ExprInspection + +// See issue https://github.com/llvm/llvm-project/issues/62663 +

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread via cfe-commits
@@ -392,19 +393,26 @@ void DynamicTypePropagation::checkPostCall(const CallEvent &Call, } } -/// TODO: Handle explicit casts. -/// Handle C++ casts. -/// -/// Precondition: the cast is between ObjCObjectPointers. ExplodedNode *DynamicTypePropagation::dynamicTypePropa

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread Balazs Benics via cfe-commits
@@ -0,0 +1,105 @@ +// RUN: %clang_analyze_cc1 %s -verify \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=alpha.security.taint.TaintPropagation \ +// RUN: -analyzer-checker=debug.ExprInspection + +// See issue https://github.com/llvm/llvm-project/issues/62663 +

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread via cfe-commits
@@ -0,0 +1,105 @@ +// RUN: %clang_analyze_cc1 %s -verify \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=alpha.security.taint.TaintPropagation \ +// RUN: -analyzer-checker=debug.ExprInspection + +// See issue https://github.com/llvm/llvm-project/issues/62663 +

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread Balazs Benics via cfe-commits
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/69057 >From 8ed4effd114ebd83d4ceaa37655ffd9b7105b28e Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Sat, 14 Oct 2023 15:51:42 +0200 Subject: [PATCH 1/3] [analyzer] Trust base to derived casts for dynamic types Wh

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread Balazs Benics via cfe-commits
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/69057 >From 8ed4effd114ebd83d4ceaa37655ffd9b7105b28e Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Sat, 14 Oct 2023 15:51:42 +0200 Subject: [PATCH 1/4] [analyzer] Trust base to derived casts for dynamic types Wh

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread Balazs Benics via cfe-commits
@@ -392,19 +393,26 @@ void DynamicTypePropagation::checkPostCall(const CallEvent &Call, } } -/// TODO: Handle explicit casts. -/// Handle C++ casts. -/// -/// Precondition: the cast is between ObjCObjectPointers. ExplodedNode *DynamicTypePropagation::dynamicTypePropa

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread Balazs Benics via cfe-commits
@@ -392,19 +393,26 @@ void DynamicTypePropagation::checkPostCall(const CallEvent &Call, } } -/// TODO: Handle explicit casts. -/// Handle C++ casts. -/// -/// Precondition: the cast is between ObjCObjectPointers. ExplodedNode *DynamicTypePropagation::dynamicTypePropa

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread Balazs Benics via cfe-commits
@@ -609,9 +617,13 @@ storeWhenMoreInformative(ProgramStateRef &State, SymbolRef Sym, /// symbol and the destination type of the cast are unrelated, report an error. void DynamicTypePropagation::checkPostStmt(const CastExpr *CE, Checke

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread Artem Dergachev via cfe-commits
@@ -392,19 +393,26 @@ void DynamicTypePropagation::checkPostCall(const CallEvent &Call, } } -/// TODO: Handle explicit casts. -/// Handle C++ casts. -/// -/// Precondition: the cast is between ObjCObjectPointers. ExplodedNode *DynamicTypePropagation::dynamicTypePropa

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread Artem Dergachev via cfe-commits
@@ -492,11 +492,13 @@ void check_required_cast() { void check_cast_behavior(OSObject *obj) { OSArray *arr1 = OSDynamicCast(OSArray, obj); - clang_analyzer_eval(arr1 == obj); // expected-warning{{TRUE}} -// expected-note@-1{{TRUE}} -

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-10-16 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/69057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-11-17 Thread Balazs Benics via cfe-commits
@@ -492,11 +492,13 @@ void check_required_cast() { void check_cast_behavior(OSObject *obj) { OSArray *arr1 = OSDynamicCast(OSArray, obj); - clang_analyzer_eval(arr1 == obj); // expected-warning{{TRUE}} -// expected-note@-1{{TRUE}} -

[clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-12-01 Thread Tom Ritter via cfe-commits
tomrittervg wrote: This sounds crazy, but I think I found a bug in this patchset. I applied it on top of the 17.0.2 tag, and then ran the whole analysis on mozilla-central. I got segfaults on about 4000 executions, all with the same stack trace: ``` 1. parser at end of file 2. Whi

[clang-tools-extra] [llvm] [clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2023-12-29 Thread Balazs Benics via cfe-commits
steakhal wrote: To illustrate the case of my previous argument, here are two examples: https://godbolt.org/z/5vWadfPM9 ```c++ // base.h BEGIN: class Base { public: virtual int fun() const = 0; }; class Derived1 final : public Base { public: int fun() const override { return 1; } }; // base.h

[llvm] [clang-tools-extra] [clang] [analyzer] Trust base to derived casts for dynamic types (PR #69057)

2024-01-02 Thread Tom Ritter via cfe-commits
tomrittervg wrote: > However, what should we do if multiple (N) classes implement Base? Trying > each N, and basically splitting the state to (N+1) ways is not going to > scale. Unless N is of course really small, like 2 or 3 at most. That's kind of what I imagined - try them all. The Analyze