This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][NFC] Prefer using isa<> instead getAs<> in conditions
ClosedPublic

Authored by steakhal on Jun 14 2022, 6:43 AM.

Diff Detail

Event Timeline

steakhal created this revision.Jun 14 2022, 6:43 AM
Herald added a project: Restricted Project. · View Herald Transcript
steakhal requested review of this revision.Jun 14 2022, 6:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2022, 6:43 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Why not replace all getAs?

I suppose you picked conditions because isa can have variadic parameters. If we are about to keep getAs then why not replace only those occurrences where we see the benefit of the variadic isa?

Why not replace all getAs?

That's a massive change. I actually experimented with it and I see no advantage with that.

I suppose you picked conditions because isa can have variadic parameters. If we are about to keep getAs then why not replace only those occurrences where we see the benefit of the variadic isa?

I believe it reads more naturally. getAs<> should be used only if we care about the value and don't know if it has one.

martong accepted this revision.Jun 15 2022, 12:48 AM

Why not replace all getAs?

That's a massive change. I actually experimented with it and I see no advantage with that.

I suppose you picked conditions because isa can have variadic parameters. If we are about to keep getAs then why not replace only those occurrences where we see the benefit of the variadic isa?

I believe it reads more naturally. getAs<> should be used only if we care about the value and don't know if it has one.

Ok, makes sense. LGTM.

This revision is now accepted and ready to land.Jun 15 2022, 12:48 AM