diff options
author | Bill Wendling <isanbard@gmail.com> | 2018-11-20 08:53:30 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2018-11-20 08:53:30 +0000 |
commit | dafd68092ceda14b5b4a24fabef35bec783876a7 (patch) | |
tree | f4e1e4c0dd0943065338a25387fb4372011b33db /include | |
parent | 9b9f33d2fa56d4637b1da517d34f65e512c578b1 (diff) |
Use is.constant intrinsic for __builtin_constant_p
Summary:
A __builtin_constant_p may end up with a constant after inlining. Use
the is.constant intrinsic if it's a variable that's in a context where
it may resolve to a constant, e.g., an argument to a function after
inlining.
Reviewers: rsmith, shafik
Subscribers: jfb, kristina, cfe-commits, nickdesaulniers, jyknight
Differential Revision: https://reviews.llvm.org/D54355
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347294 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/Expr.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 004631019c..57fe192f06 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -901,10 +901,15 @@ public: /// ConstantExpr - An expression that occurs in a constant context. class ConstantExpr : public FullExpr { -public: ConstantExpr(Expr *subexpr) : FullExpr(ConstantExprClass, subexpr) {} +public: + static ConstantExpr *Create(const ASTContext &Context, Expr *E) { + assert(!isa<ConstantExpr>(E)); + return new (Context) ConstantExpr(E); + } + /// Build an empty constant expression wrapper. explicit ConstantExpr(EmptyShell Empty) : FullExpr(ConstantExprClass, Empty) {} @@ -3091,8 +3096,8 @@ inline Expr *Expr::IgnoreImpCasts() { while (true) if (ImplicitCastExpr *ice = dyn_cast<ImplicitCastExpr>(e)) e = ice->getSubExpr(); - else if (ConstantExpr *ce = dyn_cast<ConstantExpr>(e)) - e = ce->getSubExpr(); + else if (FullExpr *fe = dyn_cast<FullExpr>(e)) + e = fe->getSubExpr(); else break; return e; |