From 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 19 Jan 2019 10:04:05 +0000 Subject: Vendor import of clang trunk r351319 (just before the release_80 branch point): https://llvm.org/svn/llvm-project/cfe/trunk@351319 --- include/clang/Basic/PlistSupport.h | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'include/clang/Basic/PlistSupport.h') diff --git a/include/clang/Basic/PlistSupport.h b/include/clang/Basic/PlistSupport.h index be92bbfde1853..e41c24737798f 100644 --- a/include/clang/Basic/PlistSupport.h +++ b/include/clang/Basic/PlistSupport.h @@ -25,24 +25,35 @@ namespace markup { using FIDMap = llvm::DenseMap; -inline void AddFID(FIDMap &FIDs, SmallVectorImpl &V, - const SourceManager &SM, SourceLocation L) { - FileID FID = SM.getFileID(SM.getExpansionLoc(L)); +inline unsigned AddFID(FIDMap &FIDs, SmallVectorImpl &V, + FileID FID) { FIDMap::iterator I = FIDs.find(FID); if (I != FIDs.end()) - return; - FIDs[FID] = V.size(); + return I->second; + unsigned NewValue = V.size(); + FIDs[FID] = NewValue; V.push_back(FID); + return NewValue; } -inline unsigned GetFID(const FIDMap &FIDs, const SourceManager &SM, - SourceLocation L) { +inline unsigned AddFID(FIDMap &FIDs, SmallVectorImpl &V, + const SourceManager &SM, SourceLocation L) { FileID FID = SM.getFileID(SM.getExpansionLoc(L)); + return AddFID(FIDs, V, FID); +} + +inline unsigned GetFID(const FIDMap &FIDs, FileID FID) { FIDMap::const_iterator I = FIDs.find(FID); assert(I != FIDs.end()); return I->second; } +inline unsigned GetFID(const FIDMap &FIDs, const SourceManager &SM, + SourceLocation L) { + FileID FID = SM.getFileID(SM.getExpansionLoc(L)); + return GetFID(FIDs, FID); +} + inline raw_ostream &Indent(raw_ostream &o, const unsigned indent) { for (unsigned i = 0; i < indent; ++i) o << ' '; -- cgit v1.2.3