1 //===--- SemaExprCXX.cpp - Semantic Analysis for Expressions --------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements semantic analysis for C++ expressions.
12 //===----------------------------------------------------------------------===//
15 #include "clang/AST/ExprCXX.h"
16 #include "clang/AST/ASTContext.h"
17 using namespace clang;
19 /// ActOnCXXCasts - Parse {dynamic,static,reinterpret,const}_cast's.
21 Sema::ActOnCXXCasts(SourceLocation OpLoc, tok::TokenKind Kind,
22 SourceLocation LAngleBracketLoc, TypeTy *Ty,
23 SourceLocation RAngleBracketLoc,
24 SourceLocation LParenLoc, ExprTy *E,
25 SourceLocation RParenLoc) {
26 CXXCastExpr::Opcode Op;
29 default: assert(0 && "Unknown C++ cast!");
30 case tok::kw_const_cast: Op = CXXCastExpr::ConstCast; break;
31 case tok::kw_dynamic_cast: Op = CXXCastExpr::DynamicCast; break;
32 case tok::kw_reinterpret_cast: Op = CXXCastExpr::ReinterpretCast; break;
33 case tok::kw_static_cast: Op = CXXCastExpr::StaticCast; break;
36 return new CXXCastExpr(Op, QualType::getFromOpaquePtr(Ty), (Expr*)E, OpLoc);
39 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
41 Sema::ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind) {
42 assert((Kind != tok::kw_true || Kind != tok::kw_false) &&
43 "Unknown C++ Boolean value!");
44 return new CXXBoolLiteralExpr(Kind == tok::kw_true, Context.BoolTy, OpLoc);