Let SourceManager::getBufferData return StringRef instead of a pair of two const char*.

llvm-svn: 98630
This commit is contained in:
Benjamin Kramer
2010-03-16 14:14:31 +00:00
parent 0eb690390d
commit eb92dc0b09
11 changed files with 34 additions and 44 deletions

View File

@@ -60,12 +60,11 @@ SourceLocation Sema::getLocationOfStringLiteralByte(const StringLiteral *SL,
std::pair<FileID, unsigned> LocInfo =
SourceMgr.getDecomposedLoc(StrTokSpellingLoc);
bool Invalid = false;
std::pair<const char *,const char *> Buffer =
SourceMgr.getBufferData(LocInfo.first, &Invalid);
llvm::StringRef Buffer = SourceMgr.getBufferData(LocInfo.first, &Invalid);
if (Invalid)
return StrTokSpellingLoc;
const char *StrData = Buffer.first+LocInfo.second;
const char *StrData = Buffer.data()+LocInfo.second;
// Create a langops struct and enable trigraphs. This is sufficient for
// relexing tokens.
@@ -73,8 +72,8 @@ SourceLocation Sema::getLocationOfStringLiteralByte(const StringLiteral *SL,
LangOpts.Trigraphs = true;
// Create a lexer starting at the beginning of this token.
Lexer TheLexer(StrTokSpellingLoc, LangOpts, Buffer.first, StrData,
Buffer.second);
Lexer TheLexer(StrTokSpellingLoc, LangOpts, Buffer.begin(), StrData,
Buffer.end());
Token TheTok;
TheLexer.LexFromRawLexer(TheTok);