[llvm] [flang] [clang] [libc] [libunwind] [clang-tools-extra] [compiler-rt] [libcxx] [lld] [lldb] Test pr (PR #71086)

2023-11-08 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [llvm] Irdl (PR #74589)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/74589

None

>From 707f1625a626faae14b8e24f7e3cf10a2ed621ce Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Sun, 24 Sep 2023 22:38:01 -0400
Subject: [PATCH 1/6] [clang][DFP] Add basic builtin type representation for
 decimal floating point types.

This change adds basic type representation support for the decimal
floating point types defined by ISO/IEC TS 18661-2 and adopted for C23.
These types will also serve as the underlying native types for the
library types defined by ISO/IEC TR 24733 and as implemented in
libstdcxx. This change does not include representation support in
LLVM IR, in debugging information, or in C++ mangling for the MS ABI;
such support will be added in later patches.
---
 clang/include/clang/AST/ASTContext.h  |  2 ++
 clang/include/clang/AST/BuiltinTypes.def  | 17 
 clang/include/clang/Basic/TargetInfo.h| 17 
 clang/include/clang/Basic/TokenKinds.def  |  4 +++-
 .../include/clang/Serialization/ASTBitCodes.h |  9 +
 clang/lib/AST/ASTContext.cpp  | 20 +++
 clang/lib/AST/ExprConstant.cpp|  2 ++
 clang/lib/AST/ItaniumMangle.cpp   |  9 +
 clang/lib/AST/MicrosoftMangle.cpp |  6 ++
 clang/lib/AST/NSAPI.cpp   |  3 +++
 clang/lib/AST/PrintfFormatString.cpp  |  4 
 clang/lib/AST/Type.cpp|  7 +++
 clang/lib/AST/TypeLoc.cpp |  3 +++
 clang/lib/Basic/TargetInfo.cpp|  5 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  7 +++
 clang/lib/CodeGen/CodeGenTypes.cpp|  8 
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  3 +++
 clang/lib/Index/USRGeneration.cpp |  6 ++
 clang/lib/Sema/SemaType.cpp   | 16 ++-
 clang/lib/Serialization/ASTCommon.cpp |  9 +
 clang/lib/Serialization/ASTReader.cpp |  9 +
 clang/test/Sema/types.c   |  4 +++-
 clang/tools/libclang/CIndex.cpp   |  1 +
 23 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 4ee32c76a95d8..f862456797b5f 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1098,6 +1098,8 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  // ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+  CanQualType DecimalFloat32Ty, DecimalFloat64Ty, DecimalFloat128Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index c04f6f6f12719..3a0f78fb6a33f 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -44,6 +44,10 @@
 #define FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
 
+#ifndef DECIMAL_FLOATING_TYPE
+#define DECIMAL_FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
+#endif
+
 #ifndef PLACEHOLDER_TYPE
 #define PLACEHOLDER_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
@@ -221,6 +225,18 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+//===- Decimal floating point types 
---===//
+// ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+
+// '_Decimal32'
+DECIMAL_FLOATING_TYPE(DecimalFloat32, DecimalFloat32Ty)
+
+// '_Decimal64'
+DECIMAL_FLOATING_TYPE(DecimalFloat64, DecimalFloat64Ty)
+
+// '_Decimal128'
+DECIMAL_FLOATING_TYPE(DecimalFloat128, DecimalFloat128Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
@@ -336,6 +352,7 @@ LAST_BUILTIN_TYPE(OMPIterator)
 #undef SHARED_SINGLETON_TYPE
 #undef PLACEHOLDER_TYPE
 #undef FLOATING_TYPE
+#undef DECIMAL_FLOATING_TYPE
 #undef SIGNED_TYPE
 #undef UNSIGNED_TYPE
 #undef BUILTIN_TYPE
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 61be52149341f..ddf166c971fec 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -95,6 +95,11 @@ struct TransferrableTargetInfo {
   unsigned char LongLongWidth, LongLongAlign;
   unsigned char Int128Align;
 
+  // Decimal floating-point bit widths and alignment.
+  unsigned char DecimalFloat32Width, DecimalFloat32Align;
+  unsigned char DecimalFloat64Width, DecimalFloat64Align;
+  unsigned char DecimalFloat128Width, DecimalFloat128Align;
+
   // Fixed point bit widths
   unsigned char ShortAcc

[clang] [llvm] Irdl2 (PR #74596)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/74596

None

>From 707f1625a626faae14b8e24f7e3cf10a2ed621ce Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Sun, 24 Sep 2023 22:38:01 -0400
Subject: [PATCH 1/6] [clang][DFP] Add basic builtin type representation for
 decimal floating point types.

This change adds basic type representation support for the decimal
floating point types defined by ISO/IEC TS 18661-2 and adopted for C23.
These types will also serve as the underlying native types for the
library types defined by ISO/IEC TR 24733 and as implemented in
libstdcxx. This change does not include representation support in
LLVM IR, in debugging information, or in C++ mangling for the MS ABI;
such support will be added in later patches.
---
 clang/include/clang/AST/ASTContext.h  |  2 ++
 clang/include/clang/AST/BuiltinTypes.def  | 17 
 clang/include/clang/Basic/TargetInfo.h| 17 
 clang/include/clang/Basic/TokenKinds.def  |  4 +++-
 .../include/clang/Serialization/ASTBitCodes.h |  9 +
 clang/lib/AST/ASTContext.cpp  | 20 +++
 clang/lib/AST/ExprConstant.cpp|  2 ++
 clang/lib/AST/ItaniumMangle.cpp   |  9 +
 clang/lib/AST/MicrosoftMangle.cpp |  6 ++
 clang/lib/AST/NSAPI.cpp   |  3 +++
 clang/lib/AST/PrintfFormatString.cpp  |  4 
 clang/lib/AST/Type.cpp|  7 +++
 clang/lib/AST/TypeLoc.cpp |  3 +++
 clang/lib/Basic/TargetInfo.cpp|  5 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  7 +++
 clang/lib/CodeGen/CodeGenTypes.cpp|  8 
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  3 +++
 clang/lib/Index/USRGeneration.cpp |  6 ++
 clang/lib/Sema/SemaType.cpp   | 16 ++-
 clang/lib/Serialization/ASTCommon.cpp |  9 +
 clang/lib/Serialization/ASTReader.cpp |  9 +
 clang/test/Sema/types.c   |  4 +++-
 clang/tools/libclang/CIndex.cpp   |  1 +
 23 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 4ee32c76a95d8..f862456797b5f 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1098,6 +1098,8 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  // ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+  CanQualType DecimalFloat32Ty, DecimalFloat64Ty, DecimalFloat128Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index c04f6f6f12719..3a0f78fb6a33f 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -44,6 +44,10 @@
 #define FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
 
+#ifndef DECIMAL_FLOATING_TYPE
+#define DECIMAL_FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
+#endif
+
 #ifndef PLACEHOLDER_TYPE
 #define PLACEHOLDER_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
@@ -221,6 +225,18 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+//===- Decimal floating point types 
---===//
+// ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+
+// '_Decimal32'
+DECIMAL_FLOATING_TYPE(DecimalFloat32, DecimalFloat32Ty)
+
+// '_Decimal64'
+DECIMAL_FLOATING_TYPE(DecimalFloat64, DecimalFloat64Ty)
+
+// '_Decimal128'
+DECIMAL_FLOATING_TYPE(DecimalFloat128, DecimalFloat128Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
@@ -336,6 +352,7 @@ LAST_BUILTIN_TYPE(OMPIterator)
 #undef SHARED_SINGLETON_TYPE
 #undef PLACEHOLDER_TYPE
 #undef FLOATING_TYPE
+#undef DECIMAL_FLOATING_TYPE
 #undef SIGNED_TYPE
 #undef UNSIGNED_TYPE
 #undef BUILTIN_TYPE
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 61be52149341f..ddf166c971fec 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -95,6 +95,11 @@ struct TransferrableTargetInfo {
   unsigned char LongLongWidth, LongLongAlign;
   unsigned char Int128Align;
 
+  // Decimal floating-point bit widths and alignment.
+  unsigned char DecimalFloat32Width, DecimalFloat32Align;
+  unsigned char DecimalFloat64Width, DecimalFloat64Align;
+  unsigned char DecimalFloat128Width, DecimalFloat128Align;
+
   // Fixed point bit widths
   unsigned char ShortAcc

[llvm] [clang] Irdl2 (PR #74596)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [llvm] Irdl2 (PR #74597)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/74597

None

>From 707f1625a626faae14b8e24f7e3cf10a2ed621ce Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Sun, 24 Sep 2023 22:38:01 -0400
Subject: [PATCH 1/6] [clang][DFP] Add basic builtin type representation for
 decimal floating point types.

This change adds basic type representation support for the decimal
floating point types defined by ISO/IEC TS 18661-2 and adopted for C23.
These types will also serve as the underlying native types for the
library types defined by ISO/IEC TR 24733 and as implemented in
libstdcxx. This change does not include representation support in
LLVM IR, in debugging information, or in C++ mangling for the MS ABI;
such support will be added in later patches.
---
 clang/include/clang/AST/ASTContext.h  |  2 ++
 clang/include/clang/AST/BuiltinTypes.def  | 17 
 clang/include/clang/Basic/TargetInfo.h| 17 
 clang/include/clang/Basic/TokenKinds.def  |  4 +++-
 .../include/clang/Serialization/ASTBitCodes.h |  9 +
 clang/lib/AST/ASTContext.cpp  | 20 +++
 clang/lib/AST/ExprConstant.cpp|  2 ++
 clang/lib/AST/ItaniumMangle.cpp   |  9 +
 clang/lib/AST/MicrosoftMangle.cpp |  6 ++
 clang/lib/AST/NSAPI.cpp   |  3 +++
 clang/lib/AST/PrintfFormatString.cpp  |  4 
 clang/lib/AST/Type.cpp|  7 +++
 clang/lib/AST/TypeLoc.cpp |  3 +++
 clang/lib/Basic/TargetInfo.cpp|  5 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  7 +++
 clang/lib/CodeGen/CodeGenTypes.cpp|  8 
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  3 +++
 clang/lib/Index/USRGeneration.cpp |  6 ++
 clang/lib/Sema/SemaType.cpp   | 16 ++-
 clang/lib/Serialization/ASTCommon.cpp |  9 +
 clang/lib/Serialization/ASTReader.cpp |  9 +
 clang/test/Sema/types.c   |  4 +++-
 clang/tools/libclang/CIndex.cpp   |  1 +
 23 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 4ee32c76a95d8..f862456797b5f 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1098,6 +1098,8 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  // ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+  CanQualType DecimalFloat32Ty, DecimalFloat64Ty, DecimalFloat128Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index c04f6f6f12719..3a0f78fb6a33f 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -44,6 +44,10 @@
 #define FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
 
+#ifndef DECIMAL_FLOATING_TYPE
+#define DECIMAL_FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
+#endif
+
 #ifndef PLACEHOLDER_TYPE
 #define PLACEHOLDER_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
@@ -221,6 +225,18 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+//===- Decimal floating point types 
---===//
+// ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+
+// '_Decimal32'
+DECIMAL_FLOATING_TYPE(DecimalFloat32, DecimalFloat32Ty)
+
+// '_Decimal64'
+DECIMAL_FLOATING_TYPE(DecimalFloat64, DecimalFloat64Ty)
+
+// '_Decimal128'
+DECIMAL_FLOATING_TYPE(DecimalFloat128, DecimalFloat128Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
@@ -336,6 +352,7 @@ LAST_BUILTIN_TYPE(OMPIterator)
 #undef SHARED_SINGLETON_TYPE
 #undef PLACEHOLDER_TYPE
 #undef FLOATING_TYPE
+#undef DECIMAL_FLOATING_TYPE
 #undef SIGNED_TYPE
 #undef UNSIGNED_TYPE
 #undef BUILTIN_TYPE
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 61be52149341f..ddf166c971fec 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -95,6 +95,11 @@ struct TransferrableTargetInfo {
   unsigned char LongLongWidth, LongLongAlign;
   unsigned char Int128Align;
 
+  // Decimal floating-point bit widths and alignment.
+  unsigned char DecimalFloat32Width, DecimalFloat32Align;
+  unsigned char DecimalFloat64Width, DecimalFloat64Align;
+  unsigned char DecimalFloat128Width, DecimalFloat128Align;
+
   // Fixed point bit widths
   unsigned char ShortAcc

[llvm] [clang] Irdl2 (PR #74597)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

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


[llvm] [clang] Test pr (PR #74599)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/74599

None

>From 707f1625a626faae14b8e24f7e3cf10a2ed621ce Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Sun, 24 Sep 2023 22:38:01 -0400
Subject: [PATCH 1/6] [clang][DFP] Add basic builtin type representation for
 decimal floating point types.

This change adds basic type representation support for the decimal
floating point types defined by ISO/IEC TS 18661-2 and adopted for C23.
These types will also serve as the underlying native types for the
library types defined by ISO/IEC TR 24733 and as implemented in
libstdcxx. This change does not include representation support in
LLVM IR, in debugging information, or in C++ mangling for the MS ABI;
such support will be added in later patches.
---
 clang/include/clang/AST/ASTContext.h  |  2 ++
 clang/include/clang/AST/BuiltinTypes.def  | 17 
 clang/include/clang/Basic/TargetInfo.h| 17 
 clang/include/clang/Basic/TokenKinds.def  |  4 +++-
 .../include/clang/Serialization/ASTBitCodes.h |  9 +
 clang/lib/AST/ASTContext.cpp  | 20 +++
 clang/lib/AST/ExprConstant.cpp|  2 ++
 clang/lib/AST/ItaniumMangle.cpp   |  9 +
 clang/lib/AST/MicrosoftMangle.cpp |  6 ++
 clang/lib/AST/NSAPI.cpp   |  3 +++
 clang/lib/AST/PrintfFormatString.cpp  |  4 
 clang/lib/AST/Type.cpp|  7 +++
 clang/lib/AST/TypeLoc.cpp |  3 +++
 clang/lib/Basic/TargetInfo.cpp|  5 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  7 +++
 clang/lib/CodeGen/CodeGenTypes.cpp|  8 
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  3 +++
 clang/lib/Index/USRGeneration.cpp |  6 ++
 clang/lib/Sema/SemaType.cpp   | 16 ++-
 clang/lib/Serialization/ASTCommon.cpp |  9 +
 clang/lib/Serialization/ASTReader.cpp |  9 +
 clang/test/Sema/types.c   |  4 +++-
 clang/tools/libclang/CIndex.cpp   |  1 +
 23 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 4ee32c76a95d8..f862456797b5f 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1098,6 +1098,8 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  // ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+  CanQualType DecimalFloat32Ty, DecimalFloat64Ty, DecimalFloat128Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index c04f6f6f12719..3a0f78fb6a33f 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -44,6 +44,10 @@
 #define FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
 
+#ifndef DECIMAL_FLOATING_TYPE
+#define DECIMAL_FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
+#endif
+
 #ifndef PLACEHOLDER_TYPE
 #define PLACEHOLDER_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
@@ -221,6 +225,18 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+//===- Decimal floating point types 
---===//
+// ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+
+// '_Decimal32'
+DECIMAL_FLOATING_TYPE(DecimalFloat32, DecimalFloat32Ty)
+
+// '_Decimal64'
+DECIMAL_FLOATING_TYPE(DecimalFloat64, DecimalFloat64Ty)
+
+// '_Decimal128'
+DECIMAL_FLOATING_TYPE(DecimalFloat128, DecimalFloat128Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
@@ -336,6 +352,7 @@ LAST_BUILTIN_TYPE(OMPIterator)
 #undef SHARED_SINGLETON_TYPE
 #undef PLACEHOLDER_TYPE
 #undef FLOATING_TYPE
+#undef DECIMAL_FLOATING_TYPE
 #undef SIGNED_TYPE
 #undef UNSIGNED_TYPE
 #undef BUILTIN_TYPE
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 61be52149341f..ddf166c971fec 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -95,6 +95,11 @@ struct TransferrableTargetInfo {
   unsigned char LongLongWidth, LongLongAlign;
   unsigned char Int128Align;
 
+  // Decimal floating-point bit widths and alignment.
+  unsigned char DecimalFloat32Width, DecimalFloat32Align;
+  unsigned char DecimalFloat64Width, DecimalFloat64Align;
+  unsigned char DecimalFloat128Width, DecimalFloat128Align;
+
   // Fixed point bit widths
   unsigned char ShortAcc

[llvm] [clang] Test pr (PR #74599)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [llvm] Dfp (PR #74604)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/74604

None

>From 707f1625a626faae14b8e24f7e3cf10a2ed621ce Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Sun, 24 Sep 2023 22:38:01 -0400
Subject: [PATCH 1/5] [clang][DFP] Add basic builtin type representation for
 decimal floating point types.

This change adds basic type representation support for the decimal
floating point types defined by ISO/IEC TS 18661-2 and adopted for C23.
These types will also serve as the underlying native types for the
library types defined by ISO/IEC TR 24733 and as implemented in
libstdcxx. This change does not include representation support in
LLVM IR, in debugging information, or in C++ mangling for the MS ABI;
such support will be added in later patches.
---
 clang/include/clang/AST/ASTContext.h  |  2 ++
 clang/include/clang/AST/BuiltinTypes.def  | 17 
 clang/include/clang/Basic/TargetInfo.h| 17 
 clang/include/clang/Basic/TokenKinds.def  |  4 +++-
 .../include/clang/Serialization/ASTBitCodes.h |  9 +
 clang/lib/AST/ASTContext.cpp  | 20 +++
 clang/lib/AST/ExprConstant.cpp|  2 ++
 clang/lib/AST/ItaniumMangle.cpp   |  9 +
 clang/lib/AST/MicrosoftMangle.cpp |  6 ++
 clang/lib/AST/NSAPI.cpp   |  3 +++
 clang/lib/AST/PrintfFormatString.cpp  |  4 
 clang/lib/AST/Type.cpp|  7 +++
 clang/lib/AST/TypeLoc.cpp |  3 +++
 clang/lib/Basic/TargetInfo.cpp|  5 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  7 +++
 clang/lib/CodeGen/CodeGenTypes.cpp|  8 
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  3 +++
 clang/lib/Index/USRGeneration.cpp |  6 ++
 clang/lib/Sema/SemaType.cpp   | 16 ++-
 clang/lib/Serialization/ASTCommon.cpp |  9 +
 clang/lib/Serialization/ASTReader.cpp |  9 +
 clang/test/Sema/types.c   |  4 +++-
 clang/tools/libclang/CIndex.cpp   |  1 +
 23 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 4ee32c76a95d8..f862456797b5f 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1098,6 +1098,8 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  // ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+  CanQualType DecimalFloat32Ty, DecimalFloat64Ty, DecimalFloat128Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index c04f6f6f12719..3a0f78fb6a33f 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -44,6 +44,10 @@
 #define FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
 
+#ifndef DECIMAL_FLOATING_TYPE
+#define DECIMAL_FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
+#endif
+
 #ifndef PLACEHOLDER_TYPE
 #define PLACEHOLDER_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
@@ -221,6 +225,18 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+//===- Decimal floating point types 
---===//
+// ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+
+// '_Decimal32'
+DECIMAL_FLOATING_TYPE(DecimalFloat32, DecimalFloat32Ty)
+
+// '_Decimal64'
+DECIMAL_FLOATING_TYPE(DecimalFloat64, DecimalFloat64Ty)
+
+// '_Decimal128'
+DECIMAL_FLOATING_TYPE(DecimalFloat128, DecimalFloat128Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
@@ -336,6 +352,7 @@ LAST_BUILTIN_TYPE(OMPIterator)
 #undef SHARED_SINGLETON_TYPE
 #undef PLACEHOLDER_TYPE
 #undef FLOATING_TYPE
+#undef DECIMAL_FLOATING_TYPE
 #undef SIGNED_TYPE
 #undef UNSIGNED_TYPE
 #undef BUILTIN_TYPE
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 61be52149341f..ddf166c971fec 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -95,6 +95,11 @@ struct TransferrableTargetInfo {
   unsigned char LongLongWidth, LongLongAlign;
   unsigned char Int128Align;
 
+  // Decimal floating-point bit widths and alignment.
+  unsigned char DecimalFloat32Width, DecimalFloat32Align;
+  unsigned char DecimalFloat64Width, DecimalFloat64Align;
+  unsigned char DecimalFloat128Width, DecimalFloat128Align;
+
   // Fixed point bit widths
   unsigned char ShortAcc

[clang] [llvm] Dfp (PR #74604)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [llvm] Dfp (PR #74606)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/74606

None

>From 707f1625a626faae14b8e24f7e3cf10a2ed621ce Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Sun, 24 Sep 2023 22:38:01 -0400
Subject: [PATCH 1/5] [clang][DFP] Add basic builtin type representation for
 decimal floating point types.

This change adds basic type representation support for the decimal
floating point types defined by ISO/IEC TS 18661-2 and adopted for C23.
These types will also serve as the underlying native types for the
library types defined by ISO/IEC TR 24733 and as implemented in
libstdcxx. This change does not include representation support in
LLVM IR, in debugging information, or in C++ mangling for the MS ABI;
such support will be added in later patches.
---
 clang/include/clang/AST/ASTContext.h  |  2 ++
 clang/include/clang/AST/BuiltinTypes.def  | 17 
 clang/include/clang/Basic/TargetInfo.h| 17 
 clang/include/clang/Basic/TokenKinds.def  |  4 +++-
 .../include/clang/Serialization/ASTBitCodes.h |  9 +
 clang/lib/AST/ASTContext.cpp  | 20 +++
 clang/lib/AST/ExprConstant.cpp|  2 ++
 clang/lib/AST/ItaniumMangle.cpp   |  9 +
 clang/lib/AST/MicrosoftMangle.cpp |  6 ++
 clang/lib/AST/NSAPI.cpp   |  3 +++
 clang/lib/AST/PrintfFormatString.cpp  |  4 
 clang/lib/AST/Type.cpp|  7 +++
 clang/lib/AST/TypeLoc.cpp |  3 +++
 clang/lib/Basic/TargetInfo.cpp|  5 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  7 +++
 clang/lib/CodeGen/CodeGenTypes.cpp|  8 
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  3 +++
 clang/lib/Index/USRGeneration.cpp |  6 ++
 clang/lib/Sema/SemaType.cpp   | 16 ++-
 clang/lib/Serialization/ASTCommon.cpp |  9 +
 clang/lib/Serialization/ASTReader.cpp |  9 +
 clang/test/Sema/types.c   |  4 +++-
 clang/tools/libclang/CIndex.cpp   |  1 +
 23 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 4ee32c76a95d8..f862456797b5f 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1098,6 +1098,8 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  // ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+  CanQualType DecimalFloat32Ty, DecimalFloat64Ty, DecimalFloat128Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index c04f6f6f12719..3a0f78fb6a33f 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -44,6 +44,10 @@
 #define FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
 
+#ifndef DECIMAL_FLOATING_TYPE
+#define DECIMAL_FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
+#endif
+
 #ifndef PLACEHOLDER_TYPE
 #define PLACEHOLDER_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
@@ -221,6 +225,18 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+//===- Decimal floating point types 
---===//
+// ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+
+// '_Decimal32'
+DECIMAL_FLOATING_TYPE(DecimalFloat32, DecimalFloat32Ty)
+
+// '_Decimal64'
+DECIMAL_FLOATING_TYPE(DecimalFloat64, DecimalFloat64Ty)
+
+// '_Decimal128'
+DECIMAL_FLOATING_TYPE(DecimalFloat128, DecimalFloat128Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
@@ -336,6 +352,7 @@ LAST_BUILTIN_TYPE(OMPIterator)
 #undef SHARED_SINGLETON_TYPE
 #undef PLACEHOLDER_TYPE
 #undef FLOATING_TYPE
+#undef DECIMAL_FLOATING_TYPE
 #undef SIGNED_TYPE
 #undef UNSIGNED_TYPE
 #undef BUILTIN_TYPE
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 61be52149341f..ddf166c971fec 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -95,6 +95,11 @@ struct TransferrableTargetInfo {
   unsigned char LongLongWidth, LongLongAlign;
   unsigned char Int128Align;
 
+  // Decimal floating-point bit widths and alignment.
+  unsigned char DecimalFloat32Width, DecimalFloat32Align;
+  unsigned char DecimalFloat64Width, DecimalFloat64Align;
+  unsigned char DecimalFloat128Width, DecimalFloat128Align;
+
   // Fixed point bit widths
   unsigned char ShortAcc

[clang] [llvm] Dfp (PR #74606)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

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


[llvm] [clang] Dlbr (PR #74618)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/74618

None

>From 707f1625a626faae14b8e24f7e3cf10a2ed621ce Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Sun, 24 Sep 2023 22:38:01 -0400
Subject: [PATCH 1/6] [clang][DFP] Add basic builtin type representation for
 decimal floating point types.

This change adds basic type representation support for the decimal
floating point types defined by ISO/IEC TS 18661-2 and adopted for C23.
These types will also serve as the underlying native types for the
library types defined by ISO/IEC TR 24733 and as implemented in
libstdcxx. This change does not include representation support in
LLVM IR, in debugging information, or in C++ mangling for the MS ABI;
such support will be added in later patches.
---
 clang/include/clang/AST/ASTContext.h  |  2 ++
 clang/include/clang/AST/BuiltinTypes.def  | 17 
 clang/include/clang/Basic/TargetInfo.h| 17 
 clang/include/clang/Basic/TokenKinds.def  |  4 +++-
 .../include/clang/Serialization/ASTBitCodes.h |  9 +
 clang/lib/AST/ASTContext.cpp  | 20 +++
 clang/lib/AST/ExprConstant.cpp|  2 ++
 clang/lib/AST/ItaniumMangle.cpp   |  9 +
 clang/lib/AST/MicrosoftMangle.cpp |  6 ++
 clang/lib/AST/NSAPI.cpp   |  3 +++
 clang/lib/AST/PrintfFormatString.cpp  |  4 
 clang/lib/AST/Type.cpp|  7 +++
 clang/lib/AST/TypeLoc.cpp |  3 +++
 clang/lib/Basic/TargetInfo.cpp|  5 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  7 +++
 clang/lib/CodeGen/CodeGenTypes.cpp|  8 
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  3 +++
 clang/lib/Index/USRGeneration.cpp |  6 ++
 clang/lib/Sema/SemaType.cpp   | 16 ++-
 clang/lib/Serialization/ASTCommon.cpp |  9 +
 clang/lib/Serialization/ASTReader.cpp |  9 +
 clang/test/Sema/types.c   |  4 +++-
 clang/tools/libclang/CIndex.cpp   |  1 +
 23 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 4ee32c76a95d8..f862456797b5f 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1098,6 +1098,8 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  // ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+  CanQualType DecimalFloat32Ty, DecimalFloat64Ty, DecimalFloat128Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index c04f6f6f12719..3a0f78fb6a33f 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -44,6 +44,10 @@
 #define FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
 
+#ifndef DECIMAL_FLOATING_TYPE
+#define DECIMAL_FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
+#endif
+
 #ifndef PLACEHOLDER_TYPE
 #define PLACEHOLDER_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
@@ -221,6 +225,18 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+//===- Decimal floating point types 
---===//
+// ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+
+// '_Decimal32'
+DECIMAL_FLOATING_TYPE(DecimalFloat32, DecimalFloat32Ty)
+
+// '_Decimal64'
+DECIMAL_FLOATING_TYPE(DecimalFloat64, DecimalFloat64Ty)
+
+// '_Decimal128'
+DECIMAL_FLOATING_TYPE(DecimalFloat128, DecimalFloat128Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
@@ -336,6 +352,7 @@ LAST_BUILTIN_TYPE(OMPIterator)
 #undef SHARED_SINGLETON_TYPE
 #undef PLACEHOLDER_TYPE
 #undef FLOATING_TYPE
+#undef DECIMAL_FLOATING_TYPE
 #undef SIGNED_TYPE
 #undef UNSIGNED_TYPE
 #undef BUILTIN_TYPE
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 61be52149341f..ddf166c971fec 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -95,6 +95,11 @@ struct TransferrableTargetInfo {
   unsigned char LongLongWidth, LongLongAlign;
   unsigned char Int128Align;
 
+  // Decimal floating-point bit widths and alignment.
+  unsigned char DecimalFloat32Width, DecimalFloat32Align;
+  unsigned char DecimalFloat64Width, DecimalFloat64Align;
+  unsigned char DecimalFloat128Width, DecimalFloat128Align;
+
   // Fixed point bit widths
   unsigned char ShortAcc

[llvm] [clang] Dlbr (PR #74618)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [llvm] Dlpr2 (PR #74619)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/74619

None

>From 707f1625a626faae14b8e24f7e3cf10a2ed621ce Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Sun, 24 Sep 2023 22:38:01 -0400
Subject: [PATCH 1/5] [clang][DFP] Add basic builtin type representation for
 decimal floating point types.

This change adds basic type representation support for the decimal
floating point types defined by ISO/IEC TS 18661-2 and adopted for C23.
These types will also serve as the underlying native types for the
library types defined by ISO/IEC TR 24733 and as implemented in
libstdcxx. This change does not include representation support in
LLVM IR, in debugging information, or in C++ mangling for the MS ABI;
such support will be added in later patches.
---
 clang/include/clang/AST/ASTContext.h  |  2 ++
 clang/include/clang/AST/BuiltinTypes.def  | 17 
 clang/include/clang/Basic/TargetInfo.h| 17 
 clang/include/clang/Basic/TokenKinds.def  |  4 +++-
 .../include/clang/Serialization/ASTBitCodes.h |  9 +
 clang/lib/AST/ASTContext.cpp  | 20 +++
 clang/lib/AST/ExprConstant.cpp|  2 ++
 clang/lib/AST/ItaniumMangle.cpp   |  9 +
 clang/lib/AST/MicrosoftMangle.cpp |  6 ++
 clang/lib/AST/NSAPI.cpp   |  3 +++
 clang/lib/AST/PrintfFormatString.cpp  |  4 
 clang/lib/AST/Type.cpp|  7 +++
 clang/lib/AST/TypeLoc.cpp |  3 +++
 clang/lib/Basic/TargetInfo.cpp|  5 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  7 +++
 clang/lib/CodeGen/CodeGenTypes.cpp|  8 
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  3 +++
 clang/lib/Index/USRGeneration.cpp |  6 ++
 clang/lib/Sema/SemaType.cpp   | 16 ++-
 clang/lib/Serialization/ASTCommon.cpp |  9 +
 clang/lib/Serialization/ASTReader.cpp |  9 +
 clang/test/Sema/types.c   |  4 +++-
 clang/tools/libclang/CIndex.cpp   |  1 +
 23 files changed, 168 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 4ee32c76a95d8..f862456797b5f 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1098,6 +1098,8 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  // ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+  CanQualType DecimalFloat32Ty, DecimalFloat64Ty, DecimalFloat128Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index c04f6f6f12719..3a0f78fb6a33f 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -44,6 +44,10 @@
 #define FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
 
+#ifndef DECIMAL_FLOATING_TYPE
+#define DECIMAL_FLOATING_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
+#endif
+
 #ifndef PLACEHOLDER_TYPE
 #define PLACEHOLDER_TYPE(Id, SingletonId) BUILTIN_TYPE(Id, SingletonId)
 #endif
@@ -221,6 +225,18 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+//===- Decimal floating point types 
---===//
+// ISO/IEC TS 18661-2, ISO/IEC TR 24733, and C23 decimal floating-point.
+
+// '_Decimal32'
+DECIMAL_FLOATING_TYPE(DecimalFloat32, DecimalFloat32Ty)
+
+// '_Decimal64'
+DECIMAL_FLOATING_TYPE(DecimalFloat64, DecimalFloat64Ty)
+
+// '_Decimal128'
+DECIMAL_FLOATING_TYPE(DecimalFloat128, DecimalFloat128Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
@@ -336,6 +352,7 @@ LAST_BUILTIN_TYPE(OMPIterator)
 #undef SHARED_SINGLETON_TYPE
 #undef PLACEHOLDER_TYPE
 #undef FLOATING_TYPE
+#undef DECIMAL_FLOATING_TYPE
 #undef SIGNED_TYPE
 #undef UNSIGNED_TYPE
 #undef BUILTIN_TYPE
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 61be52149341f..ddf166c971fec 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -95,6 +95,11 @@ struct TransferrableTargetInfo {
   unsigned char LongLongWidth, LongLongAlign;
   unsigned char Int128Align;
 
+  // Decimal floating-point bit widths and alignment.
+  unsigned char DecimalFloat32Width, DecimalFloat32Align;
+  unsigned char DecimalFloat64Width, DecimalFloat64Align;
+  unsigned char DecimalFloat128Width, DecimalFloat128Align;
+
   // Fixed point bit widths
   unsigned char ShortAcc

[clang] [llvm] Dlpr2 (PR #74619)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [llvm] Irdl (PR #74589)

2023-12-06 Thread Zahira Ammarguellat via cfe-commits

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


[libunwind] [compiler-rt] [lldb] [flang] [clang] [lld] [clang-tools-extra] [libcxx] [libc] [llvm] Test pr (PR #71086)

2023-11-02 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/71086

None

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/4] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0d..3ce317d318f9bb6 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333a..ca883689b05c28a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUSh

[libunwind] [libcxx] [flang] [libc] [clang] [clang-tools-extra] [lld] [compiler-rt] [lldb] [llvm] Test branch (PR #70505)

2023-11-02 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/70505

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/5] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0d..3ce317d318f9bb6 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333a..ca883689b05c28a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortFra

[llvm] [libc] [libcxx] [lldb] [flang] [clang-tools-extra] [lld] [libunwind] [clang] [compiler-rt] Test pr (PR #71086)

2023-11-02 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/71086

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/5] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0d..3ce317d318f9bb6 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333a..ca883689b05c28a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortFra

[clang] clang: Add pragma clang fp reciprocal (PR #68267)

2023-11-03 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

> Just follow allow with the reassociate pragma.

What does that mean?

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


[clang] clang: Add pragma clang fp reciprocal (PR #68267)

2023-11-28 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

LGTM.

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


[clang] clang: Add pragma clang fp reciprocal (PR #68267)

2023-11-28 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam approved this pull request.


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


[llvm] [clang-tools-extra] [libcxx] [compiler-rt] [lld] [clang] [libc] [libunwind] [flang] [lldb] Warn inf nan fast fp (PR #76854)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/76854

None

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/4] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0..3ce317d318f9bb 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333..ca883689b05c28 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortF

[lldb] [libunwind] [lld] [libc] [libcxx] [clang-tools-extra] [compiler-rt] [flang] [clang] [llvm] [mlir] Warn inf nan fast fp (PR #76854)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/76854

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/4] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0..3ce317d318f9bb 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333..ca883689b05c28 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortFract:

[llvm] [clang-tools-extra] [libcxx] [compiler-rt] [lld] [clang] [libc] [libunwind] [flang] [lldb] [mlir] Test pr1 (PR #76856)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/76856

None

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/4] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0..3ce317d318f9bb 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333..ca883689b05c28 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortF

[llvm] [clang-tools-extra] [libcxx] [compiler-rt] [lld] [clang] [libc] [libunwind] [flang] [lldb] [mlir] Test pr1 (PR #76856)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

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


[llvm] [clang-tools-extra] [libcxx] [compiler-rt] [lld] [clang] [libc] [libunwind] [flang] [lldb] [mlir] Warn inf nan fast fp (PR #76854)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

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


[lldb] [libunwind] [lld] [libc] [libcxx] [clang-tools-extra] [compiler-rt] [flang] [clang] [llvm] [mlir] Test pr (PR #76859)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/76859

None

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/4] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0..3ce317d318f9bb 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333..ca883689b05c28 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortF

[lldb] [libunwind] [lld] [libc] [libcxx] [clang-tools-extra] [compiler-rt] [flang] [clang] [llvm] [mlir] Test pr (PR #76859)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [clang] Add support for -fcx-limited-range and #pragma CX_LIMITED_RANGE. (PR #68820)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

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


[clang-tools-extra] [llvm] [flang] [compiler-rt] [clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #67592)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Check for comparisons to INF and NaN when in ffast-math mode (PR #76862)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/76862

and generate a warning.

>From 55ee9ac2d36c1485573aa5e291e5867e8f1d5099 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Wed, 3 Jan 2024 12:41:44 -0800
Subject: [PATCH] Check for comparisons to INF and NaN when in ffast-math mode
 and generate a warning.

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e54f969c19039d..1b75ae8f678b68 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6771,6 +6771,9 @@ def warn_pointer_sub_null_ptr : Warning<
 def warn_floatingpoint_eq : Warning<
   "comparing floating point with == or != is unsafe">,
   InGroup>, DefaultIgnore;
+def warn_fast_floatingpoint_eq : Warning<
+  "explicit comparison with %0 in fast floating point mode">,
+  InGroup;
 
 def err_setting_eval_method_used_in_unsafe_context : Error <
   "%select{'#pragma clang fp eval_method'|option 'ffp-eval-method'}0 cannot be 
used with "

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


[clang] Check for comparisons to INF and NaN when in ffast-math mode (PR #76862)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/76862

>From 55ee9ac2d36c1485573aa5e291e5867e8f1d5099 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Wed, 3 Jan 2024 12:41:44 -0800
Subject: [PATCH 1/2] Check for comparisons to INF and NaN when in ffast-math
 mode and generate a warning.

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e54f969c19039d..1b75ae8f678b68 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6771,6 +6771,9 @@ def warn_pointer_sub_null_ptr : Warning<
 def warn_floatingpoint_eq : Warning<
   "comparing floating point with == or != is unsafe">,
   InGroup>, DefaultIgnore;
+def warn_fast_floatingpoint_eq : Warning<
+  "explicit comparison with %0 in fast floating point mode">,
+  InGroup;
 
 def err_setting_eval_method_used_in_unsafe_context : Error <
   "%select{'#pragma clang fp eval_method'|option 'ffp-eval-method'}0 cannot be 
used with "

>From 230922cf23716ba9d1c2d532c986c86350619740 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Wed, 3 Jan 2024 12:41:44 -0800
Subject: [PATCH 2/2] Check for comparisons to INF and NaN when in ffast-math
 mode and generate a warning.

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 +++
 clang/include/clang/Sema/Sema.h  | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e54f969c19039d..1b75ae8f678b68 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6771,6 +6771,9 @@ def warn_pointer_sub_null_ptr : Warning<
 def warn_floatingpoint_eq : Warning<
   "comparing floating point with == or != is unsafe">,
   InGroup>, DefaultIgnore;
+def warn_fast_floatingpoint_eq : Warning<
+  "explicit comparison with %0 in fast floating point mode">,
+  InGroup;
 
 def err_setting_eval_method_used_in_unsafe_context : Error <
   "%select{'#pragma clang fp eval_method'|option 'ffp-eval-method'}0 cannot be 
used with "
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5e3b57ea33220b..235308a8034e9a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13998,6 +13998,8 @@ class Sema final {
 SourceRange range,
 llvm::SmallBitVector &CheckedVarArgs);
 
+  void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
+
   void CheckAbsoluteValueFunction(const CallExpr *Call,
   const FunctionDecl *FDecl);
 

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


[clang] Check for comparisons to INF and NaN when in ffast-math mode (PR #76862)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Add warning when comparing to INF or NAN in fast math mode. (PR #76873)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/76873

None

>From 7dbaf037b6b2196cee7c0c837e0a89ce3c2556ed Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Wed, 3 Jan 2024 14:37:17 -0800
Subject: [PATCH] [CLANG] Add warning when comparing to INF or NAN in fast math
 mode.

---
 .../clang/Basic/DiagnosticSemaKinds.td|   3 +
 clang/include/clang/Sema/Sema.h   |   4 +
 clang/lib/Sema/SemaChecking.cpp   |  65 +++
 clang/lib/Sema/SemaExpr.cpp   |   7 +-
 clang/test/Sema/warn-fp-fast-compare.cpp  | 171 ++
 5 files changed, 248 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Sema/warn-fp-fast-compare.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e54f969c19039d..1b75ae8f678b68 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6771,6 +6771,9 @@ def warn_pointer_sub_null_ptr : Warning<
 def warn_floatingpoint_eq : Warning<
   "comparing floating point with == or != is unsafe">,
   InGroup>, DefaultIgnore;
+def warn_fast_floatingpoint_eq : Warning<
+  "explicit comparison with %0 in fast floating point mode">,
+  InGroup;
 
 def err_setting_eval_method_used_in_unsafe_context : Error <
   "%select{'#pragma clang fp eval_method'|option 'ffp-eval-method'}0 cannot be 
used with "
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5e3b57ea33220b..6125e7ebb6b48a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13998,6 +13998,8 @@ class Sema final {
 SourceRange range,
 llvm::SmallBitVector &CheckedVarArgs);
 
+  void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
+
   void CheckAbsoluteValueFunction(const CallExpr *Call,
   const FunctionDecl *FDecl);
 
@@ -14024,6 +14026,8 @@ class Sema final {
 public:
   void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
 BinaryOperatorKind Opcode);
+  void CheckInfNaNFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
+  BinaryOperatorKind Opcode);
 
 private:
   void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 3168d38dd66c36..2e9f61f40b795b 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2169,6 +2169,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 ICEArguments &= ~(1 << ArgNo);
   }
 
+  FPOptions FPO;
   switch (BuiltinID) {
   case Builtin::BI__builtin___CFStringMakeConstantString:
 // CFStringMakeConstantString is currently not implemented for GOFF (i.e.,
@@ -2245,6 +2246,11 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI__builtin_islessequal:
   case Builtin::BI__builtin_islessgreater:
   case Builtin::BI__builtin_isunordered:
+if (BuiltinID == Builtin::BI__builtin_isunordered) {
+  if (TheCall->getFPFeaturesInEffect(getLangOpts()).getNoHonorNaNs())
+Diag(TheCall->getBeginLoc(), diag::warn_fast_floatingpoint_eq)
+<< "NaN" << TheCall->getSourceRange();
+}
 if (SemaBuiltinUnorderedCompare(TheCall))
   return ExprError();
 break;
@@ -2267,6 +2273,16 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI__builtin_signbit:
   case Builtin::BI__builtin_signbitf:
   case Builtin::BI__builtin_signbitl:
+FPO = TheCall->getFPFeaturesInEffect(getLangOpts());
+if (FPO.getNoHonorInfs() && (BuiltinID == Builtin::BI__builtin_isfinite ||
+ BuiltinID == Builtin::BI__builtin_isinf ||
+ BuiltinID == Builtin::BI__builtin_isinf_sign))
+  Diag(TheCall->getBeginLoc(), diag::warn_fast_floatingpoint_eq)
+  << "infinity" << TheCall->getSourceRange();
+if (FPO.getNoHonorNaNs() && (BuiltinID == Builtin::BI__builtin_isnan ||
+ BuiltinID == 
Builtin::BI__builtin_isunordered))
+  Diag(TheCall->getBeginLoc(), diag::warn_fast_floatingpoint_eq)
+  << "NaN" << TheCall->getSourceRange();
 if (SemaBuiltinFPClassification(TheCall, 1))
   return ExprError();
 break;
@@ -7621,6 +7637,7 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, 
CallExpr *TheCall,
 
   CheckAbsoluteValueFunction(TheCall, FDecl);
   CheckMaxUnsignedZero(TheCall, FDecl);
+  CheckInfNaNFunction(TheCall, FDecl);
 
   if (getLangOpts().ObjC)
 DiagnoseCStringFormatDirectiveInCFAPI(*this, FDecl, Args, NumArgs);
@@ -12878,6 +12895,23 @@ static bool IsStdFunction(const FunctionDecl *FDecl,
   return true;
 }
 
+void Sema::CheckInfNaNFunction(const CallExpr *Call,

[clang] [CLANG] Add warning when comparing to INF or NAN in fast math mode. (PR #76873)

2024-01-03 Thread Zahira Ammarguellat via cfe-commits

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


[compiler-rt] [clang] [flang] [llvm] [clang-tools-extra] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #67592)

2024-01-04 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Add warning when comparing to INF or NAN in fast math mode. (PR #76873)

2024-01-05 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/76873

>From 7dbaf037b6b2196cee7c0c837e0a89ce3c2556ed Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Wed, 3 Jan 2024 14:37:17 -0800
Subject: [PATCH 1/2] [CLANG] Add warning when comparing to INF or NAN in fast
 math mode.

---
 .../clang/Basic/DiagnosticSemaKinds.td|   3 +
 clang/include/clang/Sema/Sema.h   |   4 +
 clang/lib/Sema/SemaChecking.cpp   |  65 +++
 clang/lib/Sema/SemaExpr.cpp   |   7 +-
 clang/test/Sema/warn-fp-fast-compare.cpp  | 171 ++
 5 files changed, 248 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Sema/warn-fp-fast-compare.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e54f969c19039d..1b75ae8f678b68 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6771,6 +6771,9 @@ def warn_pointer_sub_null_ptr : Warning<
 def warn_floatingpoint_eq : Warning<
   "comparing floating point with == or != is unsafe">,
   InGroup>, DefaultIgnore;
+def warn_fast_floatingpoint_eq : Warning<
+  "explicit comparison with %0 in fast floating point mode">,
+  InGroup;
 
 def err_setting_eval_method_used_in_unsafe_context : Error <
   "%select{'#pragma clang fp eval_method'|option 'ffp-eval-method'}0 cannot be 
used with "
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5e3b57ea33220b..6125e7ebb6b48a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13998,6 +13998,8 @@ class Sema final {
 SourceRange range,
 llvm::SmallBitVector &CheckedVarArgs);
 
+  void CheckInfNaNFunction(const CallExpr *Call, const FunctionDecl *FDecl);
+
   void CheckAbsoluteValueFunction(const CallExpr *Call,
   const FunctionDecl *FDecl);
 
@@ -14024,6 +14026,8 @@ class Sema final {
 public:
   void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
 BinaryOperatorKind Opcode);
+  void CheckInfNaNFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
+  BinaryOperatorKind Opcode);
 
 private:
   void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 3168d38dd66c36..2e9f61f40b795b 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2169,6 +2169,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 ICEArguments &= ~(1 << ArgNo);
   }
 
+  FPOptions FPO;
   switch (BuiltinID) {
   case Builtin::BI__builtin___CFStringMakeConstantString:
 // CFStringMakeConstantString is currently not implemented for GOFF (i.e.,
@@ -2245,6 +2246,11 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI__builtin_islessequal:
   case Builtin::BI__builtin_islessgreater:
   case Builtin::BI__builtin_isunordered:
+if (BuiltinID == Builtin::BI__builtin_isunordered) {
+  if (TheCall->getFPFeaturesInEffect(getLangOpts()).getNoHonorNaNs())
+Diag(TheCall->getBeginLoc(), diag::warn_fast_floatingpoint_eq)
+<< "NaN" << TheCall->getSourceRange();
+}
 if (SemaBuiltinUnorderedCompare(TheCall))
   return ExprError();
 break;
@@ -2267,6 +2273,16 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI__builtin_signbit:
   case Builtin::BI__builtin_signbitf:
   case Builtin::BI__builtin_signbitl:
+FPO = TheCall->getFPFeaturesInEffect(getLangOpts());
+if (FPO.getNoHonorInfs() && (BuiltinID == Builtin::BI__builtin_isfinite ||
+ BuiltinID == Builtin::BI__builtin_isinf ||
+ BuiltinID == Builtin::BI__builtin_isinf_sign))
+  Diag(TheCall->getBeginLoc(), diag::warn_fast_floatingpoint_eq)
+  << "infinity" << TheCall->getSourceRange();
+if (FPO.getNoHonorNaNs() && (BuiltinID == Builtin::BI__builtin_isnan ||
+ BuiltinID == 
Builtin::BI__builtin_isunordered))
+  Diag(TheCall->getBeginLoc(), diag::warn_fast_floatingpoint_eq)
+  << "NaN" << TheCall->getSourceRange();
 if (SemaBuiltinFPClassification(TheCall, 1))
   return ExprError();
 break;
@@ -7621,6 +7637,7 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, 
CallExpr *TheCall,
 
   CheckAbsoluteValueFunction(TheCall, FDecl);
   CheckMaxUnsignedZero(TheCall, FDecl);
+  CheckInfNaNFunction(TheCall, FDecl);
 
   if (getLangOpts().ObjC)
 DiagnoseCStringFormatDirectiveInCFAPI(*this, FDecl, Args, NumArgs);
@@ -12878,6 +12895,23 @@ static bool IsStdFunction(const FunctionDecl *FDecl,
   return true;
 }
 
+void Sema::CheckInfNaNFunction(const CallExpr *Call,
+

[clang] [CLANG] Add warning when comparing to INF or NAN in fast math mode. (PR #76873)

2024-01-05 Thread Zahira Ammarguellat via cfe-commits


@@ -2267,6 +2273,16 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI__builtin_signbit:
   case Builtin::BI__builtin_signbitf:
   case Builtin::BI__builtin_signbitl:
+FPO = TheCall->getFPFeaturesInEffect(getLangOpts());

zahiraam wrote:

Done.

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


[clang] [CLANG] Add warning when comparing to INF or NAN in fast math mode. (PR #76873)

2024-01-05 Thread Zahira Ammarguellat via cfe-commits


@@ -13846,6 +13880,37 @@ Sema::CheckReturnValExpr(Expr *RetValExp, QualType 
lhsType,
 CheckPPCMMAType(RetValExp->getType(), ReturnLoc);
 }
 
+/// Diagnose comparison to NAN or INFINITY in fast math modes.
+/// The comparison to NaN or INFINITY is always false in
+/// fast modes: float evaluation will not result in inf or nan.
+void Sema::CheckInfNaNFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,

zahiraam wrote:

It's 79 chars long.

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


[clang] [CLANG] Add warning when comparing to INF or NAN in fast math mode. (PR #76873)

2024-01-05 Thread Zahira Ammarguellat via cfe-commits


@@ -13846,6 +13880,37 @@ Sema::CheckReturnValExpr(Expr *RetValExp, QualType 
lhsType,
 CheckPPCMMAType(RetValExp->getType(), ReturnLoc);
 }
 
+/// Diagnose comparison to NAN or INFINITY in fast math modes.
+/// The comparison to NaN or INFINITY is always false in
+/// fast modes: float evaluation will not result in inf or nan.
+void Sema::CheckInfNaNFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
+  BinaryOperatorKind Opcode) {
+  Expr *LeftExprSansParen = LHS->IgnoreParenImpCasts();
+  Expr *RightExprSansParen = RHS->IgnoreParenImpCasts();
+
+  FPOptions FPO = LHS->getFPFeaturesInEffect(getLangOpts());
+  bool NoHonorNaNs = FPO.getNoHonorNaNs();
+  bool NoHonorInfs = FPO.getNoHonorInfs();
+  llvm::APFloat Value(0.0);
+  bool IsConstant;
+  IsConstant = !LHS->isValueDependent() &&

zahiraam wrote:

Done.

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


[clang] [CLANG] Add warning when comparing to INF or NAN in fast math mode. (PR #76873)

2024-01-05 Thread Zahira Ammarguellat via cfe-commits


@@ -13044,9 +13044,12 @@ static QualType checkArithmeticOrEnumeralCompare(Sema 
&S, ExprResult &LHS,
   if (Type->isAnyComplexType() && BinaryOperator::isRelationalOp(Opc))
 return S.InvalidOperands(Loc, LHS, RHS);
 
-  // Check for comparisons of floating point operands using != and ==.
-  if (Type->hasFloatingRepresentation())
+  if (Type->hasFloatingRepresentation()) {
+// Check for comparisons to NAN or INFINITY in fast math mode.
+S.CheckInfNaNFloatComparison(Loc, LHS.get(), RHS.get(), Opc);

zahiraam wrote:

Done.

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


[clang] [CLANG] Add warning when comparing to INF or NAN in fast math mode. (PR #76873)

2024-01-05 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

> Expanding the scope a bit, it would also be useful to have warnings for 
> constant NaN or Inf values passed as arguments or used in binary operations.

Added that.

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


[clang] [CLANG] Add warning when comparing to INF or NAN in fast math mode. (PR #76873)

2024-01-08 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-08 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-08 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-10 Thread Zahira Ammarguellat via cfe-commits


@@ -6771,6 +6771,9 @@ def warn_pointer_sub_null_ptr : Warning<
 def warn_floatingpoint_eq : Warning<
   "comparing floating point with == or != is unsafe">,
   InGroup>, DefaultIgnore;
+def warn_fast_floatingpoint_eq : Warning<
+  "explicit comparison with %0 when the program is assumed to not use or 
produce %0">,

zahiraam wrote:

Not sure this makes sense. Since I am also adding this warning to things like a 
* INF/NaN or foo(INF).

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


[clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-10 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-10 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-10 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

2024-01-11 Thread Zahira Ammarguellat via cfe-commits


@@ -6771,6 +6771,9 @@ def warn_pointer_sub_null_ptr : Warning<
 def warn_floatingpoint_eq : Warning<
   "comparing floating point with == or != is unsafe">,
   InGroup>, DefaultIgnore;
+def warn_fast_floatingpoint_eq : Warning<
+  "explicit comparison with %0 when the program is assumed to not use or 
produce %0">,

zahiraam wrote:

If it's ok I will use "use of infinity|NaN will always" only because the 
warning is not triggered only for comparison but for binary operators using 
inf/nan and function calls with inf/nan arguments.

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


[clang] 4d165ad - In fast-math mode, when unsafe math optimizations are enabled, the

2022-04-05 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2022-04-05T04:58:19-07:00
New Revision: 4d165ad7d9b3395a59c287ef60542b4de3a4d95a

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

LOG: In fast-math mode, when unsafe math optimizations are enabled, the
compiler is allowed to use optimizations that allow reassociation and
transformations that don’t guaranty accuracy.
For example (x+y)+z is transformed into x+(y+z) . Although
mathematically equivalent, these two expressions may not lead to the
same final result due to errors of summation.
Or x/x is transformed into 1.0 but x could be 0.0, INF or NaN. And so
this transformation also may not lead to the same final result.
Setting the eval method 'ffp-eval-method' or via '#pragma clang fp
eval_method' in this mode, doesn’t have any effect.
This patch adds code to warn the user of this.

Differential Revision: https://reviews.llvm.org/D122155

Added: 
clang/test/Driver/eval-method-with-unsafe-math.c
clang/test/Sema/eval-method-with-unsafe-math.c

Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaAttr.cpp
clang/test/CodeGen/X86/32bit-behavior.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index eacb7e4de0ead..afc166b5d087a 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -48,6 +48,10 @@ def warn_fe_backend_unsupported_fp_exceptions : Warning<
 "overriding currently unsupported use of floating point exceptions "
 "on this target">, InGroup;
 
+def err_incompatible_fp_eval_method_options : Error<
+"option 'ffp-eval-method' cannot be used with option "
+"%select{'fapprox-func'|'mreassociate'|'freciprocal'}0">;
+
 def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo,
 InGroup;
 def remark_fe_backend_optimization_remark_missed : Remark<"%0">, BackendInfo,

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index aec172c39ed9a..c5171359e7e4c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6491,6 +6491,10 @@ def warn_floatingpoint_eq : Warning<
   "comparing floating point with == or != is unsafe">,
   InGroup>, DefaultIgnore;
 
+def err_setting_eval_method_used_in_unsafe_context : Error <
+  "%select{'#pragma clang fp eval_method'|option 'ffp-eval-method'}0 cannot be 
used with "
+  "%select{option 'fapprox-func'|option 'mreassociate'|option 
'freciprocal'|option 'ffp-eval-method'|'#pragma clang fp reassociate'}1">;
+
 def warn_remainder_division_by_zero : Warning<
   "%select{remainder|division}0 by zero is undefined">,
   InGroup;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f8fd3a2900237..91adacdee3ad7 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -503,6 +503,22 @@ static bool FixupInvocation(CompilerInvocation &Invocation,
 Diags.Report(diag::warn_ignored_hip_only_option)
 << 
Args.getLastArg(OPT_gpu_max_threads_per_block_EQ)->getAsString(Args);
 
+  // When these options are used, the compiler is allowed to apply
+  // optimizations that may affect the final result. For example
+  // (x+y)+z is transformed to x+(y+z) but may not give the same
+  // final result; it's not value safe.
+  // Another example can be to simplify x/x to 1.0 but x could be 0.0, INF
+  // or NaN. Final result may then 
diff er. An error is issued when the eval
+  // method is set with one of these options.
+  if (Args.hasArg(OPT_ffp_eval_method_EQ)) {
+if (LangOpts.ApproxFunc)
+  Diags.Report(diag::err_incompatible_fp_eval_method_options) << 0;
+if (LangOpts.AllowFPReassoc)
+  Diags.Report(diag::err_incompatible_fp_eval_method_options) << 1;
+if (LangOpts.AllowRecip)
+  Diags.Report(diag::err_incompatible_fp_eval_method_options) << 2;
+  }
+
   // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
   // This option should be deprecated for CL > 1.0 because
   // this option was added for compatibility with OpenCL 1.0.

diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 9e94136ce76d0..113b3ac89f463 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -486,6 +486,12 @@ void Sema::ActOnPragmaFPEvalMethod(SourceLocation Loc,
 NewFPFeatures.setFPEvalMethodOverride(LangOptions::FEM_Extended);
 break;
   }
+  if (getLangOpts().ApproxFunc)
+Diag(Loc, diag::err_set

[clang] 15ef06f - Diagnose when `#pragma clang fp eval_method` doesn't have a supported value.

2022-03-10 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2022-03-10T13:19:53-08:00
New Revision: 15ef06f453c6f9513b476e80dd9567d01fc662e8

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

LOG: Diagnose when `#pragma clang fp eval_method` doesn't have a supported 
value.
Currently the compiler is crashing.

Differential Revision: https://reviews.llvm.org/D121380

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/test/Sema/fp-eval-pragma.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 92ae27d6212a0..7af15f5504ff9 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1489,7 +1489,8 @@ def err_pragma_fp_invalid_argument : Error<
   "%select{"
   "'fast' or 'on' or 'off'|"
   "'on' or 'off'|"
-  "'ignore', 'maytrap' or 'strict'}2">;
+  "'ignore', 'maytrap' or 'strict'|"
+  "'source', 'double' or 'extended'}2">;
 
 def err_pragma_invalid_keyword : Error<
   "invalid argument; expected 'enable'%select{|, 'full'}0%select{|, 
'assume_safety'}1 or 'disable'">;

diff  --git a/clang/test/Sema/fp-eval-pragma.cpp 
b/clang/test/Sema/fp-eval-pragma.cpp
index 42d88fd438e81..571b8097e9abf 100644
--- a/clang/test/Sema/fp-eval-pragma.cpp
+++ b/clang/test/Sema/fp-eval-pragma.cpp
@@ -27,6 +27,16 @@ int foo2() {
   return 0;
 }
 
+void apply_pragma_with_wrong_value() {
+  // expected-error@+1{{unexpected argument 'value' to '#pragma clang fp 
eval_method'; expected 'source', 'double' or 'extended'}}
+#pragma clang fp eval_method(value)
+}
+
+int foo3() {
+  apply_pragma_with_wrong_value();
+  return 0;
+}
+
 void foo() {
   auto a = __FLT_EVAL_METHOD__;
   {



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


[clang] bbf0d19 - Currently the control of the eval-method is mixed with fast-math.

2022-03-17 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2022-03-17T11:48:03-07:00
New Revision: bbf0d1932a3c1be970ed8a580e51edf571b80fd5

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

LOG: Currently the control of the eval-method is mixed with fast-math.
FLT_EVAL_METHOD tells the user the precision at which, temporary results
are evaluated but when fast-math is enabled, the numeric values are not
guaranteed to match the source semantics, so the eval-method is
meaningless.
For example, the expression `x + y + z` has as source semantics `(x + y)
+ z`. FLT_EVAL_METHOD is telling the user at which precision `(x + y)`
is evaluated. With fast-math enable the compiler can choose to
evaluate the expression as `(y + z) + x`.
The correct behavior is to set the FLT_EVAL_METHOD to `-1` to tell the
user that the precision of the intermediate values is unknow. This
patch is doing that.

Differential Revision: https://reviews.llvm.org/D121122

Added: 
clang/test/CodeGen/eval-method-fast-math.cpp

Modified: 
clang/include/clang/Lex/Preprocessor.h
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 4eb96f1cac4b7..36bf8ed64c2bc 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -192,6 +192,11 @@ class Preprocessor {
   LangOptions::FPEvalMethodKind CurrentFPEvalMethod =
   LangOptions::FPEvalMethodKind::FEM_UnsetOnCommandLine;
 
+  // Keeps the value of the last evaluation method before a
+  // `pragma float_control (precise,off) is applied.
+  LangOptions::FPEvalMethodKind LastFPEvalMethod =
+  LangOptions::FPEvalMethodKind::FEM_UnsetOnCommandLine;
+
   // The most recent pragma location where the floating point evaluation
   // method was modified. This is used to determine whether the
   // 'pragma clang fp eval_method' was used whithin the current scope.
@@ -2078,6 +2083,14 @@ class Preprocessor {
 return LastFPEvalPragmaLocation;
   }
 
+  LangOptions::FPEvalMethodKind getLastFPEvalMethod() const {
+return LastFPEvalMethod;
+  }
+
+  void setLastFPEvalMethod(LangOptions::FPEvalMethodKind Val) {
+LastFPEvalMethod = Val;
+  }
+
   void setCurrentFPEvalMethod(SourceLocation PragmaLoc,
   LangOptions::FPEvalMethodKind Val) {
 assert(Val != LangOptions::FEM_UnsetOnCommandLine &&

diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index 82fc57c8f2e88..c2b7c194a2ba3 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1577,14 +1577,35 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
 Tok.setKind(tok::string_literal);
   } else if (II == Ident__FLT_EVAL_METHOD__) {
 // __FLT_EVAL_METHOD__ is set to the default value.
-OS << getTUFPEvalMethod();
-// __FLT_EVAL_METHOD__ expands to a simple numeric value.
-Tok.setKind(tok::numeric_constant);
-if (getLastFPEvalPragmaLocation().isValid()) {
-  // The program is ill-formed. The value of __FLT_EVAL_METHOD__ is altered
-  // by the pragma.
-  Diag(Tok, diag::err_illegal_use_of_flt_eval_macro);
-  Diag(getLastFPEvalPragmaLocation(), diag::note_pragma_entered_here);
+if (getTUFPEvalMethod() ==
+LangOptions::FPEvalMethodKind::FEM_Indeterminable) {
+  // This is possible if `AllowFPReassoc` or `AllowReciprocal` is enabled.
+  // These modes can be triggered via the command line option `-ffast-math`
+  // or via a `pragam float_control`.
+  // __FLT_EVAL_METHOD__ expands to -1.
+  // The `minus` operator is the next token we read from the stream.
+  auto Toks = std::make_unique(1);
+  OS << "-";
+  Tok.setKind(tok::minus);
+  // Push the token `1` to the stream.
+  Token NumberToken;
+  NumberToken.startToken();
+  NumberToken.setKind(tok::numeric_constant);
+  NumberToken.setLiteralData("1");
+  NumberToken.setLength(1);
+  Toks[0] = NumberToken;
+  EnterTokenStream(std::move(Toks), 1, /*DisableMacroExpansion*/ false,
+   /*IsReinject*/ false);
+} else {
+  OS << getTUFPEvalMethod();
+  // __FLT_EVAL_METHOD__ expands to a simple numeric value.
+  Tok.setKind(tok::numeric_constant);
+  if (getLastFPEvalPragmaLocation().isValid()) {
+// The program is ill-formed. The value of __FLT_EVAL_METHOD__ is
+// altered by the pragma.
+Diag(Tok, diag::err_illegal_use_of_flt_eval_macro);
+Diag(getLastFPEvalPragmaLocation(), diag::note_pragma_entered_here);
+  }
 }
   } else if (II == Ident__COUNTER__) {
 // __COUNTER__ expands to a simple numeric value.

d

[clang] b0bc93d - Revert "[clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable""."

2022-03-23 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2022-03-23T04:54:00-07:00
New Revision: b0bc93da926a943cdc2d8b04f8dcbe23a774520c

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

LOG: Revert "[clang] roll-forward "[clang] Mark `trivial_abi` types as 
"trivially relocatable""."

This reverts commit 56d46b36fc231a0beb518602503035bba92043e0.

The LIT test SemaCXX/attr-trivial-abi.cpp is failing with 32bit build on
Windows. All the lines with the ifdef WIN32 are asserting but they are
not expected to. It looks like the LIT test was not tested on a 32bit
build of the compiler.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/AST/Type.h
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/TokenKinds.def
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/attr-trivial-abi.cpp
clang/test/SemaCXX/type-traits.cpp
clang/test/SemaObjCXX/arc-type-traits.mm
clang/test/SemaObjCXX/objc-weak-type-traits.mm

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 685f834a8495a..05d8d53d44c1c 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1434,11 +1434,6 @@ The following type trait primitives are supported by 
Clang. Those traits marked
 * ``__is_trivially_constructible`` (C++, GNU, Microsoft)
 * ``__is_trivially_copyable`` (C++, GNU, Microsoft)
 * ``__is_trivially_destructible`` (C++, MSVC 2013)
-* ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
-  of the given type, and then destroying the source object, is known to be
-  functionally equivalent to copying the underlying bytes and then dropping the
-  source object on the floor. This is true of trivial types and types which
-  were made trivially relocatable via the ``clang::trivial_abi`` attribute.
 * ``__is_union`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_unsigned`` (C++, Embarcadero):
   Returns false for enumeration types. Note, before Clang 13, returned true for

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 050391563f889..448dd2fdd8e49 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -830,8 +830,6 @@ class QualType {
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext &Context) const;
 
-  /// Return true if this is a trivially relocatable type.
-  bool isTriviallyRelocatableType(const ASTContext &Context) const;
 
   /// Returns true if it is a class and it might be dynamic.
   bool mayBeDynamicClass() const;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index d7cd31174bc5b..ebf0725a0a392 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -,9 +,6 @@ If a type is trivial for the purposes of calls, has a 
non-trivial destructor,
 and is passed as an argument by value, the convention is that the callee will
 destroy the object before returning.
 
-If a type is trivial for the purpose of calls, it is assumed to be trivially
-relocatable for the purpose of ``__is_trivially_relocatable``.
-
 Attribute ``trivial_abi`` has no effect in the following cases:
 
 - The class directly declares a virtual base or virtual methods.

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 1d2082717bf97..1f07cad9459cd 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -510,7 +510,6 @@ TYPE_TRAIT_1(__has_unique_object_representations,
 KEYWORD(__underlying_type   , KEYCXX)
 
 // Clang-only C++ Type Traits
-TYPE_TRAIT_1(__is_trivially_relocatable, IsTriviallyRelocatable, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
 
 // Embarcadero Expression Traits

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 1803fe12d69c8..a7fdcdd99c2fd 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2506,25 +2506,6 @@ bool QualType::isTriviallyCopyableType(const ASTContext 
&Context) const {
   return false;
 }
 
-bool QualType::isTriviallyRelocatableType(const ASTContext &Context) const {
-  QualType BaseElementType = Context.getBaseElementType(*this);
-
-  if (BaseElementType->isIncompleteType()) {
-return false;
-  } else if (const auto *RD = BaseElementType->getAsRecordDecl()) {
-return RD->canPassInRegisters();
-  } else {
-switch (isNonTrivialToPrimitiveDestructiveMove()) {
-case PCK_Trivial:
-  return !isDestructedType();
-case PCK_ARCStrong:
-  return true;
-default:
-  return false;
-}
-  }
-}
-
 

[clang] 4bafe65 - Add support for floating-point option `ffp-eval-method` and for

2022-02-15 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2022-02-15T13:59:27-08:00
New Revision: 4bafe65c2b2f1ce745894a509a6d80c87fb1c335

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

LOG: Add support for floating-point option `ffp-eval-method` and for
`pragma clang fp eval_method`.

Added: 
clang/test/CodeGen/X86/32bit-behavior-no-eval.c
clang/test/CodeGen/X86/32bit-behavior.c
clang/test/CodeGen/X86/fp-eval-method.c
clang/test/CodeGen/flt_eval_macro.cpp
clang/test/Preprocessor/flt_eval_macro.cpp
clang/test/Sema/fp-eval-pragma.cpp
clang/test/Sema/x86-eval-method.c
clang/test/Sema/x86_64-eval-method.c

Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/UsersManual.rst
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Basic/FPOptions.def
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Basic/Targets/X86.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/Preprocessor/init-aarch64.c
clang/test/Preprocessor/init-arm.c
clang/test/Preprocessor/init-mips.c
clang/test/Preprocessor/init-ppc.c
clang/test/Preprocessor/init-ppc64.c
clang/test/Preprocessor/init-s390x.c
clang/test/Preprocessor/init-v7k-compat.c
clang/test/Preprocessor/init-x86.c
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index f45d88092eb4a..5249d3f3f7930 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3907,6 +3907,38 @@ A ``#pragma clang fp`` pragma may contain any number of 
options:
 ...
   }
 
+``#pragma clang fp eval_method`` allows floating-point behavior to be specified
+for a section of the source code. This pragma can appear at file or namespace
+scope, or at the start of a compound statement (excluding comments).
+The pragma is active within the scope of the compound statement.
+
+When ``pragma clang fp eval_method(source)`` is enabled, the section of code
+governed by the pragma behaves as though the command-line option
+``-ffp-eval-method=source`` is enabled. Rounds intermediate results to
+source-defined precision.
+
+When ``pragma clang fp eval_method(double)`` is enabled, the section of code
+governed by the pragma behaves as though the command-line option
+``-ffp-eval-method=double`` is enabled. Rounds intermediate results to
+``double`` precision.
+
+When ``pragma clang fp eval_method(extended)`` is enabled, the section of code
+governed by the pragma behaves as though the command-line option
+``-ffp-eval-method=extended`` is enabled. Rounds intermediate results to
+target-dependent ``long double`` precision. In Win32 programming, for instance,
+the long double data type maps to the double, 64-bit precision data type.
+
+The full syntax this pragma supports is
+``#pragma clang fp eval_method(source|double|extended)``.
+
+.. code-block:: c++
+
+  for(...) {
+// The compiler will use long double as the floating-point evaluation
+// method.
+#pragma clang fp eval_method(extended)
+a = b[i] * c[i] + e;
+  }
 
 The ``#pragma float_control`` pragma allows precise floating-point
 semantics and floating-point exception behavior to be specified

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 1df96296cb8ac..70fee29ab2a84 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1566,6 +1566,22 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may raise exceptions 
that would not have been raised by the original code. Constant folding 
performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
+.. option:: -ffp-eval-method=
+
+   Specify the floating-point evaluation method for intermediate results within
+   a single expression of the code.
+
+   Valid values are: ``source``, ``double``, and ``extended``.
+   For 64-bit targets, the default value is ``source``. For 32-bit x86 

[clang] 32b73bc - Add support for floating-point option `ffp-eval-method` and for

2022-02-17 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2022-02-17T08:59:21-08:00
New Revision: 32b73bc6ab8234b670c34d5ef999300e072cc706

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

LOG: Add support for floating-point option `ffp-eval-method` and for
`pragma clang fp eval_method`.

https://reviews.llvm.org/D109239

Added: 
clang/test/CodeGen/X86/32bit-behavior-no-eval.c
clang/test/CodeGen/X86/32bit-behavior.c
clang/test/CodeGen/X86/fp-eval-method.c
clang/test/CodeGen/flt_eval_macro.cpp
clang/test/Preprocessor/flt_eval_macro.cpp
clang/test/Sema/fp-eval-pragma.cpp
clang/test/Sema/x86-eval-method.c
clang/test/Sema/x86_64-eval-method.c

Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/UsersManual.rst
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/FPOptions.def
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Basic/Targets/X86.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/Preprocessor/init-aarch64.c
clang/test/Preprocessor/init-arm.c
clang/test/Preprocessor/init-mips.c
clang/test/Preprocessor/init-ppc.c
clang/test/Preprocessor/init-ppc64.c
clang/test/Preprocessor/init-s390x.c
clang/test/Preprocessor/init-v7k-compat.c
clang/test/Preprocessor/init-x86.c
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index f45d88092eb4a..5249d3f3f7930 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3907,6 +3907,38 @@ A ``#pragma clang fp`` pragma may contain any number of 
options:
 ...
   }
 
+``#pragma clang fp eval_method`` allows floating-point behavior to be specified
+for a section of the source code. This pragma can appear at file or namespace
+scope, or at the start of a compound statement (excluding comments).
+The pragma is active within the scope of the compound statement.
+
+When ``pragma clang fp eval_method(source)`` is enabled, the section of code
+governed by the pragma behaves as though the command-line option
+``-ffp-eval-method=source`` is enabled. Rounds intermediate results to
+source-defined precision.
+
+When ``pragma clang fp eval_method(double)`` is enabled, the section of code
+governed by the pragma behaves as though the command-line option
+``-ffp-eval-method=double`` is enabled. Rounds intermediate results to
+``double`` precision.
+
+When ``pragma clang fp eval_method(extended)`` is enabled, the section of code
+governed by the pragma behaves as though the command-line option
+``-ffp-eval-method=extended`` is enabled. Rounds intermediate results to
+target-dependent ``long double`` precision. In Win32 programming, for instance,
+the long double data type maps to the double, 64-bit precision data type.
+
+The full syntax this pragma supports is
+``#pragma clang fp eval_method(source|double|extended)``.
+
+.. code-block:: c++
+
+  for(...) {
+// The compiler will use long double as the floating-point evaluation
+// method.
+#pragma clang fp eval_method(extended)
+a = b[i] * c[i] + e;
+  }
 
 The ``#pragma float_control`` pragma allows precise floating-point
 semantics and floating-point exception behavior to be specified

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 981909aa16eaf..4a776eb86775c 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1566,6 +1566,22 @@ Note that floating-point operations performed as part of 
constant initialization
* ``maytrap`` The compiler avoids transformations that may raise exceptions 
that would not have been raised by the original code. Constant folding 
performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly 
preserve the floating point exception semantics of the original code.
 
+.. option:: -ffp-eval-method=
+
+   Specify the floating-point evaluation method for intermediate results within
+   a single expression of the code.
+
+   Valid values are: ``source``, ``double``, and ``extended``.
+   For 64-bit targets, the default val

[clang] 4dfa68e - [NFC] Fix debug-info-hotpatch.cpp failure due to downstream regex issue.

2022-02-17 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2022-02-17T10:59:54-08:00
New Revision: 4dfa68e483137cc13eb9027c0dd834ede19f2fd4

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

LOG: [NFC] Fix debug-info-hotpatch.cpp failure due to downstream regex issue.

In our downstream, we discovered that the that the .* wildcard
in debug-info-hotpatch.cpp (added https://reviews.llvm.org/D116511)
ended up matching the entire line on our Windows configurations, causing
the -function-padmin check to already be consumed. After digging into it
we weren't able to find any sort of reason why the platform would matter
here, however we suspect there must be some difference in the regex
matcher between systems.
This NFC patch replaces the regex with a more conservative regex that
prevents this from happening by replacing the . match with an 'everything
but double-quote match, [^"].

https://reviews.llvm.org/D120066

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-hotpatch.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-hotpatch.cpp 
b/clang/test/CodeGenCXX/debug-info-hotpatch.cpp
index fde1a6ad085ea..e005c9c5ee489 100644
--- a/clang/test/CodeGenCXX/debug-info-hotpatch.cpp
+++ b/clang/test/CodeGenCXX/debug-info-hotpatch.cpp
@@ -12,7 +12,7 @@
 // RUN: %clang_cl --target=x86_64-windows-msvc /hotpatch -### -- %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix=FUNCTIONPADMIN
 // FUNCTIONPADMIN: clang{{.*}}
-// FUNCTIONPADMIN: {{link.*"}}
+// FUNCTIONPADMIN: {{link[^"]*"}} 
 // FUNCTIONPADMIN: -functionpadmin
 
 int main() {



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


[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #84014)

2024-03-14 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/84014

>From bdefe754c14c5e050ebf2b9c82eca458041564a4 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 5 Mar 2024 05:35:16 -0800
Subject: [PATCH 1/6] [clang-cl] Fix value of __FUNCTION__ in MSVC mode.

---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/include/clang/AST/Expr.h|  3 +-
 clang/lib/AST/Expr.cpp| 26 ++--
 clang/lib/AST/TypePrinter.cpp | 24 +--
 clang/lib/Sema/SemaExpr.cpp   |  5 +-
 clang/test/AST/Interp/literals.cpp|  8 +--
 clang/test/Analysis/eval-predefined-exprs.cpp | 22 +--
 clang/test/SemaCXX/source_location.cpp| 64 +++
 clang/unittests/AST/DeclPrinterTest.cpp   | 15 +
 9 files changed, 149 insertions(+), 21 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 612b4329727455..20c14fae1dd31b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -224,6 +224,9 @@ Bug Fixes in This Version
   for variables created through copy initialization having side-effects in 
C++17 and later.
   Fixes (#GH64356) (#GH79518).
 
+- Fix value of predefined macro ``__FUNCTION__`` to match MSVC's value. Fixes
+  (`#66114 `_).
+
 Bug Fixes to Compiler Builtins
 ^^
 
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index bf0622bdeca30e..ce8e64a4bed04b 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2034,7 +2034,8 @@ class PredefinedExpr final
   }
 
   static std::string ComputeName(PredefinedIdentKind IK,
- const Decl *CurrentDecl);
+ const Decl *CurrentDecl,
+ bool ForceElaboratedPrinting = false);
 
   SourceLocation getBeginLoc() const { return getLocation(); }
   SourceLocation getEndLoc() const { return getLocation(); }
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b4de2155adcebd..796e50817ee319 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -673,7 +673,8 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedIdentKind IK) {
 // FIXME: Maybe this should use DeclPrinter with a special "print predefined
 // expr" policy instead.
 std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
-const Decl *CurrentDecl) {
+const Decl *CurrentDecl,
+bool ForceElaboratedPrinting) {
   ASTContext &Context = CurrentDecl->getASTContext();
 
   if (IK == PredefinedIdentKind::FuncDName) {
@@ -721,10 +722,17 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 return std::string(Out.str());
   }
   if (const FunctionDecl *FD = dyn_cast(CurrentDecl)) {
-if (IK != PredefinedIdentKind::PrettyFunction &&
-IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
-IK != PredefinedIdentKind::FuncSig &&
-IK != PredefinedIdentKind::LFuncSig)
+const auto &LO = Context.getLangOpts();
+if ((ForceElaboratedPrinting &&
+ (((IK == PredefinedIdentKind::Func ||
+IK == PredefinedIdentKind ::Function) &&
+   !LO.MicrosoftExt) ||
+  (IK == PredefinedIdentKind::LFunction && LO.MicrosoftExt))) ||
+(!ForceElaboratedPrinting &&
+ (IK != PredefinedIdentKind::PrettyFunction &&
+  IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
+  IK != PredefinedIdentKind::FuncSig &&
+  IK != PredefinedIdentKind::LFuncSig)))
   return FD->getNameAsString();
 
 SmallString<256> Name;
@@ -752,6 +760,8 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind 
IK,
 PrintingPolicy Policy(Context.getLangOpts());
 PrettyCallbacks PrettyCB(Context.getLangOpts());
 Policy.Callbacks = &PrettyCB;
+if (IK == PredefinedIdentKind::Function && ForceElaboratedPrinting)
+  Policy.SuppressTagKeyword = !LO.MicrosoftExt;
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
@@ -779,6 +789,12 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 
 FD->printQualifiedName(POut, Policy);
 
+if (IK == PredefinedIdentKind::Function) {
+  POut.flush();
+  Out << Proto;
+  return std::string(Name);
+}
+
 POut << "(";
 if (FT) {
   for (unsigned i = 0, e = Decl->getNumParams(); i != e; ++i) {
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 7dcc4348f8e036..21605e1f53e3d9 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1635,6 +1635,17 @@ void TypePrinter::printElaboratedBefore(const 
ElaboratedType *T,
 if (T->getKeyword() != ElaboratedTypeKeyword::None)
   OS << " ";
 NestedNameSpecifier *Q

[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #84014)

2024-03-14 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/84014

>From bdefe754c14c5e050ebf2b9c82eca458041564a4 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 5 Mar 2024 05:35:16 -0800
Subject: [PATCH 1/7] [clang-cl] Fix value of __FUNCTION__ in MSVC mode.

---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/include/clang/AST/Expr.h|  3 +-
 clang/lib/AST/Expr.cpp| 26 ++--
 clang/lib/AST/TypePrinter.cpp | 24 +--
 clang/lib/Sema/SemaExpr.cpp   |  5 +-
 clang/test/AST/Interp/literals.cpp|  8 +--
 clang/test/Analysis/eval-predefined-exprs.cpp | 22 +--
 clang/test/SemaCXX/source_location.cpp| 64 +++
 clang/unittests/AST/DeclPrinterTest.cpp   | 15 +
 9 files changed, 149 insertions(+), 21 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 612b4329727455..20c14fae1dd31b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -224,6 +224,9 @@ Bug Fixes in This Version
   for variables created through copy initialization having side-effects in 
C++17 and later.
   Fixes (#GH64356) (#GH79518).
 
+- Fix value of predefined macro ``__FUNCTION__`` to match MSVC's value. Fixes
+  (`#66114 `_).
+
 Bug Fixes to Compiler Builtins
 ^^
 
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index bf0622bdeca30e..ce8e64a4bed04b 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2034,7 +2034,8 @@ class PredefinedExpr final
   }
 
   static std::string ComputeName(PredefinedIdentKind IK,
- const Decl *CurrentDecl);
+ const Decl *CurrentDecl,
+ bool ForceElaboratedPrinting = false);
 
   SourceLocation getBeginLoc() const { return getLocation(); }
   SourceLocation getEndLoc() const { return getLocation(); }
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b4de2155adcebd..796e50817ee319 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -673,7 +673,8 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedIdentKind IK) {
 // FIXME: Maybe this should use DeclPrinter with a special "print predefined
 // expr" policy instead.
 std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
-const Decl *CurrentDecl) {
+const Decl *CurrentDecl,
+bool ForceElaboratedPrinting) {
   ASTContext &Context = CurrentDecl->getASTContext();
 
   if (IK == PredefinedIdentKind::FuncDName) {
@@ -721,10 +722,17 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 return std::string(Out.str());
   }
   if (const FunctionDecl *FD = dyn_cast(CurrentDecl)) {
-if (IK != PredefinedIdentKind::PrettyFunction &&
-IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
-IK != PredefinedIdentKind::FuncSig &&
-IK != PredefinedIdentKind::LFuncSig)
+const auto &LO = Context.getLangOpts();
+if ((ForceElaboratedPrinting &&
+ (((IK == PredefinedIdentKind::Func ||
+IK == PredefinedIdentKind ::Function) &&
+   !LO.MicrosoftExt) ||
+  (IK == PredefinedIdentKind::LFunction && LO.MicrosoftExt))) ||
+(!ForceElaboratedPrinting &&
+ (IK != PredefinedIdentKind::PrettyFunction &&
+  IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
+  IK != PredefinedIdentKind::FuncSig &&
+  IK != PredefinedIdentKind::LFuncSig)))
   return FD->getNameAsString();
 
 SmallString<256> Name;
@@ -752,6 +760,8 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind 
IK,
 PrintingPolicy Policy(Context.getLangOpts());
 PrettyCallbacks PrettyCB(Context.getLangOpts());
 Policy.Callbacks = &PrettyCB;
+if (IK == PredefinedIdentKind::Function && ForceElaboratedPrinting)
+  Policy.SuppressTagKeyword = !LO.MicrosoftExt;
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
@@ -779,6 +789,12 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 
 FD->printQualifiedName(POut, Policy);
 
+if (IK == PredefinedIdentKind::Function) {
+  POut.flush();
+  Out << Proto;
+  return std::string(Name);
+}
+
 POut << "(";
 if (FT) {
   for (unsigned i = 0, e = Decl->getNumParams(); i != e; ++i) {
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 7dcc4348f8e036..21605e1f53e3d9 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1635,6 +1635,17 @@ void TypePrinter::printElaboratedBefore(const 
ElaboratedType *T,
 if (T->getKeyword() != ElaboratedTypeKeyword::None)
   OS << " ";
 NestedNameSpecifier *Q

[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #84014)

2024-03-14 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/84014

>From bdefe754c14c5e050ebf2b9c82eca458041564a4 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 5 Mar 2024 05:35:16 -0800
Subject: [PATCH 1/8] [clang-cl] Fix value of __FUNCTION__ in MSVC mode.

---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/include/clang/AST/Expr.h|  3 +-
 clang/lib/AST/Expr.cpp| 26 ++--
 clang/lib/AST/TypePrinter.cpp | 24 +--
 clang/lib/Sema/SemaExpr.cpp   |  5 +-
 clang/test/AST/Interp/literals.cpp|  8 +--
 clang/test/Analysis/eval-predefined-exprs.cpp | 22 +--
 clang/test/SemaCXX/source_location.cpp| 64 +++
 clang/unittests/AST/DeclPrinterTest.cpp   | 15 +
 9 files changed, 149 insertions(+), 21 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 612b4329727455..20c14fae1dd31b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -224,6 +224,9 @@ Bug Fixes in This Version
   for variables created through copy initialization having side-effects in 
C++17 and later.
   Fixes (#GH64356) (#GH79518).
 
+- Fix value of predefined macro ``__FUNCTION__`` to match MSVC's value. Fixes
+  (`#66114 `_).
+
 Bug Fixes to Compiler Builtins
 ^^
 
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index bf0622bdeca30e..ce8e64a4bed04b 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2034,7 +2034,8 @@ class PredefinedExpr final
   }
 
   static std::string ComputeName(PredefinedIdentKind IK,
- const Decl *CurrentDecl);
+ const Decl *CurrentDecl,
+ bool ForceElaboratedPrinting = false);
 
   SourceLocation getBeginLoc() const { return getLocation(); }
   SourceLocation getEndLoc() const { return getLocation(); }
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b4de2155adcebd..796e50817ee319 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -673,7 +673,8 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedIdentKind IK) {
 // FIXME: Maybe this should use DeclPrinter with a special "print predefined
 // expr" policy instead.
 std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
-const Decl *CurrentDecl) {
+const Decl *CurrentDecl,
+bool ForceElaboratedPrinting) {
   ASTContext &Context = CurrentDecl->getASTContext();
 
   if (IK == PredefinedIdentKind::FuncDName) {
@@ -721,10 +722,17 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 return std::string(Out.str());
   }
   if (const FunctionDecl *FD = dyn_cast(CurrentDecl)) {
-if (IK != PredefinedIdentKind::PrettyFunction &&
-IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
-IK != PredefinedIdentKind::FuncSig &&
-IK != PredefinedIdentKind::LFuncSig)
+const auto &LO = Context.getLangOpts();
+if ((ForceElaboratedPrinting &&
+ (((IK == PredefinedIdentKind::Func ||
+IK == PredefinedIdentKind ::Function) &&
+   !LO.MicrosoftExt) ||
+  (IK == PredefinedIdentKind::LFunction && LO.MicrosoftExt))) ||
+(!ForceElaboratedPrinting &&
+ (IK != PredefinedIdentKind::PrettyFunction &&
+  IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
+  IK != PredefinedIdentKind::FuncSig &&
+  IK != PredefinedIdentKind::LFuncSig)))
   return FD->getNameAsString();
 
 SmallString<256> Name;
@@ -752,6 +760,8 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind 
IK,
 PrintingPolicy Policy(Context.getLangOpts());
 PrettyCallbacks PrettyCB(Context.getLangOpts());
 Policy.Callbacks = &PrettyCB;
+if (IK == PredefinedIdentKind::Function && ForceElaboratedPrinting)
+  Policy.SuppressTagKeyword = !LO.MicrosoftExt;
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
@@ -779,6 +789,12 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 
 FD->printQualifiedName(POut, Policy);
 
+if (IK == PredefinedIdentKind::Function) {
+  POut.flush();
+  Out << Proto;
+  return std::string(Name);
+}
+
 POut << "(";
 if (FT) {
   for (unsigned i = 0, e = Decl->getNumParams(); i != e; ++i) {
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 7dcc4348f8e036..21605e1f53e3d9 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1635,6 +1635,17 @@ void TypePrinter::printElaboratedBefore(const 
ElaboratedType *T,
 if (T->getKeyword() != ElaboratedTypeKeyword::None)
   OS << " ";
 NestedNameSpecifier *Q

[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-15 Thread Zahira Ammarguellat via cfe-commits


@@ -1046,30 +1046,35 @@ defm offload_uniform_block : 
BoolFOption<"offload-uniform-block",
   NegFlag,
   BothFlags<[], [ClangOption], " that kernels are launched with uniform block 
sizes (default true for CUDA/HIP and false otherwise)">>;
 
-def fcx_limited_range : Joined<["-"], "fcx-limited-range">,
+def fcomplex_arithmetic_EQ : Joined<["-"], "fcomplex-arithmetic=">, 
Group,
+  Visibility<[ClangOption, CC1Option]>,
+  Values<"full,improved,promoted,basic">, NormalizedValuesScope<"LangOptions">,
+  NormalizedValues<["CX_Full", "CX_Improved", "CX_Promoted", "CX_Basic"]>;
+
+def complex_range_EQ : Joined<["-"], "complex-range=">, Group,
+  Visibility<[CC1Option]>,
+  Values<"full,improved,promoted,basic">, NormalizedValuesScope<"LangOptions">,
+  NormalizedValues<["CX_Full", "CX_Improved", "CX_Promoted", "CX_Basic"]>,
+  MarshallingInfoEnum, "CX_Full">;
+
+def fcx_limited_range : Flag<["-"], "fcx-limited-range">,
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Basic algebraic expansions of complex arithmetic operations "
"involving are enabled.">;
 
-def fno_cx_limited_range : Joined<["-"], "fno-cx-limited-range">,
+def fno_cx_limited_range : Flag<["-"], "fno-cx-limited-range">,
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Basic algebraic expansions of complex arithmetic operations "
"involving are disabled.">;
 
-def fcx_fortran_rules : Joined<["-"], "fcx-fortran-rules">,
+def fcx_fortran_rules : Flag<["-"], "fcx-fortran-rules">,
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Range reduction is enabled for complex arithmetic operations.">;
 
-def fno_cx_fortran_rules : Joined<["-"], "fno-cx-fortran-rules">,
+def fno_cx_fortran_rules : Flag<["-"], "fno-cx-fortran-rules">,

zahiraam wrote:

Can `BoolOptionWithoutMarshalling` be used for clang options?

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-15 Thread Zahira Ammarguellat via cfe-commits


@@ -794,8 +834,10 @@ ComplexPairTy ComplexExprEmitter::EmitBinMul(const 
BinOpInfo &Op) {
   ResR = Builder.CreateFSub(AC, BD, "mul_r");
   ResI = Builder.CreateFAdd(AD, BC, "mul_i");
 
-  if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Limited ||
-  Op.FPFeatures.getComplexRange() == LangOptions::CX_Fortran)
+  if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Basic ||
+  Op.FPFeatures.getComplexRange() == LangOptions::CX_Improved ||
+  Op.FPFeatures.getComplexRange() == LangOptions::CX_Promoted ||
+  CGF.getLangOpts().NoHonorInfs || CGF.getLangOpts().NoHonorNaNs)

zahiraam wrote:

This code is in `EmitBinMul` and your `godbolt` link has a `div` operation.
At any case the `complex-range` is **not** set when `-ffinite-math-only` is 
used on the command line. The function `applyFastMath` sets the range only when 
`ffast-math` or `fp-model` are used. With `CGF.getLangOpts().NoHonorInfs || 
CGF.getLangOpts().NoHonorNaNs` we would get the same behavior than `gcc` for a` 
mul` operation: algebraic  implementation with no `nan` testing.
If you don't want this condition  here. then `applyFastMath` needs to be called 
when `ffinite-math-only` is on the command line.
WDYT?

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-15 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-15 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-15 Thread Zahira Ammarguellat via cfe-commits


@@ -2824,26 +2816,89 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 switch (optID) {
 default:
   break;
-case options::OPT_fcx_limited_range: {
-  EmitComplexRangeDiag(D, Range, 
LangOptions::ComplexRangeKind::CX_Limited);
-  Range = LangOptions::ComplexRangeKind::CX_Limited;
+case options::OPT_fcx_limited_range:
+  if (GccRangeComplexOption.empty()) {
+if (Range != LangOptions::ComplexRangeKind::CX_Basic)
+  EmitComplexRangeDiag(D, RenderComplexRangeOption(Range),
+   "-fcx-limited-range");
+  } else {
+if (GccRangeComplexOption != "-fno-cx-limited-range")
+  EmitComplexRangeDiag(D, GccRangeComplexOption, "-fcx-limited-range");
+  }
+  GccRangeComplexOption = "-fcx-limited-range";
+  Range = LangOptions::ComplexRangeKind::CX_Basic;
   break;
-}
 case options::OPT_fno_cx_limited_range:
-  EmitComplexRangeDiag(D, Range, LangOptions::ComplexRangeKind::CX_Full,
-   "-fno-cx-limited-range");
+  if (GccRangeComplexOption.empty()) {
+EmitComplexRangeDiag(D, RenderComplexRangeOption(Range),
+ "-fno-cx-limited-range");
+  } else {
+if (GccRangeComplexOption.compare("-fcx-limited-range") != 0 &&
+GccRangeComplexOption.compare("-fno-cx-fortran-rules") != 0)
+  EmitComplexRangeDiag(D, GccRangeComplexOption,
+   "-fno-cx-limited-range");
+  }
+  GccRangeComplexOption = "-fno-cx-limited-range";
   Range = LangOptions::ComplexRangeKind::CX_Full;
   break;
-case options::OPT_fcx_fortran_rules: {
-  EmitComplexRangeDiag(D, Range, 
LangOptions::ComplexRangeKind::CX_Fortran);
-  Range = LangOptions::ComplexRangeKind::CX_Fortran;
+case options::OPT_fcx_fortran_rules:
+  if (GccRangeComplexOption.empty())
+EmitComplexRangeDiag(D, RenderComplexRangeOption(Range),
+ "-fcx-fortran-rules");
+  else
+EmitComplexRangeDiag(D, GccRangeComplexOption, "-fcx-fortran-rules");
+  GccRangeComplexOption = "-fcx-fortran-rules";
+  Range = LangOptions::ComplexRangeKind::CX_Improved;
   break;
-}
 case options::OPT_fno_cx_fortran_rules:
-  EmitComplexRangeDiag(D, Range, LangOptions::ComplexRangeKind::CX_Full,
-   "-fno-cx-fortran-rules");
+  if (GccRangeComplexOption.empty()) {
+EmitComplexRangeDiag(D, RenderComplexRangeOption(Range),
+ "-fno-cx-fortran-rules");
+  } else {
+if (GccRangeComplexOption != "-fno-cx-limited-range")
+  EmitComplexRangeDiag(D, GccRangeComplexOption,
+   "-fno-cx-fortran-rules");
+  }
+  GccRangeComplexOption = "-fno-cx-fortran-rules";
   Range = LangOptions::ComplexRangeKind::CX_Full;
   break;
+case options::OPT_fcomplex_arithmetic_EQ: {
+  LangOptions::ComplexRangeKind RangeVal;
+  StringRef Val = A->getValue();
+  if (Val.equals("full"))
+RangeVal = LangOptions::ComplexRangeKind::CX_Full;
+  else if (Val.equals("improved"))
+RangeVal = LangOptions::ComplexRangeKind::CX_Improved;
+  else if (Val.equals("promoted"))
+RangeVal = LangOptions::ComplexRangeKind::CX_Promoted;
+  else if (Val.equals("basic"))
+RangeVal = LangOptions::ComplexRangeKind::CX_Basic;
+  else
+D.Diag(diag::err_drv_unsupported_option_argument)
+<< A->getSpelling() << LangOptions::ComplexRangeKind::CX_None;
+  if (GccRangeComplexOption.empty() && !SeenUnsafeMathModeOption) {

zahiraam wrote:

Yes.

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-15 Thread Zahira Ammarguellat via cfe-commits


@@ -986,13 +1028,17 @@ ComplexPairTy ComplexExprEmitter::EmitBinDiv(const 
BinOpInfo &Op) {
 llvm::Value *OrigLHSi = LHSi;
 if (!LHSi)
   LHSi = llvm::Constant::getNullValue(RHSi->getType());
-if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Fortran)
+QualType ComplexElementTy = Op.Ty->castAs()->getElementType();
+if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Improved ||
+(Op.FPFeatures.getComplexRange() == LangOptions::CX_Promoted &&
+ FPHasBeenPromoted == LangOptions::CX_Improved))

zahiraam wrote:

I think may be using a boolean for this variable makes sense. It's only set 
when there is type promotion. In which case the name of the variable is 
appropriate?

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-15 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-15 Thread Zahira Ammarguellat via cfe-commits


@@ -287,9 +288,47 @@ class ComplexExprEmitter
   ComplexPairTy EmitComplexBinOpLibCall(StringRef LibCallName,
 const BinOpInfo &Op);
 
-  QualType getPromotionType(QualType Ty) {
+  QualType GetHigherPrecisionFPType(QualType ElementType) {
+const auto *CurrentBT = dyn_cast(ElementType);
+switch (CurrentBT->getKind()) {
+case BuiltinType::Kind::Float16:
+  return CGF.getContext().FloatTy;
+case BuiltinType::Kind::Float:
+case BuiltinType::Kind::BFloat16:
+  return CGF.getContext().DoubleTy;
+case BuiltinType::Kind::Double:
+  return CGF.getContext().LongDoubleTy;
+default:
+  return ElementType;
+}
+  }
+
+  QualType HigherPrecisionTypeForComplexArithmetic(QualType ElementType,
+   bool IsDivOpCode) {
+QualType HigherElementType = GetHigherPrecisionFPType(ElementType);
+const llvm::fltSemantics &ElementTypeSemantics =
+CGF.getContext().getFloatTypeSemantics(ElementType);
+const llvm::fltSemantics &HigherElementTypeSemantics =
+CGF.getContext().getFloatTypeSemantics(HigherElementType);
+if (llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 <=
+llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) {
+  return CGF.getContext().getComplexType(HigherElementType);
+} else {
+  FPHasBeenPromoted = LangOptions::ComplexRangeKind::CX_Improved;

zahiraam wrote:

Yes I see the problem. Working on this. May be the` FPHasBeenPromoted` should 
be "attached" to the `BinOpInfo` instead?

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-15 Thread Zahira Ammarguellat via cfe-commits


@@ -287,9 +288,47 @@ class ComplexExprEmitter
   ComplexPairTy EmitComplexBinOpLibCall(StringRef LibCallName,
 const BinOpInfo &Op);
 
-  QualType getPromotionType(QualType Ty) {
+  QualType GetHigherPrecisionFPType(QualType ElementType) {
+const auto *CurrentBT = dyn_cast(ElementType);
+switch (CurrentBT->getKind()) {
+case BuiltinType::Kind::Float16:
+  return CGF.getContext().FloatTy;
+case BuiltinType::Kind::Float:
+case BuiltinType::Kind::BFloat16:
+  return CGF.getContext().DoubleTy;
+case BuiltinType::Kind::Double:
+  return CGF.getContext().LongDoubleTy;
+default:
+  return ElementType;
+}
+  }
+
+  QualType HigherPrecisionTypeForComplexArithmetic(QualType ElementType,
+   bool IsDivOpCode) {
+QualType HigherElementType = GetHigherPrecisionFPType(ElementType);
+const llvm::fltSemantics &ElementTypeSemantics =
+CGF.getContext().getFloatTypeSemantics(ElementType);
+const llvm::fltSemantics &HigherElementTypeSemantics =
+CGF.getContext().getFloatTypeSemantics(HigherElementType);
+if (llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 <=
+llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) {
+  return CGF.getContext().getComplexType(HigherElementType);
+} else {
+  FPHasBeenPromoted = LangOptions::ComplexRangeKind::CX_Improved;

zahiraam wrote:

I do see 2 different `ComplexExprEmitter` each with a different value of 
`FPHasBeenPromoted` though.

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-15 Thread Zahira Ammarguellat via cfe-commits


@@ -2824,26 +2816,89 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 switch (optID) {
 default:
   break;
-case options::OPT_fcx_limited_range: {
-  EmitComplexRangeDiag(D, Range, 
LangOptions::ComplexRangeKind::CX_Limited);
-  Range = LangOptions::ComplexRangeKind::CX_Limited;
+case options::OPT_fcx_limited_range:
+  if (GccRangeComplexOption.empty()) {
+if (Range != LangOptions::ComplexRangeKind::CX_Basic)
+  EmitComplexRangeDiag(D, RenderComplexRangeOption(Range),
+   "-fcx-limited-range");
+  } else {
+if (GccRangeComplexOption != "-fno-cx-limited-range")
+  EmitComplexRangeDiag(D, GccRangeComplexOption, "-fcx-limited-range");
+  }
+  GccRangeComplexOption = "-fcx-limited-range";
+  Range = LangOptions::ComplexRangeKind::CX_Basic;
   break;
-}
 case options::OPT_fno_cx_limited_range:
-  EmitComplexRangeDiag(D, Range, LangOptions::ComplexRangeKind::CX_Full,
-   "-fno-cx-limited-range");
+  if (GccRangeComplexOption.empty()) {
+EmitComplexRangeDiag(D, RenderComplexRangeOption(Range),
+ "-fno-cx-limited-range");
+  } else {
+if (GccRangeComplexOption.compare("-fcx-limited-range") != 0 &&
+GccRangeComplexOption.compare("-fno-cx-fortran-rules") != 0)
+  EmitComplexRangeDiag(D, GccRangeComplexOption,
+   "-fno-cx-limited-range");
+  }
+  GccRangeComplexOption = "-fno-cx-limited-range";
   Range = LangOptions::ComplexRangeKind::CX_Full;
   break;
-case options::OPT_fcx_fortran_rules: {
-  EmitComplexRangeDiag(D, Range, 
LangOptions::ComplexRangeKind::CX_Fortran);
-  Range = LangOptions::ComplexRangeKind::CX_Fortran;
+case options::OPT_fcx_fortran_rules:
+  if (GccRangeComplexOption.empty())
+EmitComplexRangeDiag(D, RenderComplexRangeOption(Range),
+ "-fcx-fortran-rules");
+  else
+EmitComplexRangeDiag(D, GccRangeComplexOption, "-fcx-fortran-rules");
+  GccRangeComplexOption = "-fcx-fortran-rules";
+  Range = LangOptions::ComplexRangeKind::CX_Improved;
   break;
-}
 case options::OPT_fno_cx_fortran_rules:
-  EmitComplexRangeDiag(D, Range, LangOptions::ComplexRangeKind::CX_Full,
-   "-fno-cx-fortran-rules");
+  if (GccRangeComplexOption.empty()) {
+EmitComplexRangeDiag(D, RenderComplexRangeOption(Range),
+ "-fno-cx-fortran-rules");
+  } else {
+if (GccRangeComplexOption != "-fno-cx-limited-range")
+  EmitComplexRangeDiag(D, GccRangeComplexOption,
+   "-fno-cx-fortran-rules");
+  }
+  GccRangeComplexOption = "-fno-cx-fortran-rules";
   Range = LangOptions::ComplexRangeKind::CX_Full;
   break;
+case options::OPT_fcomplex_arithmetic_EQ: {
+  LangOptions::ComplexRangeKind RangeVal;
+  StringRef Val = A->getValue();
+  if (Val.equals("full"))
+RangeVal = LangOptions::ComplexRangeKind::CX_Full;
+  else if (Val.equals("improved"))
+RangeVal = LangOptions::ComplexRangeKind::CX_Improved;
+  else if (Val.equals("promoted"))
+RangeVal = LangOptions::ComplexRangeKind::CX_Promoted;
+  else if (Val.equals("basic"))
+RangeVal = LangOptions::ComplexRangeKind::CX_Basic;
+  else
+D.Diag(diag::err_drv_unsupported_option_argument)
+<< A->getSpelling() << LangOptions::ComplexRangeKind::CX_None;
+  if (GccRangeComplexOption.empty() && !SeenUnsafeMathModeOption) {

zahiraam wrote:

Fixed.

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-18 Thread Zahira Ammarguellat via cfe-commits


@@ -287,9 +288,47 @@ class ComplexExprEmitter
   ComplexPairTy EmitComplexBinOpLibCall(StringRef LibCallName,
 const BinOpInfo &Op);
 
-  QualType getPromotionType(QualType Ty) {
+  QualType GetHigherPrecisionFPType(QualType ElementType) {
+const auto *CurrentBT = dyn_cast(ElementType);
+switch (CurrentBT->getKind()) {
+case BuiltinType::Kind::Float16:
+  return CGF.getContext().FloatTy;
+case BuiltinType::Kind::Float:
+case BuiltinType::Kind::BFloat16:
+  return CGF.getContext().DoubleTy;
+case BuiltinType::Kind::Double:
+  return CGF.getContext().LongDoubleTy;
+default:
+  return ElementType;
+}
+  }
+
+  QualType HigherPrecisionTypeForComplexArithmetic(QualType ElementType,
+   bool IsDivOpCode) {
+QualType HigherElementType = GetHigherPrecisionFPType(ElementType);
+const llvm::fltSemantics &ElementTypeSemantics =
+CGF.getContext().getFloatTypeSemantics(ElementType);
+const llvm::fltSemantics &HigherElementTypeSemantics =
+CGF.getContext().getFloatTypeSemantics(HigherElementType);
+if (llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 <=
+llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) {
+  return CGF.getContext().getComplexType(HigherElementType);
+} else {
+  FPHasBeenPromoted = LangOptions::ComplexRangeKind::CX_Improved;

zahiraam wrote:

The test is at line #2319 of CodeGen/cx-complex-range.c. 


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


[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #84014)

2024-03-18 Thread Zahira Ammarguellat via cfe-commits


@@ -855,7 +868,17 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
 Out << Proto << " -> ";
 Proto.clear();
   }
-  AFT->getReturnType().print(Out, Policy, Proto);
+  if (!Policy.SuppressTagKeyword && Policy.SuppressScope &&
+  !Policy.SuppressUnwrittenScope) {
+AddPrefix(Policy, AFT->getReturnType(), Out);

zahiraam wrote:

Removed it from `MaybePrintTagKeywordIfSupressingScopes` .

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


[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #84014)

2024-03-18 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/84014

>From bdefe754c14c5e050ebf2b9c82eca458041564a4 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 5 Mar 2024 05:35:16 -0800
Subject: [PATCH 1/9] [clang-cl] Fix value of __FUNCTION__ in MSVC mode.

---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/include/clang/AST/Expr.h|  3 +-
 clang/lib/AST/Expr.cpp| 26 ++--
 clang/lib/AST/TypePrinter.cpp | 24 +--
 clang/lib/Sema/SemaExpr.cpp   |  5 +-
 clang/test/AST/Interp/literals.cpp|  8 +--
 clang/test/Analysis/eval-predefined-exprs.cpp | 22 +--
 clang/test/SemaCXX/source_location.cpp| 64 +++
 clang/unittests/AST/DeclPrinterTest.cpp   | 15 +
 9 files changed, 149 insertions(+), 21 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 612b4329727455..20c14fae1dd31b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -224,6 +224,9 @@ Bug Fixes in This Version
   for variables created through copy initialization having side-effects in 
C++17 and later.
   Fixes (#GH64356) (#GH79518).
 
+- Fix value of predefined macro ``__FUNCTION__`` to match MSVC's value. Fixes
+  (`#66114 `_).
+
 Bug Fixes to Compiler Builtins
 ^^
 
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index bf0622bdeca30e..ce8e64a4bed04b 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2034,7 +2034,8 @@ class PredefinedExpr final
   }
 
   static std::string ComputeName(PredefinedIdentKind IK,
- const Decl *CurrentDecl);
+ const Decl *CurrentDecl,
+ bool ForceElaboratedPrinting = false);
 
   SourceLocation getBeginLoc() const { return getLocation(); }
   SourceLocation getEndLoc() const { return getLocation(); }
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b4de2155adcebd..796e50817ee319 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -673,7 +673,8 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedIdentKind IK) {
 // FIXME: Maybe this should use DeclPrinter with a special "print predefined
 // expr" policy instead.
 std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
-const Decl *CurrentDecl) {
+const Decl *CurrentDecl,
+bool ForceElaboratedPrinting) {
   ASTContext &Context = CurrentDecl->getASTContext();
 
   if (IK == PredefinedIdentKind::FuncDName) {
@@ -721,10 +722,17 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 return std::string(Out.str());
   }
   if (const FunctionDecl *FD = dyn_cast(CurrentDecl)) {
-if (IK != PredefinedIdentKind::PrettyFunction &&
-IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
-IK != PredefinedIdentKind::FuncSig &&
-IK != PredefinedIdentKind::LFuncSig)
+const auto &LO = Context.getLangOpts();
+if ((ForceElaboratedPrinting &&
+ (((IK == PredefinedIdentKind::Func ||
+IK == PredefinedIdentKind ::Function) &&
+   !LO.MicrosoftExt) ||
+  (IK == PredefinedIdentKind::LFunction && LO.MicrosoftExt))) ||
+(!ForceElaboratedPrinting &&
+ (IK != PredefinedIdentKind::PrettyFunction &&
+  IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
+  IK != PredefinedIdentKind::FuncSig &&
+  IK != PredefinedIdentKind::LFuncSig)))
   return FD->getNameAsString();
 
 SmallString<256> Name;
@@ -752,6 +760,8 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind 
IK,
 PrintingPolicy Policy(Context.getLangOpts());
 PrettyCallbacks PrettyCB(Context.getLangOpts());
 Policy.Callbacks = &PrettyCB;
+if (IK == PredefinedIdentKind::Function && ForceElaboratedPrinting)
+  Policy.SuppressTagKeyword = !LO.MicrosoftExt;
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
@@ -779,6 +789,12 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 
 FD->printQualifiedName(POut, Policy);
 
+if (IK == PredefinedIdentKind::Function) {
+  POut.flush();
+  Out << Proto;
+  return std::string(Name);
+}
+
 POut << "(";
 if (FT) {
   for (unsigned i = 0, e = Decl->getNumParams(); i != e; ++i) {
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 7dcc4348f8e036..21605e1f53e3d9 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1635,6 +1635,17 @@ void TypePrinter::printElaboratedBefore(const 
ElaboratedType *T,
 if (T->getKeyword() != ElaboratedTypeKeyword::None)
   OS << " ";
 NestedNameSpecifier *Q

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-18 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

I have uploaded your patch and compared the attributes generated from your 
patch and the little test case from 
https://github.com/llvm/llvm-project/issues/62098.  The attributes generated 
are different. Therefore, the expected optimizations from this patch are going 
to be different than what we currently have. I think that's a problem.

Attributes with this patch (only the ones that differ):

attributes #0 = { "no-infs-fp-math"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "unsafe-fp-math"="false" }

and without the patch:
attributes #0 = { "no-infs-fp-math"="true" "no-nans-fp-math"="true" 
"no-signed-zeros-fp-math"="true" "unsafe-fp-math"="true" }


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


[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #84014)

2024-03-18 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/84014

>From bdefe754c14c5e050ebf2b9c82eca458041564a4 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 5 Mar 2024 05:35:16 -0800
Subject: [PATCH 01/10] [clang-cl] Fix value of __FUNCTION__ in MSVC mode.

---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/include/clang/AST/Expr.h|  3 +-
 clang/lib/AST/Expr.cpp| 26 ++--
 clang/lib/AST/TypePrinter.cpp | 24 +--
 clang/lib/Sema/SemaExpr.cpp   |  5 +-
 clang/test/AST/Interp/literals.cpp|  8 +--
 clang/test/Analysis/eval-predefined-exprs.cpp | 22 +--
 clang/test/SemaCXX/source_location.cpp| 64 +++
 clang/unittests/AST/DeclPrinterTest.cpp   | 15 +
 9 files changed, 149 insertions(+), 21 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 612b4329727455..20c14fae1dd31b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -224,6 +224,9 @@ Bug Fixes in This Version
   for variables created through copy initialization having side-effects in 
C++17 and later.
   Fixes (#GH64356) (#GH79518).
 
+- Fix value of predefined macro ``__FUNCTION__`` to match MSVC's value. Fixes
+  (`#66114 `_).
+
 Bug Fixes to Compiler Builtins
 ^^
 
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index bf0622bdeca30e..ce8e64a4bed04b 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2034,7 +2034,8 @@ class PredefinedExpr final
   }
 
   static std::string ComputeName(PredefinedIdentKind IK,
- const Decl *CurrentDecl);
+ const Decl *CurrentDecl,
+ bool ForceElaboratedPrinting = false);
 
   SourceLocation getBeginLoc() const { return getLocation(); }
   SourceLocation getEndLoc() const { return getLocation(); }
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b4de2155adcebd..796e50817ee319 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -673,7 +673,8 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedIdentKind IK) {
 // FIXME: Maybe this should use DeclPrinter with a special "print predefined
 // expr" policy instead.
 std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
-const Decl *CurrentDecl) {
+const Decl *CurrentDecl,
+bool ForceElaboratedPrinting) {
   ASTContext &Context = CurrentDecl->getASTContext();
 
   if (IK == PredefinedIdentKind::FuncDName) {
@@ -721,10 +722,17 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 return std::string(Out.str());
   }
   if (const FunctionDecl *FD = dyn_cast(CurrentDecl)) {
-if (IK != PredefinedIdentKind::PrettyFunction &&
-IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
-IK != PredefinedIdentKind::FuncSig &&
-IK != PredefinedIdentKind::LFuncSig)
+const auto &LO = Context.getLangOpts();
+if ((ForceElaboratedPrinting &&
+ (((IK == PredefinedIdentKind::Func ||
+IK == PredefinedIdentKind ::Function) &&
+   !LO.MicrosoftExt) ||
+  (IK == PredefinedIdentKind::LFunction && LO.MicrosoftExt))) ||
+(!ForceElaboratedPrinting &&
+ (IK != PredefinedIdentKind::PrettyFunction &&
+  IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
+  IK != PredefinedIdentKind::FuncSig &&
+  IK != PredefinedIdentKind::LFuncSig)))
   return FD->getNameAsString();
 
 SmallString<256> Name;
@@ -752,6 +760,8 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind 
IK,
 PrintingPolicy Policy(Context.getLangOpts());
 PrettyCallbacks PrettyCB(Context.getLangOpts());
 Policy.Callbacks = &PrettyCB;
+if (IK == PredefinedIdentKind::Function && ForceElaboratedPrinting)
+  Policy.SuppressTagKeyword = !LO.MicrosoftExt;
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
@@ -779,6 +789,12 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 
 FD->printQualifiedName(POut, Policy);
 
+if (IK == PredefinedIdentKind::Function) {
+  POut.flush();
+  Out << Proto;
+  return std::string(Name);
+}
+
 POut << "(";
 if (FT) {
   for (unsigned i = 0, e = Decl->getNumParams(); i != e; ++i) {
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 7dcc4348f8e036..21605e1f53e3d9 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1635,6 +1635,17 @@ void TypePrinter::printElaboratedBefore(const 
ElaboratedType *T,
 if (T->getKeyword() != ElaboratedTypeKeyword::None)
   OS << " ";
 NestedNameSpecifier 

[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #84014)

2024-03-19 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/84014

>From bdefe754c14c5e050ebf2b9c82eca458041564a4 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 5 Mar 2024 05:35:16 -0800
Subject: [PATCH 01/10] [clang-cl] Fix value of __FUNCTION__ in MSVC mode.

---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/include/clang/AST/Expr.h|  3 +-
 clang/lib/AST/Expr.cpp| 26 ++--
 clang/lib/AST/TypePrinter.cpp | 24 +--
 clang/lib/Sema/SemaExpr.cpp   |  5 +-
 clang/test/AST/Interp/literals.cpp|  8 +--
 clang/test/Analysis/eval-predefined-exprs.cpp | 22 +--
 clang/test/SemaCXX/source_location.cpp| 64 +++
 clang/unittests/AST/DeclPrinterTest.cpp   | 15 +
 9 files changed, 149 insertions(+), 21 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 612b4329727455..20c14fae1dd31b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -224,6 +224,9 @@ Bug Fixes in This Version
   for variables created through copy initialization having side-effects in 
C++17 and later.
   Fixes (#GH64356) (#GH79518).
 
+- Fix value of predefined macro ``__FUNCTION__`` to match MSVC's value. Fixes
+  (`#66114 `_).
+
 Bug Fixes to Compiler Builtins
 ^^
 
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index bf0622bdeca30e..ce8e64a4bed04b 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2034,7 +2034,8 @@ class PredefinedExpr final
   }
 
   static std::string ComputeName(PredefinedIdentKind IK,
- const Decl *CurrentDecl);
+ const Decl *CurrentDecl,
+ bool ForceElaboratedPrinting = false);
 
   SourceLocation getBeginLoc() const { return getLocation(); }
   SourceLocation getEndLoc() const { return getLocation(); }
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b4de2155adcebd..796e50817ee319 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -673,7 +673,8 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedIdentKind IK) {
 // FIXME: Maybe this should use DeclPrinter with a special "print predefined
 // expr" policy instead.
 std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
-const Decl *CurrentDecl) {
+const Decl *CurrentDecl,
+bool ForceElaboratedPrinting) {
   ASTContext &Context = CurrentDecl->getASTContext();
 
   if (IK == PredefinedIdentKind::FuncDName) {
@@ -721,10 +722,17 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 return std::string(Out.str());
   }
   if (const FunctionDecl *FD = dyn_cast(CurrentDecl)) {
-if (IK != PredefinedIdentKind::PrettyFunction &&
-IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
-IK != PredefinedIdentKind::FuncSig &&
-IK != PredefinedIdentKind::LFuncSig)
+const auto &LO = Context.getLangOpts();
+if ((ForceElaboratedPrinting &&
+ (((IK == PredefinedIdentKind::Func ||
+IK == PredefinedIdentKind ::Function) &&
+   !LO.MicrosoftExt) ||
+  (IK == PredefinedIdentKind::LFunction && LO.MicrosoftExt))) ||
+(!ForceElaboratedPrinting &&
+ (IK != PredefinedIdentKind::PrettyFunction &&
+  IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
+  IK != PredefinedIdentKind::FuncSig &&
+  IK != PredefinedIdentKind::LFuncSig)))
   return FD->getNameAsString();
 
 SmallString<256> Name;
@@ -752,6 +760,8 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind 
IK,
 PrintingPolicy Policy(Context.getLangOpts());
 PrettyCallbacks PrettyCB(Context.getLangOpts());
 Policy.Callbacks = &PrettyCB;
+if (IK == PredefinedIdentKind::Function && ForceElaboratedPrinting)
+  Policy.SuppressTagKeyword = !LO.MicrosoftExt;
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
@@ -779,6 +789,12 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 
 FD->printQualifiedName(POut, Policy);
 
+if (IK == PredefinedIdentKind::Function) {
+  POut.flush();
+  Out << Proto;
+  return std::string(Name);
+}
+
 POut << "(";
 if (FT) {
   for (unsigned i = 0, e = Decl->getNumParams(); i != e; ++i) {
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 7dcc4348f8e036..21605e1f53e3d9 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1635,6 +1635,17 @@ void TypePrinter::printElaboratedBefore(const 
ElaboratedType *T,
 if (T->getKeyword() != ElaboratedTypeKeyword::None)
   OS << " ";
 NestedNameSpecifier 

[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #84014)

2024-03-19 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

Thank you all for the reviews.

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


[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #84014)

2024-03-19 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-19 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

2024-03-20 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Fix printing of templated records. (PR #86339)

2024-03-22 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/86339

None

>From ab7d280abf053b67b716e0723e2e70876e639810 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Fri, 22 Mar 2024 13:55:44 -0700
Subject: [PATCH] Fix printing of templated records.

---
 clang/lib/AST/TypePrinter.cpp   |  5 -
 clang/unittests/AST/DeclPrinterTest.cpp | 21 +
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 7032ff2f18468c..d9504f9dcb3899 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -2303,11 +2303,6 @@ printTo(raw_ostream &OS, ArrayRef Args, const 
PrintingPolicy &Policy,
 } else {
   if (!FirstArg)
 OS << Comma;
-  if (!Policy.SuppressTagKeyword &&
-  Argument.getKind() == TemplateArgument::Type &&
-  isa(Argument.getAsType()))
-OS << Argument.getAsType().getAsString();
-  else
 // Tries to print the argument with location info if exists.
 printArgument(Arg, Policy, ArgOS,
   TemplateParameterList::shouldIncludeTypeForArgument(
diff --git a/clang/unittests/AST/DeclPrinterTest.cpp 
b/clang/unittests/AST/DeclPrinterTest.cpp
index e024c41e03b484..f0e360f9caf44a 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/unittests/AST/DeclPrinterTest.cpp
@@ -1386,6 +1386,27 @@ TEST(DeclPrinter, TestTemplateArgumentList16) {
   ASSERT_TRUE(PrintedDeclCXX11Matches(Code, "NT2", "int NT2 = 5"));
 }
 
+TEST(DeclPrinter, TestCXXRecordDecl17) {
+  ASSERT_TRUE(PrintedDeclCXX98Matches("template struct Z {};"
+  "struct X {};"
+  "Z A;",
+  "A",
+  "Z A"));
+  [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; };
+}
+
+TEST(DeclPrinter, TestCXXRecordDecl18) {
+  ASSERT_TRUE(PrintedDeclCXX98Matches("template struct Z {};"
+  "struct X {};"
+  "Z A;" 
+  "template "
+  "struct Y{};"
+  "Y, 2> B;",
+  "B", 
+  "Y, 2> B"));
+  [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; };
+}
+
 TEST(DeclPrinter, TestFunctionParamUglified) {
   llvm::StringLiteral Code = R"cpp(
 class __c;

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


[clang] Fix printing of templated records. (PR #86339)

2024-03-25 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/86339

>From ab7d280abf053b67b716e0723e2e70876e639810 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Fri, 22 Mar 2024 13:55:44 -0700
Subject: [PATCH 1/2] Fix printing of templated records.

---
 clang/lib/AST/TypePrinter.cpp   |  5 -
 clang/unittests/AST/DeclPrinterTest.cpp | 21 +
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 7032ff2f18468c..d9504f9dcb3899 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -2303,11 +2303,6 @@ printTo(raw_ostream &OS, ArrayRef Args, const 
PrintingPolicy &Policy,
 } else {
   if (!FirstArg)
 OS << Comma;
-  if (!Policy.SuppressTagKeyword &&
-  Argument.getKind() == TemplateArgument::Type &&
-  isa(Argument.getAsType()))
-OS << Argument.getAsType().getAsString();
-  else
 // Tries to print the argument with location info if exists.
 printArgument(Arg, Policy, ArgOS,
   TemplateParameterList::shouldIncludeTypeForArgument(
diff --git a/clang/unittests/AST/DeclPrinterTest.cpp 
b/clang/unittests/AST/DeclPrinterTest.cpp
index e024c41e03b484..f0e360f9caf44a 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/unittests/AST/DeclPrinterTest.cpp
@@ -1386,6 +1386,27 @@ TEST(DeclPrinter, TestTemplateArgumentList16) {
   ASSERT_TRUE(PrintedDeclCXX11Matches(Code, "NT2", "int NT2 = 5"));
 }
 
+TEST(DeclPrinter, TestCXXRecordDecl17) {
+  ASSERT_TRUE(PrintedDeclCXX98Matches("template struct Z {};"
+  "struct X {};"
+  "Z A;",
+  "A",
+  "Z A"));
+  [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; };
+}
+
+TEST(DeclPrinter, TestCXXRecordDecl18) {
+  ASSERT_TRUE(PrintedDeclCXX98Matches("template struct Z {};"
+  "struct X {};"
+  "Z A;" 
+  "template "
+  "struct Y{};"
+  "Y, 2> B;",
+  "B", 
+  "Y, 2> B"));
+  [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; };
+}
+
 TEST(DeclPrinter, TestFunctionParamUglified) {
   llvm::StringLiteral Code = R"cpp(
 class __c;

>From b1623cab26804c368adfea2eec17663e5a04f8d8 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Mon, 25 Mar 2024 05:04:47 -0700
Subject: [PATCH 2/2] Fixed format and added tests.

---
 clang/unittests/AST/DeclPrinterTest.cpp | 58 ++---
 1 file changed, 53 insertions(+), 5 deletions(-)

diff --git a/clang/unittests/AST/DeclPrinterTest.cpp 
b/clang/unittests/AST/DeclPrinterTest.cpp
index f0e360f9caf44a..07fa02bd96e25d 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/unittests/AST/DeclPrinterTest.cpp
@@ -1390,23 +1390,71 @@ TEST(DeclPrinter, TestCXXRecordDecl17) {
   ASSERT_TRUE(PrintedDeclCXX98Matches("template struct Z {};"
   "struct X {};"
   "Z A;",
-  "A",
-  "Z A"));
+  "A", "Z A"));
   [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; };
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl18) {
   ASSERT_TRUE(PrintedDeclCXX98Matches("template struct Z {};"
   "struct X {};"
-  "Z A;" 
+  "Z A;"
   "template "
   "struct Y{};"
   "Y, 2> B;",
-  "B", 
-  "Y, 2> B"));
+  "B", "Y, 2> B"));
   [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; };
 }
 
+TEST(DeclPrinter, TestCXXRecordDecl19) {
+  ASSERT_TRUE(PrintedDeclCXX98Matches("template struct Z {};"
+  "struct X {};"
+  "Z A;"
+  "template "
+  "struct Y{};"
+  "Y, 2> B;",
+  "B", "Y, 2> B"));
+  [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = true; };
+}
+TEST(DeclPrinter, TestCXXRecordDecl20) {
+  ASSERT_TRUE(PrintedDeclCXX98Matches(
+  "template  class Inner;"
+  "template "
+  "class Inner{Inner(T val){}};"
+  "template  class Outer {"
+  "public:"
+  "struct NestedStruct {"
+  "int nestedValue;"
+  "NestedStruct(int

[clang] Fix printing of templated records. (PR #86339)

2024-03-25 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Fix printing of templated records. (PR #86339)

2024-03-25 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Fix printing of templated records. (PR #86339)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits


@@ -2303,11 +2303,6 @@ printTo(raw_ostream &OS, ArrayRef Args, const 
PrintingPolicy &Policy,
 } else {
   if (!FirstArg)
 OS << Comma;
-  if (!Policy.SuppressTagKeyword &&
-  Argument.getKind() == TemplateArgument::Type &&
-  isa(Argument.getAsType()))
-OS << Argument.getAsType().getAsString();
-  else

zahiraam wrote:

This code was wrongly added in 
https://github.com/intel/llvm/commit/6503b015d4a8 and was not reached by any 
tests. Some of our internal testing did hit this and realized the code was 
wrong. Created reproducers from internal tests to show that the code is wrong.

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


[clang] Fix printing of templated records. (PR #86339)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Fix printing of templated records. (PR #86339)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Fix printing of templated records. (PR #86339)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

@AaronBallman Thanks!


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


[clang] Fix printing of templated records. (PR #86339)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Fix failure in buildbot, builds/25788. (PR #86661)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/86661

None

>From 5ef0aca43c2eefbb9967b98c70a58a29a9407e97 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 26 Mar 2024 06:53:31 -0700
Subject: [PATCH] Fix failure in buildbot, builds/25788.

---
 clang/lib/AST/TypePrinter.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index d9504f9dcb3899..d0ba6066fa0180 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -2303,10 +2303,10 @@ printTo(raw_ostream &OS, ArrayRef Args, const 
PrintingPolicy &Policy,
 } else {
   if (!FirstArg)
 OS << Comma;
-// Tries to print the argument with location info if exists.
-printArgument(Arg, Policy, ArgOS,
-  TemplateParameterList::shouldIncludeTypeForArgument(
-  Policy, TPL, ParmIndex));
+  // Tries to print the argument with location info if exists.
+  printArgument(Arg, Policy, ArgOS,
+TemplateParameterList::shouldIncludeTypeForArgument(
+Policy, TPL, ParmIndex));
 }
 StringRef ArgString = ArgOS.str();
 

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


[clang] Fix failure in buildbot (PR #86661)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Fix failure in buildbot (PR #86661)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Fix failure in buildbot (PR #86661)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [AST] Fix a warning (PR #86690)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

I have a PR ready for it. 


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


[clang] Fix failure in buildbot (PR #86661)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Fix printing of templated records. (PR #86339)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

> I'm getting errors like:
> 
> ```
> llvm-project/clang/unittests/AST/DeclPrinterTest.cpp:1394:3: error: 
> expression result unused [-Werror,-Wunused-value]
>   [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; };
> ```
> 
> This file being a clang test, I am wondering if this is actually part of the 
> test. Shall we put `[[maybe_unused]]` here?

@kazutakahirata  When do you get this error? 

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


[clang] Fix printing of templated records. (PR #86339)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

Creating a PR with 
`[](PrintingPolicy [[maybe_unused]] & Policy) {
Policy.SuppressTagKeyword = true;
  };`
  on those tests.

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


[clang] Fix printing of templated records. (PR #86339)

2024-03-26 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

oh! I think I know what the issue is. I have a fix for it. PR following up.

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


  1   2   3   4   5   6   7   8   >