This is an archive of the discontinued LLVM Phabricator instance.

Analyzer: Teach analyzer how to handle TypeTraitExpr
ClosedPublic

Authored by ismailp on Aug 30 2015, 10:34 AM.

Details

Summary

TypeTraitExprs are not supported by the ExprEngine today. Analyzer
creates a sink, and aborts the block. Therefore, certain bugs that
involve type traits intrinsics cannot be detected (see PR24710).

This patch creates boolean SVals for TypeTraitExprs, which are
evaluated by the compiler.

Test within the patch is a summary of PR24710.

Diff Detail

Repository
rL LLVM

Event Timeline

ismailp updated this revision to Diff 33542.Aug 30 2015, 10:34 AM
ismailp retitled this revision from to Analyzer: Teach analyzer how to handle TypeTraitExpr.
ismailp updated this object.
ismailp added reviewers: zaks.anna, dcoughlin, krememek.
ismailp added a subscriber: cfe-commits.
dcoughlin edited edge metadata.Sep 21 2015, 11:25 AM

Ismail, is 24710 the right bug? It is "clang-tidy segfaults with relative include paths". https://llvm.org/bugs/show_bug.cgi?id=24710

Sorry, that's a typo. It is 24170.

You should add a test covering the added logic in SValBuilder. For example:

clang_analyzer_eval(__is_trivial(NonTrivial)); // expected-warning {{FALSE}}

And while we're at it, it would be good to add a test for UnaryExprOrTypeTraitExpr as well:

clang_analyzer_eval(__alignof(NonTrivial) > 0); // expected-warning {{TRUE}}

Other than that, looks good to me. Thanks Ismail!

lib/StaticAnalyzer/Core/SValBuilder.cpp
264 ↗(On Diff #33542)

Extra semi-colon here.

ismailp updated this revision to Diff 35384.Sep 22 2015, 10:20 AM
ismailp edited edge metadata.

Addressed comments.

ismailp marked an inline comment as done.Sep 22 2015, 10:22 AM

Thanks for reviewing.

dcoughlin accepted this revision.Sep 22 2015, 11:06 AM
dcoughlin edited edge metadata.
This revision is now accepted and ready to land.Sep 22 2015, 11:06 AM
This revision was automatically updated to reflect the committed changes.