[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-05 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 289f8630dccf916b8cf7cc43758bae60df036c5d Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 1/3] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of file

>From 78fecd58986e25147b47220ee9ef0a392c45651e Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 2/3] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..88ed3018c58ea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of f

[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-05 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 289f8630dccf916b8cf7cc43758bae60df036c5d Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 1/2] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of file

>From 78fecd58986e25147b47220ee9ef0a392c45651e Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 2/2] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..88ed3018c58ea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of f

[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-05 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 289f8630dccf916b8cf7cc43758bae60df036c5d Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of file

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-05 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 289f8630dccf916b8cf7cc43758bae60df036c5d Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of file

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-02 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 3a3dea21957b70dfedc4eab47be0c1717ff0a229 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 1 Apr 2025 00:51:11 -0700
Subject: [PATCH 1/2] fixed clang frontend crash with friend class declaration
 and overloaded operator ==

---
 clang/lib/Sema/SemaDeclCXX.cpp|  5 +++--
 .../class/class.compare/class.compare.default/p1.cpp  | 11 +++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..6cee832f98e6a 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,9 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return F->getFriendDecl() &&
+ FD->getCanonicalDecl() ==
+ F->getFriendDecl()->getCanonicalDecl();
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..37bf98be889d5 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,14 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {};
+  
+  struct l {
+friend bool operator==(const l& a, const l& b);
+friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}

>From 38f520e1f363f1cdc3afb30a07e379e0049e7e63 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 1 Apr 2025 00:51:11 -0700
Subject: [PATCH 2/2] fixed clang frontend crash with friend class declaration
 and overloaded operator ==

---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp|  3 +--
 .../class/class.compare/class.compare.default/p1.cpp  | 11 +++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..37bf98be889d5 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,14 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {};
+  
+  struct l {
+friend bool operator==(const l& a, const l& b);
+friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-02 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 289f8630dccf916b8cf7cc43758bae60df036c5d Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 1/2] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of file

>From 78fecd58986e25147b47220ee9ef0a392c45651e Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 2/2] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..88ed3018c58ea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of f

[clang] Upstream enum support (PR #136807)

2025-04-22 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 created 
https://github.com/llvm/llvm-project/pull/136807

#136055 

This PR adds basic support for enum declarations in CIR by handling the 
Decl::Enum case in CIRGenModule::emitTopLevelDecl(). The implementation 
currently asserts when debug info generation is requested.

A simple test case with an anonymous enum declaration has been added to verify 
the functionality.


>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Upstream enum support (PR #136807)

2025-04-22 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 ready_for_review 
https://github.com/llvm/llvm-project/pull/136807
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream enum support (PR #136807)

2025-04-26 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/11] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/11] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/11] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/11] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -2

[clang] [CIR] Upstream enum support (PR #136807)

2025-04-26 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/10] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/10] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/10] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/10] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -2

[clang] [CIR] Upstream enum support (PR #136807)

2025-04-28 Thread Ankur Ahir via cfe-commits


@@ -399,6 +399,14 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());

Ankur-0429 wrote:

There is a function 
[UpdateCompletedType](https://github.com/llvm/clangir/blob/a9eac21b2f5bcfa4169bde20faca769f70a06f28/clang/lib/CIR/CodeGen/CIRGenTypes.cpp#L830)
 that currently does not exist in this repo. Is this something that should be 
added? Wasn't too sure how much the fork diverged from the currently llvm repo.

https://github.com/llvm/llvm-project/pull/136807
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream enum support (PR #136807)

2025-04-28 Thread Ankur Ahir via cfe-commits


@@ -399,6 +399,14 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());

Ankur-0429 wrote:

The original comment referenced this function. That was why I left it out.

https://github.com/llvm/llvm-project/pull/136807
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream enum support (PR #136807)

2025-04-26 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 1/9] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 2/9] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 3/9] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 4/9] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -254,7 +25

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-05 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Upstream enum support (PR #136807)

2025-04-23 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 1/2] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 2/2] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Upstream enum support (PR #136807)

2025-04-23 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 1/3] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 2/3] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 3/3] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Upstream enum support (PR #136807)

2025-04-23 Thread Ankur Ahir via cfe-commits

Ankur-0429 wrote:

> I would also want to see tests that show uses of an enum, as well as fixed 
> underlying type, scoped enums/etc.

Going to wait to confirm I did the "fixed underlying type" part first. 

If you have more specific enum use cases that we should test for, please let me 
know.

https://github.com/llvm/llvm-project/pull/136807
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Upstream enum support (PR #136807)

2025-04-23 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 1/6] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 2/6] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 3/6] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 4/6] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -254,7 +25

[clang] [CIR] Upstream enum support (PR #136807)

2025-04-25 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 1/7] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 2/7] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 3/7] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 4/7] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -254,7 +25

[clang] [CIR] Upstream enum support (PR #136807)

2025-04-26 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 1/8] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 2/8] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 3/8] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 4/8] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -254,7 +25

