[clang-tidy] Reuse FileID in getLocation
authorChih-Hung Hsieh <chh@google.com>
Thu, 30 Mar 2017 22:09:17 +0000 (22:09 +0000)
committerChih-Hung Hsieh <chh@google.com>
Thu, 30 Mar 2017 22:09:17 +0000 (22:09 +0000)
One FileID per warning will increase and overflow NextLocalOffset
when input file is large with many warnings.
Reusing FileID avoids this problem.

Differential Revision: http://reviews.llvm.org/D31406

llvm-svn: 299119

clang-tools-extra/clang-tidy/ClangTidy.cpp

index 2da9e14..6ed8306 100644 (file)
@@ -238,7 +238,7 @@ private:
       return SourceLocation();
 
     const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-    FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+    FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
     return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }