diff options
author | Richard Smith <richard@metafoo.co.uk> | 2019-12-04 15:25:27 -0800 |
---|---|---|
committer | Richard Smith <richard@metafoo.co.uk> | 2019-12-08 23:21:52 -0800 |
commit | cafc7416baf7eecef8ecaf05802f2f7c0da725c0 (patch) | |
tree | 3ba432597b80af750b0263767ed58d5df9f46865 /clang/lib/AST/ExprConstant.cpp | |
parent | 27f5d35137cb45e60d9988a9b55875883c55023c (diff) | |
download | bcm5719-llvm-cafc7416baf7eecef8ecaf05802f2f7c0da725c0.tar.gz bcm5719-llvm-cafc7416baf7eecef8ecaf05802f2f7c0da725c0.zip |
[c++20] Synthesis of defaulted comparison functions.
Array members are not yet handled. In addition, defaulted comparisons
can't yet find comparison operators by unqualified lookup (only by
member lookup and ADL). These issues will be fixed in follow-on changes.
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 3151ec044cb..5aa151984e5 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -6830,6 +6830,36 @@ public: return StmtVisitorTy::Visit(Source); } + bool VisitPseudoObjectExpr(const PseudoObjectExpr *E) { + for (const Expr *SemE : E->semantics()) { + if (auto *OVE = dyn_cast<OpaqueValueExpr>(SemE)) { + // FIXME: We can't handle the case where an OpaqueValueExpr is also the + // result expression: there could be two different LValues that would + // refer to the same object in that case, and we can't model that. + if (SemE == E->getResultExpr()) + return Error(E); + + // Unique OVEs get evaluated if and when we encounter them when + // emitting the rest of the semantic form, rather than eagerly. + if (OVE->isUnique()) + continue; + + LValue LV; + if (!Evaluate(Info.CurrentCall->createTemporary( + OVE, getStorageType(Info.Ctx, OVE), false, LV), + Info, OVE->getSourceExpr())) + return false; + } else if (SemE == E->getResultExpr()) { + if (!StmtVisitorTy::Visit(SemE)) + return false; + } else { + if (!EvaluateIgnoredValue(Info, SemE)) + return false; + } + } + return true; + } + bool VisitCallExpr(const CallExpr *E) { APValue Result; if (!handleCallExpr(E, Result, nullptr)) |