https://github.com/erichkeane created 
https://github.com/llvm/llvm-project/pull/234951

Since the former is in an anonymous namespace, this ends "creating" one of 
these namespaces per TU. It doesn't actually get created/used anywhere else, 
but this did get caught by a newer version of MSVC.

The only thing the friendship did was save us from having to do getBuilder 
instead of builder, so this just fixes that.

>From da7c234febfd7420aa55a5eaaf04fe68af99643e Mon Sep 17 00:00:00 2001
From: erichkeane <[email protected]>
Date: Fri, 23 Oct 2026 06:53:13 -0700
Subject: [PATCH] [CIR] Stop making CIRGen's ExprScalar be a friend of
 CIRGenFunction

Since the former is in an anonymous namespace, this ends "creating" one
of these namespaces per TU. It doesn't actually get created/used
anywhere else, but this did get caught by a newer version of MSVC.

The only thing the friendship did was save us from having to do
getBuilder instead of builder, so this just fixes that.
---
 clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 14 ++++++++------
 clang/lib/CIR/CodeGen/CIRGenFunction.h     |  5 -----
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index eef3a4e479ba8..5d2b946c9bf42 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -360,7 +360,8 @@ class ScalarExprEmitter : public 
StmtVisitor<ScalarExprEmitter, mlir::Value> {
       const mlir::Location loc = cgf.getLoc(e->getSourceRange());
       const mlir::Value vecValue = Visit(e->getBase());
       const mlir::Value indexValue = Visit(e->getIdx());
-      return cir::VecExtractOp::create(cgf.builder, loc, vecValue, indexValue);
+      return cir::VecExtractOp::create(cgf.getBuilder(), loc, vecValue,
+                                       indexValue);
     }
     // Just load the lvalue formed by the subscript expression.
     return emitLoadOfLValue(e);
@@ -371,8 +372,9 @@ class ScalarExprEmitter : public 
StmtVisitor<ScalarExprEmitter, mlir::Value> {
       // The undocumented form of __builtin_shufflevector.
       mlir::Value inputVec = Visit(e->getExpr(0));
       mlir::Value indexVec = Visit(e->getExpr(1));
-      return cir::VecShuffleDynamicOp::create(
-          cgf.builder, cgf.getLoc(e->getSourceRange()), inputVec, indexVec);
+      return cir::VecShuffleDynamicOp::create(cgf.getBuilder(),
+                                              cgf.getLoc(e->getSourceRange()),
+                                              inputVec, indexVec);
     }
 
     mlir::Value vec1 = Visit(e->getExpr(0));
@@ -384,16 +386,16 @@ class ScalarExprEmitter : public 
StmtVisitor<ScalarExprEmitter, mlir::Value> {
     SmallVector<mlir::Attribute, 8> indices;
     for (unsigned i = 2; i < e->getNumSubExprs(); ++i) {
       indices.push_back(
-          cir::IntAttr::get(cgf.builder.getSInt64Ty(),
+          cir::IntAttr::get(cgf.getBuilder().getSInt64Ty(),
                             e->getExpr(i)
                                 ->EvaluateKnownConstInt(cgf.getContext())
                                 .getSExtValue()));
     }
 
-    return cir::VecShuffleOp::create(cgf.builder,
+    return cir::VecShuffleOp::create(cgf.getBuilder(),
                                      cgf.getLoc(e->getSourceRange()),
                                      cgf.convertType(e->getType()), vec1, vec2,
-                                     cgf.builder.getArrayAttr(indices));
+                                     cgf.getBuilder().getArrayAttr(indices));
   }
 
   mlir::Value VisitConvertVectorExpr(ConvertVectorExpr *e) {
diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.h 
b/clang/lib/CIR/CodeGen/CIRGenFunction.h
index b97b0fe1f700c..218b97ecb4035 100644
--- a/clang/lib/CIR/CodeGen/CIRGenFunction.h
+++ b/clang/lib/CIR/CodeGen/CIRGenFunction.h
@@ -42,10 +42,6 @@
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Intrinsics.h"
 
-namespace {
-class ScalarExprEmitter;
-} // namespace
-
 namespace mlir {
 namespace acc {
 class LoopOp;
@@ -66,7 +62,6 @@ class CIRGenFunction : public CIRGenTypeCache {
   CIRGenModule &cgm;
 
 private:
-  friend class ::ScalarExprEmitter;
   /// The builder is a helper class to create IR inside a function. The
   /// builder is stateful, in particular it keeps an "insertion point": this
   /// is where the next operations will be introduced.

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

Reply via email to