From: Chris Lattner Date: Wed, 17 Nov 2010 06:35:43 +0000 (+0000) Subject: push use of Preprocessor out of getOffsetOfStringByte X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ca1475ea0e76da6b852796610139ed9b49c8d4a6;p=clang push use of Preprocessor out of getOffsetOfStringByte git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119470 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Lex/LiteralSupport.h b/include/clang/Lex/LiteralSupport.h index 387baa8140..7210a1a53c 100644 --- a/include/clang/Lex/LiteralSupport.h +++ b/include/clang/Lex/LiteralSupport.h @@ -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); }; diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index 26be1d0ae1..0739c88d20 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -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; diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index c33eba9fab..278d820320 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -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