[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 11 12:46:42 PDT 2018


vsk added inline comments.


================
Comment at: lib/CodeGen/CGExprScalar.cpp:1694
 // handle things like function to ptr-to-function decay etc.
 Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
   Expr *E = CE->getSubExpr();
----------------
lebedev.ri wrote:
> vsk wrote:
> > I think maintaining a stack of visited cast exprs in the emitter be cheaper/simpler than using ASTContext::getParents. You could push CE here and use a RAII helper to pop it. The 'isCastPartOfExplicitCast' check then simplifies to a quick stack traversal.
> Hmm, two things come to mind:
> 1. This pessimizes the (most popular) case when the sanitizer is disabled.
> 2. `ASTContext::getParents()` may return more than one parent. I'm not sure if that matters here?
> I'll take a look..
As for (1), it's not necessary to push/pop the stack when this sanitizer is disabled. And for (2), IIUC the only interesting case is "explicit-cast <implicit-cast>+", and none of the implicit casts here have more than one parent.


Repository:
  rC Clang

https://reviews.llvm.org/D48958





More information about the cfe-commits mailing list