[clang] [CIR] Upstream enum support (PR #136807)

2025-04-25 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 1/6] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 2/6] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 3/6] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 4/6] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -254,7 +25

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-02 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/14] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/14] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/14] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/14] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -2

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-01 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/12] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/12] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/12] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/12] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -2

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-01 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/12] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/12] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/12] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/12] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -2

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-02 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/13] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/13] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/13] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/13] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -2

[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-02 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 289f8630dccf916b8cf7cc43758bae60df036c5d Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 1/4] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of file

>From 78fecd58986e25147b47220ee9ef0a392c45651e Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 2/4] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..88ed3018c58ea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of f

[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-02 Thread Ankur Ahir via cfe-commits

Ankur-0429 wrote:

@cor3ntin feel free to merge the PR when it's ready. Happy to help!

https://github.com/llvm/llvm-project/pull/133878
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-03 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 reopened 
https://github.com/llvm/llvm-project/pull/133878
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-02 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 289f8630dccf916b8cf7cc43758bae60df036c5d Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of file

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-02 Thread Ankur Ahir via cfe-commits

Ankur-0429 wrote:

@zyn0217 changes were made :)

https://github.com/llvm/llvm-project/pull/133878
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-02 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 289f8630dccf916b8cf7cc43758bae60df036c5d Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 1/4] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of file

>From 78fecd58986e25147b47220ee9ef0a392c45651e Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 2/4] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..88ed3018c58ea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of f

[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-02 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 289f8630dccf916b8cf7cc43758bae60df036c5d Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 1/4] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of file

>From 78fecd58986e25147b47220ee9ef0a392c45651e Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 2/4] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..88ed3018c58ea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of f

[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-04 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 3a3dea21957b70dfedc4eab47be0c1717ff0a229 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 1 Apr 2025 00:51:11 -0700
Subject: [PATCH] fixed clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/lib/Sema/SemaDeclCXX.cpp|  5 +++--
 .../class/class.compare/class.compare.default/p1.cpp  | 11 +++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..6cee832f98e6a 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,9 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return F->getFriendDecl() &&
+ FD->getCanonicalDecl() ==
+ F->getFriendDecl()->getCanonicalDecl();
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..37bf98be889d5 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,14 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {};
+  
+  struct l {
+friend bool operator==(const l& a, const l& b);
+friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream enum support (PR #136807)

2025-05-11 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 682fa79810682385066be06450c8cba0c8297632 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/11] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 82bd139295b10..3de807d6cd474 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -787,6 +787,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::UsingDirective: // using namespace X; [C++]
   case Decl::Typedef:
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index b5b3e36b4aa08..f81b7e5eb3c04 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -141,3 +141,8 @@ void ref_local(short x) {
 // CHECK:   %[[Y_REF_ADDR:.*]] = cir.alloca !cir.ptr, 
!cir.ptr>, ["y", init, const] {alignment = 8 : i64}
 // CHECK:   cir.store %[[ARG]], %[[X_ADDR]] : !s16i, !cir.ptr
 // CHECK:   cir.store %[[X_ADDR]], %[[Y_REF_ADDR]] : !cir.ptr, 
!cir.ptr>
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From d32029ffd44341f04ab52b15b60878d2a46a1d10 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/11] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3de807d6cd474..6899e49d990db 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -788,9 +788,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::UsingDirective: // using namespace X; [C++]
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]

>From 53e77826c280c7335f090c1807131f040c2fd7b8 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/11] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index f81b7e5eb3c04..578b2602fdbca 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -145,4 +145,4 @@ void ref_local(short x) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From fb57bf256ae107c0b00bd4ae8958c5c2b63afe31 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/11] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index 313a6a0edc8ef..c5efc80574197 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -420,6 +420,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/C

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-11 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 682fa79810682385066be06450c8cba0c8297632 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/13] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 82bd139295b10..3de807d6cd474 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -787,6 +787,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::UsingDirective: // using namespace X; [C++]
   case Decl::Typedef:
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index b5b3e36b4aa08..f81b7e5eb3c04 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -141,3 +141,8 @@ void ref_local(short x) {
 // CHECK:   %[[Y_REF_ADDR:.*]] = cir.alloca !cir.ptr, 
!cir.ptr>, ["y", init, const] {alignment = 8 : i64}
 // CHECK:   cir.store %[[ARG]], %[[X_ADDR]] : !s16i, !cir.ptr
 // CHECK:   cir.store %[[X_ADDR]], %[[Y_REF_ADDR]] : !cir.ptr, 
!cir.ptr>
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From d32029ffd44341f04ab52b15b60878d2a46a1d10 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/13] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3de807d6cd474..6899e49d990db 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -788,9 +788,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::UsingDirective: // using namespace X; [C++]
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]

