[clang] [Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 13 16:50:45 PDT 2024
================
@@ -1911,18 +1911,22 @@ SourceManager::getDecomposedIncludedLoc(FileID FID) const {
return DecompLoc;
}
-FileID SourceManager::getFirstFIDOfLoadedAST(SourceLocation Loc) const {
+unsigned SourceManager::getUniqueLoadedASTID(SourceLocation Loc) const {
assert(isLoadedSourceLocation(Loc) &&
"Must be a source location in a loaded PCH/Module file");
auto [FID, Ignore] = getDecomposedLoc(Loc);
+ // `LoadedSLocEntryAllocBegin` stores the sorted lowest FID of each loaded
+ // allocation. Later allocations have lower FileIDs. The call below is to find
+ // the lowest FID of a loaded allocation from any FID in the same allocation.
+ // The lowest FID is used to identify a loaded allocation.
const FileID *FirstFID =
llvm::lower_bound(LoadedSLocEntryAllocBegin, FID, std::greater<FileID>{});
assert(FirstFID &&
"The failure to find the first FileID of a "
"loaded AST from a loaded source location was unexpected.");
- return *FirstFID;
+ return FirstFID->getHashValue();
----------------
haoNoQ wrote:
Hmm can we go back to returning `FileID` here? We really shouldn't rely on the fact that the _hash_ value is equal to the actual thing we're looking for.
https://github.com/llvm/llvm-project/pull/92031
More information about the cfe-commits
mailing list