summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/Lexer.cpp9
-rw-r--r--clang/lib/Lex/PPLexerChange.cpp6
-rw-r--r--clang/lib/Lex/TokenLexer.cpp5
3 files changed, 15 insertions, 5 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 3207062ccad..149041559ab 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -229,7 +229,14 @@ unsigned Lexer::MeasureTokenLength(SourceLocation Loc,
// the token this macro expanded to.
Loc = SM.getInstantiationLoc(Loc);
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Loc);
- std::pair<const char *,const char *> Buffer = SM.getBufferData(LocInfo.first);
+ llvm::StringRef FileName;
+ std::string ErrorStr;
+ std::pair<const char *,const char *> Buffer = SM.getBufferData(LocInfo.first,
+ FileName,
+ ErrorStr);
+ if (!Buffer.first)
+ return 0;
+
const char *StrData = Buffer.first+LocInfo.second;
if (isWhitespace(StrData[0]))
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index 0b26ccbecba..4fba7b7bee1 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/lib/Lex/PPLexerChange.cpp
@@ -80,9 +80,9 @@ bool Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir,
}
// Get the MemoryBuffer for this FID, if it fails, we fail.
- const llvm::MemoryBuffer *InputFile =
- getSourceManager().getBuffer(FID, &ErrorStr);
- if (!ErrorStr.empty())
+ const llvm::MemoryBuffer *InputFile
+ = getSourceManager().getBuffer(FID).getBuffer(getDiagnostics());
+ if (!InputFile)
return true;
EnterSourceFileWithLexer(new Lexer(FID, InputFile, *this), CurDir);
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp
index efd1efed293..7ccaa89fe3e 100644
--- a/clang/lib/Lex/TokenLexer.cpp
+++ b/clang/lib/Lex/TokenLexer.cpp
@@ -439,7 +439,10 @@ bool TokenLexer::PasteTokens(Token &Tok) {
SourceManager &SourceMgr = PP.getSourceManager();
FileID LocFileID = SourceMgr.getFileID(ResultTokLoc);
- const char *ScratchBufStart = SourceMgr.getBufferData(LocFileID).first;
+ const char *ScratchBufStart
+ = SourceMgr.getBufferData(LocFileID, PP.getDiagnostics()).first;
+ if (!ScratchBufStart)
+ return false;
// Make a lexer to lex this string from. Lex just this one token.
// Make a lexer object so that we lex and expand the paste result.
OpenPOWER on IntegriCloud