Reduce Clang header exposure in lower library (#7511)

Remove clang/CodeGen/ModuleBuilder.h from toolchain/lower/file_context.h
to reduce transitive dependencies. Forward declare clang::CodeGenerator
and clang::FunctionDecl instead.

Add an explicit include of ModuleBuilder.h to context.cpp where the
complete types are required.

Assisted-by: Antigravity with Gemini
This commit is contained in:
Chandler Carruth
2026-07-15 00:59:03 +00:00
committed by GitHub
parent 45d1c74df8
commit 730db0f903
3 changed files with 10 additions and 2 deletions
+1
View File
@@ -5,6 +5,7 @@
#include "toolchain/lower/context.h"
#include "clang/Basic/SourceManager.h"
#include "clang/CodeGen/ModuleBuilder.h"
#include "common/check.h"
#include "common/growing_range.h"
#include "common/raw_string_ostream.h"
+4
View File
@@ -20,6 +20,10 @@
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/inst_namer.h"
namespace clang {
class CodeGenerator;
}
namespace Carbon::Lower {
class FileContext;
+5 -2
View File
@@ -5,8 +5,6 @@
#ifndef CARBON_TOOLCHAIN_LOWER_FILE_CONTEXT_H_
#define CARBON_TOOLCHAIN_LOWER_FILE_CONTEXT_H_
#include "clang/CodeGen/ModuleBuilder.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "toolchain/lower/context.h"
#include "toolchain/lower/specific_coalescer.h"
#include "toolchain/lower/type.h"
@@ -15,6 +13,11 @@
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/inst_namer.h"
namespace clang {
class CodeGenerator;
class FunctionDecl;
} // namespace clang
namespace Carbon::Lower {
// Information about how a given function declaration is lowered.