This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][NFC] Introduce SVal::isa<Ts...>
AbandonedPublic

Authored by steakhal on May 17 2022, 1:27 AM.

Details

Summary

This cleans up the uses of getAs at quite a few places leading to more readable code.

Also prefer V.isUndef() to V.isa<UndefinedVal>().
That being said, Loc::isa<UnknownVal>() and
Loc::isa<UndefinedSVal>() does not exit, since a Loc
is already more constrained than those.
Checking these makes no sense.

Diff Detail

Event Timeline

steakhal created this revision.May 17 2022, 1:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 1:27 AM
steakhal requested review of this revision.May 17 2022, 1:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 1:27 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
steakhal added inline comments.
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
99–100

This is the core of this change :)

steakhal updated this revision to Diff 429960.May 17 2022, 1:38 AM

Refactor in the getAs uses of clang/include/StaticAnalyzer directory as well.

Not a qualified reviewer for anything other than the llvm::isa usage and that line looks good to me!

xazax.hun added inline comments.May 17 2022, 10:02 AM
clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
44

Is there a difference between isa<UndefinedVal> vs IsUndef? I think we should standardize on one of them (or potentially remove IsUndef and the like?

steakhal added inline comments.May 17 2022, 10:18 AM
clang/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp
44

Yea, they are the same. I'm not sure which to pick though.
I still like the terser member function style. I'll replace this occurrence and similars.

steakhal updated this revision to Diff 430326.May 18 2022, 4:52 AM
steakhal marked an inline comment as done.
steakhal edited the summary of this revision. (Show Details)
  • Prefer V.isUndef() to V.isa<UndefinedVal>().
  • Remove tautologically true assertions.

There is one minor problem with this patch.

At SVal member function's context one needs to call llvm::isa<...>() with by the qualified name, otherwise, the isa is ambiguous.
The compiler won't know if we want to refer to the free-function or the variadic member function; and the error message is not particularly helpful.

steakhal abandoned this revision.Jun 14 2022, 7:02 AM

We don't have the consensus to make me confident in landing this change.