diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-03-16 14:14:31 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-03-16 14:14:31 +0000 |
commit | f6ac97b101c8840efa92bf29166077ce4049e293 (patch) | |
tree | ae3c4bd11598f49ee678e6fba5a3e2df38d24427 /tools/CIndex/CIndex.cpp | |
parent | c506357c3778092c2a3251243f12524e8eb89274 (diff) |
Let SourceManager::getBufferData return StringRef instead of a pair of two const char*.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98630 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/CIndex/CIndex.cpp')
-rw-r--r-- | tools/CIndex/CIndex.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index c100caeecb..663b32fa1a 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -2044,13 +2044,12 @@ CXString clang_getTokenSpelling(CXTranslationUnit TU, CXToken CXTok) { std::pair<FileID, unsigned> LocInfo = CXXUnit->getSourceManager().getDecomposedLoc(Loc); bool Invalid = false; - std::pair<const char *,const char *> Buffer + llvm::StringRef Buffer = CXXUnit->getSourceManager().getBufferData(LocInfo.first, &Invalid); if (Invalid) return createCXString(""); - return createCXString(llvm::StringRef(Buffer.first+LocInfo.second, - CXTok.int_data[2])); + return createCXString(Buffer.substr(LocInfo.second, CXTok.int_data[2])); } CXSourceLocation clang_getTokenLocation(CXTranslationUnit TU, CXToken CXTok) { @@ -2100,16 +2099,16 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, // Create a lexer bool Invalid = false; - std::pair<const char *,const char *> Buffer + llvm::StringRef Buffer = SourceMgr.getBufferData(BeginLocInfo.first, &Invalid); Lexer Lex(SourceMgr.getLocForStartOfFile(BeginLocInfo.first), CXXUnit->getASTContext().getLangOptions(), - Buffer.first, Buffer.first + BeginLocInfo.second, Buffer.second); + Buffer.begin(), Buffer.data() + BeginLocInfo.second, Buffer.end()); Lex.SetCommentRetentionState(true); // Lex tokens until we hit the end of the range. - const char *EffectiveBufferEnd = Buffer.first + EndLocInfo.second; + const char *EffectiveBufferEnd = Buffer.data() + EndLocInfo.second; llvm::SmallVector<CXToken, 32> CXTokens; Token Tok; do { @@ -2135,12 +2134,12 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, std::pair<FileID, unsigned> LocInfo = SourceMgr.getDecomposedLoc(Tok.getLocation()); bool Invalid = false; - std::pair<const char *, const char *> Buf + llvm::StringRef Buf = CXXUnit->getSourceManager().getBufferData(LocInfo.first, &Invalid); if (Invalid) return; - const char *StartPos= Buf.first + LocInfo.second; + const char *StartPos = Buf.data() + LocInfo.second; IdentifierInfo *II = CXXUnit->getPreprocessor().LookUpIdentifierInfo(Tok, StartPos); CXTok.int_data[0] = II->getTokenID() == tok::identifier? |