]> granicus.if.org Git - clang/commitdiff
Add a flag to StringLiteral to keep track of whether the string is a pascal string...
authorAnders Carlsson <andersca@mac.com>
Thu, 14 Apr 2011 00:40:03 +0000 (00:40 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 14 Apr 2011 00:40:03 +0000 (00:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129488 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/AST/Expr.cpp
lib/Rewrite/RewriteObjC.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprObjC.cpp
lib/Serialization/ASTReaderStmt.cpp
lib/Serialization/ASTWriterStmt.cpp

index a6c3d49a2fe6b5e0b5b810eaae809300ea9e50f9..ef677610e6b36d6479088daa67a68b722fe44017 100644 (file)
@@ -1135,9 +1135,12 @@ public:
 /// In this case, getByteLength() will return 6, but the string literal will
 /// have type "char[2]".
 class StringLiteral : public Expr {
+  friend class ASTStmtReader;
+
   const char *StrData;
   unsigned ByteLength;
   bool IsWide;
+  bool IsPascal;
   unsigned NumConcatenated;
   SourceLocation TokLocs[1];
 
@@ -1148,14 +1151,15 @@ public:
   /// This is the "fully general" constructor that allows representation of
   /// strings formed from multiple concatenated tokens.
   static StringLiteral *Create(ASTContext &C, const char *StrData,
-                               unsigned ByteLength, bool Wide, QualType Ty,
+                               unsigned ByteLength, bool Wide, bool Pascal,
+                               QualType Ty,
                                const SourceLocation *Loc, unsigned NumStrs);
 
   /// Simple constructor for string literals made from one token.
   static StringLiteral *Create(ASTContext &C, const char *StrData,
-                               unsigned ByteLength,
-                               bool Wide, QualType Ty, SourceLocation Loc) {
-    return Create(C, StrData, ByteLength, Wide, Ty, &Loc, 1);
+                               unsigned ByteLength, bool Wide, 
+                               bool Pascal, QualType Ty, SourceLocation Loc) {
+    return Create(C, StrData, ByteLength, Wide, Pascal, Ty, &Loc, 1);
   }
 
   /// \brief Construct an empty string literal.
@@ -1171,8 +1175,8 @@ public:
   void setString(ASTContext &C, llvm::StringRef Str);
 
   bool isWide() const { return IsWide; }
-  void setWide(bool W) { IsWide = W; }
-
+  bool isPascal() const { return IsPascal; }
+  
   bool containsNonAsciiOrNull() const {
     llvm::StringRef Str = getString();
     for (unsigned i = 0, e = Str.size(); i != e; ++i)
index 59de3fe6eec037fc17744a5b6c9450dabb12bc4f..259c39c7d8eba5fe68d8e8cf457c8f1c4fd4cf44 100644 (file)
@@ -511,7 +511,7 @@ double FloatingLiteral::getValueAsApproximateDouble() const {
 
 StringLiteral *StringLiteral::Create(ASTContext &C, const char *StrData,
                                      unsigned ByteLength, bool Wide,
-                                     QualType Ty,
+                                     bool Pascal, QualType Ty,
                                      const SourceLocation *Loc,
                                      unsigned NumStrs) {
   // Allocate enough space for the StringLiteral plus an array of locations for
@@ -527,6 +527,7 @@ StringLiteral *StringLiteral::Create(ASTContext &C, const char *StrData,
   SL->StrData = AStrData;
   SL->ByteLength = ByteLength;
   SL->IsWide = Wide;
+  SL->IsPascal = Pascal;
   SL->TokLocs[0] = Loc[0];
   SL->NumConcatenated = NumStrs;
 
index ff4c5e915260a7cd755c5ac5060b3081cef8f22c..6ab96effe3a6a6afca6bd6daacb805d2472e9622 100644 (file)
@@ -2111,7 +2111,8 @@ Stmt *RewriteObjC::RewriteAtEncode(ObjCEncodeExpr *Exp) {
   std::string StrEncoding;
   Context->getObjCEncodingForType(Exp->getEncodedType(), StrEncoding);
   Expr *Replacement = StringLiteral::Create(*Context,StrEncoding.c_str(),
-                                            StrEncoding.length(), false,StrType,
+                                            StrEncoding.length(),
+                                            false, false, StrType,
                                             SourceLocation());
   ReplaceStmt(Exp, Replacement);
 
@@ -2130,7 +2131,8 @@ Stmt *RewriteObjC::RewriteAtSelector(ObjCSelectorExpr *Exp) {
   SelExprs.push_back(StringLiteral::Create(*Context,
                                        Exp->getSelector().getAsString().c_str(),
                                        Exp->getSelector().getAsString().size(),
-                                       false, argType, SourceLocation()));
+                                       false, false, argType, 
+                                           SourceLocation()));
   CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
                                                  &SelExprs[0], SelExprs.size());
   ReplaceStmt(Exp, SelExp);
@@ -2796,7 +2798,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
     ClsExprs.push_back(StringLiteral::Create(*Context,
                                    ClassDecl->getIdentifier()->getNameStart(),
                                    ClassDecl->getIdentifier()->getLength(),
-                                   false, argType, SourceLocation()));
+                                   false, false, argType, SourceLocation()));
     CallExpr *Cls = SynthesizeCallToFunctionDecl(GetMetaClassFunctionDecl,
                                                  &ClsExprs[0],
                                                  ClsExprs.size(),
@@ -2875,8 +2877,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
     ClsExprs.push_back(StringLiteral::Create(*Context,
                                              clsName->getNameStart(),
                                              clsName->getLength(),
-                                             false, argType,
-                                             SourceLocation()));
+                                             false, false, 
+                                             argType, SourceLocation()));
     CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
                                                  &ClsExprs[0],
                                                  ClsExprs.size(), 
@@ -2907,7 +2909,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
     ClsExprs.push_back(StringLiteral::Create(*Context,
                                    ClassDecl->getIdentifier()->getNameStart(),
                                    ClassDecl->getIdentifier()->getLength(),
-                                   false, argType, SourceLocation()));
+                                   false, false, argType, SourceLocation()));
     CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
                                                  &ClsExprs[0],
                                                  ClsExprs.size(), 
@@ -2989,7 +2991,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
   SelExprs.push_back(StringLiteral::Create(*Context,
                                        Exp->getSelector().getAsString().c_str(),
                                        Exp->getSelector().getAsString().size(),
-                                       false, argType, SourceLocation()));
+                                       false, false, argType, SourceLocation()));
   CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
                                                  &SelExprs[0], SelExprs.size(),
                                                   StartLoc,
