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
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 0cd68ce..81da444 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -39,20 +39,36 @@
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();