forked from OSchip/llvm-project
Implement instantiation of a few boring, simple expressions. I don't think these are testable yet, though.
llvm-svn: 71953
This commit is contained in:
parent
4f8b8ed2ac
commit
e769ecf8ab
|
@ -361,6 +361,8 @@ public:
|
|||
explicit PredefinedExpr(EmptyShell Empty)
|
||||
: Expr(PredefinedExprClass, Empty) { }
|
||||
|
||||
PredefinedExpr* Clone(ASTContext &C) const;
|
||||
|
||||
IdentType getIdentType() const { return Type; }
|
||||
void setIdentType(IdentType IT) { Type = IT; }
|
||||
|
||||
|
@ -433,6 +435,8 @@ public:
|
|||
/// \brief Construct an empty character literal.
|
||||
CharacterLiteral(EmptyShell Empty) : Expr(CharacterLiteralClass, Empty) { }
|
||||
|
||||
CharacterLiteral* Clone(ASTContext &C) const;
|
||||
|
||||
SourceLocation getLoc() const { return Loc; }
|
||||
bool isWide() const { return IsWide; }
|
||||
|
||||
|
@ -464,9 +468,11 @@ public:
|
|||
: Expr(FloatingLiteralClass, Type), Value(V), IsExact(*isexact), Loc(L) {}
|
||||
|
||||
/// \brief Construct an empty floating-point literal.
|
||||
FloatingLiteral(EmptyShell Empty)
|
||||
explicit FloatingLiteral(EmptyShell Empty)
|
||||
: Expr(FloatingLiteralClass, Empty), Value(0.0) { }
|
||||
|
||||
FloatingLiteral* Clone(ASTContext &C) const;
|
||||
|
||||
const llvm::APFloat &getValue() const { return Value; }
|
||||
void setValue(const llvm::APFloat &Val) { Value = Val; }
|
||||
|
||||
|
@ -1806,6 +1812,8 @@ public:
|
|||
/// \brief Build an empty GNU __null expression.
|
||||
explicit GNUNullExpr(EmptyShell Empty) : Expr(GNUNullExprClass, Empty) { }
|
||||
|
||||
GNUNullExpr* Clone(ASTContext &C) const;
|
||||
|
||||
/// getTokenLocation - The location of the __null token.
|
||||
SourceLocation getTokenLocation() const { return TokenLoc; }
|
||||
void setTokenLocation(SourceLocation L) { TokenLoc = L; }
|
||||
|
|
|
@ -208,6 +208,8 @@ public:
|
|||
CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
|
||||
Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {}
|
||||
|
||||
CXXBoolLiteralExpr* Clone(ASTContext &C) const;
|
||||
|
||||
bool getValue() const { return Value; }
|
||||
|
||||
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
|
||||
|
@ -229,6 +231,8 @@ public:
|
|||
CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) :
|
||||
Expr(CXXNullPtrLiteralExprClass, Ty), Loc(l) {}
|
||||
|
||||
CXXNullPtrLiteralExpr* Clone(ASTContext &C) const;
|
||||
|
||||
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
|
||||
|
||||
static bool classof(const Stmt *T) {
|
||||
|
|
|
@ -27,10 +27,27 @@ using namespace clang;
|
|||
// Primary Expressions.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
PredefinedExpr* PredefinedExpr::Clone(ASTContext &C) const {
|
||||
return new (C) PredefinedExpr(Loc, getType(), Type);
|
||||
}
|
||||
|
||||
IntegerLiteral* IntegerLiteral::Clone(ASTContext &C) const {
|
||||
return new (C) IntegerLiteral(Value, getType(), Loc);
|
||||
}
|
||||
|
||||
CharacterLiteral* CharacterLiteral::Clone(ASTContext &C) const {
|
||||
return new (C) CharacterLiteral(Value, IsWide, getType(), Loc);
|
||||
}
|
||||
|
||||
FloatingLiteral* FloatingLiteral::Clone(ASTContext &C) const {
|
||||
bool exact = IsExact;
|
||||
return new (C) FloatingLiteral(Value, &exact, getType(), Loc);
|
||||
}
|
||||
|
||||
GNUNullExpr* GNUNullExpr::Clone(ASTContext &C) const {
|
||||
return new (C) GNUNullExpr(getType(), TokenLoc);
|
||||
}
|
||||
|
||||
/// getValueAsApproximateDouble - This returns the value as an inaccurate
|
||||
/// double. Note that this may cause loss of precision, but is useful for
|
||||
/// debugging dumps, etc.
|
||||
|
|
|
@ -309,3 +309,15 @@ Stmt::child_iterator CXXExprWithTemporaries::child_end() {
|
|||
return &SubExpr + 1;
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Cloners
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
CXXBoolLiteralExpr* CXXBoolLiteralExpr::Clone(ASTContext &C) const {
|
||||
return new (C) CXXBoolLiteralExpr(Value, getType(), Loc);
|
||||
}
|
||||
|
||||
CXXNullPtrLiteralExpr* CXXNullPtrLiteralExpr::Clone(ASTContext &C) const {
|
||||
return new (C) CXXNullPtrLiteralExpr(getType(), Loc);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,11 @@ namespace {
|
|||
// FIXME: Once we get closer to completion, replace these manually-written
|
||||
// declarations with automatically-generated ones from
|
||||
// clang/AST/StmtNodes.def.
|
||||
OwningExprResult VisitPredefinedExpr(PredefinedExpr *E);
|
||||
OwningExprResult VisitIntegerLiteral(IntegerLiteral *E);
|
||||
OwningExprResult VisitFloatingLiteral(FloatingLiteral *E);
|
||||
OwningExprResult VisitStringLiteral(StringLiteral *E);
|
||||
OwningExprResult VisitCharacterLiteral(CharacterLiteral *E);
|
||||
OwningExprResult VisitDeclRefExpr(DeclRefExpr *E);
|
||||
OwningExprResult VisitParenExpr(ParenExpr *E);
|
||||
OwningExprResult VisitUnaryOperator(UnaryOperator *E);
|
||||
|
@ -49,6 +53,9 @@ namespace {
|
|||
OwningExprResult VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E);
|
||||
OwningExprResult VisitImplicitCastExpr(ImplicitCastExpr *E);
|
||||
OwningExprResult VisitCXXThisExpr(CXXThisExpr *E);
|
||||
OwningExprResult VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
|
||||
OwningExprResult VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E);
|
||||
OwningExprResult VisitGNUNullExpr(GNUNullExpr *E);
|
||||
|
||||
// Base case. I'm supposed to ignore this.
|
||||
Sema::OwningExprResult VisitStmt(Stmt *S) {
|
||||
|
@ -59,11 +66,46 @@ namespace {
|
|||
};
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitPredefinedExpr(PredefinedExpr *E) {
|
||||
return SemaRef.Clone(E);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitIntegerLiteral(IntegerLiteral *E) {
|
||||
return SemaRef.Clone(E);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitFloatingLiteral(FloatingLiteral *E) {
|
||||
return SemaRef.Clone(E);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitStringLiteral(StringLiteral *E) {
|
||||
return SemaRef.Clone(E);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitCharacterLiteral(CharacterLiteral *E) {
|
||||
return SemaRef.Clone(E);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
|
||||
return SemaRef.Clone(E);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
|
||||
return SemaRef.Clone(E);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitGNUNullExpr(GNUNullExpr *E) {
|
||||
return SemaRef.Clone(E);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult
|
||||
TemplateExprInstantiator::VisitDeclRefExpr(DeclRefExpr *E) {
|
||||
Decl *D = E->getDecl();
|
||||
|
|
Loading…
Reference in New Issue