summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@boostpro.com>2011-04-25 06:54:41 +0000
committerJohn Wiegley <johnw@boostpro.com>2011-04-25 06:54:41 +0000
commitf9f6584e950ed92b679afd056e0872388c95cf20 (patch)
tree67c1813adee3d1d82541ebfbbe806356e1d7e9a6 /clang/lib/Sema/SemaExprCXX.cpp
parent03b77b37d60fc1a218709a7d3705bc2998c83685 (diff)
downloadbcm5719-llvm-f9f6584e950ed92b679afd056e0872388c95cf20.tar.gz
bcm5719-llvm-f9f6584e950ed92b679afd056e0872388c95cf20.zip
t/clang/expr-traits
Patch authored by David Abrahams. These two expression traits (__is_lvalue_expr, __is_rvalue_expr) are used for parsing code that employs certain features of the Embarcadero C++ compiler. llvm-svn: 130122
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 27545d802e4..edfa4a532df 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2739,6 +2739,45 @@ ExprResult Sema::BuildBinaryTypeTrait(BinaryTypeTrait BTT,
ResultType));
}
+ExprResult Sema::ActOnExpressionTrait(ExpressionTrait ET,
+ SourceLocation KWLoc,
+ Expr* Queried,
+ SourceLocation RParen) {
+ // If error parsing the expression, ignore.
+ if (!Queried)
+ return ExprError();
+
+ ExprResult Result
+ = BuildExpressionTrait(ET, KWLoc, Queried, RParen);
+
+ return move(Result);
+}
+
+ExprResult Sema::BuildExpressionTrait(ExpressionTrait ET,
+ SourceLocation KWLoc,
+ Expr* Queried,
+ SourceLocation RParen) {
+ if (Queried->isTypeDependent()) {
+ // Delay type-checking for type-dependent expressions.
+ } else if (Queried->getType()->isPlaceholderType()) {
+ ExprResult PE = CheckPlaceholderExpr(Queried);
+ if (PE.isInvalid()) return ExprError();
+ return BuildExpressionTrait(ET, KWLoc, PE.take(), RParen);
+ }
+
+ bool Value = false;
+ switch (ET) {
+ default: llvm_unreachable("Unknown or unimplemented expression trait");
+ case ET_IsLValueExpr: Value = Queried->isLValue(); break;
+ case ET_IsRValueExpr: Value = Queried->isRValue(); break;
+ }
+
+ // C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
+ return Owned(
+ new (Context) ExpressionTraitExpr(
+ KWLoc, ET, Queried, Value, RParen, Context.BoolTy));
+}
+
QualType Sema::CheckPointerToMemberOperands(ExprResult &lex, ExprResult &rex,
ExprValueKind &VK,
SourceLocation Loc,
OpenPOWER on IntegriCloud