commit 204006a0e5cf496daee77d9282c7390ffbc4596f
parent a8fdc928a8c158cec7591199404484342e517d2f
Author: Tooru Fujisawa <arai_a@mac.com>
Date: Thu, 8 Jan 2026 06:56:00 +0000
Bug 2003110 - Emit the context for included files. r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D274491
Diffstat:
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/build/clang-plugin/mozsearch-plugin/MozsearchIndexer.cpp b/build/clang-plugin/mozsearch-plugin/MozsearchIndexer.cpp
@@ -2907,7 +2907,7 @@ public:
NotIdentifierToken | LocRangeEndValid);
}
- void inclusionDirective(SourceRange FileNameRange, const FileEntry *File) {
+ void inclusionDirective(SourceLocation HashLoc, SourceRange FileNameRange, const FileEntry *File) {
std::string includedFile(File->tryGetRealPathName());
FileType type = relativizePath(includedFile, CI.getHeaderSearchOpts());
if (type == FileType::Unknown) {
@@ -2932,8 +2932,15 @@ public:
endMacroExpansion();
}
+ normalizeLocation(&HashLoc);
+ FileInfo *thisFile = getFileInfo(HashLoc);
+ FileType thisType = thisFile->Generated ? FileType::Generated : FileType::Source;
+ std::string thisFilePretty = thisFile->Realname;
+ std::string thisFileSym =
+ std::string("FILE_") + mangleFile(thisFile->Realname, thisType);
+
visitIdentifier("use", "file", includedFile, FileNameRange, symbol,
- QualType(), Context(),
+ QualType(), Context(thisFilePretty, thisFileSym),
NotIdentifierToken | LocRangeEndValid);
}
@@ -3177,10 +3184,10 @@ void PreprocessorHook::InclusionDirective(
if (!File) {
return;
}
- Indexer->inclusionDirective(FileNameRange.getAsRange(),
+ Indexer->inclusionDirective(HashLoc, FileNameRange.getAsRange(),
&File->getFileEntry());
#else
- Indexer->inclusionDirective(FileNameRange.getAsRange(), File);
+ Indexer->inclusionDirective(HashLoc, FileNameRange.getAsRange(), File);
#endif
}