[PATCH] D128056: [clang][dataflow] Singleton pointer values for null pointers.
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 17 09:53:08 PDT 2022
xazax.hun added a comment.
I am wondering about the future plans regarding how pointers are represented.
What will be the expected behavior when the analysis discovers that the pointer has a null value? E.g.:
if (p == nullptr)
{
....
}
Would we expect `p` in this case to have the same singleton value in the then block of the if statement?
================
Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:146
+ /// `PointeeType`.
+ void setNullPointerVal(QualType PointeeType, PointerValue &Val) {
+ assert(NullPointerVals.find(PointeeType.getAsString()) ==
----------------
Since you always want this function to create a null pointer value, I think it would be less error prone to ask for the location instead of an arbitrary value. Currently, a confused caller could put a non-null value into a table.
================
Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:149
+ NullPointerVals.end());
+ NullPointerVals[PointeeType.getAsString()] = &Val;
+ }
----------------
I think `getAsString` is considered expensive. Could you use `QualType` directly as the key?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128056/new/
https://reviews.llvm.org/D128056
More information about the cfe-commits
mailing list