summaryrefslogtreecommitdiffstats
path: root/clang/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
commita39058118b6168425b5760895c53bcce2ef5a9ad (patch)
treeacc84ce8d43b941abc8824d0b5f62e916c4656fa /clang/lib/AST/Expr.cpp
parent6d4256c3c13b99c12384ff064acbfc725f7760bc (diff)
downloadbcm5719-llvm-a39058118b6168425b5760895c53bcce2ef5a9ad.tar.gz
bcm5719-llvm-a39058118b6168425b5760895c53bcce2ef5a9ad.zip
Add the ability to clone integer and string literals. Use it when instantiating template expressions.
llvm-svn: 67030
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r--clang/lib/AST/Expr.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index e34412e1909..669f5c8225a 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/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));
OpenPOWER on IntegriCloud