summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-15 16:35:07 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-15 16:35:07 +0000
commit958dfc9bbd6a419c66b5e351545737d2a50eac05 (patch)
treefe5a363bfc2070736d8a2d71c7653b2ea4cc3605 /clang/lib/AST/Expr.cpp
parenta7b5e219bb5365b19f01c554b72c29cdde0e1244 (diff)
downloadbcm5719-llvm-958dfc9bbd6a419c66b5e351545737d2a50eac05.tar.gz
bcm5719-llvm-958dfc9bbd6a419c66b5e351545737d2a50eac05.zip
PCH support for string literals
llvm-svn: 69172
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r--clang/lib/AST/Expr.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index e2dd64a7036..53633977e98 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -68,6 +68,17 @@ StringLiteral *StringLiteral::Create(ASTContext &C, const char *StrData,
return SL;
}
+StringLiteral *StringLiteral::CreateEmpty(ASTContext &C, unsigned NumStrs) {
+ void *Mem = C.Allocate(sizeof(StringLiteral)+
+ sizeof(SourceLocation)*(NumStrs-1),
+ llvm::alignof<StringLiteral>());
+ StringLiteral *SL = new (Mem) StringLiteral(QualType());
+ SL->StrData = 0;
+ SL->ByteLength = 0;
+ SL->NumConcatenated = NumStrs;
+ return SL;
+}
+
StringLiteral* StringLiteral::Clone(ASTContext &C) const {
return Create(C, StrData, ByteLength, IsWide, getType(),
TokLocs, NumConcatenated);
@@ -79,6 +90,16 @@ void StringLiteral::Destroy(ASTContext &C) {
C.Deallocate(this);
}
+void StringLiteral::setStrData(ASTContext &C, const char *Str, unsigned Len) {
+ if (StrData)
+ C.Deallocate(const_cast<char*>(StrData));
+
+ char *AStrData = new (C, 1) char[Len];
+ memcpy(AStrData, Str, Len);
+ StrData = AStrData;
+ ByteLength = Len;
+}
+
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
/// corresponds to, e.g. "sizeof" or "[pre]++".
const char *UnaryOperator::getOpcodeStr(Opcode Op) {
OpenPOWER on IntegriCloud