mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 09:33:43 +08:00
For the FileChanged Preprocessor callback, when exiting a file, pass its FileID.
llvm-svn: 141681
This commit is contained in:
@@ -42,8 +42,11 @@ public:
|
||||
/// EnteringFile indicates whether this is because we are entering a new
|
||||
/// #include'd file (when true) or whether we're exiting one because we ran
|
||||
/// off the end (when false).
|
||||
///
|
||||
/// \param PrevFID the file that was exited if \arg Reason is ExitFile.
|
||||
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
SrcMgr::CharacteristicKind FileType,
|
||||
FileID PrevFID = FileID()) {
|
||||
}
|
||||
|
||||
/// FileSkipped - This callback is invoked whenever a source file is
|
||||
@@ -211,9 +214,10 @@ public:
|
||||
}
|
||||
|
||||
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
First->FileChanged(Loc, Reason, FileType);
|
||||
Second->FileChanged(Loc, Reason, FileType);
|
||||
SrcMgr::CharacteristicKind FileType,
|
||||
FileID PrevFID) {
|
||||
First->FileChanged(Loc, Reason, FileType, PrevFID);
|
||||
Second->FileChanged(Loc, Reason, FileType, PrevFID);
|
||||
}
|
||||
|
||||
virtual void FileSkipped(const FileEntry &ParentFile,
|
||||
|
||||
@@ -52,7 +52,8 @@ public:
|
||||
AddMissingHeaderDeps(Opts.AddMissingHeaderDeps) {}
|
||||
|
||||
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
|
||||
SrcMgr::CharacteristicKind FileType);
|
||||
SrcMgr::CharacteristicKind FileType,
|
||||
FileID PrevFID);
|
||||
virtual void InclusionDirective(SourceLocation HashLoc,
|
||||
const Token &IncludeTok,
|
||||
StringRef FileName,
|
||||
@@ -107,7 +108,8 @@ bool DependencyFileCallback::FileMatchesDepCriteria(const char *Filename,
|
||||
|
||||
void DependencyFileCallback::FileChanged(SourceLocation Loc,
|
||||
FileChangeReason Reason,
|
||||
SrcMgr::CharacteristicKind FileType) {
|
||||
SrcMgr::CharacteristicKind FileType,
|
||||
FileID PrevFID) {
|
||||
if (Reason != PPCallbacks::EnterFile)
|
||||
return;
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
|
||||
SrcMgr::CharacteristicKind FileType);
|
||||
SrcMgr::CharacteristicKind FileType,
|
||||
FileID PrevFID);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -72,7 +73,8 @@ void clang::AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders,
|
||||
|
||||
void HeaderIncludesCallback::FileChanged(SourceLocation Loc,
|
||||
FileChangeReason Reason,
|
||||
SrcMgr::CharacteristicKind NewFileType) {
|
||||
SrcMgr::CharacteristicKind NewFileType,
|
||||
FileID PrevFID) {
|
||||
// Unless we are exiting a #include, make sure to skip ahead to the line the
|
||||
// #include directive was at.
|
||||
PresumedLoc UserLoc = SM.getPresumedLoc(Loc);
|
||||
|
||||
@@ -118,7 +118,8 @@ public:
|
||||
bool StartNewLineIfNeeded();
|
||||
|
||||
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
|
||||
SrcMgr::CharacteristicKind FileType);
|
||||
SrcMgr::CharacteristicKind FileType,
|
||||
FileID PrevFID);
|
||||
virtual void Ident(SourceLocation Loc, const std::string &str);
|
||||
virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
|
||||
const std::string &Str);
|
||||
@@ -235,7 +236,8 @@ bool PrintPPOutputPPCallbacks::StartNewLineIfNeeded() {
|
||||
/// position.
|
||||
void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
|
||||
FileChangeReason Reason,
|
||||
SrcMgr::CharacteristicKind NewFileType) {
|
||||
SrcMgr::CharacteristicKind NewFileType,
|
||||
FileID PrevFID) {
|
||||
// Unless we are exiting a #include, make sure to skip ahead to the line the
|
||||
// #include directive was at.
|
||||
SourceManager &SourceMgr = SM;
|
||||
|
||||
@@ -256,6 +256,10 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
|
||||
SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs);
|
||||
}
|
||||
|
||||
FileID ExitedFID;
|
||||
if (Callbacks && !isEndOfMacro && CurPPLexer)
|
||||
ExitedFID = CurPPLexer->getFileID();
|
||||
|
||||
// We're done with the #included file.
|
||||
RemoveTopOfLexerStack();
|
||||
|
||||
@@ -264,7 +268,7 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
|
||||
SrcMgr::CharacteristicKind FileType =
|
||||
SourceMgr.getFileCharacteristic(CurPPLexer->getSourceLocation());
|
||||
Callbacks->FileChanged(CurPPLexer->getSourceLocation(),
|
||||
PPCallbacks::ExitFile, FileType);
|
||||
PPCallbacks::ExitFile, FileType, ExitedFID);
|
||||
}
|
||||
|
||||
// Client should lex another token.
|
||||
|
||||
Reference in New Issue
Block a user