Allow force updating the NumCreatedFIDsForFileID.

Our internal clients implement parsing cache based on FileID. In order for the
Preprocessor to reenter the cached FileID it needs to reset its
NumCreatedFIDsForFileID.

Differential Revision: https://reviews.llvm.org/D51295

llvm-svn: 347304
This commit is contained in:
Vassil Vassilev 2018-11-20 13:53:20 +00:00
parent ee8b96f253
commit 6fbb3e08d7
1 changed files with 3 additions and 2 deletions

View File

@ -1024,13 +1024,14 @@ public:
/// Set the number of FileIDs (files and macros) that were created
/// during preprocessing of \p FID, including it.
void setNumCreatedFIDsForFileID(FileID FID, unsigned NumFIDs) const {
void setNumCreatedFIDsForFileID(FileID FID, unsigned NumFIDs,
bool Force = false) const {
bool Invalid = false;
const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid);
if (Invalid || !Entry.isFile())
return;
assert(Entry.getFile().NumCreatedFIDs == 0 && "Already set!");
assert((Force || Entry.getFile().NumCreatedFIDs == 0) && "Already set!");
const_cast<SrcMgr::FileInfo &>(Entry.getFile()).NumCreatedFIDs = NumFIDs;
}