[cfe-commits] r71953 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/ExprCXX.h lib/AST/Expr.cpp lib/AST/ExprCXX.cpp lib/Sema/SemaTemplateInstantiateExpr.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Sat May 16 11:50:48 PDT 2009
Author: cornedbee
Date: Sat May 16 13:50:46 2009
New Revision: 71953
URL: http://llvm.org/viewvc/llvm-project?rev=71953&view=rev
Log:
Implement instantiation of a few boring, simple expressions. I don't think these are testable yet, though.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=71953&r1=71952&r2=71953&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sat May 16 13:50:46 2009
@@ -361,6 +361,8 @@
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 @@
/// \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 @@
: 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 @@
/// \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; }
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=71953&r1=71952&r2=71953&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Sat May 16 13:50:46 2009
@@ -207,7 +207,9 @@
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 @@
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) {
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=71953&r1=71952&r2=71953&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sat May 16 13:50:46 2009
@@ -27,10 +27,27 @@
// 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.
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=71953&r1=71952&r2=71953&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Sat May 16 13:50:46 2009
@@ -309,3 +309,15 @@
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);
+}
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=71953&r1=71952&r2=71953&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Sat May 16 13:50:46 2009
@@ -36,7 +36,11 @@
// 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,7 +53,10 @@
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) {
S->dump();
@@ -59,12 +66,47 @@
};
}
-Sema::OwningExprResult
+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();
if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
More information about the cfe-commits
mailing list