[cfe-commits] r119470 - in /cfe/trunk: include/clang/Lex/LiteralSupport.h lib/Lex/LiteralSupport.cpp lib/Sema/SemaChecking.cpp

Chris Lattner sabre at nondot.org
Tue Nov 16 22:35:43 PST 2010


Author: lattner
Date: Wed Nov 17 00:35:43 2010
New Revision: 119470

URL: http://llvm.org/viewvc/llvm-project?rev=119470&view=rev
Log:
push use of Preprocessor out of getOffsetOfStringByte 

Modified:
    cfe/trunk/include/clang/Lex/LiteralSupport.h
    cfe/trunk/lib/Lex/LiteralSupport.cpp
    cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Lex/LiteralSupport.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LiteralSupport.h?rev=119470&r1=119469&r2=119470&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/LiteralSupport.h (original)
+++ cfe/trunk/include/clang/Lex/LiteralSupport.h Wed Nov 17 00:35:43 2010
@@ -27,6 +27,8 @@
 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 @@
   /// 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);
 };

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=119470&r1=119469&r2=119470&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Wed Nov 17 00:35:43 2010
@@ -1007,18 +1007,17 @@
 /// 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 @@
     // 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;

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=119470&r1=119469&r2=119470&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Nov 17 00:35:43 2010
@@ -90,7 +90,9 @@
     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





More information about the cfe-commits mailing list