[clang] 57eb205 - [clang][NFC] Fill in historical data on when C++ DRs 2000-2799 were fixed

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-09T11:12:54+03:00
New Revision: 57eb2054e308da7fb394375dedf8d7b627d1b528

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

LOG: [clang][NFC] Fill in historical data on when C++ DRs 2000-2799 were fixed

Added: 


Modified: 
clang/test/CXX/drs/dr2390.cpp
clang/test/CXX/drs/dr2406.cpp
clang/test/CXX/drs/dr26xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr2390.cpp b/clang/test/CXX/drs/dr2390.cpp
index d8ab1e9a1b3853..3931365b568ceb 100644
--- a/clang/test/CXX/drs/dr2390.cpp
+++ b/clang/test/CXX/drs/dr2390.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -E -P %s -o - | FileCheck %s
 
-// dr2390: yes
+// dr2390: 14
 
 namespace PR48462 {
 // Test that macro expansion of the builtin argument works.

diff  --git a/clang/test/CXX/drs/dr2406.cpp b/clang/test/CXX/drs/dr2406.cpp
index 7ea0870fb70b38..0ab198e6f1498e 100644
--- a/clang/test/CXX/drs/dr2406.cpp
+++ b/clang/test/CXX/drs/dr2406.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -x c++ %s  -verify
 
-// dr2406: yes
+// dr2406: 5
 
 void fallthrough(int n) {
   void g(), h(), i();

diff  --git a/clang/test/CXX/drs/dr26xx.cpp b/clang/test/CXX/drs/dr26xx.cpp
index 8517cd5872b183..1d702e66bf8c7f 100644
--- a/clang/test/CXX/drs/dr26xx.cpp
+++ b/clang/test/CXX/drs/dr26xx.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify
 
 
-namespace dr2621 { // dr2621: yes
+namespace dr2621 { // dr2621: 16
 enum class E { a };
 namespace One {
 using E_t = E;
@@ -101,7 +101,7 @@ int y = dr2640_a\N{LOTUS}); // expected-error {{character 
 not allowed
 
   // dr2642: na
 
-namespace dr2644 { // dr2644: yes
+namespace dr2644 { // dr2644: 8
 
 auto z = [a = 42](int a) { // expected-error {{a lambda parameter cannot 
shadow an explicitly captured entity}} \
// expected-note {{variable 'a' is explicitly 
captured here}}
@@ -111,7 +111,7 @@ auto z = [a = 42](int a) { // expected-error {{a lambda 
parameter cannot shadow
 }
 
 #if __cplusplus >= 202302L
-namespace dr2650 { // dr2650: yes
+namespace dr2650 { // dr2650: 17
 template  struct S {};
 template  int f(S*); // expected-note {{type 'X' of non-type 
template parameter is not a structural type}}
 class X {

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 3f519ff06742fd..d09cf616899ad4 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -14147,7 +14147,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2390.html";>2390
 CD5
 Is the argument of __has_cpp_attribute macro-expanded?
-Yes
+Clang 14
   
   
 https://cplusplus.github.io/CWG/issues/2391.html";>2391
@@ -14243,7 +14243,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2406.html";>2406
 CD5
 [[fallthrough]] attribute and iteration statements
-Yes
+Clang 5
   
   
 https://cplusplus.github.io/CWG/issues/2407.html";>2407
@@ -15533,7 +15533,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2621.html";>2621
 C++23
 Kind of lookup for using enum declarations
-Yes
+Clang 16
   
   
 https://cplusplus.github.io/CWG/issues/2622.html";>2622
@@ -15671,7 +15671,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2644.html";>2644
 C++23
 Incorrect comment in example
-Yes
+Clang 8
   
   
 https://cplusplus.github.io/CWG/issues/2645.html";>2645
@@ -15707,7 +15707,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2650.html";>2650
 C++23
 Incorrect example for ill-formed non-type template arguments
-Yes
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/2651.html";>2651



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


[clang] [clang][NFC] Refactor expected directives in C++ DRs 2000-2799 (PR #74921)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/74921

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.

>From 436502773b1720e0511f4371c7a04079e7d38215 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sat, 9 Dec 2023 11:12:19 +0300
Subject: [PATCH] [clang][NFC] Refactor expected directives in C++ DRs
 2000-2799

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.
---
 clang/test/CXX/drs/dr20xx.cpp | 219 +-
 clang/test/CXX/drs/dr21xx.cpp | 141 ++
 clang/test/CXX/drs/dr22xx.cpp |  37 +++---
 clang/test/CXX/drs/dr2354.cpp |  10 --
 clang/test/CXX/drs/dr23xx.cpp |  57 ++---
 clang/test/CXX/drs/dr2406.cpp |  30 -
 clang/test/CXX/drs/dr24xx.cpp |  51 +++-
 clang/test/CXX/drs/dr25xx.cpp | 106 
 clang/test/CXX/drs/dr26xx.cpp | 121 ---
 clang/test/CXX/drs/dr27xx.cpp |  25 +++-
 10 files changed, 499 insertions(+), 298 deletions(-)
 delete mode 100644 clang/test/CXX/drs/dr2354.cpp
 delete mode 100644 clang/test/CXX/drs/dr2406.cpp

diff --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp
index 4f81b0b413d4bd..60ee7684440f54 100644
--- a/clang/test/CXX/drs/dr20xx.cpp
+++ b/clang/test/CXX/drs/dr20xx.cpp
@@ -1,13 +1,14 @@
-// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors \
-// RUN:-Wno-variadic-macros -Wno-c11-extensions
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-
-#if __cplusplus < 201103L
-#define static_assert(...) _Static_assert(__VA_ARGS__)
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+
+#if __cplusplus == 199711L
+#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
+// cxx98-error@-1 {{variadic macros are a C99 feature}}
 #endif
 
 namespace dr2007 { // dr2007: 3.4
@@ -15,8 +16,12 @@ template struct A { typename T::error e; };
 template struct B { };
 B > b1;
 B > b2 = b1;
-int a = b2[0]; // expected-error {{does not provide a subscript operator}}
-int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
+int a = b2[0];
+// cxx98-error@-1 {{type 'B >' does not provide a subscript operator}}
+// since-cxx11-error@-2 {{type 'B>' does not provide a subscript 
operator}}
+int b = __builtin_addressof(b2)->foo;
+// cxx98-error@-1 {{no member named 'foo' in 'dr2007::B >'}}
+// since-cxx11-error@-2 {{no member named 'foo' in 
'dr2007::B>'}}
 }
 
 // dr2009: na
@@ -24,45 +29,69 @@ int b = __builtin_addressof(b2)->foo; // expected-error 
{{no member}}
 namespace dr2026 { // dr2026: 11
   template struct X {};
 
-  const int a = a + 1; // expected-warning {{uninitialized}} expected-note 
{{here}} expected-note 0-1{{outside its lifetime}}
-  X xa; // expected-error {{constant expression}} expected-note 
{{initializer of 'a'}}
+  const int a = a + 1; // #dr2026-a
+  // expected-warning@-1 {{variable 'a' is uninitialized when used within its 
own initialization}}
+  X xa; // #dr2026-xa
+  // cxx98-error@-1 {{non-type template argument of type 'int' is not an 
integral constant expression}}
+  //   cxx98-note@-2 {{initializer of 'a' is not a constant expression}}
+  //   cxx98-note@#dr2026-a {{declared here}

[clang] [clang][NFC] Refactor expected directives in C++ DRs 2000-2799 (PR #74921)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

This PR is created to check the patch against CI.

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


[clang] [clang][NFC] Refactor expected directives in C++ DRs 2000-2799 (PR #74921)

2023-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.

---

Patch is 68.85 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74921.diff


10 Files Affected:

- (modified) clang/test/CXX/drs/dr20xx.cpp (+139-80) 
- (modified) clang/test/CXX/drs/dr21xx.cpp (+92-49) 
- (modified) clang/test/CXX/drs/dr22xx.cpp (+23-14) 
- (removed) clang/test/CXX/drs/dr2354.cpp (-10) 
- (modified) clang/test/CXX/drs/dr23xx.cpp (+41-16) 
- (removed) clang/test/CXX/drs/dr2406.cpp (-30) 
- (modified) clang/test/CXX/drs/dr24xx.cpp (+47-4) 
- (modified) clang/test/CXX/drs/dr25xx.cpp (+58-48) 
- (modified) clang/test/CXX/drs/dr26xx.cpp (+80-41) 
- (modified) clang/test/CXX/drs/dr27xx.cpp (+19-6) 


``diff
diff --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp
index 4f81b0b413d4b..60ee7684440f5 100644
--- a/clang/test/CXX/drs/dr20xx.cpp
+++ b/clang/test/CXX/drs/dr20xx.cpp
@@ -1,13 +1,14 @@
-// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors \
-// RUN:-Wno-variadic-macros -Wno-c11-extensions
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-
-#if __cplusplus < 201103L
-#define static_assert(...) _Static_assert(__VA_ARGS__)
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+
+#if __cplusplus == 199711L
+#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
+// cxx98-error@-1 {{variadic macros are a C99 feature}}
 #endif
 
 namespace dr2007 { // dr2007: 3.4
@@ -15,8 +16,12 @@ template struct A { typename T::error e; };
 template struct B { };
 B > b1;
 B > b2 = b1;
-int a = b2[0]; // expected-error {{does not provide a subscript operator}}
-int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
+int a = b2[0];
+// cxx98-error@-1 {{type 'B >' does not provide a subscript operator}}
+// since-cxx11-error@-2 {{type 'B>' does not provide a subscript 
operator}}
+int b = __builtin_addressof(b2)->foo;
+// cxx98-error@-1 {{no member named 'foo' in 'dr2007::B >'}}
+// since-cxx11-error@-2 {{no member named 'foo' in 
'dr2007::B>'}}
 }
 
 // dr2009: na
@@ -24,45 +29,69 @@ int b = __builtin_addressof(b2)->foo; // expected-error 
{{no member}}
 namespace dr2026 { // dr2026: 11
   template struct X {};
 
-  const int a = a + 1; // expected-warning {{uninitialized}} expected-note 
{{here}} expected-note 0-1{{outside its lifetime}}
-  X xa; // expected-error {{constant expression}} expected-note 
{{initializer of 'a'}}
+  const int a = a + 1; // #dr2026-a
+  // expected-warning@-1 {{variable 'a' is uninitialized when used within its 
own initialization}}
+  X xa; // #dr2026-xa
+  // cxx98-error@-1 {{non-type template argument of type 'int' is not an 
integral constant expression}}
+  //   cxx98-note@-2 {{initializer of 'a' is not a constant expression}}
+  //   cxx98-note@#dr2026-a {{declared here}}
+  // since-cxx11-error@#dr2026-xa {{non-type template argument is not a 
constant expression}}
+  //   since-cxx11-note@#dr2026-xa {{initializer of 'a' is not a constant 
expression}}
+  //   since-cxx11-note@#dr2026-a {{declared here}}
 
 #if __cplusplus >= 201103L
-  constexpr int b = b; // expected-error {{constant expressio

[clang] [clang] Adjust TargetInfo bitfield (PR #74893)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

Yeah, I shouldn't have annotated this bit-field. Nice catch!

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


[clang] [clang] Adjust TargetInfo bitfield (PR #74893)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

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


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


[clang] [clang][ASTImporter] Support Importer of BuiltinBitCastExpr (PR #74813)

2023-12-09 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/74813

>From 53e0a0bb8061e5fbd49c58b30bc1217cbb669352 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Fri, 8 Dec 2023 15:26:01 +0800
Subject: [PATCH] [clang][ASTImporter] Support Importer of BuiltinBitCastExpr

---
 clang/lib/AST/ASTImporter.cpp   | 12 
 clang/unittests/AST/ASTImporterTest.cpp | 18 ++
 2 files changed, 30 insertions(+)

diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index f1f335118f37a..0edb6930ed0a0 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -7820,6 +7820,18 @@ ExpectedStmt 
ASTNodeImporter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
 *ToLParenLocOrErr, OCE->getBridgeKind(), E->getCastKind(),
 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
   }
+  case Stmt::BuiltinBitCastExprClass: {
+auto *BBC = cast(E);
+ExpectedSLoc ToKWLocOrErr = import(BBC->getBeginLoc());
+if (!ToKWLocOrErr)
+  return ToKWLocOrErr.takeError();
+ExpectedSLoc ToRParenLocOrErr = import(BBC->getEndLoc());
+if (!ToRParenLocOrErr)
+  return ToRParenLocOrErr.takeError();
+return new (Importer.getToContext()) BuiltinBitCastExpr(
+ToType, E->getValueKind(), E->getCastKind(), ToSubExpr,
+ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
+  }
   default:
 llvm_unreachable("Cast expression of unsupported type!");
 return make_error(ASTImportError::UnsupportedConstruct);
diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 4dd7510bf8ddf..27137c5b8ad06 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -9284,6 +9284,24 @@ TEST_P(ASTImporterOptionSpecificTestBase,
   // EXPECT_EQ(ToF1Imported->getPreviousDecl(), ToF1);
 }
 
+const internal::VariadicDynCastAllOfMatcher
+builtinBitCastExpr;
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportBuiltinBitCastExpr) {
+  const char *CodeFrom =
+  R"(
+  void foo(int T) { (void)__builtin_bit_cast(float, T); }
+  )";
+  Decl *FromTU = getTuDecl(CodeFrom, Lang_CXX20);
+  auto *FromFoo = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("foo")));
+  auto *ToFoo = Import(FromFoo, Lang_CXX20);
+  EXPECT_TRUE(ToFoo);
+  auto *ToBuiltinBitCastExpr =
+  FirstDeclMatcher().match(ToFoo, 
builtinBitCastExpr());
+  EXPECT_TRUE(ToBuiltinBitCastExpr);
+}
+
 INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest,
  DefaultTestValuesForRunOptions);
 

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


[clang] [flang] [flang][driver] Rename `flang-new` as `flang` (PR #74377)

2023-12-09 Thread Michael Klemm via cfe-commits

mjklemm wrote:

I have a Windows test machine.  How can I help?

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


[clang] [clang][ASTImporter] Support Importer of BuiltinBitCastExpr (PR #74813)

2023-12-09 Thread Qizhi Hu via cfe-commits


@@ -7820,6 +7820,18 @@ ExpectedStmt 
ASTNodeImporter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
 *ToLParenLocOrErr, OCE->getBridgeKind(), E->getCastKind(),
 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
   }
+  case Stmt::BuiltinBitCastExprClass: {
+auto *BBC = cast(E);
+ExpectedSLoc ToLParenLocOrErr = import(BBC->getBeginLoc());

jcsxky wrote:

 Fixed according to your suggestion and description has been updated.

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


[clang] [Driver][LTO] Copy fix empty stats filename to AMDGPU, HIPAMD, MinGW (PR #74178)

2023-12-09 Thread Brad Smith via cfe-commits

brad0 wrote:

@MaskRay Any response to what [yxsamliu](https://github.com/yxsamliu) said?

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


[clang] 6ed9a81 - [clang][NFC] Refactor expected directives in C++ DRs 2000-2799 (#74921)

2023-12-09 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-09T12:53:48+04:00
New Revision: 6ed9a81f7ebd23f125867dd270785dd0e63043c6

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

LOG: [clang][NFC] Refactor expected directives in C++ DRs 2000-2799 (#74921)

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its
corresponding PR for details.

Added: 


Modified: 
clang/test/CXX/drs/dr20xx.cpp
clang/test/CXX/drs/dr21xx.cpp
clang/test/CXX/drs/dr22xx.cpp
clang/test/CXX/drs/dr23xx.cpp
clang/test/CXX/drs/dr24xx.cpp
clang/test/CXX/drs/dr25xx.cpp
clang/test/CXX/drs/dr26xx.cpp
clang/test/CXX/drs/dr27xx.cpp

Removed: 
clang/test/CXX/drs/dr2354.cpp
clang/test/CXX/drs/dr2406.cpp



diff  --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp
index 4f81b0b413d4b..60ee7684440f5 100644
--- a/clang/test/CXX/drs/dr20xx.cpp
+++ b/clang/test/CXX/drs/dr20xx.cpp
@@ -1,13 +1,14 @@
-// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors \
-// RUN:-Wno-variadic-macros -Wno-c11-extensions
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
-
-#if __cplusplus < 201103L
-#define static_assert(...) _Static_assert(__VA_ARGS__)
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx20 -fexceptions 
-fcxx-exceptions -pedantic-errors
+
+#if __cplusplus == 199711L
+#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
+// cxx98-error@-1 {{variadic macros are a C99 feature}}
 #endif
 
 namespace dr2007 { // dr2007: 3.4
@@ -15,8 +16,12 @@ template struct A { typename T::error e; };
 template struct B { };
 B > b1;
 B > b2 = b1;
-int a = b2[0]; // expected-error {{does not provide a subscript operator}}
-int b = __builtin_addressof(b2)->foo; // expected-error {{no member}}
+int a = b2[0];
+// cxx98-error@-1 {{type 'B >' does not provide a subscript operator}}
+// since-cxx11-error@-2 {{type 'B>' does not provide a subscript 
operator}}
+int b = __builtin_addressof(b2)->foo;
+// cxx98-error@-1 {{no member named 'foo' in 'dr2007::B >'}}
+// since-cxx11-error@-2 {{no member named 'foo' in 
'dr2007::B>'}}
 }
 
 // dr2009: na
@@ -24,45 +29,69 @@ int b = __builtin_addressof(b2)->foo; // expected-error 
{{no member}}
 namespace dr2026 { // dr2026: 11
   template struct X {};
 
-  const int a = a + 1; // expected-warning {{uninitialized}} expected-note 
{{here}} expected-note 0-1{{outside its lifetime}}
-  X xa; // expected-error {{constant expression}} expected-note 
{{initializer of 'a'}}
+  const int a = a + 1; // #dr2026-a
+  // expected-warning@-1 {{variable 'a' is uninitialized when used within its 
own initialization}}
+  X xa; // #dr2026-xa
+  // cxx98-error@-1 {{non-type template argument of type 'int' is not an 
integral constant expression}}
+  //   cxx98-note@-2 {{initializer of 'a' is not a constant expression}}
+  //   cxx98-note@#dr2026-a {{declared here}}
+  // since-cxx11-error@#dr2026-xa {{non-type template argument is not a 
constant expression}}
+  //   since-cxx11-note@#dr2026-xa {{initializer of 'a' is not a constant 
expression}}
+  //   since-cxx11-note@#dr2026-a {{declared here}}
 
 #if __cplusplus >= 201103L

[clang] [clang][NFC] Refactor expected directives in C++ DRs 2000-2799 (PR #74921)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

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


[llvm] [clang] [flang] [clang-tools-extra] [libcxx] [openmp] [mlir] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,49 @@
+//===--- ReplaceMemcpyWithStdCopy.h - clang-tidy--*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_WITH_STDCOPY_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_WITH_STDCOPY_H
+
+#include "../ClangTidyCheck.h"
+#include "../utils/IncludeInserter.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+// Replace the C memcpy function with std::copy
+class ReplaceMemcpyWithStdCopy : public ClangTidyCheck {
+public:
+  ReplaceMemcpyWithStdCopy(StringRef Name, ClangTidyContext *Context);
+  ~ReplaceMemcpyWithStdCopy() override = default;
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Options) override;
+

PiotrZSL wrote:

Exclude implicit code with:
```
  std::optional getCheckTraversalKind() const override {
return TK_IgnoreUnlessSpelledInSource;
  }
```

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


[libcxx] [clang] [clang-tools-extra] [flang] [mlir] [openmp] [llvm] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -275,6 +275,7 @@ Clang-Tidy Checks
:doc:`modernize-raw-string-literal `, "Yes"
:doc:`modernize-redundant-void-arg `, "Yes"
:doc:`modernize-replace-auto-ptr `, "Yes"
+   :doc:`modernize-replace-memcpy-with-std-copy `, 
"Yes"

PiotrZSL wrote:

wrong link to check, didn't you use 
clang-tools-extra/clang-tidy/add_new_check.py to create a check ?

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


[libcxx] [flang] [clang] [mlir] [llvm] [openmp] [clang-tools-extra] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,47 @@
+.. title:: clang-tidy - modernize-replace-memcpy-with-stdcopy
+
+modernize-replace-memcpy-with-stdcopy
+===
+
+Replaces all occurrences of the C ``memcpy`` function with ``std::copy``

PiotrZSL wrote:

not function, but "calls", if i take address of memcpy then it wont replace

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


[mlir] [clang-tools-extra] [libcxx] [openmp] [llvm] [clang] [flang] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -275,6 +275,7 @@ Clang-Tidy Checks
:doc:`modernize-raw-string-literal `, "Yes"
:doc:`modernize-redundant-void-arg `, "Yes"
:doc:`modernize-replace-auto-ptr `, "Yes"
+   :doc:`modernize-replace-memcpy-with-std-copy `, 
"Yes"

PiotrZSL wrote:

And wrong check name

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


[openmp] [llvm] [flang] [mlir] [clang] [clang-tools-extra] [libcxx] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyWithStdCopy.cpp - clang-tidy*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceMemcpyWithStdCopy.h"
+#include "../utils/OptionsUtils.h"
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyWithStdCopy::ReplaceMemcpyWithStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM)) 
{
+}
+
+void ReplaceMemcpyWithStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");
+
+  Finder->addMatcher(MemcpyMatcher, this);
+}
+
+void ReplaceMemcpyWithStdCopy::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Inserter =
+  std::make_unique(SM, getLangOpts(),

PiotrZSL wrote:

why creating separate inserter ?

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


[clang-tools-extra] [mlir] [libcxx] [llvm] [flang] [openmp] [clang] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyWithStdCopy.cpp - clang-tidy*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceMemcpyWithStdCopy.h"
+#include "../utils/OptionsUtils.h"
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyWithStdCopy::ReplaceMemcpyWithStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM)) 
{
+}
+
+void ReplaceMemcpyWithStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");
+
+  Finder->addMatcher(MemcpyMatcher, this);
+}
+
+void ReplaceMemcpyWithStdCopy::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Inserter =
+  std::make_unique(SM, getLangOpts(),
+   IncludeStyle);
+  PP->addPPCallbacks(Inserter->CreatePPCallbacks());
+}
+
+void ReplaceMemcpyWithStdCopy::check(const MatchFinder::MatchResult &Result) {
+  const auto *MemcpyNode = Result.Nodes.getNodeAs("memcpy_function");
+  assert(MemcpyNode != nullptr);
+
+  DiagnosticBuilder Diag =
+  diag(MemcpyNode->getExprLoc(), "use std::copy instead of memcpy");
+
+  renameFunction(Diag, MemcpyNode);
+  reorderArgs(Diag, MemcpyNode);
+  insertHeader(Diag, MemcpyNode, Result.SourceManager);
+}
+
+void ReplaceMemcpyWithStdCopy::storeOptions(ClangTidyOptions::OptionMap &Opts) 
{
+  Options.store(Opts, "IncludeStyle",
+utils::IncludeSorter::toString(IncludeStyle));
+}
+
+void ReplaceMemcpyWithStdCopy::renameFunction(DiagnosticBuilder &Diag,
+  const CallExpr *MemcpyNode) {
+  const CharSourceRange FunctionNameSourceRange = 
CharSourceRange::getCharRange(
+  MemcpyNode->getBeginLoc(), MemcpyNode->getArg(0)->getBeginLoc());

PiotrZSL wrote:

wrong, use MemcpyNode->getCallee()->getSourceRange(), and remove additional "("

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


[clang-tools-extra] [openmp] [mlir] [clang] [llvm] [libcxx] [flang] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyWithStdCopy.cpp - clang-tidy*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceMemcpyWithStdCopy.h"
+#include "../utils/OptionsUtils.h"
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyWithStdCopy::ReplaceMemcpyWithStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM)) 
{
+}
+
+void ReplaceMemcpyWithStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),

