Author: Kirill Stoimenov
Date: 2026-02-26T09:02:24-08:00
New Revision: a6a77fd1a7a95098bc3bc530683cc5609f800f54

URL: 
https://github.com/llvm/llvm-project/commit/a6a77fd1a7a95098bc3bc530683cc5609f800f54
DIFF: 
https://github.com/llvm/llvm-project/commit/a6a77fd1a7a95098bc3bc530683cc5609f800f54.diff

LOG: [clang] Fixed a bug causing failure with CFI icalls enabled.  (#183428)

This is fixing a regression when abi_tag is used in conjunction with CFI.

Added: 
    clang/test/CodeGen/cfi-icall-with-abi-tag.cpp

Modified: 
    clang/lib/AST/ItaniumMangle.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index df00760fa911b..7c34377fc6e1a 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -423,7 +423,8 @@ class CXXNameMangler {
       : Context(C), Out(Out_), NormalizeIntegers(NormalizeIntegers_),
         NullOut(false), Structor(nullptr), AbiTagsRoot(AbiTags) {}
   CXXNameMangler(CXXNameMangler &Outer, raw_ostream &Out_)
-      : Context(Outer.Context), Out(Out_), Structor(Outer.Structor),
+      : Context(Outer.Context), Out(Out_),
+        NormalizeIntegers(Outer.NormalizeIntegers), Structor(Outer.Structor),
         StructorType(Outer.StructorType), SeqID(Outer.SeqID),
         FunctionTypeDepth(Outer.FunctionTypeDepth), AbiTagsRoot(AbiTags),
         Substitutions(Outer.Substitutions),

diff  --git a/clang/test/CodeGen/cfi-icall-with-abi-tag.cpp 
b/clang/test/CodeGen/cfi-icall-with-abi-tag.cpp
new file mode 100644
index 0000000000000..dba9253e0c9e1
--- /dev/null
+++ b/clang/test/CodeGen/cfi-icall-with-abi-tag.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -std=c++20 -fsanitize=cfi-icall \
+// RUN: -fsanitize-cfi-icall-experimental-normalize-integers \
+// RUN: -S %s -o-
+
+// This is a regression test.
+
+template <class _Fn>
+void invoke(_Fn) {
+  return;
+}
+
+template <class _Iter>
+struct reverse_iterator {
+  _Iter operator*() {
+    _Iter __tmp;
+    *__tmp;
+    return __tmp;
+  }
+  void operator++();
+};
+
+template <class _Iter1, class _Iter2> bool operator!=(_Iter1, _Iter2);
+
+template <typename _Fn>
+struct __attribute__((__abi_tag__("v1"))) transform_view {
+  void operator*() { invoke(__func_); }
+  _Fn __func_;
+};
+
+template <typename It>
+struct range {
+  It begin();
+  It end();
+};
+
+template <class>
+struct VarargsNodeTMixin {
+  auto args() {
+    return transform_view([] {});
+  }
+};
+
+struct Call : VarargsNodeTMixin<int> {
+  void GenerateCode();
+};
+
+void Call::GenerateCode() {
+  for (auto item : range<reverse_iterator<decltype(args())>>{}) { }
+}


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

Reply via email to