[PATCH] D29755: Cache FileID when translating diagnostics in PCH files

Erik Verbruggen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 14 06:32:37 PST 2017


erikjv updated this revision to Diff 88366.

https://reviews.llvm.org/D29755

Files:
  lib/Frontend/ASTUnit.cpp


Index: lib/Frontend/ASTUnit.cpp
===================================================================
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -2539,14 +2539,19 @@
 
   SmallVector<StoredDiagnostic, 4> Result;
   Result.reserve(Diags.size());
+  const FileEntry *PreviousFE = nullptr;
+  FileID FID;
   for (const StandaloneDiagnostic &SD : Diags) {
     // Rebuild the StoredDiagnostic.
     if (SD.Filename.empty())
       continue;
     const FileEntry *FE = FileMgr.getFile(SD.Filename);
     if (!FE)
       continue;
-    FileID FID = SrcMgr.translateFile(FE);
+    if (FE != PreviousFE) {
+      FID = SrcMgr.translateFile(FE);
+      PreviousFE = FE;
+    }
     SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
     if (FileLoc.isInvalid())
       continue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29755.88366.patch
Type: text/x-patch
Size: 795 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170214/2601908e/attachment.bin>


More information about the cfe-commits mailing list