https://github.com/snprajwal created 
https://github.com/llvm/llvm-project/pull/215373

Public API can never be defined in function bodies, since that would make the 
type function-local only. The symbol graph must not contain any such symbols as 
they cannot be used by a downstream consumer. Skip parsing function bodies in 
ExtractAPI. This also addresses cases where inlinable functions sometimes had 
their local types erroneously included in the symbol graph due to the 
definition being retained in the PCM file.

rdar://181241162

>From c6beaf63f445281c084a8356bea965f1a23e81f9 Mon Sep 17 00:00:00 2001
From: Prajwal Nadig <[email protected]>
Date: Mon, 10 Aug 2026 20:26:12 +0100
Subject: [PATCH] [ExtractAPI] Skip parsing function bodies

Public API can never be defined in function bodies, since that would
make the type function-local only. The symbol graph must not contain any
such symbols as they cannot be used by a downstream consumer. Skip
parsing function bodies in ExtractAPI. This also addresses cases where
inlinable functions sometimes had their local types erroneously included
in the symbol graph due to the definition being retained in the PCM
file.

rdar://181241162
---
 clang/lib/ExtractAPI/ExtractAPIConsumer.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp 
b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index 85da480fb67a6..237decf2f0bd5 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -448,6 +448,9 @@ ExtractAPIAction::CreateASTConsumer(CompilerInstance &CI, 
StringRef InFile) {
 }
 
 bool ExtractAPIAction::PrepareToExecuteAction(CompilerInstance &CI) {
+  // Public API can never be inside function bodies, so skip parsing them.
+  CI.getFrontendOpts().SkipFunctionBodies = true;
+
   auto &Inputs = CI.getFrontendOpts().Inputs;
   if (Inputs.empty())
     return true;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to