diff options
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 8 | ||||
-rw-r--r-- | lib/Lex/PPExpressions.cpp | 7 | ||||
-rw-r--r-- | lib/Lex/PPMacroExpansion.cpp | 8 | ||||
-rw-r--r-- | lib/Lex/Pragma.cpp | 5 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 6 |
5 files changed, 10 insertions, 24 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 4803c5ab85..976c94eda3 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -1024,13 +1024,9 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok, return; case tok::angle_string_literal: - case tok::string_literal: { - FilenameBuffer.resize(FilenameTok.getLength()); - const char *FilenameStart = &FilenameBuffer[0]; - unsigned Len = getSpelling(FilenameTok, FilenameStart); - Filename = llvm::StringRef(FilenameStart, Len); + case tok::string_literal: + Filename = getSpelling(FilenameTok, FilenameBuffer); break; - } case tok::less: // This could be a <foo/bar.h> file coming from a macro expansion. In this diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp index 3b620d0934..6c9212632f 100644 --- a/lib/Lex/PPExpressions.cpp +++ b/lib/Lex/PPExpressions.cpp @@ -218,10 +218,9 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT, } case tok::char_constant: { // 'x' llvm::SmallString<32> CharBuffer; - CharBuffer.resize(PeekTok.getLength()); - const char *ThisTokBegin = &CharBuffer[0]; - unsigned ActualLength = PP.getSpelling(PeekTok, ThisTokBegin); - CharLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength, + llvm::StringRef ThisTok = PP.getSpelling(PeekTok, CharBuffer); + + CharLiteralParser Literal(ThisTok.begin(), ThisTok.end(), PeekTok.getLocation(), PP); if (Literal.hadError()) return true; // A diagnostic was already emitted. diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index fd67f4c912..d60cf0804f 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -541,13 +541,9 @@ static bool EvaluateHasIncludeCommon(bool &Result, Token &Tok, return false; case tok::angle_string_literal: - case tok::string_literal: { - FilenameBuffer.resize(Tok.getLength()); - const char *FilenameStart = &FilenameBuffer[0]; - unsigned Len = PP.getSpelling(Tok, FilenameStart); - Filename = llvm::StringRef(FilenameStart, Len); + case tok::string_literal: + Filename = PP.getSpelling(Tok, FilenameBuffer); break; - } case tok::less: // This could be a <foo/bar.h> file coming from a macro expansion. In this diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index 63b23b6d5c..654d4606a9 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -287,11 +287,8 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) { // Reserve a buffer to get the spelling. llvm::SmallString<128> FilenameBuffer; - FilenameBuffer.resize(FilenameTok.getLength()); + llvm::StringRef Filename = getSpelling(FilenameTok, FilenameBuffer); - const char *FilenameStart = &FilenameBuffer[0]; - unsigned Len = getSpelling(FilenameTok, FilenameStart); - llvm::StringRef Filename(FilenameStart, Len); bool isAngled = GetIncludeFilenameSpelling(FilenameTok.getLocation(), Filename); // If GetIncludeFilenameSpelling set the start ptr to null, there was an diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index df0e702ab4..84ce062a6a 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -503,10 +503,8 @@ IdentifierInfo *Preprocessor::LookUpIdentifierInfo(Token &Identifier, } else { // Cleaning needed, alloca a buffer, clean into it, then use the buffer. llvm::SmallVector<char, 64> IdentifierBuffer; - IdentifierBuffer.resize(Identifier.getLength()); - const char *TmpBuf = &IdentifierBuffer[0]; - unsigned Size = getSpelling(Identifier, TmpBuf); - II = getIdentifierInfo(llvm::StringRef(TmpBuf, Size)); + llvm::StringRef CleanedStr = getSpelling(Identifier, IdentifierBuffer); + II = getIdentifierInfo(CleanedStr); } Identifier.setIdentifierInfo(II); return II; |