This is an archive of the discontinued LLVM Phabricator instance.

[CFG] NFC: Remove implicit conversion from CFGTerminator to Stmt *, make it a variant class instead.
ClosedPublic

Authored by NoQ on May 10 2019, 8:02 PM.

Details

Summary

This conversion does indeed save some code, but i plan to add support for more kinds of terminators that aren't necessarily based on statements, and as i do, it becomes more and more confusing to have it implicitly convertible to a Stmt *.

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ created this revision.May 10 2019, 8:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2019, 8:02 PM
a_sidorin accepted this revision.May 11 2019, 11:17 AM

The conversion operator indeed looks non-evident.

clang/include/clang/Analysis/CFG.h
513 ↗(On Diff #199117)

It seems to me that isStmt() and isTemporaryDtorBranch() methods can make the code a bit cleaner in few places by avoiding comparisons with enums.

This revision is now accepted and ready to land.May 11 2019, 11:17 AM
Szelethus accepted this revision.May 14 2019, 1:39 PM

LGTM!

clang/include/clang/Analysis/CFG.h
514 ↗(On Diff #199117)

Can we add something to check that the integer part of Data is actually large enough to store an object of type Kind, even if we add more values to the enum?

NoQ updated this revision to Diff 199531.May 14 2019, 4:26 PM
NoQ marked 2 inline comments as done.

Fxd.

a_sidorin added inline comments.May 19 2019, 12:45 PM
clang/lib/Analysis/ReachableCode.cpp
465 ↗(On Diff #199531)

isStmtBranch()?

NoQ marked an inline comment as done.May 23 2019, 6:32 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2019, 6:34 PM