Thread the 'Invalid' out parameter through SourceManager::getSLocEntry() and callees of SourceManager::getSLocEntryByID().

Also add an 'Invalid' check in SourceManager::computeMacroArgsCache().

llvm-svn: 183538
This commit is contained in:
Argyrios Kyrtzidis 2013-06-07 17:57:59 +00:00
parent 158d8069ad
commit fe68302fe8
2 changed files with 8 additions and 5 deletions

View File

@ -1483,7 +1483,7 @@ public:
if (Invalid) *Invalid = true; if (Invalid) *Invalid = true;
return LocalSLocEntryTable[0]; return LocalSLocEntryTable[0];
} }
return getSLocEntryByID(FID.ID); return getSLocEntryByID(FID.ID, Invalid);
} }
unsigned getNextLocalOffset() const { return NextLocalOffset; } unsigned getNextLocalOffset() const { return NextLocalOffset; }
@ -1547,11 +1547,11 @@ private:
const SrcMgr::SLocEntry &loadSLocEntry(unsigned Index, bool *Invalid) const; const SrcMgr::SLocEntry &loadSLocEntry(unsigned Index, bool *Invalid) const;
/// \brief Get the entry with the given unwrapped FileID. /// \brief Get the entry with the given unwrapped FileID.
const SrcMgr::SLocEntry &getSLocEntryByID(int ID) const { const SrcMgr::SLocEntry &getSLocEntryByID(int ID, bool *Invalid = 0) const {
assert(ID != -1 && "Using FileID sentinel value"); assert(ID != -1 && "Using FileID sentinel value");
if (ID < 0) if (ID < 0)
return getLoadedSLocEntryByID(ID); return getLoadedSLocEntryByID(ID, Invalid);
return getLocalSLocEntry(static_cast<unsigned>(ID)); return getLocalSLocEntry(static_cast<unsigned>(ID), Invalid);
} }
const SrcMgr::SLocEntry &getLoadedSLocEntryByID(int ID, const SrcMgr::SLocEntry &getLoadedSLocEntryByID(int ID,

View File

@ -1808,7 +1808,10 @@ void SourceManager::computeMacroArgsCache(MacroArgsMap *&CachePtr,
return; return;
} }
const SrcMgr::SLocEntry &Entry = getSLocEntryByID(ID); bool Invalid = false;
const SrcMgr::SLocEntry &Entry = getSLocEntryByID(ID, &Invalid);
if (Invalid)
return;
if (Entry.isFile()) { if (Entry.isFile()) {
SourceLocation IncludeLoc = Entry.getFile().getIncludeLoc(); SourceLocation IncludeLoc = Entry.getFile().getIncludeLoc();
if (IncludeLoc.isInvalid()) if (IncludeLoc.isInvalid())