https://github.com/steakhal edited
https://github.com/llvm/llvm-project/pull/82089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/steakhal approved this pull request.
LGTM
https://github.com/llvm/llvm-project/pull/82089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/huang-me updated
https://github.com/llvm/llvm-project/pull/82089
>From 2802ef4b9ed88da3cacb16ab7738907ee806 Mon Sep 17 00:00:00 2001
From: huang-me
Date: Sat, 17 Feb 2024 10:43:48 +0800
Subject: [PATCH 1/6] Fix crash on StaticAnalyzer loop unrolling
---
@@ -226,6 +226,21 @@ static bool isPossiblyEscaped(ExplodedNode *N, const
DeclRefExpr *DR) {
return false;
}
}
+
+if (const SwitchStmt *SS = dyn_cast(S)) {
+ if (const CompoundStmt *CST = dyn_cast(SS->getBody())) {
+for (const Stmt *CB :
https://github.com/huang-me updated
https://github.com/llvm/llvm-project/pull/82089
>From 2802ef4b9ed88da3cacb16ab7738907ee806 Mon Sep 17 00:00:00 2001
From: huang-me
Date: Sat, 17 Feb 2024 10:43:48 +0800
Subject: [PATCH 1/4] Fix crash on StaticAnalyzer loop unrolling
---
@@ -226,6 +226,21 @@ static bool isPossiblyEscaped(ExplodedNode *N, const
DeclRefExpr *DR) {
return false;
}
}
+
+if (const SwitchStmt *SS = dyn_cast(S)) {
+ if (const CompoundStmt *CST = dyn_cast(SS->getBody())) {
steakhal wrote:
@@ -0,0 +1,11 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config
unroll-loops=true -verify %s
+
+void test_escaping_on_var_before_switch_case_no_crash(int c) {
+ switch (c) {
+int i; // expected error{{Reached root without finding the declaration of
https://github.com/steakhal requested changes to this pull request.
Thanks for working on this.
I think iterating the direct child nodes of the switch is fine. I can't think
of a better way.
https://github.com/llvm/llvm-project/pull/82089
___
@@ -226,6 +226,21 @@ static bool isPossiblyEscaped(ExplodedNode *N, const
DeclRefExpr *DR) {
return false;
}
}
+
+if (const SwitchStmt *SS = dyn_cast(S)) {
+ if (const CompoundStmt *CST = dyn_cast(SS->getBody())) {
+for (const Stmt *CB :
https://github.com/steakhal edited
https://github.com/llvm/llvm-project/pull/82089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
huang-me wrote:
I've added the test case to illustrate the goal of this change.
https://github.com/llvm/llvm-project/pull/82089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/huang-me updated
https://github.com/llvm/llvm-project/pull/82089
>From 2802ef4b9ed88da3cacb16ab7738907ee806 Mon Sep 17 00:00:00 2001
From: huang-me
Date: Sat, 17 Feb 2024 10:43:48 +0800
Subject: [PATCH 1/3] Fix crash on StaticAnalyzer loop unrolling
---
NagyDonat wrote:
That sounds reasonable. Unfortunately I don't know much about the context of
this change, so let's wait for a review from @danix800 (or somebody else who's
knows enough) before merging this change.
Also, perhaps it would be a good idea to add a testcase (or a few of them) in
huang-me wrote:
> If I understand it correctly, your change doesn't handle declarations that
> are in inner statements, e.g. the variable "x" in the following code:
>
> ```c++
> switch (get_value()) {
> case 42:
> do {
> int x;
> // ...
> } while (running);
> //...
> }
> ```
>
>
NagyDonat wrote:
If I understand it correctly, your change doesn't handle declarations that are
in inner statements, e.g. the variable "x" in the following code:
```cpp
switch (get_value()) {
case 42:
do {
int x;
// ...
} while (running);
//...
}
```
Is this compatible with the
https://github.com/huang-me updated
https://github.com/llvm/llvm-project/pull/82089
>From 2802ef4b9ed88da3cacb16ab7738907ee806 Mon Sep 17 00:00:00 2001
From: huang-me
Date: Sat, 17 Feb 2024 10:43:48 +0800
Subject: [PATCH 1/2] Fix crash on StaticAnalyzer loop unrolling
---
@@ -226,6 +226,17 @@ static bool isPossiblyEscaped(ExplodedNode *N, const
DeclRefExpr *DR) {
return false;
}
}
+
+if (const SwitchStmt *SS = dyn_cast(S)) {
+ for (const Stmt *CB : dyn_cast(SS->getBody())->body()) {
+for (const Decl *D :
@@ -226,6 +226,17 @@ static bool isPossiblyEscaped(ExplodedNode *N, const
DeclRefExpr *DR) {
return false;
}
}
+
+if (const SwitchStmt *SS = dyn_cast(S)) {
+ for (const Stmt *CB : dyn_cast(SS->getBody())->body()) {
huang-me wrote:
@@ -226,6 +226,17 @@ static bool isPossiblyEscaped(ExplodedNode *N, const
DeclRefExpr *DR) {
return false;
}
}
+
+if (const SwitchStmt *SS = dyn_cast(S)) {
+ for (const Stmt *CB : dyn_cast(SS->getBody())->body()) {
+for (const Decl *D :
https://github.com/NagyDonat requested changes to this pull request.
https://github.com/llvm/llvm-project/pull/82089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -226,6 +226,17 @@ static bool isPossiblyEscaped(ExplodedNode *N, const
DeclRefExpr *DR) {
return false;
}
}
+
+if (const SwitchStmt *SS = dyn_cast(S)) {
+ for (const Stmt *CB : dyn_cast(SS->getBody())->body()) {
NagyDonat
https://github.com/NagyDonat edited
https://github.com/llvm/llvm-project/pull/82089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/huang-me updated
https://github.com/llvm/llvm-project/pull/82089
>From 2802ef4b9ed88da3cacb16ab7738907ee806 Mon Sep 17 00:00:00 2001
From: huang-me
Date: Sat, 17 Feb 2024 10:43:48 +0800
Subject: [PATCH] Fix crash on StaticAnalyzer loop unrolling
---
https://github.com/huang-me updated
https://github.com/llvm/llvm-project/pull/82089
>From 4ebdf475b79d059c97881ad83aeecf677fb32631 Mon Sep 17 00:00:00 2001
From: huang-me
Date: Sat, 17 Feb 2024 10:43:48 +0800
Subject: [PATCH] Fix crash on StaticAnalyzer loop unrolling
---
github-actions[bot] wrote:
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
You can test this locally with the following command:
``bash
git-clang-format --diff 8ba915fe1096de290f5e569d6de97a8bcc8652f7
a590abda0570d922eb7032096de6fdd8cbbe4c63 --
llvmbot wrote:
@llvm/pr-subscribers-clang-static-analyzer-1
Author: None (huang-me)
Changes
StaticAnalyzer didn't check if the variable is declared in `CompoundStmt` under
`SwitchStmt`, which make static analyzer reach root without finding the
declaration.
Fixes #68819
---
Full diff:
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: None (huang-me)
Changes
StaticAnalyzer didn't check if the variable is declared in `CompoundStmt` under
`SwitchStmt`, which make static analyzer reach root without finding the
declaration.
Fixes #68819
---
Full diff:
github-actions[bot] wrote:
Thank you for submitting a Pull Request (PR) to the LLVM Project!
This PR will be automatically labeled and the relevant teams will be
notified.
If you wish to, you can add reviewers by using the "Reviewers" section on this
page.
If this is not working for you,
https://github.com/huang-me created
https://github.com/llvm/llvm-project/pull/82089
StaticAnalyzer didn't check if the variable is declared in `CompoundStmt` under
`SwitchStmt`, which make static analyzer reach root without finding the
declaration.
Fixes #68819
>From
29 matches
Mail list logo