[PATCH] D153589: [NFC] Initialize pointer fields and remove a needless null check.
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 27 10:21:36 PDT 2023
aaron.ballman added inline comments.
================
Comment at: clang/lib/Analysis/CFG.cpp:4156
// CFG generation for unevaluated operands.
- if (S && !S->isTypeDependent() && S->isPotentiallyEvaluated())
+ if (!S->isTypeDependent() && S->isPotentiallyEvaluated())
return VisitChildren(S);
----------------
schittir wrote:
> schittir wrote:
> > erichkeane wrote:
> > > schittir wrote:
> > > > erichkeane wrote:
> > > > > schittir wrote:
> > > > > > erichkeane wrote:
> > > > > > > I get that we're counting on the dereference on 4145 to have made this check irrelevant, but are we sure that we KNOW that "S" is non-null here otherwise? That is, is the bug actually 4145 doing 'alwaysAdd' without checking vs the unnecessary check here?
> > > > > > VisitCXXTypeidExpr is used only in one place - here https://github.com/llvm/llvm-project/blob/a89c9b35be08b665cc1a01d840bc20349ba1308f/clang/lib/Analysis/CFG.cpp#L2288 where S is not null. Null check for S already happens at the beginning of the method where VisitCXXTypeidExpr is called.
> > > > > SG, an assert is perhaps not a bad idea, but LGTM. I don't know very much about the CFG stuff, so aaron might wish to take a final look.
> > > > What is SG?
> > > "Sounds Good"
> > Haha!
> > Thanks for the review.
> > SG, an assert is perhaps not a bad idea, but LGTM. I don't know very much about the CFG stuff, so aaron might wish to take a final look.
>
> Hi @aaron.ballman, could you please comment on this? Thank you!
I don't think an assert is necessary; I think it's a predicate to pass non-null nodes to the Visit functions in general, and I don't think we get a whole lot out of asserting in each Visit method that its given node is nonnull.
================
Comment at: clang/lib/CodeGen/CGObjCGNU.cpp:58
/// used as arguments will necessarily be available at construction time.
- LazyRuntimeFunction()
- : CGM(nullptr), FunctionName(nullptr), Function(nullptr) {}
+ LazyRuntimeFunction() {}
----------------
schittir wrote:
> erichkeane wrote:
> > schittir wrote:
> > > erichkeane wrote:
> > > >
> > > The comment above needs to be updated?
> > I don't think so? It still leaves the class uninitialized.
> Right! Still valid.
I think the comment is stale or imprecise -- the class certainly is initialized (it was being initialized previously as well, just not fully initialized). I think it may have meant "not initialized to useful values", so we could either repair it that way or remove the comment entirely.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153589/new/
https://reviews.llvm.org/D153589
More information about the cfe-commits
mailing list