diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-18 05:49:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-18 05:49:11 +0000 |
commit | 726e168dc09fb23f53c7b004f8e919421ee91806 (patch) | |
tree | 31e28ff92e011dd2ffbc9bb0efdc83405749c99f /lib/AST/Expr.cpp | |
parent | b103f01e5e2072c04ea5619c587a2b7ff2e63022 (diff) |
change the StringLiteral AST node to track all of the SourceLocations of
the various PPTokens that are pasted together to make it. In the course
of working on this, I discovered ParseObjCStringLiteral which needs some
work. I'll tackle it next.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64892 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 0cd68ce3b8..81da44407b 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -39,20 +39,36 @@ double FloatingLiteral::getValueAsApproximateDouble() const { StringLiteral::StringLiteral(ASTContext& C, const char *strData, - unsigned byteLength, bool Wide, QualType t, - SourceLocation firstLoc, - SourceLocation lastLoc) : - Expr(StringLiteralClass, t) { + unsigned byteLength, bool Wide, QualType Ty, + SourceLocation Loc) : + Expr(StringLiteralClass, Ty) { // OPTIMIZE: could allocate this appended to the StringLiteral. char *AStrData = new (C, 1) char[byteLength]; memcpy(AStrData, strData, byteLength); StrData = AStrData; ByteLength = byteLength; IsWide = Wide; - firstTokLoc = firstLoc; - lastTokLoc = lastLoc; + TokLocs[0] = Loc; + NumConcatenated = 1; } +StringLiteral::StringLiteral(ASTContext &C, const char *strData, + unsigned byteLength, bool Wide, QualType Ty, + SourceLocation *Loc, unsigned NumStrs) : + Expr(StringLiteralClass, Ty) { + // OPTIMIZE: could allocate this appended to the StringLiteral. + char *AStrData = new (C, 1) char[byteLength]; + memcpy(AStrData, strData, byteLength); + StrData = AStrData; + ByteLength = byteLength; + IsWide = Wide; + TokLocs[0] = Loc[0]; + NumConcatenated = NumStrs; + if (NumStrs != 1) + memcpy(&TokLocs[1], Loc+1, sizeof(SourceLocation)*(NumStrs-1)); +} + + void StringLiteral::Destroy(ASTContext &C) { C.Deallocate(const_cast<char*>(StrData)); this->~StringLiteral(); |