PiotrZSL wrote:

use callee instead of hasDeclaration

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


[clang] [clang-tools-extra] [llvm] [libcxx] [openmp] [flang] [mlir] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,49 @@
+//===--- ReplaceMemcpyWithStdCopy.h - clang-tidy--*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_WITH_STDCOPY_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_WITH_STDCOPY_H
+
+#include "../ClangTidyCheck.h"
+#include "../utils/IncludeInserter.h"
+#include 
+#include 

PiotrZSL wrote:

vector and string is not used.

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


[clang] [libcxx] [flang] [openmp] [clang-tools-extra] [mlir] [llvm] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyWithStdCopy.cpp - clang-tidy*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceMemcpyWithStdCopy.h"
+#include "../utils/OptionsUtils.h"
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyWithStdCopy::ReplaceMemcpyWithStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM)) 
{
+}
+
+void ReplaceMemcpyWithStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");
+
+  Finder->addMatcher(MemcpyMatcher, this);
+}
+
+void ReplaceMemcpyWithStdCopy::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Inserter =
+  std::make_unique(SM, getLangOpts(),
+   IncludeStyle);
+  PP->addPPCallbacks(Inserter->CreatePPCallbacks());
+}
+
+void ReplaceMemcpyWithStdCopy::check(const MatchFinder::MatchResult &Result) {
+  const auto *MemcpyNode = Result.Nodes.getNodeAs("memcpy_function");
+  assert(MemcpyNode != nullptr);
+
+  DiagnosticBuilder Diag =
+  diag(MemcpyNode->getExprLoc(), "use std::copy instead of memcpy");
+
+  renameFunction(Diag, MemcpyNode);
+  reorderArgs(Diag, MemcpyNode);
+  insertHeader(Diag, MemcpyNode, Result.SourceManager);
+}
+
+void ReplaceMemcpyWithStdCopy::storeOptions(ClangTidyOptions::OptionMap &Opts) 
{
+  Options.store(Opts, "IncludeStyle",
+utils::IncludeSorter::toString(IncludeStyle));
+}
+
+void ReplaceMemcpyWithStdCopy::renameFunction(DiagnosticBuilder &Diag,
+  const CallExpr *MemcpyNode) {
+  const CharSourceRange FunctionNameSourceRange = 
CharSourceRange::getCharRange(
+  MemcpyNode->getBeginLoc(), MemcpyNode->getArg(0)->getBeginLoc());
+
+  Diag << FixItHint::CreateReplacement(FunctionNameSourceRange, "std::copy(");
+}
+
+void ReplaceMemcpyWithStdCopy::reorderArgs(DiagnosticBuilder &Diag,
+   const CallExpr *MemcpyNode) {
+  std::array arg;
+
+  LangOptions LangOpts;
+  LangOpts.CPlusPlus = true;
+  PrintingPolicy Policy(LangOpts);
+
+  // Retrieve all the arguments
+  for (uint8_t i = 0; i < arg.size(); i++) {
+llvm::raw_string_ostream s(arg[i]);
+MemcpyNode->getArg(i)->printPretty(s, nullptr, Policy);
+  }
+
+  // Create lambda that return SourceRange of an argument
+  auto getSourceRange = [MemcpyNode](uint8_t ArgCount) -> SourceRange {
+return SourceRange(MemcpyNode->getArg(ArgCount)->getBeginLoc(),
+   MemcpyNode->getArg(ArgCount)->getEndLoc());
+  };
+
+  // Reorder the arguments
+  Diag << FixItHint::CreateReplacement(getSourceRange(0), arg[1]);
+
+  arg[2] = arg[1] + " + ((" + arg[2] + ") / sizeof(*(" + arg[1] + ")))";
+  Diag << FixItHint::CreateReplacement(getSourceRange(1), arg[2]);
+
+  Diag << FixItHint::CreateReplacement(getSourceRange(2), arg[0]);
+}
+
+void ReplaceMemcpyWithStdCopy::insertHeader(DiagnosticBuilder &Diag,
+const CallExpr *MemcpyNode,
+SourceManager *const SM) {
+  Optional FixInclude = Inserter->CreateIncludeInsertion(
+  /*FileID=*/SM->getMainFileID(), /*Header=*/"algorithm",

PiotrZSL wrote:

wrong file, how do you know that you changing an main file, maybe you change a 
header file.
get file from MemcpyNode

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


[openmp] [libcxx] [llvm] [clang-tools-extra] [flang] [clang] [mlir] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,47 @@
+.. title:: clang-tidy - modernize-replace-memcpy-with-stdcopy
+
+modernize-replace-memcpy-with-stdcopy
+===

PiotrZSL wrote:

should cover check name

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


[libcxx] [llvm] [clang-tools-extra] [mlir] [clang] [openmp] [flang] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyWithStdCopy.cpp - clang-tidy*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceMemcpyWithStdCopy.h"
+#include "../utils/OptionsUtils.h"
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyWithStdCopy::ReplaceMemcpyWithStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM)) 
{
+}
+
+void ReplaceMemcpyWithStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");
+
+  Finder->addMatcher(MemcpyMatcher, this);
+}
+
+void ReplaceMemcpyWithStdCopy::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Inserter =
+  std::make_unique(SM, getLangOpts(),
+   IncludeStyle);
+  PP->addPPCallbacks(Inserter->CreatePPCallbacks());
+}
+
+void ReplaceMemcpyWithStdCopy::check(const MatchFinder::MatchResult &Result) {
+  const auto *MemcpyNode = Result.Nodes.getNodeAs("memcpy_function");
+  assert(MemcpyNode != nullptr);
+
+  DiagnosticBuilder Diag =
+  diag(MemcpyNode->getExprLoc(), "use std::copy instead of memcpy");
+
+  renameFunction(Diag, MemcpyNode);
+  reorderArgs(Diag, MemcpyNode);
+  insertHeader(Diag, MemcpyNode, Result.SourceManager);
+}
+
+void ReplaceMemcpyWithStdCopy::storeOptions(ClangTidyOptions::OptionMap &Opts) 
{
+  Options.store(Opts, "IncludeStyle",
+utils::IncludeSorter::toString(IncludeStyle));
+}
+
+void ReplaceMemcpyWithStdCopy::renameFunction(DiagnosticBuilder &Diag,
+  const CallExpr *MemcpyNode) {
+  const CharSourceRange FunctionNameSourceRange = 
CharSourceRange::getCharRange(
+  MemcpyNode->getBeginLoc(), MemcpyNode->getArg(0)->getBeginLoc());
+
+  Diag << FixItHint::CreateReplacement(FunctionNameSourceRange, "std::copy(");
+}
+
+void ReplaceMemcpyWithStdCopy::reorderArgs(DiagnosticBuilder &Diag,
+   const CallExpr *MemcpyNode) {
+  std::array arg;
+
+  LangOptions LangOpts;
+  LangOpts.CPlusPlus = true;
+  PrintingPolicy Policy(LangOpts);
+
+  // Retrieve all the arguments
+  for (uint8_t i = 0; i < arg.size(); i++) {

PiotrZSL wrote:

just read from a source by using tooling::fixit::getText, or way around with:
CreateInsertionFromRange and CreateRemoval


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


[mlir] [llvm] [clang] [libcxx] [openmp] [flang] [clang-tools-extra] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,49 @@
+//===--- ReplaceMemcpyWithStdCopy.h - clang-tidy--*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_WITH_STDCOPY_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_WITH_STDCOPY_H
+
+#include "../ClangTidyCheck.h"
+#include "../utils/IncludeInserter.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+// Replace the C memcpy function with std::copy
+class ReplaceMemcpyWithStdCopy : public ClangTidyCheck {
+public:
+  ReplaceMemcpyWithStdCopy(StringRef Name, ClangTidyContext *Context);
+  ~ReplaceMemcpyWithStdCopy() override = default;
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Options) override;
+
+private:
+  void renameFunction(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void reorderArgs(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void insertHeader(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode,
+SourceManager *const SM);
+
+private:
+  std::unique_ptr Inserter;
+  utils::IncludeInserter IncludeInserter;
+  const utils::IncludeSorter::IncludeStyle IncludeStyle;

PiotrZSL wrote:

IncludeStyle is uninitialized.

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


[libcxx] [llvm] [flang] [openmp] [mlir] [clang] [clang-tools-extra] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

**Missing tests.**
Lot of issues.
Personally i would consider modernize-use-std-copy-fill as an name, and cover 
also memset, as this would be the same code. And I would convert this into 
std::copy_n or std::full_n.

The only thing when std::copy should eb used would be if call to memset would 
be:
memset(other_begin, begin, end-begin);

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


[openmp] [flang] [libcxx] [llvm] [mlir] [clang] [clang-tools-extra] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyWithStdCopy.cpp - clang-tidy*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceMemcpyWithStdCopy.h"
+#include "../utils/OptionsUtils.h"
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyWithStdCopy::ReplaceMemcpyWithStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM)) 
{
+}
+
+void ReplaceMemcpyWithStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),
+   isExpansionInSystemHeader())),
+   isExpansionInMainFile())
+  .bind("memcpy_function");
+
+  Finder->addMatcher(MemcpyMatcher, this);
+}
+
+void ReplaceMemcpyWithStdCopy::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  if (!getLangOpts().CPlusPlus)

PiotrZSL wrote:

remove, check other comment

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


[libcxx] [flang] [llvm] [clang-tools-extra] [openmp] [clang] [mlir] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyWithStdCopy.cpp - clang-tidy*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceMemcpyWithStdCopy.h"
+#include "../utils/OptionsUtils.h"
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyWithStdCopy::ReplaceMemcpyWithStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM)) 
{
+}
+
+void ReplaceMemcpyWithStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);

PiotrZSL wrote:

not needed

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


[clang-tools-extra] [clang] [flang] [libcxx] [openmp] [llvm] [mlir] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyWithStdCopy.cpp - clang-tidy*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceMemcpyWithStdCopy.h"
+#include "../utils/OptionsUtils.h"
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyWithStdCopy::ReplaceMemcpyWithStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM)) 
{
+}
+
+void ReplaceMemcpyWithStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)

PiotrZSL wrote:

use 
```
bool
  isLanguageVersionSupported(const LangOptions &LangOptions) const override {
return LangOptions.CPlusPlus;
  }
```

instead

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


[clang-tools-extra] [libcxx] [llvm] [flang] [openmp] [mlir] [clang] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits

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


[mlir] [libcxx] [openmp] [flang] [clang] [clang-tools-extra] [llvm] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyWithStdCopy.cpp - clang-tidy*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceMemcpyWithStdCopy.h"
+#include "../utils/OptionsUtils.h"
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyWithStdCopy::ReplaceMemcpyWithStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM)) 
{
+}
+
+void ReplaceMemcpyWithStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),

PiotrZSL wrote:

Use hasAnyName("::std::memcpy", "::memcpy"))

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


[clang] [libcxx] [llvm] [openmp] [clang-tools-extra] [flang] [mlir] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,49 @@
+//===--- ReplaceMemcpyWithStdCopy.h - clang-tidy--*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_WITH_STDCOPY_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_MEMCPY_WITH_STDCOPY_H
+
+#include "../ClangTidyCheck.h"
+#include "../utils/IncludeInserter.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+// Replace the C memcpy function with std::copy
+class ReplaceMemcpyWithStdCopy : public ClangTidyCheck {
+public:
+  ReplaceMemcpyWithStdCopy(StringRef Name, ClangTidyContext *Context);
+  ~ReplaceMemcpyWithStdCopy() override = default;
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Options) override;
+
+private:
+  void renameFunction(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void reorderArgs(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode);
+  void insertHeader(DiagnosticBuilder &Diag, const CallExpr *MemcpyNode,
+SourceManager *const SM);
+
+private:
+  std::unique_ptr Inserter;

PiotrZSL wrote:

Why you create 2 Include inserters ? create only one.

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


[llvm] [openmp] [clang] [mlir] [libcxx] [flang] [clang-tools-extra] [clang-tidy] Replace memcpy with std::copy (PR #74663)

2023-12-09 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,119 @@
+//===--- ReplaceMemcpyWithStdCopy.cpp - clang-tidy*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ReplaceMemcpyWithStdCopy.h"
+#include "../utils/OptionsUtils.h"
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+ReplaceMemcpyWithStdCopy::ReplaceMemcpyWithStdCopy(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM)) 
{
+}
+
+void ReplaceMemcpyWithStdCopy::registerMatchers(MatchFinder *Finder) {
+  assert(Finder != nullptr);
+
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  auto MemcpyMatcher =
+  callExpr(hasDeclaration(functionDecl(hasName("memcpy"),

PiotrZSL wrote:

Verify interface of memcpy, at least verify that this is one with 3 arguments - 
argumentsCountIs(3)




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


[clang] [llvm] [DirectX] Move ROV info into HLSL metadata. NFC (PR #74896)

2023-12-09 Thread Justin Bogner via cfe-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/74896

>From 133bdc09eed41545794a369d3fa4d2afb720815e Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Fri, 8 Dec 2023 15:41:14 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 clang/lib/CodeGen/CGHLSLRuntime.cpp   |  9 ++---
 clang/lib/CodeGen/CGHLSLRuntime.h |  1 +
 .../builtins/RWBuffer-annotations.hlsl| 12 +--
 clang/test/CodeGenHLSL/cbuf.hlsl  |  4 ++--
 .../include/llvm/Frontend/HLSL/HLSLResource.h |  5 +++--
 llvm/lib/Frontend/HLSL/HLSLResource.cpp   | 14 +
 llvm/lib/Target/DirectX/DXILResource.cpp  |  4 +---
 llvm/test/CodeGen/DirectX/UAVMetadata.ll  | 20 +--
 llvm/test/CodeGen/DirectX/cbuf.ll |  2 +-
 .../CodeGen/DirectX/legacy_cb_layout_0.ll |  2 +-
 .../CodeGen/DirectX/legacy_cb_layout_1.ll |  2 +-
 .../CodeGen/DirectX/legacy_cb_layout_2.ll |  4 ++--
 .../CodeGen/DirectX/legacy_cb_layout_3.ll |  2 +-
 13 files changed, 45 insertions(+), 36 deletions(-)

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index c239bc17ef267e..3e8a40e7540bef 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -184,7 +184,8 @@ void CGHLSLRuntime::finishCodeGen() {
   : llvm::hlsl::ResourceKind::TBuffer;
 std::string TyName =
 Buf.Name.str() + (Buf.IsCBuffer ? ".cb." : ".tb.") + "ty";
-addBufferResourceAnnotation(GV, TyName, RC, RK, Buf.Binding);
+addBufferResourceAnnotation(GV, TyName, RC, RK, /*IsROV=*/false,
+Buf.Binding);
   }
 }
 
@@ -196,6 +197,7 @@ void 
CGHLSLRuntime::addBufferResourceAnnotation(llvm::GlobalVariable *GV,
 llvm::StringRef TyName,
 llvm::hlsl::ResourceClass RC,
 llvm::hlsl::ResourceKind RK,
+bool IsROV,
 BufferResBinding &Binding) {
   llvm::Module &M = CGM.getModule();
 
@@ -219,7 +221,7 @@ void 
CGHLSLRuntime::addBufferResourceAnnotation(llvm::GlobalVariable *GV,
  "ResourceMD must have been set by the switch above.");
 
   llvm::hlsl::FrontendResource Res(
-  GV, TyName, RK, Binding.Reg.value_or(UINT_MAX), Binding.Space);
+  GV, TyName, RK, IsROV, Binding.Reg.value_or(UINT_MAX), Binding.Space);
   ResourceMD->addOperand(Res.getMetadata());
 }
 
@@ -236,10 +238,11 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl 
*D, GlobalVariable *GV) {
 
   llvm::hlsl::ResourceClass RC = Attr->getResourceClass();
   llvm::hlsl::ResourceKind RK = Attr->getResourceKind();
+  bool IsROV = Attr->getIsROV();
 
   QualType QT(Ty, 0);
   BufferResBinding Binding(D->getAttr());
-  addBufferResourceAnnotation(GV, QT.getAsString(), RC, RK, Binding);
+  addBufferResourceAnnotation(GV, QT.getAsString(), RC, RK, IsROV, Binding);
 }
 
 CGHLSLRuntime::BufferResBinding::BufferResBinding(
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 67413fbd4a78e1..0979a0c5eb9ad0 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -93,6 +93,7 @@ class CGHLSLRuntime {
llvm::StringRef TyName,
llvm::hlsl::ResourceClass RC,
llvm::hlsl::ResourceKind RK,
+   bool IsROV,
BufferResBinding &Binding);
   void addConstant(VarDecl *D, Buffer &CB);
   void addBufferDecls(const DeclContext *DC, Buffer &CB);
diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
index 77091f8390a15a..a70e224b81e4b7 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
@@ -16,9 +16,9 @@ void main() {
 }
 
 // CHECK: !hlsl.uavs = !{![[Single:[0-9]+]], ![[Array:[0-9]+]], 
![[SingleAllocated:[0-9]+]], ![[ArrayAllocated:[0-9]+]], 
![[SingleSpace:[0-9]+]], ![[ArraySpace:[0-9]+]]}
-// CHECK-DAG: ![[Single]] = !{ptr @"?Buffer1@@3V?$RWBuffer@M@hlsl@@A", 
!"RWBuffer", i32 10, i32 -1, i32 0}
-// CHECK-DAG: ![[Array]] = !{ptr 
@"?BufferArray@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", 
!"RWBuffer >", i32 10, i32 -1, i32 0}
-// CHECK-DAG: ![[SingleAllocated]] = !{ptr 
@"?Buffer2@@3V?$RWBuffer@M@hlsl@@A", !"RWBuffer", i32 10, i32 3, i32 0}
-// CHECK-DAG: ![[ArrayAllocated]] = !{ptr 
@"?BufferArray2@@3PAV?$RWBuffer@T?$__vector@M$03@__clang@@@hlsl@@A", 
!"RWBuffer >",

