]> granicus.if.org Git - clang/commitdiff
push use of Preprocessor out of getOffsetOfStringByte
authorChris Lattner <sabre@nondot.org>
Wed, 17 Nov 2010 06:35:43 +0000 (06:35 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 17 Nov 2010 06:35:43 +0000 (06:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119470 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/LiteralSupport.h
lib/Lex/LiteralSupport.cpp
lib/Sema/SemaChecking.cpp

index 387baa8140004ddc5809fa77dfc726bc71516e85..7210a1a53c3fd9fa86b60774a6855c383c0c8c68 100644 (file)
@@ -27,6 +27,8 @@ class Preprocessor;
 class Token;
 class SourceLocation;
 class TargetInfo;
+class SourceManager;
+class LangOptions;
 
 /// NumericLiteralParser - This performs strict semantic analysis of the content
 /// of a ppnumber, classifying it as either integer, floating, or erroneous,
@@ -167,7 +169,8 @@ public:
   /// If the Diagnostics pointer is non-null, then this will do semantic
   /// checking of the string literal and emit errors and warnings.
   static unsigned getOffsetOfStringByte(const Token &TheTok, unsigned ByteNo,
-                                        Preprocessor &PP,
+                                        const SourceManager &SM,
+                                        const LangOptions &Features,
                                         const TargetInfo &Target,
                                         Diagnostic *Diags = 0);
 };
index 26be1d0ae1e7f15635c04133b342eec651ec5968..0739c88d20ce53bedc38b1dbd799f8172072ed84 100644 (file)
@@ -1007,18 +1007,17 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
 /// advancing over escape sequences in the string.
 unsigned StringLiteralParser::getOffsetOfStringByte(const Token &Tok,
                                                     unsigned ByteNo,
-                                                    Preprocessor &PP, 
+                                                    const SourceManager &SM,
+                                                    const LangOptions &Features, 
                                                     const TargetInfo &Target,
                                                     Diagnostic *Diags) {
   // Get the spelling of the token.
-  llvm::SmallString<16> SpellingBuffer;
+  llvm::SmallString<32> SpellingBuffer;
   SpellingBuffer.resize(Tok.getLength());
 
   bool StringInvalid = false;
   const char *SpellingPtr = &SpellingBuffer[0];
-  unsigned TokLen = Preprocessor::getSpelling(Tok, SpellingPtr,
-                                              PP.getSourceManager(),
-                                              PP.getLangOptions(),
+  unsigned TokLen = Preprocessor::getSpelling(Tok, SpellingPtr, SM, Features,
                                               &StringInvalid);
   if (StringInvalid)
     return 0;
@@ -1047,7 +1046,7 @@ unsigned StringLiteralParser::getOffsetOfStringByte(const Token &Tok,
     // Otherwise, this is an escape character.  Advance over it.
     bool HadError = false;
     ProcessCharEscape(SpellingPtr, SpellingEnd, HadError,
-                      FullSourceLoc(Tok.getLocation(), PP.getSourceManager()),
+                      FullSourceLoc(Tok.getLocation(), SM),
                       false, Diags, Target);
     assert(!HadError && "This method isn't valid on erroneous strings");
     --ByteNo;
index c33eba9fabccf4458ccfdf8d963ad35437f1a2dd..278d8203201937211db58d0a912437b22248ba97 100644 (file)
@@ -90,7 +90,9 @@ SourceLocation Sema::getLocationOfStringLiteralByte(const StringLiteral *SL,
     if (ByteNo < TokNumBytes ||
         (ByteNo == TokNumBytes && TokNo == SL->getNumConcatenated())) {
       unsigned Offset =
-        StringLiteralParser::getOffsetOfStringByte(TheTok, ByteNo, PP,
+        StringLiteralParser::getOffsetOfStringByte(TheTok, ByteNo, 
+                                                   PP.getSourceManager(),
+                                                   PP.getLangOptions(),
                                                    PP.getTargetInfo());
 
       // Now that we know the offset of the token in the spelling, use the