[clang] [Clang][analyzer] replace Stmt* with ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-05-13 Thread Greg Bedwell via cfe-commits

gregbedwell wrote:

We've observed a crash in clang since this commit when using `--analyze` in 
conjunction with `-ftime-trace`.  I've put the details in #139779.  Please 
could you take a look?

https://github.com/llvm/llvm-project/pull/137355
___
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 ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-05-12 Thread Balazs Benics via cfe-commits

https://github.com/steakhal closed 
https://github.com/llvm/llvm-project/pull/137355
___
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 ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-05-12 Thread Balazs Benics via cfe-commits

https://github.com/steakhal approved this pull request.

LGTM. Thanks for the ping.

https://github.com/llvm/llvm-project/pull/137355
___
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 ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-05-12 Thread Fangyi Zhou via cfe-commits

fangyi-zhou wrote:

Gentle ping

https://github.com/llvm/llvm-project/pull/137355
___
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 ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-05-07 Thread Fangyi Zhou via cfe-commits

https://github.com/fangyi-zhou updated 
https://github.com/llvm/llvm-project/pull/137355



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


___
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 ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-05-07 Thread Balazs Benics via cfe-commits

steakhal wrote:

Sorry about my availability. I barely have any focus time these days.
Could you please split your commit into: 1) the original commit we had to later 
revert, 2) the changes to fix it that would make it on par with what you have 
here now

This would allow me to review the affected parts, saving me precious time. I 
know you did a diff of the diffs, but that's not really helpful.

https://github.com/llvm/llvm-project/pull/137355
___
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 ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-05-06 Thread Fangyi Zhou via cfe-commits

fangyi-zhou wrote:

gentle ping

https://github.com/llvm/llvm-project/pull/137355
___
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 ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-04-29 Thread Fangyi Zhou via cfe-commits

fangyi-zhou wrote:

@steakhal 

https://github.com/llvm/llvm-project/pull/137355
___
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 ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-04-29 Thread Fangyi Zhou via cfe-commits

https://github.com/fangyi-zhou edited 
https://github.com/llvm/llvm-project/pull/137355
___
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 ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-04-25 Thread Fangyi Zhou via cfe-commits

fangyi-zhou wrote:

Range diff against previous PR: 
https://gist.github.com/fangyi-zhou/7d3a73a9b95f93755af3e823228c7a0d

https://github.com/llvm/llvm-project/pull/137355
___
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 ConstCFGElement in SymbolConjured (reland) (PR #137355)

2025-04-25 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-analysis

Author: Fangyi Zhou (fangyi-zhou)


Changes

Closes #57270.

This PR changes the `Stmt *` field in `SymbolConjured` with
`CFGBlock::ConstCFGElementRef`. The motivation is that, when conjuring a
symbol, there might not always be a statement available, causing
information to be lost for conjured symbols, whereas the CFGElementRef
can always be provided at the callsite.

Following the idea, this PR changes callsites of functions to create
conjured symbols, and replaces them with appropriate `CFGElementRef`s.

There is a caveat at loop widening, where the correct location is the
CFG terminator (which is not an element and does not have a ref). In
this case, the first element in the block is passed as a location.

Previous PR #128251, Reverted at #137304.


---

Patch is 124.28 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/137355.diff


38 Files Affected:

- (modified) clang/include/clang/Analysis/CFG.h (+9-1) 
- (modified) clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h 
(+10-1) 
- (modified) 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h (+2) 
- (modified) clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(+1-1) 
- (modified) 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h (+2-1) 
- (modified) 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h (+8-7) 
- (modified) 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h (+10-27) 
- (modified) clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h 
(+4-4) 
- (modified) 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h (+49-22) 
- (modified) clang/lib/Analysis/CFG.cpp (+26-20) 
- (modified) clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (+40-38) 
- (modified) clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp (+29-26) 
- (modified) clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp (+3-3) 
- (modified) clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h (+3-2) 
- (modified) clang/lib/StaticAnalyzer/Checkers/Iterator.cpp (+3-2) 
- (modified) clang/lib/StaticAnalyzer/Checkers/Iterator.h (+2-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp (+51-42) 
- (modified) clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (+5-3) 
- (modified) clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp 
(+14-12) 
- (modified) clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp (+14-12) 
- (modified) clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
(+1-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp (+22-21) 
- (modified) clang/lib/StaticAnalyzer/Core/CallEvent.cpp (+1-1) 
- (modified) clang/lib/StaticAnalyzer/Core/ExprEngine.cpp (+28-18) 
- (modified) clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp (+29-24) 
- (modified) clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp (+7-6) 
- (modified) clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (+4-3) 
- (modified) clang/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp (+8-6) 
- (modified) clang/lib/StaticAnalyzer/Core/LoopWidening.cpp (+5-24) 
- (modified) clang/lib/StaticAnalyzer/Core/ProgramState.cpp (+4-4) 
- (modified) clang/lib/StaticAnalyzer/Core/RegionStore.cpp (+27-26) 
- (modified) clang/lib/StaticAnalyzer/Core/SValBuilder.cpp (+14-18) 
- (modified) clang/lib/StaticAnalyzer/Core/SymbolManager.cpp (+1-1) 
- (added) clang/test/Analysis/PR57270.cpp (+30) 
- (modified) clang/test/Analysis/container-modeling.cpp (+2-2) 
- (modified) clang/test/Analysis/dump_egraph.cpp (-1) 
- (modified) clang/test/Analysis/explain-svals.cpp (+6-6) 
- (modified) clang/test/Analysis/explain-svals.m (+2-2) 


``diff
diff --git a/clang/include/clang/Analysis/CFG.h 
b/clang/include/clang/Analysis/CFG.h
index a7ff38c786a8f..e70c70335e597 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -122,7 +122,8 @@ class CFGElement {
 return (Kind) x;
   }
 
-  void dumpToStream(llvm::raw_ostream &OS) const;
+  void dumpToStream(llvm::raw_ostream &OS,
+bool TerminateWithNewLine = true) const;
 
   void dump() const {
 dumpToStream(llvm::errs());
@@ -695,6 +696,11 @@ class CFGBlock {
 void dump() const {
   dumpToStream(llvm::errs());
 }
+
+void Profile(llvm::FoldingSetNodeID &ID) const {
+  ID.AddPointer(Parent);
+  ID.AddInteger(Index);
+}
   };
 
   template  class ElementRefIterator {
@@ -1190,6 +1196,8 @@ class CFGBlock {
   }
 };
 
+using ConstCFGElementRef = CFGBlock::ConstCFGElementRef;
+
 /// CFGCallback defines methods that should be called when a logical
 /// operator error is found when building the CFG.
 class CFGCallback {
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h 
b/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
index 519d2d5b3676b..6c1025ecc7f4d 100644
--- a/clang/i