>From 53e77826c280c7335f090c1807131f040c2fd7b8 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/13] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index f81b7e5eb3c04..578b2602fdbca 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -145,4 +145,4 @@ void ref_local(short x) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From fb57bf256ae107c0b00bd4ae8958c5c2b63afe31 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/13] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index 313a6a0edc8ef..c5efc80574197 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -420,6 +420,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/C

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-11 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 682fa79810682385066be06450c8cba0c8297632 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/14] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 82bd139295b10..3de807d6cd474 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -787,6 +787,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::UsingDirective: // using namespace X; [C++]
   case Decl::Typedef:
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index b5b3e36b4aa08..f81b7e5eb3c04 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -141,3 +141,8 @@ void ref_local(short x) {
 // CHECK:   %[[Y_REF_ADDR:.*]] = cir.alloca !cir.ptr, 
!cir.ptr>, ["y", init, const] {alignment = 8 : i64}
 // CHECK:   cir.store %[[ARG]], %[[X_ADDR]] : !s16i, !cir.ptr
 // CHECK:   cir.store %[[X_ADDR]], %[[Y_REF_ADDR]] : !cir.ptr, 
!cir.ptr>
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From d32029ffd44341f04ab52b15b60878d2a46a1d10 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/14] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3de807d6cd474..6899e49d990db 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -788,9 +788,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::UsingDirective: // using namespace X; [C++]
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]

>From 53e77826c280c7335f090c1807131f040c2fd7b8 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/14] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index f81b7e5eb3c04..578b2602fdbca 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -145,4 +145,4 @@ void ref_local(short x) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From fb57bf256ae107c0b00bd4ae8958c5c2b63afe31 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/14] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index 313a6a0edc8ef..c5efc80574197 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -420,6 +420,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/C

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-11 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 682fa79810682385066be06450c8cba0c8297632 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/12] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 82bd139295b10..3de807d6cd474 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -787,6 +787,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::UsingDirective: // using namespace X; [C++]
   case Decl::Typedef:
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index b5b3e36b4aa08..f81b7e5eb3c04 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -141,3 +141,8 @@ void ref_local(short x) {
 // CHECK:   %[[Y_REF_ADDR:.*]] = cir.alloca !cir.ptr, 
!cir.ptr>, ["y", init, const] {alignment = 8 : i64}
 // CHECK:   cir.store %[[ARG]], %[[X_ADDR]] : !s16i, !cir.ptr
 // CHECK:   cir.store %[[X_ADDR]], %[[Y_REF_ADDR]] : !cir.ptr, 
!cir.ptr>
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From d32029ffd44341f04ab52b15b60878d2a46a1d10 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/12] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3de807d6cd474..6899e49d990db 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -788,9 +788,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::UsingDirective: // using namespace X; [C++]
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]

>From 53e77826c280c7335f090c1807131f040c2fd7b8 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/12] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index f81b7e5eb3c04..578b2602fdbca 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -145,4 +145,4 @@ void ref_local(short x) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From fb57bf256ae107c0b00bd4ae8958c5c2b63afe31 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/12] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index 313a6a0edc8ef..c5efc80574197 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -420,6 +420,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/C

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-11 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream enum support (PR #136807)

2025-05-11 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 1/9] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 2/9] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 3/9] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 4/9] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -254,7 +25

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-11 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream enum support (PR #136807)

2025-05-11 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/10] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/10] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/10] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/10] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -2

[clang] [CIR] Upstream enum support (PR #136807)

2025-05-11 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/136807

>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/11] Upstream enum support

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
 clang/test/CIR/CodeGen/basic.c | 5 +
 clang/test/CIR/CodeGen/basic.cpp   | 5 +
 3 files changed, 13 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
   case Decl::OpenACCDeclare:
 emitGlobalOpenACCDecl(cast(decl));
 break;
+  case Decl::Enum:
+assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+break;
 
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
 
 // OGCG: define{{.*}} i64 @max_size()
 // OGCG:   ret i64 2305843009213693951
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
 // CHECK:   %3 = cir.cast(integral, %2 : !s32i), !u64i
 // CHECK:   %4 = cir.const #cir.int<8> : !u64i
 // CHECK:   %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+  um = 0,
+  dois = 1,
+};
\ No newline at end of file

>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/11] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689

---
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
 emitGlobalOpenACCDecl(cast(decl));
 break;
   case Decl::Enum:
-assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
-break;
-
   case Decl::Typedef:
   case Decl::TypeAlias: // using foo = bar; [C++11]
   case Decl::Record:

>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/11] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889

---
 clang/test/CIR/CodeGen/basic.c   | 2 +-
 clang/test/CIR/CodeGen/basic.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
 enum {
   um = 0,
   dois = 1,
-};
\ No newline at end of file
+};

>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/11] resolving
 https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948

---
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |  7 +++
 clang/test/CIR/CodeGen/basic.c| 15 ---
 clang/test/CIR/CodeGen/basic.cpp  | 14 +++---
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp 
b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Enum: {
+const EnumDecl *ED = cast(ty)->getDecl();
+if (ED->isCompleteDefinition() || ED->isFixed())
+  return convertType(ED->getIntegerType());
+break;
+  }
+
   case Type::FunctionNoProto:
   case Type::FunctionProto:
 resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -2