[PATCH] D140694: [clang][dataflow] Only model struct fields that are used in the function being analyzed.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 5 13:13:06 PST 2023


ymandel marked an inline comment as done.
ymandel added a comment.

In D140694#4026244 <https://reviews.llvm.org/D140694#4026244>, @xazax.hun wrote:

> This is a big improvement, I skimmed through it and looks good to me. There might be some sneaky ways to change values of fields without mentioning them, e.g., casting a pointer to a struct to an array of chars. But I think reasoning about those scenarios is probably not something we want to model anytime soon.

Thanks!

> Another pesky scenario when we are not doing context sensitive analysis:
>
>   int* pointsToField = getField(myObj);
>
> But this can be handled correctly in a conservative way buy treating `myObj' as escaped. Overall, I dont anticipate any blockers at the moment.

Agreed. I think any other field access either falls into 1) we don't handle it soundly anyhow or 2) a conservative analysis will rule it out.



================
Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:267
 
+  void addFieldsReferencedInScope(llvm::DenseSet<const FieldDecl *> Fields);
+
----------------
xazax.hun wrote:
> Is there any scenario where check authors might invoke this function? If no, I wonder if it would be better to make this private and make Environment a friend of this class. Keeping the number of public methods minimal could be a great service to future check authors.
Good point. Done.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140694/new/

https://reviews.llvm.org/D140694



More information about the cfe-commits mailing list