diff options
author | Bill Wendling <isanbard@gmail.com> | 2018-11-09 00:41:36 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2018-11-09 00:41:36 +0000 |
commit | 8003edc9aa0160c777252b6ed8e96fc35f039bd4 (patch) | |
tree | d6a07c2e0b407f57baf6be744b81ef140079eb7d /clang/lib/CodeGen/CGExprConstant.cpp | |
parent | 009cc9b7cadc81b50127f14ccdb8ff10fccc1f00 (diff) | |
download | bcm5719-llvm-8003edc9aa0160c777252b6ed8e96fc35f039bd4.tar.gz bcm5719-llvm-8003edc9aa0160c777252b6ed8e96fc35f039bd4.zip |
Compound literals, enums, et al require const expr
Summary:
Compound literals, enums, file-scoped arrays, etc. require their
initializers and size specifiers to be constant. Wrap the initializer
expressions in a ConstantExpr so that we can easily check for this later
on.
Reviewers: rsmith, shafik
Reviewed By: rsmith
Subscribers: cfe-commits, jyknight, nickdesaulniers
Differential Revision: https://reviews.llvm.org/D53921
llvm-svn: 346455
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 1339c06646c..eb5e0109684 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -723,6 +723,10 @@ public: return nullptr; } + llvm::Constant *VisitConstantExpr(ConstantExpr *CE, QualType T) { + return Visit(CE->getSubExpr(), T); + } + llvm::Constant *VisitParenExpr(ParenExpr *PE, QualType T) { return Visit(PE->getSubExpr(), T); } @@ -1601,6 +1605,7 @@ private: ConstantLValue tryEmitBase(const APValue::LValueBase &base); ConstantLValue VisitStmt(const Stmt *S) { return nullptr; } + ConstantLValue VisitConstantExpr(const ConstantExpr *E); ConstantLValue VisitCompoundLiteralExpr(const CompoundLiteralExpr *E); ConstantLValue VisitStringLiteral(const StringLiteral *E); ConstantLValue VisitObjCEncodeExpr(const ObjCEncodeExpr *E); @@ -1756,6 +1761,11 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) { } ConstantLValue +ConstantLValueEmitter::VisitConstantExpr(const ConstantExpr *E) { + return Visit(E->getSubExpr()); +} + +ConstantLValue ConstantLValueEmitter::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) { return tryEmitGlobalCompoundLiteral(CGM, Emitter.CGF, E); } |