[cfe-dev] [analyzer]

Alexander Zaitsev via cfe-dev cfe-dev at lists.llvm.org
Wed Oct 24 17:16:25 PDT 2018


Hello. I am newbie in Clang Static Analyzer and I am trying to write new
Clang Static Analyzer check, which is aimed to find issues with casting
values to enum: if we cast anything which is no presented in target enum
it will be unspecified/undefined behavior(depends on C++ version).

So my plan is:

 1. Find all casts in source code. Seems like
    'check::PreStmt<CastExpr>>' it's what I need.
 2. In my implementation of `checkPreStmt` method I must get target type
    from CastExpr, but I don't know, how to do it - can you help with it?
 3. Then if target type in Cast is Enum, I must get all values from this
    Enum and compare it with all possible values which can be presented
    by CastExpr->getSubExpr() - here I don't know how to evaluate
    CastExpr->getSubExpr() and how to get all values from Enum.

Do you have any ideas?

-- 
Best regards,
Alexander Zaitsev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181025/c940f814/attachment.html>


More information about the cfe-dev mailing list