aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-03-15 18:34:13 +0000
committerAnders Carlsson <andersca@mac.com>2009-03-15 18:34:13 +0000
commita135fb43eb94524a6529768596a4533eed9aa70d (patch)
tree45c270453fbf2cd00cbf6770b4e6cab3f8b5ff86 /lib/AST/Expr.cpp
parentf53597fb16142bdb4a66901f8c0b768db4f2a548 (diff)
Add the ability to clone integer and string literals. Use it when instantiating template expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67030 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r--lib/AST/Expr.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index e34412e190..669f5c8225 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -26,6 +26,10 @@ using namespace clang;
// Primary Expressions.
//===----------------------------------------------------------------------===//
+IntegerLiteral* IntegerLiteral::Clone(ASTContext &C) const {
+ return new (C) IntegerLiteral(Value, getType(), Loc);
+}
+
/// getValueAsApproximateDouble - This returns the value as an inaccurate
/// double. Note that this may cause loss of precision, but is useful for
/// debugging dumps, etc.
@@ -40,7 +44,8 @@ double FloatingLiteral::getValueAsApproximateDouble() const {
StringLiteral *StringLiteral::Create(ASTContext &C, const char *StrData,
unsigned ByteLength, bool Wide,
QualType Ty,
- SourceLocation *Loc, unsigned NumStrs) {
+ const SourceLocation *Loc,
+ unsigned NumStrs) {
// Allocate enough space for the StringLiteral plus an array of locations for
// any concatenated string tokens.
void *Mem = C.Allocate(sizeof(StringLiteral)+
@@ -62,6 +67,10 @@ StringLiteral *StringLiteral::Create(ASTContext &C, const char *StrData,
return SL;
}
+StringLiteral* StringLiteral::Clone(ASTContext &C) const {
+ return Create(C, StrData, ByteLength, IsWide, getType(),
+ TokLocs, NumConcatenated);
+}
void StringLiteral::Destroy(ASTContext &C) {
C.Deallocate(const_cast<char*>(StrData));