http://bugs.llvm.org/show_bug.cgi?id=32402
One FileID per warning will increase and overflow NextLocalOffset
when input file is large with many warnings.
Reusing FileID avoids this problem.
Details
- Reviewers
alexfh - Commits
- rG90fccec5ee30: [clang-tidy] Reuse FileID in getLocation
rGb7b6c907bafc: [clang-tidy] Revert D31406 (Reuse FileID in getLocation)
rG4c2647bc2aa8: [clang-tidy] Reuse FileID in getLocation
rCTE299700: [clang-tidy] Reuse FileID in getLocation
rCTE299146: [clang-tidy] Revert D31406 (Reuse FileID in getLocation)
rCTE299119: [clang-tidy] Reuse FileID in getLocation
rL299700: [clang-tidy] Reuse FileID in getLocation
rL299146: [clang-tidy] Revert D31406 (Reuse FileID in getLocation)
rL299119: [clang-tidy] Reuse FileID in getLocation
Diff Detail
- Repository
- rL LLVM
Event Timeline
clang-tidy/ClangTidy.cpp | ||
---|---|---|
246 ↗ | (On Diff #93179) | I do not know how important the efficiency here. But you do not need to store strings (and allocate buffers). You could get the FileEntry from the FileID and query the name (which will give you a StringRef). After that modification, StringRef is relatively small, so maybe the map is a good candidate to be a DenseMap. |
clang-tidy/ClangTidy.cpp | ||
---|---|---|
246 ↗ | (On Diff #93179) | Now replaced with DenseMap<StringRef, FileID>. |
Thank you for finding out the root cause here!
clang-tidy/ClangTidy.cpp | ||
---|---|---|
241 ↗ | (On Diff #93284) | Repeating lookup three times is not necessary: FileID &ID = Path2FileID[FilePath]; if (!ID.isValid()) { const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath); ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User); } But even this seems to be unnecessary, since SourceManager provides a better API that we should have used here: FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User); |
256 ↗ | (On Diff #93284) | llvm::StringMap<FileID> would be a better container, if we needed it (see the comment above). |
This was reverted due to one failed test case clang-tidy/llvm-include-order.cpp on Windows:
Assertion failed: EndColNo <= map.getSourceLine().size() && "Invalid range!", file C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\lib\Frontend\TextDiagnostic.cpp, line 999