From b1b24d751776d5fd2218a5cb43a8d103bf59fa32 Mon Sep 17 00:00:00 2001 From: Daniel Grumberg Date: Tue, 27 Aug 2024 13:50:41 +0100 Subject: [clang][ExtractAPI] Fix quirks in interaction with submodules (#105868) Extension SGFs require the module system to be enabled in order to discover which module defines the extended external type. This patch ensures the following: - Associate symbols with their top level module name, and that only top level modules are considered as modules for emitting extension SGFs. - Ensure we don't drop macro definitions that came from a submodule. To this end look at all defined macros in `PPCalbacks::EndOfMainFile` instead of relying on `PPCallbacks::MacroDefined` being called to detect a macro definition. --- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp') diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 1bce9c5..030509d 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -928,8 +928,8 @@ bool SymbolGraphSerializer::traverseObjCCategoryRecord( return true; auto *CurrentModule = ModuleForCurrentSymbol; - if (Record->isExtendingExternalModule()) - ModuleForCurrentSymbol = &ExtendedModules[Record->Interface.Source]; + if (auto ModuleExtendedByRecord = Record->getExtendedExternalModule()) + ModuleForCurrentSymbol = &ExtendedModules[*ModuleExtendedByRecord]; if (!walkUpFromObjCCategoryRecord(Record)) return false; -- cgit v1.1