[clang] [CIR][CMake] Fix MSVC PCH ambiguity after 0173f46b7d9d (PR #235058)
Jinsong Ji via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 23 19:06:03 PDT 2026
https://github.com/jsji updated https://github.com/llvm/llvm-project/pull/235058
>From 4eecec32521b7b06addb0cb228e4c52b23286431 Mon Sep 17 00:00:00 2001
From: Jinsong Ji <jinsong.ji at intel.com>
Date: Fri, 23 Oct 2026 01:03:33 +0200
Subject: [PATCH] [CIR][CMake] Fix MSVC PCH ambiguity after 0173f46b7d9d
0173f46b7d9d added a PCH for clangCIR that includes
CIRGenFunction.h, which forward-declares ScalarExprEmitter in an
anonymous namespace. MSVC treats the anonymous namespace from the PCH
as distinct from the one in CIRGenExprScalar.cpp, causing error C2872
('ScalarExprEmitter': ambiguous symbol). Skip the PCH for that file on
MSVC.
Assisted-By: Claude Opus 5.5
---
clang/lib/CIR/CodeGen/CMakeLists.txt | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/clang/lib/CIR/CodeGen/CMakeLists.txt b/clang/lib/CIR/CodeGen/CMakeLists.txt
index fdb2c66eb1f74..c201540b962d9 100644
--- a/clang/lib/CIR/CodeGen/CMakeLists.txt
+++ b/clang/lib/CIR/CodeGen/CMakeLists.txt
@@ -90,3 +90,11 @@ add_clang_library(clangCIR
MLIRPtrMemorySpaceInterfaces
MLIRTargetLLVMIRImport
)
+
+# MSVC treats the anonymous namespace forward declaration of ScalarExprEmitter
+# in CIRGenFunction.h (compiled into the PCH) as distinct from the one in
+# CIRGenExprScalar.cpp, causing error C2872 ('ScalarExprEmitter': ambiguous
+# symbol).
+if (MSVC)
+ set_source_files_properties(CIRGenExprScalar.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
+endif()
More information about the cfe-commits
mailing list