Skip to content

Commit

Permalink
Allow force updating the NumCreatedFIDsForFileID.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vgvassilev committed Nov 20, 2018
1 parent ee8b96f commit 6fbb3e0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clang/include/clang/Basic/SourceManager.h
Expand Up @@ -1024,13 +1024,14 @@ class SourceManager : public RefCountedBase<SourceManager> {

/// 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;
}

Expand Down

0 comments on commit 6fbb3e0

Please sign in to comment.