index ac1128b361dc860a813177dc33a8e9c74f67365f..eb84cff99929312ee2eede344d911ffb84675029 100644 (file)
@@ -786,7 +786,7 @@ Sema::ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks) {
   // Pass &StringTokLocs[0], StringTokLocs.size() to factory!
   return Owned(StringLiteral::Create(Context, Literal.GetString(),
                                      Literal.GetStringLength(),
-                                     Literal.AnyWide, StrTy,
+                                     Literal.AnyWide, Literal.Pascal, StrTy,
                                      &StringTokLocs[0],
                                      StringTokLocs.size()));
 }
index 3cc9754b0648a10d9922ec3a77f93c856063a809..c769b856cd98e8751776ccf6a854a32621b552db 100644 (file)
@@ -62,7 +62,8 @@ ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
 
     // Create the aggregate string with the appropriate content and location
     // information.
-    S = StringLiteral::Create(Context, &StrBuf[0], StrBuf.size(), false,
+    S = StringLiteral::Create(Context, &StrBuf[0], StrBuf.size(),
+                              /*Wide=*/false, /*Pascal=*/false,
                               Context.getPointerType(Context.CharTy),
                               &StrLocs[0], StrLocs.size());
   }
index 70104cb18bc9aef68f968e0c86771c766c899653..557cb381954f03dfa5383d2aa1009a0f1d4eeaa7 100644 (file)
@@ -468,7 +468,8 @@ void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
   assert(Record[Idx] == E->getNumConcatenated() &&
          "Wrong number of concatenated tokens!");
   ++Idx;
-  E->setWide(Record[Idx++]);
+  E->IsWide = Record[Idx++];
+  E->IsPascal = Record[Idx++];
 
   // Read string data
   llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
index a66b550385f077c1d956bd4a2ecf5337eccfd952..875d662929894d42318d450b690627d8dc5bbb4f 100644 (file)
@@ -425,6 +425,7 @@ void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) {
   Record.push_back(E->getByteLength());
   Record.push_back(E->getNumConcatenated());
   Record.push_back(E->isWide());
+  Record.push_back(E->isPascal());
   // FIXME: String data should be stored as a blob at the end of the
   // StringLiteral. However, we can't do so now because we have no
   // provision for coping with abbreviations when we're jumping around