[flang] [clang] [flang][driver] Rename `flang-new` as `flang` (PR #74377)

2023-12-09 Thread Andrzej Warzyński via cfe-commits

banach-space wrote:

> I have a Windows test machine. How can I help?

Thank you for the offer, but it looks like CI is now passing 🥳 @DavidTruby 
kindly helped me offline 🙏🏻 

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


[clang] [Cygwin] Cygwin -fuse-cxa-atexit (PR #74913)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng updated 
https://github.com/llvm/llvm-project/pull/74913

From 75a8486443ef200abe12b4047ac89011ada15802 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:04:02 +0800
Subject: [PATCH 01/13] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index eb26bfade47b7..df062ccc9021f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,7 +6656,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
+  !RawTriple.isOSAIX() && !RawTriple.isWindowsGNUEnvironment() &&
+  !RawTriple.isWindowsMSVCEnvironment() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 899b095dd1953fc8a766dee221723dfbf1e3a3e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:24:01 +0800
Subject: [PATCH 02/13] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index df062ccc9021f..eb26bfade47b7 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,8 +6656,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isWindowsGNUEnvironment() &&
-  !RawTriple.isWindowsMSVCEnvironment() &&
+  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 4fd5b816334bd8ccd8215f69f88dcbcc56f71857 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:39:22 +0800
Subject: [PATCH 03/13] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index eb26bfade47b7..fd75ad033c4dc 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,7 +6656,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
+  !RawTriple.isOSAIX() && !(RawTriple.isOSWindows() && 
!RawTriple.isWindowsCygwinEnvironment()) &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From a51bba69eb1e2f7f509e42830e54ce71de99e74a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:44:11 +0800
Subject: [PATCH 04/13] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index fd75ad033c4dc..3e2c07399387d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,7 +6656,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !(RawTriple.isOSWindows() && 
!RawTriple.isWindowsCygwinEnvironment()) &&
+  !RawTriple.isOSAIX() &&
+  !(RawTriple.isOSWindows() &&
+!RawTriple.isWindowsCygwinEnvironment()) &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 3b906c82e613d08c6b153b355019dbf939045896 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 14:07:41 +0800
Subject: [PATCH 05/13] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 3e2c07399387d..e67adf3d6616e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6658,7 +6658,7 @@ void Clang::ConstructJob(Compilatio

[clang-tools-extra] [clangd] Resolve the dependent type from its single instantiation. Take 1 (PR #71279)

2023-12-09 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

@HighCommander4 While at the `HeuristicResolver`, I think we may have a bug 
inside `HighlightingsBuilder` defined in `SemanticHighlighting.cpp`.

https://github.com/llvm/llvm-project/blob/6ed9a81f7ebd23f125867dd270785dd0e63043c6/clang-tools-extra/clangd/SemanticHighlighting.cpp#L592

I didn't see any other lines initializing this member. so we're always yielding 
`nullptr` from `H.getResolver` calls?

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Richard Dzenis via cfe-commits

RIscRIpt wrote:

I don't have write access, but I believe it is ready to be merged.

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Richard Dzenis via cfe-commits

RIscRIpt wrote:

Suggested commit message:
```
Add support for 'msvc::constexpr' C++11 attribute

This commit adds support for MSVC-specific C++11-style attribute
`[[msvc::constexpr]]`, which was added in MSVC 14.33.
The semantics of this attribute is enabled only under MSVC compatibility
(`-fms-compatibility-version`) 14.33 and higher.
Additionally, default value of `_MSC_VER` was raised to 1433.

The current implementation misses support of:
- `[[msvc::constexpr]]` constructors (see #72149);
  at the time of implementation such support required
  unreasonable amount of changes in Clang.
- `[[msvc::constexpr]] return ::new` (constexpr placement new) from
  non-std namespace (see #74924).

Relevant to: #57696
```

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


[clang] b3e6ff3 - [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (#71300)

2023-12-09 Thread via cfe-commits

Author: Richard Dzenis
Date: 2023-12-09T14:35:38+04:00
New Revision: b3e6ff331925dde24a4707452d657da0fdf7f588

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

LOG: [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (#71300)

This commit introduces support for the MSVC-specific C++11-style
attribute `[[msvc::constexpr]]`, which was introduced in MSVC 14.33.
The semantics of this attribute are enabled only under
MSVC compatibility (`-fms-compatibility-version`) 14.33 and higher.
Additionally, the default value of `_MSC_VER` has been raised to 1433.

The current implementation lacks support for:
- `[[msvc::constexpr]]` constructors (see #72149);
  at the time of this implementation, such support would have required
  an unreasonable number of changes in Clang.
- `[[msvc::constexpr]] return ::new` (constexpr placement new) from
  non-std namespaces (see #74924).

Relevant to: #57696

Added: 
clang/test/AST/ms-constexpr.cpp
clang/test/SemaCXX/ms-constexpr-invalid.cpp
clang/test/SemaCXX/ms-constexpr-new.cpp
clang/test/SemaCXX/ms-constexpr.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/UsersManual.rst
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Basic/Targets/OSTargets.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaStmtAttr.cpp
clang/test/Driver/cl-options.c
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28f9393e28437d..b4b5352a306c1c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -238,6 +238,8 @@ Non-comprehensive list of changes in this release
   except that it returns the size of a type ignoring tail padding.
 * ``__builtin_classify_type()`` now classifies ``_BitInt`` values as the 
return value ``18``
   and vector types as return value ``19``, to match GCC 14's behavior.
+* The default value of `_MSC_VER` was raised from 1920 to 1933.
+* Since MSVC 19.33 added undocumented attribute ``[[msvc::constexpr]]``, this 
release adds the attribute as well.
 
 * Added ``#pragma clang fp reciprocal``.
 

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 9d64195ee338e2..f1b344ef5109b5 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3359,8 +3359,8 @@ default for Windows targets.
 
 For compatibility with existing code that compiles with MSVC, clang defines the
 ``_MSC_VER`` and ``_MSC_FULL_VER`` macros. When on Windows, these default to
-either the same value as the currently installed version of cl.exe, or ``1920``
-and ``19200`` (respectively). The ``-fms-compatibility-version=`` flag
+either the same value as the currently installed version of cl.exe, or ``1933``
+and ``19330`` (respectively). The ``-fms-compatibility-version=`` flag
 overrides these values.  It accepts a dotted version tuple, such as 
19.00.23506.
 Changing the MSVC compatibility version makes clang behave more like that
 version of MSVC. For example, ``-fms-compatibility-version=19`` will enable

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 121ed203829cec..b0a8ef10c500a7 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3646,6 +3646,14 @@ def : MutualExclusions<[Owner, Pointer]>;
 
 // Microsoft-related attributes
 
+def MSConstexpr : InheritableAttr {
+  let LangOpts = [MicrosoftExt];
+  let Spellings = [CXX11<"msvc", "constexpr">];
+  let Subjects = SubjectList<[Function, ReturnStmt], ErrorDiag,
+ "functions and return statements">;
+  let Documentation = [MSConstexprDocs];
+}
+
 def MSNoVTable : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"novtable">];
   let Subjects = SubjectList<[CXXRecord]>;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 88f7c65e6e847b..1a98196834cefc 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3657,6 +3657,21 @@ an error:
 }];
 }
 
+def MSConstexprDocs : Documentation {
+  let Category = DocCatStmt;
+  let Content = [{
+The ``[[msvc::constexpr]]`` attribute can be applied only to a function
+definition or a ``return`` statement. It does not impact function declarations.
+A ``[[msvc::constexpr]]`` function cannot be ``constexpr`` or ``consteval``.
+A ``[[msvc::constexpr]]`` function is treated as if it were a ``constexpr`` 
function
+when it is 

[clang] [clang-tools-extra] [clang] Extend diagnose_if to accept more detailed warning information (PR #70976)

2023-12-09 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 updated 
https://github.com/llvm/llvm-project/pull/70976

>From a91f499900d4cea4804833d004b6c4e54a7d8b15 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Sun, 3 Sep 2023 17:26:28 -0700
Subject: [PATCH] [clang] Extend diagnose_if to accept more detailed warning
 information

---
 .../clang-tidy/ClangTidyDiagnosticConsumer.h  |   4 +
 clang-tools-extra/clangd/Diagnostics.cpp  |   6 +-
 clang-tools-extra/clangd/ParsedAST.cpp|   2 +-
 clang/include/clang/Basic/Attr.td |  13 +-
 clang/include/clang/Basic/Diagnostic.h|   9 +-
 .../clang/Basic/DiagnosticCategories.h|   1 +
 clang/include/clang/Basic/DiagnosticIDs.h | 106 ++--
 .../clang/Basic/DiagnosticSemaKinds.td|   6 +
 clang/lib/Basic/Diagnostic.cpp|  15 +-
 clang/lib/Basic/DiagnosticIDs.cpp | 232 ++
 clang/lib/Frontend/LogDiagnosticPrinter.cpp   |   4 +-
 .../Frontend/SerializedDiagnosticPrinter.cpp  |   3 +-
 clang/lib/Frontend/TextDiagnosticPrinter.cpp  |   8 +-
 clang/lib/Sema/Sema.cpp   |   4 +-
 clang/lib/Sema/SemaCUDA.cpp   |   4 +-
 clang/lib/Sema/SemaDeclAttr.cpp   |  22 +-
 clang/lib/Sema/SemaOverload.cpp   |  24 +-
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |   3 +-
 clang/lib/Serialization/ASTReader.cpp |   2 +-
 clang/lib/Serialization/ASTWriter.cpp |   2 +-
 .../SemaCXX/diagnose_if-warning-group.cpp |  35 +++
 clang/tools/diagtool/ListWarnings.cpp |   7 +-
 clang/tools/diagtool/ShowEnabledWarnings.cpp  |   6 +-
 clang/tools/libclang/CXStoredDiagnostic.cpp   |  15 +-
 24 files changed, 353 insertions(+), 180 deletions(-)
 create mode 100644 clang/test/SemaCXX/diagnose_if-warning-group.cpp

diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 9280eb1e1f218d..c7694ad05f03e5 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -79,6 +79,10 @@ class ClangTidyContext {
 this->DiagEngine = DiagEngine;
   }
 
+  const DiagnosticsEngine* getDiagnosticsEngine() const {
+return DiagEngine;
+  }
+
   ~ClangTidyContext();
 
   /// Report any errors detected using this method.
diff --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index 704e61b1e4dd79..0962fd971342fd 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -579,7 +579,9 @@ std::vector StoreDiags::take(const 
clang::tidy::ClangTidyContext *Tidy) {
   for (auto &Diag : Output) {
 if (const char *ClangDiag = getDiagnosticCode(Diag.ID)) {
   // Warnings controlled by -Wfoo are better recognized by that name.
-  StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(Diag.ID);
+  StringRef Warning = Tidy->getDiagnosticsEngine()
+  ->getDiagnosticIDs()
+  ->getWarningOptionForDiag(Diag.ID);
   if (!Warning.empty()) {
 Diag.Name = ("-W" + Warning).str();
   } else {
@@ -909,7 +911,7 @@ bool isBuiltinDiagnosticSuppressed(unsigned ID,
 if (Suppress.contains(normalizeSuppressedCode(CodePtr)))
   return true;
   }
-  StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(ID);
+  StringRef Warning = DiagnosticIDs{}.getWarningOptionForDiag(ID);
   if (!Warning.empty() && Suppress.contains(Warning))
 return true;
   return false;
diff --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index edd0f77b1031ef..57d21fa2711793 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -340,7 +340,7 @@ void applyWarningOptions(llvm::ArrayRef 
ExtraArgs,
   if (Enable) {
 if (Diags.getDiagnosticLevel(ID, SourceLocation()) <
 DiagnosticsEngine::Warning) {
-  auto Group = DiagnosticIDs::getGroupForDiag(ID);
+  auto Group = Diags.getDiagnosticIDs()->getGroupForDiag(ID);
   if (!Group || !EnabledGroups(*Group))
 continue;
   Diags.setSeverity(ID, diag::Severity::Warning, SourceLocation());
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 25231c5b82b907..e08b7720508d40 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2959,18 +2959,15 @@ def DiagnoseIf : InheritableAttr {
   let Spellings = [GNU<"diagnose_if">];
   let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
   let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
-  EnumArgument<"DiagnosticType",
-   "DiagnosticType",
-   ["error", "warning"],
-   ["DT_Error", "DT_Warning"]>,
+  EnumArgument<"DefaultSeverity",
+  

[clang] [clang-tools-extra] [clang] Extend diagnose_if to accept more detailed warning information (PR #70976)

2023-12-09 Thread Nikolas Klauser via cfe-commits


@@ -171,13 +172,61 @@ class DiagnosticMapping {
 class DiagnosticIDs : public RefCountedBase {
 public:
   /// The level of the diagnostic, after it has been through mapping.
-  enum Level {
+  enum Level : uint8_t {
 Ignored, Note, Remark, Warning, Error, Fatal
   };
 
+  // Diagnostic classes.
+  enum Class {
+CLASS_NOTE   = 0x01,
+CLASS_REMARK = 0x02,
+CLASS_WARNING= 0x03,
+CLASS_EXTENSION  = 0x04,
+CLASS_ERROR  = 0x05
+  };
+
+  struct CustomDiagDesc {
+diag::Severity DefaultSeverity : 3 = diag::Severity::Warning;
+unsigned Class : 3 = CLASS_WARNING;
+unsigned ShowInSystemHeader : 1 = false;
+unsigned ShowInSystemMacro : 1 = false;
+unsigned HasGroup : 1 = false;
+diag::Group Group = {};
+std::string Description;
+
+friend bool operator==(const CustomDiagDesc &lhs, const CustomDiagDesc 
&rhs) {
+  return lhs.DefaultSeverity == rhs.DefaultSeverity &&
+  lhs.Class == rhs.Class &&
+  lhs.ShowInSystemHeader == rhs.ShowInSystemHeader &&
+  lhs.ShowInSystemMacro == rhs.ShowInSystemMacro &&
+  lhs.HasGroup == rhs.HasGroup &&
+  (!lhs.HasGroup || lhs.Group == rhs.Group) &&

philnik777 wrote:

I guess you're right. I've added a constructor to make sure it's actually an 
invariant. The `std::tie` didn't quite work, since it's binding to temporaries 
of the bitfields. I've made a value-tuple instead and that simplifies the code 
a lot. Thanks!

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [Cygwin] Cygwin -fuse-cxa-atexit (PR #74913)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng updated 
https://github.com/llvm/llvm-project/pull/74913

From 75a8486443ef200abe12b4047ac89011ada15802 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:04:02 +0800
Subject: [PATCH 01/14] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index eb26bfade47b7a..df062ccc9021f7 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,7 +6656,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
+  !RawTriple.isOSAIX() && !RawTriple.isWindowsGNUEnvironment() &&
+  !RawTriple.isWindowsMSVCEnvironment() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 899b095dd1953fc8a766dee221723dfbf1e3a3e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:24:01 +0800
Subject: [PATCH 02/14] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index df062ccc9021f7..eb26bfade47b7a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,8 +6656,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isWindowsGNUEnvironment() &&
-  !RawTriple.isWindowsMSVCEnvironment() &&
+  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 4fd5b816334bd8ccd8215f69f88dcbcc56f71857 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:39:22 +0800
Subject: [PATCH 03/14] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index eb26bfade47b7a..fd75ad033c4dca 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,7 +6656,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
+  !RawTriple.isOSAIX() && !(RawTriple.isOSWindows() && 
!RawTriple.isWindowsCygwinEnvironment()) &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From a51bba69eb1e2f7f509e42830e54ce71de99e74a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:44:11 +0800
Subject: [PATCH 04/14] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index fd75ad033c4dca..3e2c07399387d5 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,7 +6656,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !(RawTriple.isOSWindows() && 
!RawTriple.isWindowsCygwinEnvironment()) &&
+  !RawTriple.isOSAIX() &&
+  !(RawTriple.isOSWindows() &&
+!RawTriple.isWindowsCygwinEnvironment()) &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 3b906c82e613d08c6b153b355019dbf939045896 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 14:07:41 +0800
Subject: [PATCH 05/14] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 3e2c07399387d5..e67adf3d6616e6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6658,7 +6658,7 @@ void Clang::ConstructJob(

[clang] [Cygwin] Cygwin -fuse-cxa-atexit (PR #74913)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng updated 
https://github.com/llvm/llvm-project/pull/74913

From 75a8486443ef200abe12b4047ac89011ada15802 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:04:02 +0800
Subject: [PATCH 01/15] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index eb26bfade47b7a..df062ccc9021f7 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,7 +6656,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
+  !RawTriple.isOSAIX() && !RawTriple.isWindowsGNUEnvironment() &&
+  !RawTriple.isWindowsMSVCEnvironment() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 899b095dd1953fc8a766dee221723dfbf1e3a3e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:24:01 +0800
Subject: [PATCH 02/15] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index df062ccc9021f7..eb26bfade47b7a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,8 +6656,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isWindowsGNUEnvironment() &&
-  !RawTriple.isWindowsMSVCEnvironment() &&
+  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 4fd5b816334bd8ccd8215f69f88dcbcc56f71857 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:39:22 +0800
Subject: [PATCH 03/15] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index eb26bfade47b7a..fd75ad033c4dca 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,7 +6656,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
+  !RawTriple.isOSAIX() && !(RawTriple.isOSWindows() && 
!RawTriple.isWindowsCygwinEnvironment()) &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From a51bba69eb1e2f7f509e42830e54ce71de99e74a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 13:44:11 +0800
Subject: [PATCH 04/15] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index fd75ad033c4dca..3e2c07399387d5 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6656,7 +6656,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !(RawTriple.isOSWindows() && 
!RawTriple.isWindowsCygwinEnvironment()) &&
+  !RawTriple.isOSAIX() &&
+  !(RawTriple.isOSWindows() &&
+!RawTriple.isWindowsCygwinEnvironment()) &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 3b906c82e613d08c6b153b355019dbf939045896 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 14:07:41 +0800
Subject: [PATCH 05/15] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 3e2c07399387d5..e67adf3d6616e6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6658,7 +6658,7 @@ void Clang::ConstructJob(

[clang] fix issue 73559. (PR #74926)

2023-12-09 Thread via cfe-commits

https://github.com/ChipsSpectre created 
https://github.com/llvm/llvm-project/pull/74926

As stated in this issue, https://github.com/llvm/llvm-project/issues/73559, 
clang (C version of clang, not C++) crashes when C++ components are parsed.

Even a file which only contains a double-colon "::" leads to this kind of crash.

The reason for this behavior is that TryAnnotateCXXScopeToken() of the clang 
parser assumes to be executed in C++ mode only. 

But in 2 places in the code, there was no guard to ensure this function is only 
called in C++ mode. When it is called nonetheless, the aforementioned error is 
created.

>From 8269060e6b50721a847742ff8d0af2c819e52578 Mon Sep 17 00:00:00 2001
From: ChipsSpectre 
Date: Sat, 9 Dec 2023 12:07:02 +0100
Subject: [PATCH] fix issue 73559.

---
 clang/lib/Parse/ParseDecl.cpp| 3 ++-
 clang/lib/Parse/ParseDeclCXX.cpp | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index ece3698967e2f..5d1c19ae07cb5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3483,7 +3483,8 @@ void Parser::ParseDeclarationSpecifiers(
 
 case tok::coloncolon: // ::foo::bar
   // C++ scope specifier.  Annotate and loop, or bail out on error.
-  if (TryAnnotateCXXScopeToken(EnteringContext)) {
+  if (getLangOpts().CPlusPlus &&
+  TryAnnotateCXXScopeToken(EnteringContext)) {
 if (!DS.hasTypeSpecifier())
   DS.SetTypeSpecError();
 goto DoneWithDeclSpec;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 910112ecae964..eba7ea65beee9 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2702,7 +2702,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
   bool MalformedTypeSpec = false;
   if (!TemplateInfo.Kind &&
   Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
-if (TryAnnotateCXXScopeToken())
+if (getLangOpts().CPlusPlus && TryAnnotateCXXScopeToken())
   MalformedTypeSpec = true;
 
 bool isAccessDecl;

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


[clang] fix issue 73559. (PR #74926)

2023-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (ChipsSpectre)


Changes

As stated in this issue, https://github.com/llvm/llvm-project/issues/73559, 
clang (C version of clang, not C++) crashes when C++ components are parsed.

Even a file which only contains a double-colon "::" leads to this kind of crash.

The reason for this behavior is that TryAnnotateCXXScopeToken() of the clang 
parser assumes to be executed in C++ mode only. 

But in 2 places in the code, there was no guard to ensure this function is only 
called in C++ mode. When it is called nonetheless, the aforementioned error is 
created.

---
Full diff: https://github.com/llvm/llvm-project/pull/74926.diff


2 Files Affected:

- (modified) clang/lib/Parse/ParseDecl.cpp (+2-1) 
- (modified) clang/lib/Parse/ParseDeclCXX.cpp (+1-1) 


``diff
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index ece3698967e2f6..5d1c19ae07cb54 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3483,7 +3483,8 @@ void Parser::ParseDeclarationSpecifiers(
 
 case tok::coloncolon: // ::foo::bar
   // C++ scope specifier.  Annotate and loop, or bail out on error.
-  if (TryAnnotateCXXScopeToken(EnteringContext)) {
+  if (getLangOpts().CPlusPlus &&
+  TryAnnotateCXXScopeToken(EnteringContext)) {
 if (!DS.hasTypeSpecifier())
   DS.SetTypeSpecError();
 goto DoneWithDeclSpec;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 910112ecae964c..eba7ea65beee94 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2702,7 +2702,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
   bool MalformedTypeSpec = false;
   if (!TemplateInfo.Kind &&
   Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
-if (TryAnnotateCXXScopeToken())
+if (getLangOpts().CPlusPlus && TryAnnotateCXXScopeToken())
   MalformedTypeSpec = true;
 
 bool isAccessDecl;

``




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


[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-09 Thread via cfe-commits

knightXun wrote:

> This needs at least one test and a Release note.
> 
> I expect the code form the issue to be well-formed: 
> https://godbolt.org/z/bhdfG34xc
> 
> So I am curious why you are adding the diagnostic for?

but the lambda template param is unknown, how can the template instantiator 
deduce the real type?

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


[clang] 3ec6c72 - [AST] Fix -Wlogical-op-parentheses in ExprConstant.cpp (NFC)

2023-12-09 Thread Jie Fu via cfe-commits

Author: Jie Fu
Date: 2023-12-09T19:13:30+08:00
New Revision: 3ec6c72551846b8f4143c8c101a1a6203e85a2aa

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

LOG: [AST] Fix -Wlogical-op-parentheses in ExprConstant.cpp (NFC)

llvm-project/clang/lib/AST/ExprConstant.cpp:5645:74: error: '&&' within '||' 
[-Werror,-Wlogical-op-parentheses]
 5645 |   (Definition->isConstexpr() || 
Info.CurrentCall->CanEvalMSConstexpr &&
  |  ~~ 
~^~
 5646 | 
Definition->hasAttr()))
  | 
~~
llvm-project/clang/lib/AST/ExprConstant.cpp:5645:74: note: place parentheses 
around the '&&' expression to silence this warning
 5645 |   (Definition->isConstexpr() || 
Info.CurrentCall->CanEvalMSConstexpr &&
  | 
 ^
  | (
 5646 | 
Definition->hasAttr()))
  |
  | 
  )
1 error generated.

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 9bef70770a544..f035c1419f4c9 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -5642,8 +5642,8 @@ static bool CheckConstexprFunction(EvalInfo &Info, 
SourceLocation CallLoc,
 
   // Can we evaluate this function call?
   if (Definition && Body &&
-  (Definition->isConstexpr() || Info.CurrentCall->CanEvalMSConstexpr &&
-
Definition->hasAttr()))
+  (Definition->isConstexpr() || (Info.CurrentCall->CanEvalMSConstexpr &&
+
Definition->hasAttr(
 return true;
 
   if (Info.getLangOpts().CPlusPlus11) {



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


[llvm] [clang] [SPARC] Support reserving arbitrary general purpose registers (PR #74927)

2023-12-09 Thread via cfe-commits

https://github.com/koachan created 
https://github.com/llvm/llvm-project/pull/74927

This adds support for marking arbitrary general purpose registers - except for 
those with special purpose (G0, I6-I7, O6-O7) - as reserved, as needed by some 
software like the Linux kernel.

>From 956ca7e210a438caac7c5dda8c9945305a53de39 Mon Sep 17 00:00:00 2001
From: Koakuma 
Date: Wed, 29 Nov 2023 08:08:29 +0700
Subject: [PATCH] [SPARC] Support reserving arbitrary general purpose registers

This adds support for marking arbitrary general purpose registers - except
for those with special purpose (G0, I6-I7, O6-O7) - as reserved, as needed
by some software like the Linux kernel.
---
 clang/include/clang/Driver/Options.td|  12 ++
 clang/lib/Driver/ToolChains/Arch/Sparc.cpp   |  81 +
 clang/test/Driver/sparc-fixed-register.c | 181 +++
 llvm/lib/Target/Sparc/Sparc.td   |  14 ++
 llvm/lib/Target/Sparc/SparcISelLowering.cpp  |  23 +++
 llvm/lib/Target/Sparc/SparcRegisterInfo.cpp  |  45 -
 llvm/lib/Target/Sparc/SparcRegisterInfo.h|   3 +
 llvm/lib/Target/Sparc/SparcRegisterInfo.td   |   4 +
 llvm/lib/Target/Sparc/SparcSubtarget.cpp |   6 +-
 llvm/lib/Target/Sparc/SparcSubtarget.h   |  11 ++
 llvm/test/CodeGen/SPARC/reserved-arg-regs.ll |  25 +++
 llvm/test/CodeGen/SPARC/reserved-regs.ll |  17 ++
 12 files changed, 420 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/sparc-fixed-register.c
 create mode 100644 llvm/test/CodeGen/SPARC/reserved-arg-regs.ll

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index df12ba8fbcb296..94bdeff28d0146 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5730,6 +5730,18 @@ def mvis3 : Flag<["-"], "mvis3">, 
Group;
 def mno_vis3 : Flag<["-"], "mno-vis3">, Group;
 def mhard_quad_float : Flag<["-"], "mhard-quad-float">, 
Group;
 def msoft_quad_float : Flag<["-"], "msoft-quad-float">, 
Group;
+foreach i = {1-7} in
+  def ffixed_g#i : Flag<["-"], "ffixed-g"#i>, Group,
+HelpText<"Reserve the G"#i#" register (SPARC only)">;
+foreach i = {0-5} in
+  def ffixed_o#i : Flag<["-"], "ffixed-o"#i>, Group,
+HelpText<"Reserve the O"#i#" register (SPARC only)">;
+foreach i = {0-7} in
+  def ffixed_l#i : Flag<["-"], "ffixed-l"#i>, Group,
+HelpText<"Reserve the L"#i#" register (SPARC only)">;
+foreach i = {0-5} in
+  def ffixed_i#i : Flag<["-"], "ffixed-i"#i>, Group,
+HelpText<"Reserve the I"#i#" register (SPARC only)">;
 } // let Flags = [TargetSpecific]
 
 // M68k features flags
diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp 
b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
index 22e583021515e5..ae1a4ba7882627 100644
--- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -178,4 +178,85 @@ void sparc::getSparcTargetFeatures(const Driver &D, const 
ArgList &Args,
 else
   Features.push_back("-hard-quad-float");
   }
+
+  if (Args.hasArg(options::OPT_ffixed_g1))
+Features.push_back("+reserve-g1");
+
+  if (Args.hasArg(options::OPT_ffixed_g2))
+Features.push_back("+reserve-g2");
+
+  if (Args.hasArg(options::OPT_ffixed_g3))
+Features.push_back("+reserve-g3");
+
+  if (Args.hasArg(options::OPT_ffixed_g4))
+Features.push_back("+reserve-g4");
+
+  if (Args.hasArg(options::OPT_ffixed_g5))
+Features.push_back("+reserve-g5");
+
+  if (Args.hasArg(options::OPT_ffixed_g6))
+Features.push_back("+reserve-g6");
+
+  if (Args.hasArg(options::OPT_ffixed_g7))
+Features.push_back("+reserve-g7");
+
+  if (Args.hasArg(options::OPT_ffixed_o0))
+Features.push_back("+reserve-o0");
+
+  if (Args.hasArg(options::OPT_ffixed_o1))
+Features.push_back("+reserve-o1");
+
+  if (Args.hasArg(options::OPT_ffixed_o2))
+Features.push_back("+reserve-o2");
+
+  if (Args.hasArg(options::OPT_ffixed_o3))
+Features.push_back("+reserve-o3");
+
+  if (Args.hasArg(options::OPT_ffixed_o4))
+Features.push_back("+reserve-o4");
+
+  if (Args.hasArg(options::OPT_ffixed_o5))
+Features.push_back("+reserve-o5");
+
+  if (Args.hasArg(options::OPT_ffixed_l0))
+Features.push_back("+reserve-l0");
+
+  if (Args.hasArg(options::OPT_ffixed_l1))
+Features.push_back("+reserve-l1");
+
+  if (Args.hasArg(options::OPT_ffixed_l2))
+Features.push_back("+reserve-l2");
+
+  if (Args.hasArg(options::OPT_ffixed_l3))
+Features.push_back("+reserve-l3");
+
+  if (Args.hasArg(options::OPT_ffixed_l4))
+Features.push_back("+reserve-l4");
+
+  if (Args.hasArg(options::OPT_ffixed_l5))
+Features.push_back("+reserve-l5");
+
+  if (Args.hasArg(options::OPT_ffixed_l6))
+Features.push_back("+reserve-l6");
+
+  if (Args.hasArg(options::OPT_ffixed_l7))
+Features.push_back("+reserve-l7");
+
+  if (Args.hasArg(options::OPT_ffixed_i0))
+Features.push_back("+reserve-i0");
+
+  if (Args.hasArg(options::OPT_ffixed_i1))
+Features.push_back("+reserve-i1");
+
+  if

[llvm] [clang] [SPARC] Support reserving arbitrary general purpose registers (PR #74927)

2023-12-09 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Koakuma (koachan)


Changes

This adds support for marking arbitrary general purpose registers - except for 
those with special purpose (G0, I6-I7, O6-O7) - as reserved, as needed by some 
software like the Linux kernel.

---

Patch is 24.86 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74927.diff


12 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+12) 
- (modified) clang/lib/Driver/ToolChains/Arch/Sparc.cpp (+81) 
- (added) clang/test/Driver/sparc-fixed-register.c (+181) 
- (modified) llvm/lib/Target/Sparc/Sparc.td (+14) 
- (modified) llvm/lib/Target/Sparc/SparcISelLowering.cpp (+23) 
- (modified) llvm/lib/Target/Sparc/SparcRegisterInfo.cpp (+44-1) 
- (modified) llvm/lib/Target/Sparc/SparcRegisterInfo.h (+3) 
- (modified) llvm/lib/Target/Sparc/SparcRegisterInfo.td (+4) 
- (modified) llvm/lib/Target/Sparc/SparcSubtarget.cpp (+5-1) 
- (modified) llvm/lib/Target/Sparc/SparcSubtarget.h (+11) 
- (added) llvm/test/CodeGen/SPARC/reserved-arg-regs.ll (+25) 
- (modified) llvm/test/CodeGen/SPARC/reserved-regs.ll (+17) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index df12ba8fbcb29..94bdeff28d014 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5730,6 +5730,18 @@ def mvis3 : Flag<["-"], "mvis3">, 
Group;
 def mno_vis3 : Flag<["-"], "mno-vis3">, Group;
 def mhard_quad_float : Flag<["-"], "mhard-quad-float">, 
Group;
 def msoft_quad_float : Flag<["-"], "msoft-quad-float">, 
Group;
+foreach i = {1-7} in
+  def ffixed_g#i : Flag<["-"], "ffixed-g"#i>, Group,
+HelpText<"Reserve the G"#i#" register (SPARC only)">;
+foreach i = {0-5} in
+  def ffixed_o#i : Flag<["-"], "ffixed-o"#i>, Group,
+HelpText<"Reserve the O"#i#" register (SPARC only)">;
+foreach i = {0-7} in
+  def ffixed_l#i : Flag<["-"], "ffixed-l"#i>, Group,
+HelpText<"Reserve the L"#i#" register (SPARC only)">;
+foreach i = {0-5} in
+  def ffixed_i#i : Flag<["-"], "ffixed-i"#i>, Group,
+HelpText<"Reserve the I"#i#" register (SPARC only)">;
 } // let Flags = [TargetSpecific]
 
 // M68k features flags
diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp 
b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
index 22e583021515e..ae1a4ba788262 100644
--- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -178,4 +178,85 @@ void sparc::getSparcTargetFeatures(const Driver &D, const 
ArgList &Args,
 else
   Features.push_back("-hard-quad-float");
   }
+
+  if (Args.hasArg(options::OPT_ffixed_g1))
+Features.push_back("+reserve-g1");
+
+  if (Args.hasArg(options::OPT_ffixed_g2))
+Features.push_back("+reserve-g2");
+
+  if (Args.hasArg(options::OPT_ffixed_g3))
+Features.push_back("+reserve-g3");
+
+  if (Args.hasArg(options::OPT_ffixed_g4))
+Features.push_back("+reserve-g4");
+
+  if (Args.hasArg(options::OPT_ffixed_g5))
+Features.push_back("+reserve-g5");
+
+  if (Args.hasArg(options::OPT_ffixed_g6))
+Features.push_back("+reserve-g6");
+
+  if (Args.hasArg(options::OPT_ffixed_g7))
+Features.push_back("+reserve-g7");
+
+  if (Args.hasArg(options::OPT_ffixed_o0))
+Features.push_back("+reserve-o0");
+
+  if (Args.hasArg(options::OPT_ffixed_o1))
+Features.push_back("+reserve-o1");
+
+  if (Args.hasArg(options::OPT_ffixed_o2))
+Features.push_back("+reserve-o2");
+
+  if (Args.hasArg(options::OPT_ffixed_o3))
+Features.push_back("+reserve-o3");
+
+  if (Args.hasArg(options::OPT_ffixed_o4))
+Features.push_back("+reserve-o4");
+
+  if (Args.hasArg(options::OPT_ffixed_o5))
+Features.push_back("+reserve-o5");
+
+  if (Args.hasArg(options::OPT_ffixed_l0))
+Features.push_back("+reserve-l0");
+
+  if (Args.hasArg(options::OPT_ffixed_l1))
+Features.push_back("+reserve-l1");
+
+  if (Args.hasArg(options::OPT_ffixed_l2))
+Features.push_back("+reserve-l2");
+
+  if (Args.hasArg(options::OPT_ffixed_l3))
+Features.push_back("+reserve-l3");
+
+  if (Args.hasArg(options::OPT_ffixed_l4))
+Features.push_back("+reserve-l4");
+
+  if (Args.hasArg(options::OPT_ffixed_l5))
+Features.push_back("+reserve-l5");
+
+  if (Args.hasArg(options::OPT_ffixed_l6))
+Features.push_back("+reserve-l6");
+
+  if (Args.hasArg(options::OPT_ffixed_l7))
+Features.push_back("+reserve-l7");
+
+  if (Args.hasArg(options::OPT_ffixed_i0))
+Features.push_back("+reserve-i0");
+
+  if (Args.hasArg(options::OPT_ffixed_i1))
+Features.push_back("+reserve-i1");
+
+  if (Args.hasArg(options::OPT_ffixed_i2))
+Features.push_back("+reserve-i2");
+
+  if (Args.hasArg(options::OPT_ffixed_i3))
+Features.push_back("+reserve-i3");
+
+  if (Args.hasArg(options::OPT_ffixed_i4))
+Features.push_back("+reserve-i4");
+
+  if (Args.hasArg(options::OPT_ffixed_i5))
+Features.push_back("+reserve-i5");
 }
diff --

[llvm] [clang] [llvm] Add support for building on illumos (PR #74930)

2023-12-09 Thread Brad Smith via cfe-commits

https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/74930

illumos has an older version of the Solaris linker that does not
support the GNU version script compat nor version scripts and does
not support -Bsymbolic-functions. Treat illumos linker separately.

The libclang/CMakeLists part lifted from NetBSD's pkgsrc.

Build tested on Solaris 11.4 and OpenIndiana.

/usr/bin/ld --version

ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.3260
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1790 (illumos)

>From 5b41ec8ab1640e09f0fa29bf2b9f2ec89168d4c4 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Sat, 9 Dec 2023 01:43:09 -0500
Subject: [PATCH] [llvm] Add support for building on illumos

illumos has an older version of the Solaris linker that does not
support the GNU version script compat nor version scripts and does
not support -Bsymbolic-functions. Treat illumos linker separately.
---
 clang/tools/clang-shlib/CMakeLists.txt |  2 +-
 clang/tools/libclang/CMakeLists.txt| 19 +++
 llvm/cmake/modules/AddLLVM.cmake   | 13 ++---
 llvm/tools/llvm-shlib/CMakeLists.txt   |  4 ++--
 4 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/clang/tools/clang-shlib/CMakeLists.txt 
b/clang/tools/clang-shlib/CMakeLists.txt
index aa7fcd1efed45..298d3a9d18fec 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -50,7 +50,7 @@ add_clang_library(clang-cpp
   ${_DEPS})
 # Optimize function calls for default visibility definitions to avoid PLT and
 # reduce dynamic relocations.
-if (NOT APPLE AND NOT MINGW)
+if (NOT APPLE AND NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
   target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
 endif()
 if (MINGW OR CYGWIN)
diff --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index 4f23065a24727..1cfc46eb1a52f 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -185,11 +185,22 @@ if(ENABLE_SHARED)
 endif()
   endif()
   if (USE_VERSION_SCRIPT)
-target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
-# The Solaris 11.4 linker supports a subset of GNU ld version scripts,
-# but requires a special option to enable it.
 if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
-  target_link_options(libclang PRIVATE "-Wl,-z,gnu-version-script-compat")
+  include(CheckLinkerFlag)
+  # The Solaris 11.4 linker supports a subset of GNU ld version scripts,
+  # but requires a special option to enable it.
+  llvm_check_linker_flag(CXX "-Wl,-z,gnu-version-script-compat"
+ LINKER_SUPPORTS_Z_GNU_VERSION_SCRIPT_COMPAT)
+  # Older Solaris (and illumos) linker does not support GNU ld version 
scripts
+  # and does not support GNU version script compat.
+  if (LINKER_SUPPORTS_Z_GNU_VERSION_SCRIPT_COMPAT)
+target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
+target_link_options(libclang PRIVATE 
"-Wl,-z,gnu-version-script-compat")
+  else()
+target_link_options(libclang PRIVATE 
"-Wl,-M,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
+  endif()
+else()
+  target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
 endif()
 # Ensure that libclang.so gets rebuilt when the linker script changes.
 set_property(SOURCE ARCMigrate.cpp APPEND PROPERTY
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index c9bca30c8f33d..ca146ad699ff6 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -115,7 +115,7 @@ function(add_llvm_symbol_exports target_name export_file)
   DEPENDS ${export_file}
   VERBATIM
   COMMENT "Creating export file for ${target_name}")
-if (${LLVM_LINKER_IS_SOLARISLD})
+if ((${LLVM_LINKER_IS_SOLARISLD}) OR (${LLVM_LINKER_IS_SOLARISLD_ILLUMOS}))
   set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS "  
-Wl,-M,\"${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}\"")
 else()
@@ -241,6 +241,11 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
   set(LLVM_LINKER_IS_GNULD YES CACHE INTERNAL "")
   message(STATUS "Linker detection: GNU ld")
+elseif("${stderr}" MATCHES "(illumos)" OR
+   "${stdout}" MATCHES "(illumos)")
+  set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
+  set(LLVM_LINKER_IS_SOLARISLD_ILLUMOS YES CACHE INTERNAL "")
+  message(STATUS "Linker detection: Solaris ld (illumos)")
 elseif("${stderr}" MATCHES "Solaris Link Editors" OR
"${stdout}" MATCHES "Solaris Link Editors")
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
@@ -282,11 +287,13 @@ function(add_link

[llvm] [clang] [llvm] Add support for building on illumos (PR #74930)

2023-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Brad Smith (brad0)


Changes

illumos has an older version of the Solaris linker that does not
support the GNU version script compat nor version scripts and does
not support -Bsymbolic-functions. Treat illumos linker separately.

The libclang/CMakeLists part lifted from NetBSD's pkgsrc.

Build tested on Solaris 11.4 and OpenIndiana.

/usr/bin/ld --version

ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.3260
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1790 (illumos)

---
Full diff: https://github.com/llvm/llvm-project/pull/74930.diff


4 Files Affected:

- (modified) clang/tools/clang-shlib/CMakeLists.txt (+1-1) 
- (modified) clang/tools/libclang/CMakeLists.txt (+15-4) 
- (modified) llvm/cmake/modules/AddLLVM.cmake (+10-3) 
- (modified) llvm/tools/llvm-shlib/CMakeLists.txt (+2-2) 


``diff
diff --git a/clang/tools/clang-shlib/CMakeLists.txt 
b/clang/tools/clang-shlib/CMakeLists.txt
index aa7fcd1efed45b..298d3a9d18fec8 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -50,7 +50,7 @@ add_clang_library(clang-cpp
   ${_DEPS})
 # Optimize function calls for default visibility definitions to avoid PLT and
 # reduce dynamic relocations.
-if (NOT APPLE AND NOT MINGW)
+if (NOT APPLE AND NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
   target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
 endif()
 if (MINGW OR CYGWIN)
diff --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index 4f23065a247274..1cfc46eb1a52f6 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -185,11 +185,22 @@ if(ENABLE_SHARED)
 endif()
   endif()
   if (USE_VERSION_SCRIPT)
-target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
-# The Solaris 11.4 linker supports a subset of GNU ld version scripts,
-# but requires a special option to enable it.
 if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
-  target_link_options(libclang PRIVATE "-Wl,-z,gnu-version-script-compat")
+  include(CheckLinkerFlag)
+  # The Solaris 11.4 linker supports a subset of GNU ld version scripts,
+  # but requires a special option to enable it.
+  llvm_check_linker_flag(CXX "-Wl,-z,gnu-version-script-compat"
+ LINKER_SUPPORTS_Z_GNU_VERSION_SCRIPT_COMPAT)
+  # Older Solaris (and illumos) linker does not support GNU ld version 
scripts
+  # and does not support GNU version script compat.
+  if (LINKER_SUPPORTS_Z_GNU_VERSION_SCRIPT_COMPAT)
+target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
+target_link_options(libclang PRIVATE 
"-Wl,-z,gnu-version-script-compat")
+  else()
+target_link_options(libclang PRIVATE 
"-Wl,-M,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
+  endif()
+else()
+  target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
 endif()
 # Ensure that libclang.so gets rebuilt when the linker script changes.
 set_property(SOURCE ARCMigrate.cpp APPEND PROPERTY
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index c9bca30c8f33d1..ca146ad699ff6c 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -115,7 +115,7 @@ function(add_llvm_symbol_exports target_name export_file)
   DEPENDS ${export_file}
   VERBATIM
   COMMENT "Creating export file for ${target_name}")
-if (${LLVM_LINKER_IS_SOLARISLD})
+if ((${LLVM_LINKER_IS_SOLARISLD}) OR (${LLVM_LINKER_IS_SOLARISLD_ILLUMOS}))
   set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS "  
-Wl,-M,\"${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}\"")
 else()
@@ -241,6 +241,11 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
   set(LLVM_LINKER_IS_GNULD YES CACHE INTERNAL "")
   message(STATUS "Linker detection: GNU ld")
+elseif("${stderr}" MATCHES "(illumos)" OR
+   "${stdout}" MATCHES "(illumos)")
+  set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
+  set(LLVM_LINKER_IS_SOLARISLD_ILLUMOS YES CACHE INTERNAL "")
+  message(STATUS "Linker detection: Solaris ld (illumos)")
 elseif("${stderr}" MATCHES "Solaris Link Editors" OR
"${stdout}" MATCHES "Solaris Link Editors")
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
@@ -282,11 +287,13 @@ function(add_link_opts target_name)
 # ld64's implementation of -dead_strip breaks tools that use plugins.
 set_property(TARGET ${target_name} APPEND_STRING PROPERTY
  LINK_FLAGS " -Wl,-dead_strip")
-  elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
+  elseif(${CMAKE

[llvm] [clang] [llvm] Add support for building on illumos (PR #74930)

2023-12-09 Thread Brad Smith via cfe-commits

https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/74930

>From 58f07d552bb73244e1641078aebdbce64d5219e9 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Sat, 9 Dec 2023 01:43:09 -0500
Subject: [PATCH] [llvm] Add support for building on illumos

illumos has an older version of the Solaris linker that does not
support the GNU version script compat nor version scripts and does
not support -Bsymbolic-functions. Treat illumos linker separately.

The libclang/CMakeLists part lifted from NetBSD's pkgsrc.
---
 clang/tools/clang-shlib/CMakeLists.txt |  2 +-
 clang/tools/libclang/CMakeLists.txt| 19 +++
 llvm/cmake/modules/AddLLVM.cmake   | 13 ++---
 llvm/tools/llvm-shlib/CMakeLists.txt   |  4 ++--
 4 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/clang/tools/clang-shlib/CMakeLists.txt 
b/clang/tools/clang-shlib/CMakeLists.txt
index aa7fcd1efed45b..298d3a9d18fec8 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -50,7 +50,7 @@ add_clang_library(clang-cpp
   ${_DEPS})
 # Optimize function calls for default visibility definitions to avoid PLT and
 # reduce dynamic relocations.
-if (NOT APPLE AND NOT MINGW)
+if (NOT APPLE AND NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
   target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
 endif()
 if (MINGW OR CYGWIN)
diff --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index 4f23065a247274..1cfc46eb1a52f6 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -185,11 +185,22 @@ if(ENABLE_SHARED)
 endif()
   endif()
   if (USE_VERSION_SCRIPT)
-target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
-# The Solaris 11.4 linker supports a subset of GNU ld version scripts,
-# but requires a special option to enable it.
 if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
-  target_link_options(libclang PRIVATE "-Wl,-z,gnu-version-script-compat")
+  include(CheckLinkerFlag)
+  # The Solaris 11.4 linker supports a subset of GNU ld version scripts,
+  # but requires a special option to enable it.
+  llvm_check_linker_flag(CXX "-Wl,-z,gnu-version-script-compat"
+ LINKER_SUPPORTS_Z_GNU_VERSION_SCRIPT_COMPAT)
+  # Older Solaris (and illumos) linker does not support GNU ld version 
scripts
+  # and does not support GNU version script compat.
+  if (LINKER_SUPPORTS_Z_GNU_VERSION_SCRIPT_COMPAT)
+target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
+target_link_options(libclang PRIVATE 
"-Wl,-z,gnu-version-script-compat")
+  else()
+target_link_options(libclang PRIVATE 
"-Wl,-M,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
+  endif()
+else()
+  target_link_options(libclang PRIVATE 
"-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
 endif()
 # Ensure that libclang.so gets rebuilt when the linker script changes.
 set_property(SOURCE ARCMigrate.cpp APPEND PROPERTY
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index c9bca30c8f33d1..ca146ad699ff6c 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -115,7 +115,7 @@ function(add_llvm_symbol_exports target_name export_file)
   DEPENDS ${export_file}
   VERBATIM
   COMMENT "Creating export file for ${target_name}")
-if (${LLVM_LINKER_IS_SOLARISLD})
+if ((${LLVM_LINKER_IS_SOLARISLD}) OR (${LLVM_LINKER_IS_SOLARISLD_ILLUMOS}))
   set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS "  
-Wl,-M,\"${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}\"")
 else()
@@ -241,6 +241,11 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
   set(LLVM_LINKER_IS_GNULD YES CACHE INTERNAL "")
   message(STATUS "Linker detection: GNU ld")
+elseif("${stderr}" MATCHES "(illumos)" OR
+   "${stdout}" MATCHES "(illumos)")
+  set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
+  set(LLVM_LINKER_IS_SOLARISLD_ILLUMOS YES CACHE INTERNAL "")
+  message(STATUS "Linker detection: Solaris ld (illumos)")
 elseif("${stderr}" MATCHES "Solaris Link Editors" OR
"${stdout}" MATCHES "Solaris Link Editors")
   set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
@@ -282,11 +287,13 @@ function(add_link_opts target_name)
 # ld64's implementation of -dead_strip breaks tools that use plugins.
 set_property(TARGET ${target_name} APPEND_STRING PROPERTY
  LINK_FLAGS " -Wl,-dead_strip")
-  elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
+  elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND 
(LLVM_LINKER_IS_SOLARISLD OR
+ LLVM_LINKER_IS_SO

[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 
-std=c++20 -verify=supported %s

Endilll wrote:

Judging by the failure 
https://lab.llvm.org/buildbot/#/builders/60/builds/15037, you might want to 
test for specific triples.

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll commented:

Some bots are not happy with one of the tests. I contacted you on Discord about 
your next steps.

I'll have to revert the patch if I won't hear from you soon.

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


[lldb] [clang] [openmp] [polly] [flang] [mlir] [compiler-rt] [llvm] [lld] [VPlan] Compute scalable VF in preheader for induction increment. (PR #74762)

2023-12-09 Thread Florian Hahn via cfe-commits


@@ -340,8 +340,14 @@ Value *VPInstruction::generateInstruction(VPTransformState 
&State,
   auto *Phi = State.get(getOperand(0), 0);
   // The loop step is equal to the vectorization factor (num of SIMD
   // elements) times the unroll factor (num of SIMD instructions).
-  Value *Step =
-  createStepForVF(Builder, Phi->getType(), State.VF, State.UF);
+  Value *Step;
+  {
+BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this);
+IRBuilder<> PHBuilder(VectorPH->getTerminator());
+// Step is loop-invariant, calls to vscale will be placed in the
+// preheader.
+Step = createStepForVF(PHBuilder, Phi->getType(), State.VF, State.UF);
+  }

fhahn wrote:

The cow has been remove in 
https://github.com/llvm/llvm-project/commit/a5891fa4d2b76cf9dec96da9ded59fc4937d3342

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


[lldb] [clang] [openmp] [polly] [flang] [mlir] [compiler-rt] [llvm] [lld] [VPlan] Compute scalable VF in preheader for induction increment. (PR #74762)

2023-12-09 Thread Florian Hahn via cfe-commits

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


[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-09 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 12cc1fe332fbab94c1368ea95374d5a1289a22f8 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH 1/3] [Clang][Sema] Check the number of lambda non-concept
 tempate parameters Check that the number of non-concept template parameters
 is greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 .../include/clang/Basic/DiagnosticParseKinds.td  |  2 ++
 clang/lib/Sema/TreeTransform.h   | 16 
 2 files changed, 18 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab..e46fa69d013b6 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0..a140bbbc0c43d 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,6 +13662,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
+
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From e53ed4531d6918384be40de2b76bea558eac06ea Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 08:38:23 +0800
Subject: [PATCH 2/3] fix ut

---
 clang/lib/Sema/TreeTransform.h | 34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a140bbbc0c43d..9fb426c1a044b 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13594,6 +13594,24 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
 TPL);
 
+  if (E->getTemplateParameterList()) {
+// Check the number of the Concept template parameters
+size_t conceptParams = 0;
+for (auto P : *E->getTemplateParameterList()) {
+  const TemplateTypeParmDecl *CD = dyn_cast(P);
+  if (CD && CD->hasTypeConstraint()) {
+conceptParams++;
+  }
+}
+
+if (conceptParams > 0 &&
+conceptParams == E->getTemplateParameterList()->size()) {
+  getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+ diag::err_expected_non_concept_template_parameter);
+  return ExprError();
+}
+  }
+
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
   // it introduces a mapping of the original to the newly created
@@ -13662,22 +13680,6 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
-  // Check the number of the Concept template parameters
-  size_t conceptParams = 0;
-  for (auto P : *E->getTemplateParameterList()) {
-const TemplateTypeParmDecl *CD = dyn_cast(P);
-if (CD && CD->hasTypeConstraint()) {
-  conceptParams++;
-}
-  }
-
-  if (conceptParams > 0 &&
-  conceptParams == E->getTemplateParameterList()->size()) {
-getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
-   diag::err_expected_non_concept_template_parameter);
-return ExprError();
-  }
-
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From 7d2c8743d1e28342e3e6ac44424d789bba4e698b Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 21:40:36 +0800
Subject: [PATCH 3/3] fx

---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 2 --
 cla

[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Richard Dzenis via cfe-commits


@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 
-std=c++20 -verify=supported %s

RIscRIpt wrote:

We can just remove `__cdecl` altogether. I put it there to replicate 
Microsoft's STL. MSVC accepts that test case without `__cdecl` too.

Regarding other compiler error, it was fixed in 
3ec6c72551846b8f4143c8c101a1a6203e85a2aa

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


[clang] [clang] Fix '__cdecl' CC is not supported for this target (PR #74932)

2023-12-09 Thread Richard Dzenis via cfe-commits

https://github.com/RIscRIpt created 
https://github.com/llvm/llvm-project/pull/74932

Fixes regression introduced in b3e6ff331925dde24a4707452d657da0fdf7f588

.---command stderr
| error: 'supported-warning' diagnostics seen but not expected:
|   File 
C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\SemaCXX\ms-constexpr-new.cpp
 Line 7: '__cdecl' calling convention is not supported for this target
| 1 error generated.
`-

>From e16ec1411f7f813f7c1b60fd9671db116b083d02 Mon Sep 17 00:00:00 2001
From: Richard Dzenis 
Date: Sat, 9 Dec 2023 15:44:54 +0200
Subject: [PATCH] [clang] Fix '__cdecl' CC is not supported for this target

Fixes regression introduced in b3e6ff331925dde24a4707452d657da0fdf7f588

.---command stderr
| error: 'supported-warning' diagnostics seen but not expected:
|   File 
C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\SemaCXX\ms-constexpr-new.cpp
 Line 7: '__cdecl' calling convention is not supported for this target
| 1 error generated.
`-
---
 clang/test/SemaCXX/ms-constexpr-new.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/SemaCXX/ms-constexpr-new.cpp 
b/clang/test/SemaCXX/ms-constexpr-new.cpp
index 05ee5c5b4e154a..30567740b2ecbb 100644
--- a/clang/test/SemaCXX/ms-constexpr-new.cpp
+++ b/clang/test/SemaCXX/ms-constexpr-new.cpp
@@ -4,7 +4,7 @@
 
 [[nodiscard]]
 [[msvc::constexpr]] // unsupported-warning {{unknown attribute 'constexpr' 
ignored}}
-inline void* __cdecl operator new(decltype(sizeof(void*)), void* p) noexcept { 
return p; }
+inline void* operator new(decltype(sizeof(void*)), void* p) noexcept { return 
p; }
 
 namespace std {
   constexpr int* construct_at(int* p, int v) {

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


[clang] [clang-cl] Add support for [[msvc::constexpr]] C++11 attribute (PR #71300)

2023-12-09 Thread Richard Dzenis via cfe-commits


@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 
-std=c++20 -verify=supported %s

RIscRIpt wrote:

Opened #74932.

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


[clang] [clang] Fix '__cdecl' CC is not supported for this target (PR #74932)

2023-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Richard Dzenis (RIscRIpt)


Changes

Fixes regression introduced in b3e6ff331925dde24a4707452d657da0fdf7f588

.---command stderr
| error: 'supported-warning' diagnostics seen but not expected:
|   File 
C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\SemaCXX\ms-constexpr-new.cpp
 Line 7: '__cdecl' calling convention is not supported for this target
| 1 error generated.
`-

---
Full diff: https://github.com/llvm/llvm-project/pull/74932.diff


1 Files Affected:

- (modified) clang/test/SemaCXX/ms-constexpr-new.cpp (+1-1) 


``diff
diff --git a/clang/test/SemaCXX/ms-constexpr-new.cpp 
b/clang/test/SemaCXX/ms-constexpr-new.cpp
index 05ee5c5b4e154a..30567740b2ecbb 100644
--- a/clang/test/SemaCXX/ms-constexpr-new.cpp
+++ b/clang/test/SemaCXX/ms-constexpr-new.cpp
@@ -4,7 +4,7 @@
 
 [[nodiscard]]
 [[msvc::constexpr]] // unsupported-warning {{unknown attribute 'constexpr' 
ignored}}
-inline void* __cdecl operator new(decltype(sizeof(void*)), void* p) noexcept { 
return p; }
+inline void* operator new(decltype(sizeof(void*)), void* p) noexcept { return 
p; }
 
 namespace std {
   constexpr int* construct_at(int* p, int v) {

``




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


[clang] [Cygwin] Cygwin driver (PR #74933)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng created 
https://github.com/llvm/llvm-project/pull/74933

None

From daa6702f698724655b91c4fa52272c09924d2d83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 21:51:29 +0800
Subject: [PATCH] 1

---
 clang/lib/Driver/CMakeLists.txt|   1 +
 clang/lib/Driver/Driver.cpp|   4 +
 clang/lib/Driver/ToolChains/Cygwin.cpp | 731 +
 clang/lib/Driver/ToolChains/Cygwin.h   | 125 +
 clang/lib/Lex/InitHeaderSearch.cpp |  30 +-
 5 files changed, 865 insertions(+), 26 deletions(-)
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.cpp
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.h

diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 58427e3f83c42..7ab5a1ee96351 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -51,6 +51,7 @@ add_clang_library(clangDriver
   ToolChains/CrossWindows.cpp
   ToolChains/CSKYToolChain.cpp
   ToolChains/Cuda.cpp
+  ToolChains/Cygwin.cpp
   ToolChains/Darwin.cpp
   ToolChains/DragonFly.cpp
   ToolChains/Flang.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e241706b9082e..b6f3da3a006f4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -17,6 +17,7 @@
 #include "ToolChains/Clang.h"
 #include "ToolChains/CrossWindows.h"
 #include "ToolChains/Cuda.h"
+#include "ToolChains/Cygwin.h"
 #include "ToolChains/Darwin.h"
 #include "ToolChains/DragonFly.h"
 #include "ToolChains/FreeBSD.h"
@@ -6263,6 +6264,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
 else
   TC = std::make_unique(*this, Target, Args);
 break;
+  case llvm::Triple::Cygnus:
+TC = std::make_unique(*this, Target, Args);
+break;
   case llvm::Triple::GNU:
 TC = std::make_unique(*this, Target, Args);
 break;
diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp 
b/clang/lib/Driver/ToolChains/Cygwin.cpp
new file mode 100644
index 0..8aa9cf5c8ec03
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Cygwin.cpp
@@ -0,0 +1,731 @@
+//===--- Cygwin.cpp - CygwinToolChain Implementation 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Cygwin.h"
+#include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
+#include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+using namespace clang::diag;
+using namespace clang::driver;
+using namespace clang;
+using namespace llvm::opt;
+
+/// Cygwin Tools
+void tools::Cygwin::Assembler::ConstructJob(Compilation &C, const JobAction 
&JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
+  claimNoWarnArgs(Args);
+  ArgStringList CmdArgs;
+
+  if (getToolChain().getArch() == llvm::Triple::x86) {
+CmdArgs.push_back("--32");
+  } else if (getToolChain().getArch() == llvm::Triple::x86_64) {
+CmdArgs.push_back("--64");
+  }
+
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
+
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto &II : Inputs)
+CmdArgs.push_back(II.getFilename());
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ Exec, CmdArgs, Inputs, Output));
+
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
+SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
+   SplitDebugName(JA, Args, Inputs[0], Output));
+}
+
+void tools::Cygwin::Linker::AddLibGCC(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Make use of compiler-rt if --rtlib option is used
+  ToolChain::RuntimeLibType RLT = getToolChain().GetRuntimeLibType(Args);
+  if (RLT == ToolChain::RLT_Libgcc) {
+bool Static = Args.hasArg(options::OPT_static_libgcc) ||
+  Args.hasArg(options::OPT_static);
+bool Shared = Args.hasArg(options::OPT_shared);
+bool CXX = getToolChain().getDriver().CCCIsCXX();
+
+if (Static || (!CXX && !Share

[clang] [Cygwin] Cygwin driver (PR #74933)

2023-12-09 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: 徐持恒 Xu Chiheng (xu-chiheng)


Changes



---

Patch is 35.89 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74933.diff


5 Files Affected:

- (modified) clang/lib/Driver/CMakeLists.txt (+1) 
- (modified) clang/lib/Driver/Driver.cpp (+4) 
- (added) clang/lib/Driver/ToolChains/Cygwin.cpp (+731) 
- (added) clang/lib/Driver/ToolChains/Cygwin.h (+125) 
- (modified) clang/lib/Lex/InitHeaderSearch.cpp (+4-26) 


``diff
diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 58427e3f83c420..7ab5a1ee963515 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -51,6 +51,7 @@ add_clang_library(clangDriver
   ToolChains/CrossWindows.cpp
   ToolChains/CSKYToolChain.cpp
   ToolChains/Cuda.cpp
+  ToolChains/Cygwin.cpp
   ToolChains/Darwin.cpp
   ToolChains/DragonFly.cpp
   ToolChains/Flang.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e241706b9082ee..b6f3da3a006f4e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -17,6 +17,7 @@
 #include "ToolChains/Clang.h"
 #include "ToolChains/CrossWindows.h"
 #include "ToolChains/Cuda.h"
+#include "ToolChains/Cygwin.h"
 #include "ToolChains/Darwin.h"
 #include "ToolChains/DragonFly.h"
 #include "ToolChains/FreeBSD.h"
@@ -6263,6 +6264,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
 else
   TC = std::make_unique(*this, Target, Args);
 break;
+  case llvm::Triple::Cygnus:
+TC = std::make_unique(*this, Target, Args);
+break;
   case llvm::Triple::GNU:
 TC = std::make_unique(*this, Target, Args);
 break;
diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp 
b/clang/lib/Driver/ToolChains/Cygwin.cpp
new file mode 100644
index 00..8aa9cf5c8ec034
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Cygwin.cpp
@@ -0,0 +1,731 @@
+//===--- Cygwin.cpp - CygwinToolChain Implementation 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Cygwin.h"
+#include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
+#include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+using namespace clang::diag;
+using namespace clang::driver;
+using namespace clang;
+using namespace llvm::opt;
+
+/// Cygwin Tools
+void tools::Cygwin::Assembler::ConstructJob(Compilation &C, const JobAction 
&JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
+  claimNoWarnArgs(Args);
+  ArgStringList CmdArgs;
+
+  if (getToolChain().getArch() == llvm::Triple::x86) {
+CmdArgs.push_back("--32");
+  } else if (getToolChain().getArch() == llvm::Triple::x86_64) {
+CmdArgs.push_back("--64");
+  }
+
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
+
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto &II : Inputs)
+CmdArgs.push_back(II.getFilename());
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ Exec, CmdArgs, Inputs, Output));
+
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
+SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
+   SplitDebugName(JA, Args, Inputs[0], Output));
+}
+
+void tools::Cygwin::Linker::AddLibGCC(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Make use of compiler-rt if --rtlib option is used
+  ToolChain::RuntimeLibType RLT = getToolChain().GetRuntimeLibType(Args);
+  if (RLT == ToolChain::RLT_Libgcc) {
+bool Static = Args.hasArg(options::OPT_static_libgcc) ||
+  Args.hasArg(options::OPT_static);
+bool Shared = Args.hasArg(options::OPT_shared);
+bool CXX = getToolChain().getDriver().CCCIsCXX();
+
+if (Static || (!CXX && !Shared)) {
+  CmdArgs.push_back("-lgcc");
+  CmdArgs.push_back("-lgcc_eh");
+} else {
+  CmdArgs.push_back("-lgcc_s");
+  CmdArgs.push_back("-lgcc");

[clang] [Cygwin] Cygwin driver (PR #74933)

2023-12-09 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 600462a2db7c044896122acfb347ce2d4d88271f 
daa6702f698724655b91c4fa52272c09924d2d83 -- 
clang/lib/Driver/ToolChains/Cygwin.cpp clang/lib/Driver/ToolChains/Cygwin.h 
clang/lib/Driver/Driver.cpp clang/lib/Lex/InitHeaderSearch.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp 
b/clang/lib/Driver/ToolChains/Cygwin.cpp
index 8aa9cf5c8e..b34ce6ff2e 100644
--- a/clang/lib/Driver/ToolChains/Cygwin.cpp
+++ b/clang/lib/Driver/ToolChains/Cygwin.cpp
@@ -1,4 +1,5 @@
-//===--- Cygwin.cpp - CygwinToolChain Implementation 
===//
+//===--- Cygwin.cpp - CygwinToolChain Implementation
+//===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -28,10 +29,10 @@ using namespace llvm::opt;
 
 /// Cygwin Tools
 void tools::Cygwin::Assembler::ConstructJob(Compilation &C, const JobAction 
&JA,
-   const InputInfo &Output,
-   const InputInfoList &Inputs,
-   const ArgList &Args,
-   const char *LinkingOutput) const {
+const InputInfo &Output,
+const InputInfoList &Inputs,
+const ArgList &Args,
+const char *LinkingOutput) const {
   claimNoWarnArgs(Args);
   ArgStringList CmdArgs;
 
@@ -59,7 +60,7 @@ void tools::Cygwin::Assembler::ConstructJob(Compilation &C, 
const JobAction &JA,
 }
 
 void tools::Cygwin::Linker::AddLibGCC(const ArgList &Args,
- ArgStringList &CmdArgs) const {
+  ArgStringList &CmdArgs) const {
   // Make use of compiler-rt if --rtlib option is used
   ToolChain::RuntimeLibType RLT = getToolChain().GetRuntimeLibType(Args);
   if (RLT == ToolChain::RLT_Libgcc) {
@@ -83,10 +84,10 @@ void tools::Cygwin::Linker::AddLibGCC(const ArgList &Args,
 }
 
 void tools::Cygwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
-const InputInfo &Output,
-const InputInfoList &Inputs,
-const ArgList &Args,
-const char *LinkingOutput) const {
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const {
   const ToolChain &TC = getToolChain();
   const Driver &D = TC.getDriver();
   const SanitizerArgs &Sanitize = TC.getSanitizerArgs(Args);
@@ -127,7 +128,8 @@ void tools::Cygwin::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 D.Diag(diag::err_target_unknown_triple) << TC.getEffectiveTriple().str();
   }
 
-  if (!Args.getLastArgValue(options::OPT_fuse_ld_EQ, 
"link").equals_insensitive("lld")) {
+  if (!Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link")
+   .equals_insensitive("lld")) {
 if (TC.getArch() == llvm::Triple::x86) {
   CmdArgs.push_back("--wrap");
   CmdArgs.push_back("_Znwj");
@@ -435,7 +437,8 @@ static llvm::ErrorOr findGcc(const 
llvm::Triple &LiteralTriple,
   Gccs.emplace_back("cygwin-gcc");
   // Please do not add "gcc" here
   for (StringRef CandidateGcc : Gccs)
-if (llvm::ErrorOr GPPName = 
llvm::sys::findProgramByName(CandidateGcc))
+if (llvm::ErrorOr GPPName =
+llvm::sys::findProgramByName(CandidateGcc))
   return GPPName;
   return make_error_code(std::errc::no_such_file_or_directory);
 }
@@ -459,7 +462,7 @@ findClangRelativeSysroot(const Driver &D, const 
llvm::Triple &LiteralTriple,
 }
 
 toolchains::Cygwin::Cygwin(const Driver &D, const llvm::Triple &Triple,
- const ArgList &Args)
+   const ArgList &Args)
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args),
   RocmInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
@@ -493,7 +496,8 @@ toolchains::Cygwin::Cygwin(const Driver &D, const 
llvm::Triple &Triple,
   getFilePaths().push_back(
   (Base + SubdirName + llvm::sys::path::get_separator() + 
"usr/lib").str());
   getFilePaths().push_back(
-  (Base + SubdirName + llvm::sys::path::get_separator() + 
"usr/lib/w32api").str());
+  (Base + SubdirName + llvm::sys::path::get_separator() + "usr/lib/w32api")
+  .str

[clang] [clang] Fix '__cdecl' CC is not supported for this target (PR #74932)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

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

LGTM, but let's wait for CI to pass.

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


[clang] [Cygwin] Cygwin driver (PR #74933)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng updated 
https://github.com/llvm/llvm-project/pull/74933

From daa6702f698724655b91c4fa52272c09924d2d83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 21:51:29 +0800
Subject: [PATCH 1/2] 1

---
 clang/lib/Driver/CMakeLists.txt|   1 +
 clang/lib/Driver/Driver.cpp|   4 +
 clang/lib/Driver/ToolChains/Cygwin.cpp | 731 +
 clang/lib/Driver/ToolChains/Cygwin.h   | 125 +
 clang/lib/Lex/InitHeaderSearch.cpp |  30 +-
 5 files changed, 865 insertions(+), 26 deletions(-)
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.cpp
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.h

diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 58427e3f83c42..7ab5a1ee96351 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -51,6 +51,7 @@ add_clang_library(clangDriver
   ToolChains/CrossWindows.cpp
   ToolChains/CSKYToolChain.cpp
   ToolChains/Cuda.cpp
+  ToolChains/Cygwin.cpp
   ToolChains/Darwin.cpp
   ToolChains/DragonFly.cpp
   ToolChains/Flang.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e241706b9082e..b6f3da3a006f4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -17,6 +17,7 @@
 #include "ToolChains/Clang.h"
 #include "ToolChains/CrossWindows.h"
 #include "ToolChains/Cuda.h"
+#include "ToolChains/Cygwin.h"
 #include "ToolChains/Darwin.h"
 #include "ToolChains/DragonFly.h"
 #include "ToolChains/FreeBSD.h"
@@ -6263,6 +6264,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
 else
   TC = std::make_unique(*this, Target, Args);
 break;
+  case llvm::Triple::Cygnus:
+TC = std::make_unique(*this, Target, Args);
+break;
   case llvm::Triple::GNU:
 TC = std::make_unique(*this, Target, Args);
 break;
diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp 
b/clang/lib/Driver/ToolChains/Cygwin.cpp
new file mode 100644
index 0..8aa9cf5c8ec03
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Cygwin.cpp
@@ -0,0 +1,731 @@
+//===--- Cygwin.cpp - CygwinToolChain Implementation 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Cygwin.h"
+#include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
+#include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+using namespace clang::diag;
+using namespace clang::driver;
+using namespace clang;
+using namespace llvm::opt;
+
+/// Cygwin Tools
+void tools::Cygwin::Assembler::ConstructJob(Compilation &C, const JobAction 
&JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
+  claimNoWarnArgs(Args);
+  ArgStringList CmdArgs;
+
+  if (getToolChain().getArch() == llvm::Triple::x86) {
+CmdArgs.push_back("--32");
+  } else if (getToolChain().getArch() == llvm::Triple::x86_64) {
+CmdArgs.push_back("--64");
+  }
+
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
+
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto &II : Inputs)
+CmdArgs.push_back(II.getFilename());
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ Exec, CmdArgs, Inputs, Output));
+
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
+SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
+   SplitDebugName(JA, Args, Inputs[0], Output));
+}
+
+void tools::Cygwin::Linker::AddLibGCC(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Make use of compiler-rt if --rtlib option is used
+  ToolChain::RuntimeLibType RLT = getToolChain().GetRuntimeLibType(Args);
+  if (RLT == ToolChain::RLT_Libgcc) {
+bool Static = Args.hasArg(options::OPT_static_libgcc) ||
+  Args.hasArg(options::OPT_static);
+bool Shared = Args.hasArg(options::OPT_shared);
+bool CXX = getToolChain().getDriver().CCCIsCXX();
+
+if (Static || (!CXX && !Shared)

[clang] [Cygwin] Cygwin driver (PR #74933)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng updated 
https://github.com/llvm/llvm-project/pull/74933

From daa6702f698724655b91c4fa52272c09924d2d83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 21:51:29 +0800
Subject: [PATCH] 1

---
 clang/lib/Driver/CMakeLists.txt|   1 +
 clang/lib/Driver/Driver.cpp|   4 +
 clang/lib/Driver/ToolChains/Cygwin.cpp | 731 +
 clang/lib/Driver/ToolChains/Cygwin.h   | 125 +
 clang/lib/Lex/InitHeaderSearch.cpp |  30 +-
 5 files changed, 865 insertions(+), 26 deletions(-)
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.cpp
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.h

diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 58427e3f83c42..7ab5a1ee96351 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -51,6 +51,7 @@ add_clang_library(clangDriver
   ToolChains/CrossWindows.cpp
   ToolChains/CSKYToolChain.cpp
   ToolChains/Cuda.cpp
+  ToolChains/Cygwin.cpp
   ToolChains/Darwin.cpp
   ToolChains/DragonFly.cpp
   ToolChains/Flang.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e241706b9082e..b6f3da3a006f4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -17,6 +17,7 @@
 #include "ToolChains/Clang.h"
 #include "ToolChains/CrossWindows.h"
 #include "ToolChains/Cuda.h"
+#include "ToolChains/Cygwin.h"
 #include "ToolChains/Darwin.h"
 #include "ToolChains/DragonFly.h"
 #include "ToolChains/FreeBSD.h"
@@ -6263,6 +6264,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
 else
   TC = std::make_unique(*this, Target, Args);
 break;
+  case llvm::Triple::Cygnus:
+TC = std::make_unique(*this, Target, Args);
+break;
   case llvm::Triple::GNU:
 TC = std::make_unique(*this, Target, Args);
 break;
diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp 
b/clang/lib/Driver/ToolChains/Cygwin.cpp
new file mode 100644
index 0..8aa9cf5c8ec03
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Cygwin.cpp
@@ -0,0 +1,731 @@
+//===--- Cygwin.cpp - CygwinToolChain Implementation 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Cygwin.h"
+#include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
+#include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+using namespace clang::diag;
+using namespace clang::driver;
+using namespace clang;
+using namespace llvm::opt;
+
+/// Cygwin Tools
+void tools::Cygwin::Assembler::ConstructJob(Compilation &C, const JobAction 
&JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
+  claimNoWarnArgs(Args);
+  ArgStringList CmdArgs;
+
+  if (getToolChain().getArch() == llvm::Triple::x86) {
+CmdArgs.push_back("--32");
+  } else if (getToolChain().getArch() == llvm::Triple::x86_64) {
+CmdArgs.push_back("--64");
+  }
+
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
+
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto &II : Inputs)
+CmdArgs.push_back(II.getFilename());
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ Exec, CmdArgs, Inputs, Output));
+
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
+SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
+   SplitDebugName(JA, Args, Inputs[0], Output));
+}
+
+void tools::Cygwin::Linker::AddLibGCC(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Make use of compiler-rt if --rtlib option is used
+  ToolChain::RuntimeLibType RLT = getToolChain().GetRuntimeLibType(Args);
+  if (RLT == ToolChain::RLT_Libgcc) {
+bool Static = Args.hasArg(options::OPT_static_libgcc) ||
+  Args.hasArg(options::OPT_static);
+bool Shared = Args.hasArg(options::OPT_shared);
+bool CXX = getToolChain().getDriver().CCCIsCXX();
+
+if (Static || (!CXX && !Shared)) {

[clang] [Cygwin] Cygwin driver (PR #74933)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng updated 
https://github.com/llvm/llvm-project/pull/74933

From daa6702f698724655b91c4fa52272c09924d2d83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 21:51:29 +0800
Subject: [PATCH 1/2] 1

---
 clang/lib/Driver/CMakeLists.txt|   1 +
 clang/lib/Driver/Driver.cpp|   4 +
 clang/lib/Driver/ToolChains/Cygwin.cpp | 731 +
 clang/lib/Driver/ToolChains/Cygwin.h   | 125 +
 clang/lib/Lex/InitHeaderSearch.cpp |  30 +-
 5 files changed, 865 insertions(+), 26 deletions(-)
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.cpp
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.h

diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 58427e3f83c420..7ab5a1ee963515 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -51,6 +51,7 @@ add_clang_library(clangDriver
   ToolChains/CrossWindows.cpp
   ToolChains/CSKYToolChain.cpp
   ToolChains/Cuda.cpp
+  ToolChains/Cygwin.cpp
   ToolChains/Darwin.cpp
   ToolChains/DragonFly.cpp
   ToolChains/Flang.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e241706b9082ee..b6f3da3a006f4e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -17,6 +17,7 @@
 #include "ToolChains/Clang.h"
 #include "ToolChains/CrossWindows.h"
 #include "ToolChains/Cuda.h"
+#include "ToolChains/Cygwin.h"
 #include "ToolChains/Darwin.h"
 #include "ToolChains/DragonFly.h"
 #include "ToolChains/FreeBSD.h"
@@ -6263,6 +6264,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
 else
   TC = std::make_unique(*this, Target, Args);
 break;
+  case llvm::Triple::Cygnus:
+TC = std::make_unique(*this, Target, Args);
+break;
   case llvm::Triple::GNU:
 TC = std::make_unique(*this, Target, Args);
 break;
diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp 
b/clang/lib/Driver/ToolChains/Cygwin.cpp
new file mode 100644
index 00..8aa9cf5c8ec034
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Cygwin.cpp
@@ -0,0 +1,731 @@
+//===--- Cygwin.cpp - CygwinToolChain Implementation 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Cygwin.h"
+#include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
+#include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+using namespace clang::diag;
+using namespace clang::driver;
+using namespace clang;
+using namespace llvm::opt;
+
+/// Cygwin Tools
+void tools::Cygwin::Assembler::ConstructJob(Compilation &C, const JobAction 
&JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
+  claimNoWarnArgs(Args);
+  ArgStringList CmdArgs;
+
+  if (getToolChain().getArch() == llvm::Triple::x86) {
+CmdArgs.push_back("--32");
+  } else if (getToolChain().getArch() == llvm::Triple::x86_64) {
+CmdArgs.push_back("--64");
+  }
+
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
+
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto &II : Inputs)
+CmdArgs.push_back(II.getFilename());
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ Exec, CmdArgs, Inputs, Output));
+
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
+SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
+   SplitDebugName(JA, Args, Inputs[0], Output));
+}
+
+void tools::Cygwin::Linker::AddLibGCC(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Make use of compiler-rt if --rtlib option is used
+  ToolChain::RuntimeLibType RLT = getToolChain().GetRuntimeLibType(Args);
+  if (RLT == ToolChain::RLT_Libgcc) {
+bool Static = Args.hasArg(options::OPT_static_libgcc) ||
+  Args.hasArg(options::OPT_static);
+bool Shared = Args.hasArg(options::OPT_shared);
+bool CXX = getToolChain().getDriver().CCCIsCXX();
+
+if (Static || (!CXX && !S

[clang] 4cfdef7 - [clang] Fix '__cdecl' CC is not supported for this target (#74932)

2023-12-09 Thread via cfe-commits

Author: Richard Dzenis
Date: 2023-12-09T18:40:04+04:00
New Revision: 4cfdef76a2228b1b52df82fc83f58b9453397d98

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

LOG: [clang] Fix '__cdecl' CC is not supported for this target (#74932)

Fixes regression introduced in b3e6ff331925dde24a4707452d657da0fdf7f588
Fixes bot failure https://lab.llvm.org/buildbot/#/builders/60/builds/15037
```
.---command stderr
| error: 'supported-warning' diagnostics seen but not expected:
| File 
C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\SemaCXX\ms-constexpr-new.cpp
 Line 7: '__cdecl' calling convention is not supported for this target
| 1 error generated.
`-
```

Added: 


Modified: 
clang/test/SemaCXX/ms-constexpr-new.cpp

Removed: 




diff  --git a/clang/test/SemaCXX/ms-constexpr-new.cpp 
b/clang/test/SemaCXX/ms-constexpr-new.cpp
index 05ee5c5b4e154..30567740b2ecb 100644
--- a/clang/test/SemaCXX/ms-constexpr-new.cpp
+++ b/clang/test/SemaCXX/ms-constexpr-new.cpp
@@ -4,7 +4,7 @@
 
 [[nodiscard]]
 [[msvc::constexpr]] // unsupported-warning {{unknown attribute 'constexpr' 
ignored}}
-inline void* __cdecl operator new(decltype(sizeof(void*)), void* p) noexcept { 
return p; }
+inline void* operator new(decltype(sizeof(void*)), void* p) noexcept { return 
p; }
 
 namespace std {
   constexpr int* construct_at(int* p, int v) {



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


[clang] [clang] Fix '__cdecl' CC is not supported for this target (PR #74932)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-09 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 12cc1fe332fbab94c1368ea95374d5a1289a22f8 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH 1/4] [Clang][Sema] Check the number of lambda non-concept
 tempate parameters Check that the number of non-concept template parameters
 is greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 .../include/clang/Basic/DiagnosticParseKinds.td  |  2 ++
 clang/lib/Sema/TreeTransform.h   | 16 
 2 files changed, 18 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab1..e46fa69d013b61 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0c..a140bbbc0c43d5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,6 +13662,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
+
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From e53ed4531d6918384be40de2b76bea558eac06ea Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 08:38:23 +0800
Subject: [PATCH 2/4] fix ut

---
 clang/lib/Sema/TreeTransform.h | 34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a140bbbc0c43d5..9fb426c1a044b9 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13594,6 +13594,24 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
 TPL);
 
+  if (E->getTemplateParameterList()) {
+// Check the number of the Concept template parameters
+size_t conceptParams = 0;
+for (auto P : *E->getTemplateParameterList()) {
+  const TemplateTypeParmDecl *CD = dyn_cast(P);
+  if (CD && CD->hasTypeConstraint()) {
+conceptParams++;
+  }
+}
+
+if (conceptParams > 0 &&
+conceptParams == E->getTemplateParameterList()->size()) {
+  getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+ diag::err_expected_non_concept_template_parameter);
+  return ExprError();
+}
+  }
+
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
   // it introduces a mapping of the original to the newly created
@@ -13662,22 +13680,6 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
-  // Check the number of the Concept template parameters
-  size_t conceptParams = 0;
-  for (auto P : *E->getTemplateParameterList()) {
-const TemplateTypeParmDecl *CD = dyn_cast(P);
-if (CD && CD->hasTypeConstraint()) {
-  conceptParams++;
-}
-  }
-
-  if (conceptParams > 0 &&
-  conceptParams == E->getTemplateParameterList()->size()) {
-getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
-   diag::err_expected_non_concept_template_parameter);
-return ExprError();
-  }
-
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From 7d2c8743d1e28342e3e6ac44424d789bba4e698b Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 21:40:36 +0800
Subject: [PATCH 3/4] fx

---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 2 -

[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-09 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 12cc1fe332fbab94c1368ea95374d5a1289a22f8 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH 1/5] [Clang][Sema] Check the number of lambda non-concept
 tempate parameters Check that the number of non-concept template parameters
 is greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 .../include/clang/Basic/DiagnosticParseKinds.td  |  2 ++
 clang/lib/Sema/TreeTransform.h   | 16 
 2 files changed, 18 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab..e46fa69d013b6 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0..a140bbbc0c43d 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,6 +13662,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
+
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From e53ed4531d6918384be40de2b76bea558eac06ea Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 08:38:23 +0800
Subject: [PATCH 2/5] fix ut

---
 clang/lib/Sema/TreeTransform.h | 34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a140bbbc0c43d..9fb426c1a044b 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13594,6 +13594,24 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
 TPL);
 
+  if (E->getTemplateParameterList()) {
+// Check the number of the Concept template parameters
+size_t conceptParams = 0;
+for (auto P : *E->getTemplateParameterList()) {
+  const TemplateTypeParmDecl *CD = dyn_cast(P);
+  if (CD && CD->hasTypeConstraint()) {
+conceptParams++;
+  }
+}
+
+if (conceptParams > 0 &&
+conceptParams == E->getTemplateParameterList()->size()) {
+  getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+ diag::err_expected_non_concept_template_parameter);
+  return ExprError();
+}
+  }
+
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
   // it introduces a mapping of the original to the newly created
@@ -13662,22 +13680,6 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
-  // Check the number of the Concept template parameters
-  size_t conceptParams = 0;
-  for (auto P : *E->getTemplateParameterList()) {
-const TemplateTypeParmDecl *CD = dyn_cast(P);
-if (CD && CD->hasTypeConstraint()) {
-  conceptParams++;
-}
-  }
-
-  if (conceptParams > 0 &&
-  conceptParams == E->getTemplateParameterList()->size()) {
-getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
-   diag::err_expected_non_concept_template_parameter);
-return ExprError();
-  }
-
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From 7d2c8743d1e28342e3e6ac44424d789bba4e698b Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 21:40:36 +0800
Subject: [PATCH 3/5] fx

---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 2 --
 cla

[clang] [Cygwin] Cygwin driver (PR #74933)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng updated 
https://github.com/llvm/llvm-project/pull/74933

From daa6702f698724655b91c4fa52272c09924d2d83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 21:51:29 +0800
Subject: [PATCH 1/3] 1

---
 clang/lib/Driver/CMakeLists.txt|   1 +
 clang/lib/Driver/Driver.cpp|   4 +
 clang/lib/Driver/ToolChains/Cygwin.cpp | 731 +
 clang/lib/Driver/ToolChains/Cygwin.h   | 125 +
 clang/lib/Lex/InitHeaderSearch.cpp |  30 +-
 5 files changed, 865 insertions(+), 26 deletions(-)
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.cpp
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.h

diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 58427e3f83c42..7ab5a1ee96351 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -51,6 +51,7 @@ add_clang_library(clangDriver
   ToolChains/CrossWindows.cpp
   ToolChains/CSKYToolChain.cpp
   ToolChains/Cuda.cpp
+  ToolChains/Cygwin.cpp
   ToolChains/Darwin.cpp
   ToolChains/DragonFly.cpp
   ToolChains/Flang.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e241706b9082e..b6f3da3a006f4 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -17,6 +17,7 @@
 #include "ToolChains/Clang.h"
 #include "ToolChains/CrossWindows.h"
 #include "ToolChains/Cuda.h"
+#include "ToolChains/Cygwin.h"
 #include "ToolChains/Darwin.h"
 #include "ToolChains/DragonFly.h"
 #include "ToolChains/FreeBSD.h"
@@ -6263,6 +6264,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
 else
   TC = std::make_unique(*this, Target, Args);
 break;
+  case llvm::Triple::Cygnus:
+TC = std::make_unique(*this, Target, Args);
+break;
   case llvm::Triple::GNU:
 TC = std::make_unique(*this, Target, Args);
 break;
diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp 
b/clang/lib/Driver/ToolChains/Cygwin.cpp
new file mode 100644
index 0..8aa9cf5c8ec03
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Cygwin.cpp
@@ -0,0 +1,731 @@
+//===--- Cygwin.cpp - CygwinToolChain Implementation 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Cygwin.h"
+#include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
+#include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+using namespace clang::diag;
+using namespace clang::driver;
+using namespace clang;
+using namespace llvm::opt;
+
+/// Cygwin Tools
+void tools::Cygwin::Assembler::ConstructJob(Compilation &C, const JobAction 
&JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
+  claimNoWarnArgs(Args);
+  ArgStringList CmdArgs;
+
+  if (getToolChain().getArch() == llvm::Triple::x86) {
+CmdArgs.push_back("--32");
+  } else if (getToolChain().getArch() == llvm::Triple::x86_64) {
+CmdArgs.push_back("--64");
+  }
+
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
+
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto &II : Inputs)
+CmdArgs.push_back(II.getFilename());
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ Exec, CmdArgs, Inputs, Output));
+
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
+SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
+   SplitDebugName(JA, Args, Inputs[0], Output));
+}
+
+void tools::Cygwin::Linker::AddLibGCC(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Make use of compiler-rt if --rtlib option is used
+  ToolChain::RuntimeLibType RLT = getToolChain().GetRuntimeLibType(Args);
+  if (RLT == ToolChain::RLT_Libgcc) {
+bool Static = Args.hasArg(options::OPT_static_libgcc) ||
+  Args.hasArg(options::OPT_static);
+bool Shared = Args.hasArg(options::OPT_shared);
+bool CXX = getToolChain().getDriver().CCCIsCXX();
+
+if (Static || (!CXX && !Shared)

[clang] [Cygwin] Cygwin driver (PR #74933)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng updated 
https://github.com/llvm/llvm-project/pull/74933

From daa6702f698724655b91c4fa52272c09924d2d83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 21:51:29 +0800
Subject: [PATCH 1/5] 1

---
 clang/lib/Driver/CMakeLists.txt|   1 +
 clang/lib/Driver/Driver.cpp|   4 +
 clang/lib/Driver/ToolChains/Cygwin.cpp | 731 +
 clang/lib/Driver/ToolChains/Cygwin.h   | 125 +
 clang/lib/Lex/InitHeaderSearch.cpp |  30 +-
 5 files changed, 865 insertions(+), 26 deletions(-)
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.cpp
 create mode 100644 clang/lib/Driver/ToolChains/Cygwin.h

diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 58427e3f83c420..7ab5a1ee963515 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -51,6 +51,7 @@ add_clang_library(clangDriver
   ToolChains/CrossWindows.cpp
   ToolChains/CSKYToolChain.cpp
   ToolChains/Cuda.cpp
+  ToolChains/Cygwin.cpp
   ToolChains/Darwin.cpp
   ToolChains/DragonFly.cpp
   ToolChains/Flang.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e241706b9082ee..b6f3da3a006f4e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -17,6 +17,7 @@
 #include "ToolChains/Clang.h"
 #include "ToolChains/CrossWindows.h"
 #include "ToolChains/Cuda.h"
+#include "ToolChains/Cygwin.h"
 #include "ToolChains/Darwin.h"
 #include "ToolChains/DragonFly.h"
 #include "ToolChains/FreeBSD.h"
@@ -6263,6 +6264,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
 else
   TC = std::make_unique(*this, Target, Args);
 break;
+  case llvm::Triple::Cygnus:
+TC = std::make_unique(*this, Target, Args);
+break;
   case llvm::Triple::GNU:
 TC = std::make_unique(*this, Target, Args);
 break;
diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp 
b/clang/lib/Driver/ToolChains/Cygwin.cpp
new file mode 100644
index 00..8aa9cf5c8ec034
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Cygwin.cpp
@@ -0,0 +1,731 @@
+//===--- Cygwin.cpp - CygwinToolChain Implementation 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Cygwin.h"
+#include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
+#include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+using namespace clang::diag;
+using namespace clang::driver;
+using namespace clang;
+using namespace llvm::opt;
+
+/// Cygwin Tools
+void tools::Cygwin::Assembler::ConstructJob(Compilation &C, const JobAction 
&JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
+  claimNoWarnArgs(Args);
+  ArgStringList CmdArgs;
+
+  if (getToolChain().getArch() == llvm::Triple::x86) {
+CmdArgs.push_back("--32");
+  } else if (getToolChain().getArch() == llvm::Triple::x86_64) {
+CmdArgs.push_back("--64");
+  }
+
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
+
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto &II : Inputs)
+CmdArgs.push_back(II.getFilename());
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ Exec, CmdArgs, Inputs, Output));
+
+  if (Args.hasArg(options::OPT_gsplit_dwarf))
+SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
+   SplitDebugName(JA, Args, Inputs[0], Output));
+}
+
+void tools::Cygwin::Linker::AddLibGCC(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  // Make use of compiler-rt if --rtlib option is used
+  ToolChain::RuntimeLibType RLT = getToolChain().GetRuntimeLibType(Args);
+  if (RLT == ToolChain::RLT_Libgcc) {
+bool Static = Args.hasArg(options::OPT_static_libgcc) ||
+  Args.hasArg(options::OPT_static);
+bool Shared = Args.hasArg(options::OPT_shared);
+bool CXX = getToolChain().getDriver().CCCIsCXX();
+
+if (Static || (!CXX && !S

[clang] [clang] Adjust TargetInfo bitfield (PR #74893)

2023-12-09 Thread Nathan Sidwell via cfe-commits

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


[clang] 54e2749 - [clang] Adjust TargetInfo bitfield (#74893)

2023-12-09 Thread via cfe-commits

Author: Nathan Sidwell
Date: 2023-12-09T10:13:27-05:00
New Revision: 54e2749609d7114f4a48f4146cddeecf76d935a4

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

LOG: [clang] Adjust TargetInfo bitfield (#74893)

An 8 bit bitfield should not have a preferred type of bool.

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 41f3c2e403cbe..ec0189627dfbd 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -266,7 +266,6 @@ class TargetInfo : public TransferrableTargetInfo,
   LLVM_PREFERRED_TYPE(bool)
   unsigned AllowAMDGPUUnsafeFPAtomics : 1;
 
-  LLVM_PREFERRED_TYPE(bool)
   unsigned ARMCDECoprocMask : 8;
 
   unsigned MaxOpenCLWorkGroupSize;



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


[clang] [clang] Adjust TargetInfo bitfield (PR #74893)

2023-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nathan Sidwell (urnathan)


Changes

An 8 bit bitfield with preferred bool type? Seems confused.

---
Full diff: https://github.com/llvm/llvm-project/pull/74893.diff


1 Files Affected:

- (modified) clang/include/clang/Basic/TargetInfo.h (-1) 


``diff
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 41f3c2e403cbef..ec0189627dfbd2 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -266,7 +266,6 @@ class TargetInfo : public TransferrableTargetInfo,
   LLVM_PREFERRED_TYPE(bool)
   unsigned AllowAMDGPUUnsafeFPAtomics : 1;
 
-  LLVM_PREFERRED_TYPE(bool)
   unsigned ARMCDECoprocMask : 8;
 
   unsigned MaxOpenCLWorkGroupSize;

``




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


[clang] [clang] Adjust TargetInfo bitfield (PR #74893)

2023-12-09 Thread Nathan Sidwell via cfe-commits

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


[llvm] [clang] [mlir] [libcxx] [llvm][Support] Enable `TimeTraceProfiler` to accept deferred detail string (PR #74935)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/74935

>From 4e8f48947d59474e07e08cdc98e4a6fb2e3c80c1 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sat, 9 Dec 2023 17:21:35 +0300
Subject: [PATCH 1/2] [llvm][Support] Enable `TimeTraceProfiler` to accept
 deferred detail string

This patch enables `TimeTraceProfiler` and `TimeTraceScope` to accept detail 
string, which is not yet available at the time new trace entry is created. This 
is important for Clang parser use cases, e.g. when parsing a class member we 
don't yet know name of.
---
 llvm/include/llvm/Support/TimeProfiler.h | 35 
 llvm/lib/Support/TimeProfiler.cpp| 34 +++
 2 files changed, 52 insertions(+), 17 deletions(-)

diff --git a/llvm/include/llvm/Support/TimeProfiler.h 
b/llvm/include/llvm/Support/TimeProfiler.h
index 454a65f70231f..5b8af16ed4a9a 100644
--- a/llvm/include/llvm/Support/TimeProfiler.h
+++ b/llvm/include/llvm/Support/TimeProfiler.h
@@ -86,6 +86,8 @@ class raw_pwrite_stream;
 struct TimeTraceProfiler;
 TimeTraceProfiler *getTimeTraceProfilerInstance();
 
+struct TimeTraceProfilerEntry;
+
 /// Initialize the time trace profiler.
 /// This sets up the global \p TimeTraceProfilerInstance
 /// variable to be the profiler instance.
@@ -120,18 +122,29 @@ Error timeTraceProfilerWrite(StringRef PreferredFileName,
 /// Profiler copies the string data, so the pointers can be given into
 /// temporaries. Time sections can be hierarchical; every Begin must have a
 /// matching End pair but they can nest.
-void timeTraceProfilerBegin(StringRef Name, StringRef Detail);
-void timeTraceProfilerBegin(StringRef Name,
+TimeTraceProfilerEntry* timeTraceProfilerBegin(StringRef Name, StringRef 
Detail);
+TimeTraceProfilerEntry* timeTraceProfilerBegin(StringRef Name,
 llvm::function_ref Detail);
 
 /// Manually end the last time section.
 void timeTraceProfilerEnd();
 
+/// Set detail string for an existing trace entry.
+/// This function sets \p Detail string for an entry previously created by
+/// `timeTraceProfilerBegin`. String is handled in the same way as
+/// `timeTraceProfilerBegin` does. This is useful when contents of
+/// \p Detail is not (fully) known at the time trace entry is created.
+void timeTraceProfilerEntrySetDetail(TimeTraceProfilerEntry* Entry, StringRef 
Detail);
+void timeTraceProfilerEntrySetDetail(TimeTraceProfilerEntry* Entry, 
llvm::function_ref Detail);
+
 /// The TimeTraceScope is a helper class to call the begin and end functions
 /// of the time trace profiler.  When the object is constructed, it begins
 /// the section; and when it is destroyed, it stops it. If the time profiler
 /// is not initialized, the overhead is a single branch.
-struct TimeTraceScope {
+class TimeTraceScope {
+  TimeTraceProfilerEntry* Entry;
+
+public:
 
   TimeTraceScope() = delete;
   TimeTraceScope(const TimeTraceScope &) = delete;
@@ -141,20 +154,30 @@ struct TimeTraceScope {
 
   TimeTraceScope(StringRef Name) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, StringRef(""));
+  Entry = timeTraceProfilerBegin(Name, StringRef(""));
   }
   TimeTraceScope(StringRef Name, StringRef Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   TimeTraceScope(StringRef Name, llvm::function_ref Detail) {
 if (getTimeTraceProfilerInstance() != nullptr)
-  timeTraceProfilerBegin(Name, Detail);
+  Entry = timeTraceProfilerBegin(Name, Detail);
   }
   ~TimeTraceScope() {
 if (getTimeTraceProfilerInstance() != nullptr)
   timeTraceProfilerEnd();
   }
+  void setDetail(StringRef Detail) {
+if (Entry != nullptr) {
+  timeTraceProfilerEntrySetDetail(Entry, Detail);
+}
+  }
+  void setDetail(llvm::function_ref Detail) {
+if (Entry != nullptr) {
+  timeTraceProfilerEntrySetDetail(Entry, Detail);
+}
+  }
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Support/TimeProfiler.cpp 
b/llvm/lib/Support/TimeProfiler.cpp
index 4d625b3eb5b17..bd8a04ed8962d 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -64,12 +64,14 @@ using CountAndDurationType = std::pair;
 using NameAndCountAndDurationType =
 std::pair;
 
+} // anonymous namespace
+
 /// Represents an open or completed time section entry to be captured.
-struct TimeTraceProfilerEntry {
+struct llvm::TimeTraceProfilerEntry {
   const TimePointType Start;
   TimePointType End;
   const std::string Name;
-  const std::string Detail;
+  std::string Detail;
 
   TimeTraceProfilerEntry(TimePointType &&S, TimePointType &&E, std::string &&N,
  std::string &&Dt)
@@ -92,8 +94,6 @@ struct TimeTraceProfilerEntry {
   }
 };
 
-} // anonymous namespace
-
 struct llvm::TimeTraceProfiler {
   TimeTraceProfiler(unsigned TimeTraceGranularity = 0, St

[llvm] [clang] [Cygwin] Cygwin general (PR #74936)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng created 
https://github.com/llvm/llvm-project/pull/74936

Remove some uses of macro __CYGWIN__ .
Fix build error by Clang due to the conflict of CIndexer.cpp and mm_malloc.h. 
In mm_malloc.h, _WIN32 and __CYGWIN__ can't both be defined, but CIndexer.cpp 
define both.
Override Cygwin's buggy getpagesize() to Win32 computePageSize().


From d0578d50172d217618af652d5dfa87537225e41b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 23:47:37 +0800
Subject: [PATCH] 1

---
 clang/lib/Headers/mm_malloc.h|  6 +++---
 clang/tools/libclang/CIndexer.cpp| 10 ++
 llvm/lib/Support/MemoryBuffer.cpp|  8 
 llvm/lib/Support/Process.cpp | 19 +++
 llvm/lib/Support/Unix/Process.inc|  4 +++-
 llvm/lib/Support/Windows/Process.inc | 13 -
 llvm/lib/Support/raw_ostream.cpp |  4 
 llvm/tools/lli/lli.cpp   |  7 ---
 8 files changed, 27 insertions(+), 44 deletions(-)

diff --git a/clang/lib/Headers/mm_malloc.h b/clang/lib/Headers/mm_malloc.h
index d32fe59416277..6f46f10ee50f3 100644
--- a/clang/lib/Headers/mm_malloc.h
+++ b/clang/lib/Headers/mm_malloc.h
@@ -12,7 +12,7 @@
 
 #include 
 
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include 
 #else
 #ifndef __cplusplus
@@ -41,7 +41,7 @@ _mm_malloc(size_t __size, size_t __align) {
   void *__mallocedMemory;
 #if defined(__MINGW32__)
   __mallocedMemory = __mingw_aligned_malloc(__size, __align);
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
   __mallocedMemory = _aligned_malloc(__size, __align);
 #else
   if (posix_memalign(&__mallocedMemory, __align, __size))
@@ -56,7 +56,7 @@ _mm_free(void *__p)
 {
 #if defined(__MINGW32__)
   __mingw_aligned_free(__p);
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
   _aligned_free(__p);
 #else
   free(__p);
diff --git a/clang/tools/libclang/CIndexer.cpp 
b/clang/tools/libclang/CIndexer.cpp
index 77da2e4fa5ead..d1bd7ad49c5f4 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -26,12 +26,10 @@
 #include 
 
 #ifdef __CYGWIN__
-#include 
 #include 
-#define _WIN32 1
 #endif
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
 #include 
 #elif defined(_AIX)
 #include 
@@ -104,7 +102,7 @@ const std::string &CIndexer::getClangResourcesPath() {
   SmallString<128> LibClangPath;
 
   // Find the location where this library lives (libclang.dylib).
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
   MEMORY_BASIC_INFORMATION mbi;
   char path[MAX_PATH];
   VirtualQuery((void *)(uintptr_t)clang_createTranslationUnit, &mbi,
@@ -114,11 +112,7 @@ const std::string &CIndexer::getClangResourcesPath() {
 #ifdef __CYGWIN__
   char w32path[MAX_PATH];
   strcpy(w32path, path);
-#if CYGWIN_VERSION_API_MAJOR > 0 || CYGWIN_VERSION_API_MINOR >= 181
   cygwin_conv_path(CCP_WIN_A_TO_POSIX, w32path, path, MAX_PATH);
-#else
-  cygwin_conv_to_full_posix_path(w32path, path);
-#endif
 #endif
 
   LibClangPath += path;
diff --git a/llvm/lib/Support/MemoryBuffer.cpp 
b/llvm/lib/Support/MemoryBuffer.cpp
index 4cc4fe019b75b..8184b32575f21 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -384,14 +384,6 @@ static bool shouldUseMmap(sys::fs::file_t FD,
   if ((FileSize & (PageSize -1)) == 0)
 return false;
 
-#if defined(__CYGWIN__)
-  // Don't try to map files that are exactly a multiple of the physical page 
size
-  // if we need a null terminator.
-  // FIXME: We should reorganize again getPageSize() on Win32.
-  if ((FileSize & (4096 - 1)) == 0)
-return false;
-#endif
-
   return true;
 }
 
diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp
index 30c64d3ed9ed1..6d4a7275f5fa6 100644
--- a/llvm/lib/Support/Process.cpp
+++ b/llvm/lib/Support/Process.cpp
@@ -23,6 +23,10 @@
 #include 
 #include  // for _Exit
 
+#if defined(_WIN32) || defined(__CYGWIN__)
+#include 
+#endif
+
 using namespace llvm;
 using namespace sys;
 
@@ -102,6 +106,21 @@ bool Process::AreCoreFilesPrevented() { return 
coreFilesPrevented; }
 ::exit(RetCode);
 }
 
+#if defined(_WIN32) || defined(__CYGWIN__)
+// This function retrieves the page size using GetNativeSystemInfo() and is
+// present solely so it can be called once to initialize the self_process 
member
+// below.
+static unsigned computePageSize() {
+  // GetNativeSystemInfo() provides the physical page size which may differ
+  // from GetSystemInfo() in 32-bit applications running under WOW64.
+  SYSTEM_INFO info;
+  GetNativeSystemInfo(&info);
+  // FIXME: FileOffset in MapViewOfFile() should be aligned to not dwPageSize,
+  // but dwAllocationGranularity.
+  return static_cast(info.dwPageSize);
+}
+#endif
+
 // Include the platform-specific parts of this class.
 #ifdef LLVM_ON_UNIX
 #include "Unix/Process.inc"
diff --git a/llvm/lib/Support/Unix/Process.inc 
b/llvm/lib/Support/Unix/Proc

[llvm] [clang] [Cygwin] Cygwin general (PR #74936)

2023-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: 徐持恒 Xu Chiheng (xu-chiheng)


Changes

Remove some uses of macro __CYGWIN__ .
Fix build error by Clang due to the conflict of CIndexer.cpp and mm_malloc.h. 
In mm_malloc.h, _WIN32 and __CYGWIN__ can't both be defined, but CIndexer.cpp 
define both.
Override Cygwin's buggy getpagesize() to Win32 computePageSize().


---
Full diff: https://github.com/llvm/llvm-project/pull/74936.diff


8 Files Affected:

- (modified) clang/lib/Headers/mm_malloc.h (+3-3) 
- (modified) clang/tools/libclang/CIndexer.cpp (+2-8) 
- (modified) llvm/lib/Support/MemoryBuffer.cpp (-8) 
- (modified) llvm/lib/Support/Process.cpp (+19) 
- (modified) llvm/lib/Support/Unix/Process.inc (+3-1) 
- (modified) llvm/lib/Support/Windows/Process.inc (-13) 
- (modified) llvm/lib/Support/raw_ostream.cpp (-4) 
- (modified) llvm/tools/lli/lli.cpp (-7) 


``diff
diff --git a/clang/lib/Headers/mm_malloc.h b/clang/lib/Headers/mm_malloc.h
index d32fe594162774..6f46f10ee50f31 100644
--- a/clang/lib/Headers/mm_malloc.h
+++ b/clang/lib/Headers/mm_malloc.h
@@ -12,7 +12,7 @@
 
 #include 
 
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include 
 #else
 #ifndef __cplusplus
@@ -41,7 +41,7 @@ _mm_malloc(size_t __size, size_t __align) {
   void *__mallocedMemory;
 #if defined(__MINGW32__)
   __mallocedMemory = __mingw_aligned_malloc(__size, __align);
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
   __mallocedMemory = _aligned_malloc(__size, __align);
 #else
   if (posix_memalign(&__mallocedMemory, __align, __size))
@@ -56,7 +56,7 @@ _mm_free(void *__p)
 {
 #if defined(__MINGW32__)
   __mingw_aligned_free(__p);
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
   _aligned_free(__p);
 #else
   free(__p);
diff --git a/clang/tools/libclang/CIndexer.cpp 
b/clang/tools/libclang/CIndexer.cpp
index 77da2e4fa5ead0..d1bd7ad49c5f49 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -26,12 +26,10 @@
 #include 
 
 #ifdef __CYGWIN__
-#include 
 #include 
-#define _WIN32 1
 #endif
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
 #include 
 #elif defined(_AIX)
 #include 
@@ -104,7 +102,7 @@ const std::string &CIndexer::getClangResourcesPath() {
   SmallString<128> LibClangPath;
 
   // Find the location where this library lives (libclang.dylib).
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
   MEMORY_BASIC_INFORMATION mbi;
   char path[MAX_PATH];
   VirtualQuery((void *)(uintptr_t)clang_createTranslationUnit, &mbi,
@@ -114,11 +112,7 @@ const std::string &CIndexer::getClangResourcesPath() {
 #ifdef __CYGWIN__
   char w32path[MAX_PATH];
   strcpy(w32path, path);
-#if CYGWIN_VERSION_API_MAJOR > 0 || CYGWIN_VERSION_API_MINOR >= 181
   cygwin_conv_path(CCP_WIN_A_TO_POSIX, w32path, path, MAX_PATH);
-#else
-  cygwin_conv_to_full_posix_path(w32path, path);
-#endif
 #endif
 
   LibClangPath += path;
diff --git a/llvm/lib/Support/MemoryBuffer.cpp 
b/llvm/lib/Support/MemoryBuffer.cpp
index 4cc4fe019b75b1..8184b32575f21b 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -384,14 +384,6 @@ static bool shouldUseMmap(sys::fs::file_t FD,
   if ((FileSize & (PageSize -1)) == 0)
 return false;
 
-#if defined(__CYGWIN__)
-  // Don't try to map files that are exactly a multiple of the physical page 
size
-  // if we need a null terminator.
-  // FIXME: We should reorganize again getPageSize() on Win32.
-  if ((FileSize & (4096 - 1)) == 0)
-return false;
-#endif
-
   return true;
 }
 
diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp
index 30c64d3ed9ed17..6d4a7275f5fa61 100644
--- a/llvm/lib/Support/Process.cpp
+++ b/llvm/lib/Support/Process.cpp
@@ -23,6 +23,10 @@
 #include 
 #include  // for _Exit
 
+#if defined(_WIN32) || defined(__CYGWIN__)
+#include 
+#endif
+
 using namespace llvm;
 using namespace sys;
 
@@ -102,6 +106,21 @@ bool Process::AreCoreFilesPrevented() { return 
coreFilesPrevented; }
 ::exit(RetCode);
 }
 
+#if defined(_WIN32) || defined(__CYGWIN__)
+// This function retrieves the page size using GetNativeSystemInfo() and is
+// present solely so it can be called once to initialize the self_process 
member
+// below.
+static unsigned computePageSize() {
+  // GetNativeSystemInfo() provides the physical page size which may differ
+  // from GetSystemInfo() in 32-bit applications running under WOW64.
+  SYSTEM_INFO info;
+  GetNativeSystemInfo(&info);
+  // FIXME: FileOffset in MapViewOfFile() should be aligned to not dwPageSize,
+  // but dwAllocationGranularity.
+  return static_cast(info.dwPageSize);
+}
+#endif
+
 // Include the platform-specific parts of this class.
 #ifdef LLVM_ON_UNIX
 #include "Unix/Process.inc"
diff --git a/llvm/lib/Support/Unix/Process.inc 
b/llvm/lib/Support/Unix/Process.inc
index 2babf07944bf7b..2bf53ae188ebd3 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc

[llvm] [clang] [Cygwin] Cygwin general (PR #74936)

2023-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: 徐持恒 Xu Chiheng (xu-chiheng)


Changes

Remove some uses of macro __CYGWIN__ .
Fix build error by Clang due to the conflict of CIndexer.cpp and mm_malloc.h. 
In mm_malloc.h, _WIN32 and __CYGWIN__ can't both be defined, but CIndexer.cpp 
define both.
Override Cygwin's buggy getpagesize() to Win32 computePageSize().


---
Full diff: https://github.com/llvm/llvm-project/pull/74936.diff


8 Files Affected:

- (modified) clang/lib/Headers/mm_malloc.h (+3-3) 
- (modified) clang/tools/libclang/CIndexer.cpp (+2-8) 
- (modified) llvm/lib/Support/MemoryBuffer.cpp (-8) 
- (modified) llvm/lib/Support/Process.cpp (+19) 
- (modified) llvm/lib/Support/Unix/Process.inc (+3-1) 
- (modified) llvm/lib/Support/Windows/Process.inc (-13) 
- (modified) llvm/lib/Support/raw_ostream.cpp (-4) 
- (modified) llvm/tools/lli/lli.cpp (-7) 


``diff
diff --git a/clang/lib/Headers/mm_malloc.h b/clang/lib/Headers/mm_malloc.h
index d32fe594162774..6f46f10ee50f31 100644
--- a/clang/lib/Headers/mm_malloc.h
+++ b/clang/lib/Headers/mm_malloc.h
@@ -12,7 +12,7 @@
 
 #include 
 
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include 
 #else
 #ifndef __cplusplus
@@ -41,7 +41,7 @@ _mm_malloc(size_t __size, size_t __align) {
   void *__mallocedMemory;
 #if defined(__MINGW32__)
   __mallocedMemory = __mingw_aligned_malloc(__size, __align);
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
   __mallocedMemory = _aligned_malloc(__size, __align);
 #else
   if (posix_memalign(&__mallocedMemory, __align, __size))
@@ -56,7 +56,7 @@ _mm_free(void *__p)
 {
 #if defined(__MINGW32__)
   __mingw_aligned_free(__p);
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
   _aligned_free(__p);
 #else
   free(__p);
diff --git a/clang/tools/libclang/CIndexer.cpp 
b/clang/tools/libclang/CIndexer.cpp
index 77da2e4fa5ead0..d1bd7ad49c5f49 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -26,12 +26,10 @@
 #include 
 
 #ifdef __CYGWIN__
-#include 
 #include 
-#define _WIN32 1
 #endif
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
 #include 
 #elif defined(_AIX)
 #include 
@@ -104,7 +102,7 @@ const std::string &CIndexer::getClangResourcesPath() {
   SmallString<128> LibClangPath;
 
   // Find the location where this library lives (libclang.dylib).
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
   MEMORY_BASIC_INFORMATION mbi;
   char path[MAX_PATH];
   VirtualQuery((void *)(uintptr_t)clang_createTranslationUnit, &mbi,
@@ -114,11 +112,7 @@ const std::string &CIndexer::getClangResourcesPath() {
 #ifdef __CYGWIN__
   char w32path[MAX_PATH];
   strcpy(w32path, path);
-#if CYGWIN_VERSION_API_MAJOR > 0 || CYGWIN_VERSION_API_MINOR >= 181
   cygwin_conv_path(CCP_WIN_A_TO_POSIX, w32path, path, MAX_PATH);
-#else
-  cygwin_conv_to_full_posix_path(w32path, path);
-#endif
 #endif
 
   LibClangPath += path;
diff --git a/llvm/lib/Support/MemoryBuffer.cpp 
b/llvm/lib/Support/MemoryBuffer.cpp
index 4cc4fe019b75b1..8184b32575f21b 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -384,14 +384,6 @@ static bool shouldUseMmap(sys::fs::file_t FD,
   if ((FileSize & (PageSize -1)) == 0)
 return false;
 
-#if defined(__CYGWIN__)
-  // Don't try to map files that are exactly a multiple of the physical page 
size
-  // if we need a null terminator.
-  // FIXME: We should reorganize again getPageSize() on Win32.
-  if ((FileSize & (4096 - 1)) == 0)
-return false;
-#endif
-
   return true;
 }
 
diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp
index 30c64d3ed9ed17..6d4a7275f5fa61 100644
--- a/llvm/lib/Support/Process.cpp
+++ b/llvm/lib/Support/Process.cpp
@@ -23,6 +23,10 @@
 #include 
 #include  // for _Exit
 
+#if defined(_WIN32) || defined(__CYGWIN__)
+#include 
+#endif
+
 using namespace llvm;
 using namespace sys;
 
@@ -102,6 +106,21 @@ bool Process::AreCoreFilesPrevented() { return 
coreFilesPrevented; }
 ::exit(RetCode);
 }
 
+#if defined(_WIN32) || defined(__CYGWIN__)
+// This function retrieves the page size using GetNativeSystemInfo() and is
+// present solely so it can be called once to initialize the self_process 
member
+// below.
+static unsigned computePageSize() {
+  // GetNativeSystemInfo() provides the physical page size which may differ
+  // from GetSystemInfo() in 32-bit applications running under WOW64.
+  SYSTEM_INFO info;
+  GetNativeSystemInfo(&info);
+  // FIXME: FileOffset in MapViewOfFile() should be aligned to not dwPageSize,
+  // but dwAllocationGranularity.
+  return static_cast(info.dwPageSize);
+}
+#endif
+
 // Include the platform-specific parts of this class.
 #ifdef LLVM_ON_UNIX
 #include "Unix/Process.inc"
diff --git a/llvm/lib/Support/Unix/Process.inc 
b/llvm/lib/Support/Unix/Process.inc
index 2babf07944bf7b..2bf53ae188ebd3 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -7

[mlir] [llvm] [libcxx] [clang] [llvm][Support] Enable `TimeTraceProfiler` to accept deferred detail string (PR #74935)

2023-12-09 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [Cygwin] Cygwin general (PR #74936)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng updated 
https://github.com/llvm/llvm-project/pull/74936

From 50e6b5d3cd9e1a8dbcd1608d439cbc3a0deb0a1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sun, 10 Dec 2023 00:34:27 +0800
Subject: [PATCH] 1

---
 clang/lib/Headers/mm_malloc.h |  6 +++---
 clang/tools/libclang/CIndexer.cpp | 10 ++
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/clang/lib/Headers/mm_malloc.h b/clang/lib/Headers/mm_malloc.h
index d32fe59416277..6f46f10ee50f3 100644
--- a/clang/lib/Headers/mm_malloc.h
+++ b/clang/lib/Headers/mm_malloc.h
@@ -12,7 +12,7 @@
 
 #include 
 
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
 #include 
 #else
 #ifndef __cplusplus
@@ -41,7 +41,7 @@ _mm_malloc(size_t __size, size_t __align) {
   void *__mallocedMemory;
 #if defined(__MINGW32__)
   __mallocedMemory = __mingw_aligned_malloc(__size, __align);
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
   __mallocedMemory = _aligned_malloc(__size, __align);
 #else
   if (posix_memalign(&__mallocedMemory, __align, __size))
@@ -56,7 +56,7 @@ _mm_free(void *__p)
 {
 #if defined(__MINGW32__)
   __mingw_aligned_free(__p);
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
   _aligned_free(__p);
 #else
   free(__p);
diff --git a/clang/tools/libclang/CIndexer.cpp 
b/clang/tools/libclang/CIndexer.cpp
index 77da2e4fa5ead..d1bd7ad49c5f4 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -26,12 +26,10 @@
 #include 
 
 #ifdef __CYGWIN__
-#include 
 #include 
-#define _WIN32 1
 #endif
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
 #include 
 #elif defined(_AIX)
 #include 
@@ -104,7 +102,7 @@ const std::string &CIndexer::getClangResourcesPath() {
   SmallString<128> LibClangPath;
 
   // Find the location where this library lives (libclang.dylib).
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
   MEMORY_BASIC_INFORMATION mbi;
   char path[MAX_PATH];
   VirtualQuery((void *)(uintptr_t)clang_createTranslationUnit, &mbi,
@@ -114,11 +112,7 @@ const std::string &CIndexer::getClangResourcesPath() {
 #ifdef __CYGWIN__
   char w32path[MAX_PATH];
   strcpy(w32path, path);
-#if CYGWIN_VERSION_API_MAJOR > 0 || CYGWIN_VERSION_API_MINOR >= 181
   cygwin_conv_path(CCP_WIN_A_TO_POSIX, w32path, path, MAX_PATH);
-#else
-  cygwin_conv_to_full_posix_path(w32path, path);
-#endif
 #endif
 
   LibClangPath += path;

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


[clang] 08cb640 - [NFC] Remove an unused decl to avoid warning

2023-12-09 Thread Kiran Chandramohan via cfe-commits

Author: Kiran Chandramohan
Date: 2023-12-09T16:27:42Z
New Revision: 08cb64034f17d50a660ec78ce8ea81a025b0ba71

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

LOG: [NFC] Remove an unused decl to avoid warning

Added: 


Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index f04018179a5da..f131b6cf3baff 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -143,7 +143,7 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   // When optimizing, if wasm-opt is available, run it.
   std::string WasmOptPath;
-  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+  if (Args.getLastArg(options::OPT_O_Group)) {
 WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
 if (WasmOptPath == "wasm-opt") {
   WasmOptPath = {};



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


[clang] [Cygwin] Cygwin general (PR #74936)

2023-12-09 Thread 徐持恒 Xu Chiheng via cfe-commits

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


[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-09 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 12cc1fe332fbab94c1368ea95374d5a1289a22f8 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH 1/6] [Clang][Sema] Check the number of lambda non-concept
 tempate parameters Check that the number of non-concept template parameters
 is greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 .../include/clang/Basic/DiagnosticParseKinds.td  |  2 ++
 clang/lib/Sema/TreeTransform.h   | 16 
 2 files changed, 18 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab1..e46fa69d013b61 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0c..a140bbbc0c43d5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,6 +13662,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
+
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From e53ed4531d6918384be40de2b76bea558eac06ea Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 08:38:23 +0800
Subject: [PATCH 2/6] fix ut

---
 clang/lib/Sema/TreeTransform.h | 34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a140bbbc0c43d5..9fb426c1a044b9 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13594,6 +13594,24 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
 TPL);
 
+  if (E->getTemplateParameterList()) {
+// Check the number of the Concept template parameters
+size_t conceptParams = 0;
+for (auto P : *E->getTemplateParameterList()) {
+  const TemplateTypeParmDecl *CD = dyn_cast(P);
+  if (CD && CD->hasTypeConstraint()) {
+conceptParams++;
+  }
+}
+
+if (conceptParams > 0 &&
+conceptParams == E->getTemplateParameterList()->size()) {
+  getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+ diag::err_expected_non_concept_template_parameter);
+  return ExprError();
+}
+  }
+
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
   // it introduces a mapping of the original to the newly created
@@ -13662,22 +13680,6 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
-  // Check the number of the Concept template parameters
-  size_t conceptParams = 0;
-  for (auto P : *E->getTemplateParameterList()) {
-const TemplateTypeParmDecl *CD = dyn_cast(P);
-if (CD && CD->hasTypeConstraint()) {
-  conceptParams++;
-}
-  }
-
-  if (conceptParams > 0 &&
-  conceptParams == E->getTemplateParameterList()->size()) {
-getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
-   diag::err_expected_non_concept_template_parameter);
-return ExprError();
-  }
-
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From 7d2c8743d1e28342e3e6ac44424d789bba4e698b Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 21:40:36 +0800
Subject: [PATCH 3/6] fx

---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 2 -

[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)

2023-12-09 Thread via cfe-commits

https://github.com/XDeme created https://github.com/llvm/llvm-project/pull/74943

Fixes llvm/llvm-project#74901

>From b80f8579dbc745ddfaa3d60770dd0d3e79e6c641 Mon Sep 17 00:00:00 2001
From: XDeme 
Date: Sat, 9 Dec 2023 14:31:12 -0300
Subject: [PATCH] Fixes overload operator in BreakAfterAttributes

---
 clang/lib/Format/ContinuationIndenter.cpp |  3 ++-
 clang/unittests/Format/FormatTest.cpp | 14 ++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 9e4e939503dfe4..de3768d475e7b2 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -593,7 +593,8 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
 // name.
 !Style.isJavaScript()) ||
(Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) &&
-  Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) {
+  Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter &&
+  (Style.isCpp() && Current.Tok.isNot(tok::kw_operator))) {
 return true;
   }
 
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 24b2fd599dc397..a1f3beed475ff3 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -26417,6 +26417,20 @@ TEST_F(FormatTest, BreakAfterAttributes) {
"void g() {}",
CtorDtorCode, Style);
 
+  Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left;
+  constexpr StringRef OperatorOverloadCode(
+  "struct Foo {\n"
+  "[[maybe_unused]] void operator+();\n"
+  "};\n"
+  "[[nodiscard]] Foo& operator-(Foo&);");
+  verifyFormat("struct Foo {\n"
+   "  [[maybe_unused]]\n"
+   "  void operator+();\n"
+   "};\n"
+   "[[nodiscard]]\n"
+   "Foo& operator-(Foo&);",
+   OperatorOverloadCode, Style);
+
   Style.BreakBeforeBraces = FormatStyle::BS_Linux;
   verifyFormat("struct Foo {\n"
"  [[deprecated]]\n"

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


[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)

2023-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: None (XDeme)


Changes

Fixes llvm/llvm-project#74901

---
Full diff: https://github.com/llvm/llvm-project/pull/74943.diff


2 Files Affected:

- (modified) clang/lib/Format/ContinuationIndenter.cpp (+2-1) 
- (modified) clang/unittests/Format/FormatTest.cpp (+14) 


``diff
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 9e4e939503dfe4..de3768d475e7b2 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -593,7 +593,8 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
 // name.
 !Style.isJavaScript()) ||
(Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) &&
-  Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) {
+  Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter &&
+  (Style.isCpp() && Current.Tok.isNot(tok::kw_operator))) {
 return true;
   }
 
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 24b2fd599dc397..a1f3beed475ff3 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -26417,6 +26417,20 @@ TEST_F(FormatTest, BreakAfterAttributes) {
"void g() {}",
CtorDtorCode, Style);
 
+  Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left;
+  constexpr StringRef OperatorOverloadCode(
+  "struct Foo {\n"
+  "[[maybe_unused]] void operator+();\n"
+  "};\n"
+  "[[nodiscard]] Foo& operator-(Foo&);");
+  verifyFormat("struct Foo {\n"
+   "  [[maybe_unused]]\n"
+   "  void operator+();\n"
+   "};\n"
+   "[[nodiscard]]\n"
+   "Foo& operator-(Foo&);",
+   OperatorOverloadCode, Style);
+
   Style.BreakBeforeBraces = FormatStyle::BS_Linux;
   verifyFormat("struct Foo {\n"
"  [[deprecated]]\n"

``




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


[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-09 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 12cc1fe332fbab94c1368ea95374d5a1289a22f8 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH 1/7] [Clang][Sema] Check the number of lambda non-concept
 tempate parameters Check that the number of non-concept template parameters
 is greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 .../include/clang/Basic/DiagnosticParseKinds.td  |  2 ++
 clang/lib/Sema/TreeTransform.h   | 16 
 2 files changed, 18 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab..e46fa69d013b6 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0..a140bbbc0c43d 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,6 +13662,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
+
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From e53ed4531d6918384be40de2b76bea558eac06ea Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 08:38:23 +0800
Subject: [PATCH 2/7] fix ut

---
 clang/lib/Sema/TreeTransform.h | 34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a140bbbc0c43d..9fb426c1a044b 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13594,6 +13594,24 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
 TPL);
 
+  if (E->getTemplateParameterList()) {
+// Check the number of the Concept template parameters
+size_t conceptParams = 0;
+for (auto P : *E->getTemplateParameterList()) {
+  const TemplateTypeParmDecl *CD = dyn_cast(P);
+  if (CD && CD->hasTypeConstraint()) {
+conceptParams++;
+  }
+}
+
+if (conceptParams > 0 &&
+conceptParams == E->getTemplateParameterList()->size()) {
+  getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+ diag::err_expected_non_concept_template_parameter);
+  return ExprError();
+}
+  }
+
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
   // it introduces a mapping of the original to the newly created
@@ -13662,22 +13680,6 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
-  // Check the number of the Concept template parameters
-  size_t conceptParams = 0;
-  for (auto P : *E->getTemplateParameterList()) {
-const TemplateTypeParmDecl *CD = dyn_cast(P);
-if (CD && CD->hasTypeConstraint()) {
-  conceptParams++;
-}
-  }
-
-  if (conceptParams > 0 &&
-  conceptParams == E->getTemplateParameterList()->size()) {
-getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
-   diag::err_expected_non_concept_template_parameter);
-return ExprError();
-  }
-
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From 7d2c8743d1e28342e3e6ac44424d789bba4e698b Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 21:40:36 +0800
Subject: [PATCH 3/7] fx

---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 2 --
 cla

[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)

2023-12-09 Thread Björn Schäpers via cfe-commits


@@ -26417,6 +26417,20 @@ TEST_F(FormatTest, BreakAfterAttributes) {
"void g() {}",
CtorDtorCode, Style);
 
+  Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left;

HazardyKnusperkeks wrote:

You are changing the style for all following tests. (Although it may not have 
an effect on them.) I don't think you should do that.

Put your test at the bottom, or restore the value.

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


[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)

2023-12-09 Thread Björn Schäpers via cfe-commits


@@ -593,7 +593,8 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
 // name.
 !Style.isJavaScript()) ||
(Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) &&
-  Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) {
+  Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter &&
+  (Style.isCpp() && Current.Tok.isNot(tok::kw_operator))) {

HazardyKnusperkeks wrote:

Two things, you don't need the parenthesis, you are already in a conjunction.
Does it affect the other languages, that you now add a check for `isCpp()`?

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


[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)

2023-12-09 Thread Björn Schäpers via cfe-commits


@@ -26417,6 +26417,20 @@ TEST_F(FormatTest, BreakAfterAttributes) {
"void g() {}",
CtorDtorCode, Style);
 
+  Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left;
+  constexpr StringRef OperatorOverloadCode(

HazardyKnusperkeks wrote:

Don't put the code into a variable, you are only using it once.

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


[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)

2023-12-09 Thread Björn Schäpers via cfe-commits


@@ -593,7 +593,8 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
 // name.
 !Style.isJavaScript()) ||
(Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) &&
-  Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) {
+  Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter &&

HazardyKnusperkeks wrote:

Not your fault, but I'm not trying to read this condition. Can you make it more 
readable? We typically use a lambda and early `return false`.

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


[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)

2023-12-09 Thread via cfe-commits


@@ -593,7 +593,8 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
 // name.
 !Style.isJavaScript()) ||
(Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) &&
-  Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) {
+  Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter &&
+  (Style.isCpp() && Current.Tok.isNot(tok::kw_operator))) {

XDeme wrote:

I am not sure if affects other languages, so put it there. I will remove it

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


[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-09 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 12cc1fe332fbab94c1368ea95374d5a1289a22f8 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH 1/8] [Clang][Sema] Check the number of lambda non-concept
 tempate parameters Check that the number of non-concept template parameters
 is greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 .../include/clang/Basic/DiagnosticParseKinds.td  |  2 ++
 clang/lib/Sema/TreeTransform.h   | 16 
 2 files changed, 18 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab1..e46fa69d013b61 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0c..a140bbbc0c43d5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,6 +13662,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
+
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From e53ed4531d6918384be40de2b76bea558eac06ea Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 08:38:23 +0800
Subject: [PATCH 2/8] fix ut

---
 clang/lib/Sema/TreeTransform.h | 34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a140bbbc0c43d5..9fb426c1a044b9 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13594,6 +13594,24 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
 TPL);
 
+  if (E->getTemplateParameterList()) {
+// Check the number of the Concept template parameters
+size_t conceptParams = 0;
+for (auto P : *E->getTemplateParameterList()) {
+  const TemplateTypeParmDecl *CD = dyn_cast(P);
+  if (CD && CD->hasTypeConstraint()) {
+conceptParams++;
+  }
+}
+
+if (conceptParams > 0 &&
+conceptParams == E->getTemplateParameterList()->size()) {
+  getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+ diag::err_expected_non_concept_template_parameter);
+  return ExprError();
+}
+  }
+
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
   // it introduces a mapping of the original to the newly created
@@ -13662,22 +13680,6 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
-  // Check the number of the Concept template parameters
-  size_t conceptParams = 0;
-  for (auto P : *E->getTemplateParameterList()) {
-const TemplateTypeParmDecl *CD = dyn_cast(P);
-if (CD && CD->hasTypeConstraint()) {
-  conceptParams++;
-}
-  }
-
-  if (conceptParams > 0 &&
-  conceptParams == E->getTemplateParameterList()->size()) {
-getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
-   diag::err_expected_non_concept_template_parameter);
-return ExprError();
-  }
-
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From 7d2c8743d1e28342e3e6ac44424d789bba4e698b Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 21:40:36 +0800
Subject: [PATCH 3/8] fx

---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 2 -

[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)

2023-12-09 Thread via cfe-commits


@@ -26417,6 +26417,20 @@ TEST_F(FormatTest, BreakAfterAttributes) {
"void g() {}",
CtorDtorCode, Style);
 
+  Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left;

XDeme wrote:

To restore the value, is it ok if I do it like this: `Style.ReferenceAlignment 
= getLLVMStyle().ReferenceAlignment;`?

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


[clang] [Clang][Sema] Check the number of lambda non-concept tempate parameters (PR #74885)

2023-12-09 Thread via cfe-commits

https://github.com/knightXun updated 
https://github.com/llvm/llvm-project/pull/74885

>From 12cc1fe332fbab94c1368ea95374d5a1289a22f8 Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 04:57:15 +0800
Subject: [PATCH 1/9] [Clang][Sema] Check the number of lambda non-concept
 tempate parameters Check that the number of non-concept template parameters
 is greater than zero during lambda template instantiation to aviod panic Fix
 issue: https://github.com/llvm/llvm-project/issues/70601

---
 .../include/clang/Basic/DiagnosticParseKinds.td  |  2 ++
 clang/lib/Sema/TreeTransform.h   | 16 
 2 files changed, 18 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6150fc36430ab1..e46fa69d013b61 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -851,6 +851,8 @@ def err_friend_explicit_instantiation : Error<
 def err_explicit_instantiation_enum : Error<
   "enumerations cannot be explicitly instantiated">;
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_expected_non_concept_template_parameter : Error<
+  "expected non-concept template parameter">;
 def err_empty_requires_expr : Error<
   "a requires expression must contain at least one requirement">;
 def err_requires_expr_parameter_list_ellipsis : Error<
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1ad843d0bf4e0c..a140bbbc0c43d5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13662,6 +13662,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
+  // Check the number of the Concept template parameters
+  size_t conceptParams = 0;
+  for (auto P : *E->getTemplateParameterList()) {
+const TemplateTypeParmDecl *CD = dyn_cast(P);
+if (CD && CD->hasTypeConstraint()) {
+  conceptParams++;
+}
+  }
+
+  if (conceptParams > 0 &&
+  conceptParams == E->getTemplateParameterList()->size()) {
+getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+   diag::err_expected_non_concept_template_parameter);
+return ExprError();
+  }
+
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From e53ed4531d6918384be40de2b76bea558eac06ea Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 08:38:23 +0800
Subject: [PATCH 2/9] fix ut

---
 clang/lib/Sema/TreeTransform.h | 34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a140bbbc0c43d5..9fb426c1a044b9 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13594,6 +13594,24 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
 TPL);
 
+  if (E->getTemplateParameterList()) {
+// Check the number of the Concept template parameters
+size_t conceptParams = 0;
+for (auto P : *E->getTemplateParameterList()) {
+  const TemplateTypeParmDecl *CD = dyn_cast(P);
+  if (CD && CD->hasTypeConstraint()) {
+conceptParams++;
+  }
+}
+
+if (conceptParams > 0 &&
+conceptParams == E->getTemplateParameterList()->size()) {
+  getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
+ diag::err_expected_non_concept_template_parameter);
+  return ExprError();
+}
+  }
+
   // Transform the type of the original lambda's call operator.
   // The transformation MUST be done in the CurrentInstantiationScope since
   // it introduces a mapping of the original to the newly created
@@ -13662,22 +13680,6 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 return ExprError();
   }
 
-  // Check the number of the Concept template parameters
-  size_t conceptParams = 0;
-  for (auto P : *E->getTemplateParameterList()) {
-const TemplateTypeParmDecl *CD = dyn_cast(P);
-if (CD && CD->hasTypeConstraint()) {
-  conceptParams++;
-}
-  }
-
-  if (conceptParams > 0 &&
-  conceptParams == E->getTemplateParameterList()->size()) {
-getSema().Diag(E->getTemplateParameterList()->getLAngleLoc(),
-   diag::err_expected_non_concept_template_parameter);
-return ExprError();
-  }
-
   // Copy the LSI before ActOnFinishFunctionBody removes it.
   // FIXME: This is dumb. Store the lambda information somewhere that outlives
   // the call operator.

>From 7d2c8743d1e28342e3e6ac44424d789bba4e698b Mon Sep 17 00:00:00 2001
From: knightXun 
Date: Sat, 9 Dec 2023 21:40:36 +0800
Subject: [PATCH 3/9] fx

---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 2 -

  1   2   >