diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-04-15 16:35:07 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-04-15 16:35:07 +0000 |
| commit | 958dfc9bbd6a419c66b5e351545737d2a50eac05 (patch) | |
| tree | fe5a363bfc2070736d8a2d71c7653b2ea4cc3605 /clang/lib/AST/Expr.cpp | |
| parent | a7b5e219bb5365b19f01c554b72c29cdde0e1244 (diff) | |
| download | bcm5719-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.cpp | 21 |
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) { |

