[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-12-05 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 updated 
https://github.com/llvm/llvm-project/pull/73077

>From 94069d442fd703051bef0244e8c663c1390cadbb Mon Sep 17 00:00:00 2001
From: dong jianqiang 
Date: Wed, 22 Nov 2023 11:06:00 +0800
Subject: [PATCH] [clang][Sema] Add -Wswitch-default warning option

Adds a warning, issued by the clang semantic analysis. The patch warns on switch
which don't have the default branch.

This is a counterpart of gcc's Wswitch-default.
---
 clang/include/clang/Basic/DiagnosticGroups.td   |  2 +-
 .../include/clang/Basic/DiagnosticSemaKinds.td  |  2 ++
 clang/lib/Sema/SemaStmt.cpp |  3 +++
 clang/test/Sema/switch-default.c| 17 +
 4 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Sema/switch-default.c

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index ff028bbbf7426..12b11527b3057 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -632,7 +632,7 @@ def ShadowAll : DiagGroup<"shadow-all", [Shadow, 
ShadowFieldInConstructor,
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
 def : DiagGroup<"sign-promo">;
 def SignCompare : DiagGroup<"sign-compare">;
-def : DiagGroup<"switch-default">;
+def SwitchDefault  : DiagGroup<"switch-default">;
 def : DiagGroup<"synth">;
 def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
 def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 990692c06d7d3..d61a34806fc5d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10044,6 +10044,8 @@ def warn_missing_case : Warning<"%plural{"
   "3:enumeration values %1, %2, and %3 not handled in switch|"
   ":%0 enumeration values not handled in switch: %1, %2, %3...}0">,
   InGroup;
+def warn_switch_default : Warning<"'switch' missing 'default' label">,
+  InGroup, DefaultIgnore;
 
 def warn_unannotated_fallthrough : Warning<
   "unannotated fall-through between switch labels">,
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 2b45aa5dff7be..63348d27a8c94 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1327,6 +1327,9 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 }
   }
 
+  if (!TheDefaultStmt)
+Diag(SwitchLoc, diag::warn_switch_default);
+
   if (!HasDependentValue) {
 // If we don't have a default statement, check whether the
 // condition is constant.
diff --git a/clang/test/Sema/switch-default.c b/clang/test/Sema/switch-default.c
new file mode 100644
index 0..3f2e216933033
--- /dev/null
+++ b/clang/test/Sema/switch-default.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-default %s
+
+int f1(int a) {
+  switch (a) {// expected-warning {{switch missing default 
case}}
+case 1: a++; break;
+case 2: a += 2; break;
+  }
+  return a;
+}
+
+int f2(int a) {
+  switch (a) {// no-warning
+default:
+  ;
+  }
+  return a;
+}

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


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-12-05 Thread dong jianqiang via cfe-commits


@@ -10044,6 +10044,8 @@ def warn_missing_case : Warning<"%plural{"
   "3:enumeration values %1, %2, and %3 not handled in switch|"
   ":%0 enumeration values not handled in switch: %1, %2, %3...}0">,
   InGroup;
+def warn_switch_default : Warning<"switch missing default case">,

dongjianqiang2 wrote:

Thanks for the correction!

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


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-12-05 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 updated 
https://github.com/llvm/llvm-project/pull/73077

>From af54d1f1870ba43e18cb3677d171e916f8c887b2 Mon Sep 17 00:00:00 2001
From: dong jianqiang 
Date: Wed, 22 Nov 2023 11:06:00 +0800
Subject: [PATCH] [clang][Sema] Add -Wswitch-default warning option

Adds a warning, issued by the clang semantic analysis. The patch warns on switch
which don't have the default branch.

This is a counterpart of gcc's Wswitch-default.
---
 clang/include/clang/Basic/DiagnosticGroups.td   |  2 +-
 .../include/clang/Basic/DiagnosticSemaKinds.td  |  2 ++
 clang/lib/Sema/SemaStmt.cpp |  3 +++
 clang/test/Sema/switch-default.c| 17 +
 4 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Sema/switch-default.c

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index ff028bbbf7426..12b11527b3057 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -632,7 +632,7 @@ def ShadowAll : DiagGroup<"shadow-all", [Shadow, 
ShadowFieldInConstructor,
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
 def : DiagGroup<"sign-promo">;
 def SignCompare : DiagGroup<"sign-compare">;
-def : DiagGroup<"switch-default">;
+def SwitchDefault  : DiagGroup<"switch-default">;
 def : DiagGroup<"synth">;
 def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
 def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 990692c06d7d3..d61a34806fc5d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10044,6 +10044,8 @@ def warn_missing_case : Warning<"%plural{"
   "3:enumeration values %1, %2, and %3 not handled in switch|"
   ":%0 enumeration values not handled in switch: %1, %2, %3...}0">,
   InGroup;
+def warn_switch_default : Warning<"'switch' missing 'default' label">,
+  InGroup, DefaultIgnore;
 
 def warn_unannotated_fallthrough : Warning<
   "unannotated fall-through between switch labels">,
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 2b45aa5dff7be..63348d27a8c94 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1327,6 +1327,9 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 }
   }
 
+  if (!TheDefaultStmt)
+Diag(SwitchLoc, diag::warn_switch_default);
+
   if (!HasDependentValue) {
 // If we don't have a default statement, check whether the
 // condition is constant.
diff --git a/clang/test/Sema/switch-default.c b/clang/test/Sema/switch-default.c
new file mode 100644
index 0..854b561b37c48
--- /dev/null
+++ b/clang/test/Sema/switch-default.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-default %s
+
+int f1(int a) {
+  switch (a) {// expected-warning {{'switch' missing 'default' 
label}}
+case 1: a++; break;
+case 2: a += 2; break;
+  }
+  return a;
+}
+
+int f2(int a) {
+  switch (a) {// no-warning
+default:
+  ;
+  }
+  return a;
+}

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


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-12-05 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 updated 
https://github.com/llvm/llvm-project/pull/73077

>From a09d149f050918f6161e5880b4f7e352fc5e52c2 Mon Sep 17 00:00:00 2001
From: dong jianqiang 
Date: Wed, 22 Nov 2023 11:06:00 +0800
Subject: [PATCH] [clang][Sema] Add -Wswitch-default warning option

Adds a warning, issued by the clang semantic analysis. The patch warns on switch
which don't have the default branch.

This is a counterpart of gcc's Wswitch-default.
---
 clang/docs/ReleaseNotes.rst |  2 ++
 clang/include/clang/Basic/DiagnosticGroups.td   |  2 +-
 .../include/clang/Basic/DiagnosticSemaKinds.td  |  2 ++
 clang/lib/Sema/SemaStmt.cpp |  3 +++
 clang/test/Sema/switch-default.c| 17 +
 5 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Sema/switch-default.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 157afd9e86291..733971611d1c7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,8 @@ Improvements to Clang's diagnostics
   of a base class is not called in the constructor of its derived class.
 - Clang no longer emits ``-Wmissing-variable-declarations`` for variables 
declared
   with the ``register`` storage class.
+- Clang's ``-Wswitch-default`` flag now diagnoses whenever a ``switch`` 
statement
+  does not have a ``default`` label.
 - Clang's ``-Wtautological-negation-compare`` flag now diagnoses logical
   tautologies like ``x && !x`` and ``!x || x`` in expressions. This also
   makes ``-Winfinite-recursion`` diagnose more cases.
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index ff028bbbf7426..12b11527b3057 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -632,7 +632,7 @@ def ShadowAll : DiagGroup<"shadow-all", [Shadow, 
ShadowFieldInConstructor,
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
 def : DiagGroup<"sign-promo">;
 def SignCompare : DiagGroup<"sign-compare">;
-def : DiagGroup<"switch-default">;
+def SwitchDefault  : DiagGroup<"switch-default">;
 def : DiagGroup<"synth">;
 def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
 def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 990692c06d7d3..d61a34806fc5d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10044,6 +10044,8 @@ def warn_missing_case : Warning<"%plural{"
   "3:enumeration values %1, %2, and %3 not handled in switch|"
   ":%0 enumeration values not handled in switch: %1, %2, %3...}0">,
   InGroup;
+def warn_switch_default : Warning<"'switch' missing 'default' label">,
+  InGroup, DefaultIgnore;
 
 def warn_unannotated_fallthrough : Warning<
   "unannotated fall-through between switch labels">,
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 2b45aa5dff7be..63348d27a8c94 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1327,6 +1327,9 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 }
   }
 
+  if (!TheDefaultStmt)
+Diag(SwitchLoc, diag::warn_switch_default);
+
   if (!HasDependentValue) {
 // If we don't have a default statement, check whether the
 // condition is constant.
diff --git a/clang/test/Sema/switch-default.c b/clang/test/Sema/switch-default.c
new file mode 100644
index 0..854b561b37c48
--- /dev/null
+++ b/clang/test/Sema/switch-default.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-default %s
+
+int f1(int a) {
+  switch (a) {// expected-warning {{'switch' missing 'default' 
label}}
+case 1: a++; break;
+case 2: a += 2; break;
+  }
+  return a;
+}
+
+int f2(int a) {
+  switch (a) {// no-warning
+default:
+  ;
+  }
+  return a;
+}

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


[clang] [Driver][MachineOutliner] Support -moutline option for aarch64_be (PR #73223)

2023-12-06 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 updated 
https://github.com/llvm/llvm-project/pull/73223

>From 438da675d853e0b1bc38670c18361d7d3615f860 Mon Sep 17 00:00:00 2001
From: dong jianqiang 
Date: Thu, 23 Nov 2023 16:58:11 +0800
Subject: [PATCH] [Driver][MachineOutliner] Support outlining option with LTO
 for aarch64_be

This patch propagates the -moutline option when target is aarch64_be,
fix warning: 'aarch64_be' does not support '-moutline'; flag ignored 
[-Woption-ignored]
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 4 +---
 clang/test/Driver/aarch64-outliner.c   | 2 ++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1f31c6395206e..4dc471ddc098f 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2398,9 +2398,7 @@ void tools::addMachineOutlinerArgs(const Driver &D,
   // We only support -moutline in AArch64 and ARM targets right now. If
   // we're not compiling for these, emit a warning and ignore the flag.
   // Otherwise, add the proper mllvm flags.
-  if (!(Triple.isARM() || Triple.isThumb() ||
-Triple.getArch() == llvm::Triple::aarch64 ||
-Triple.getArch() == llvm::Triple::aarch64_32)) {
+  if (!(Triple.isARM() || Triple.isThumb() || Triple.isAArch64())) {
 D.Diag(diag::warn_drv_moutline_unsupported_opt) << 
Triple.getArchName();
   } else {
 addArg(Twine("-enable-machine-outliner"));
diff --git a/clang/test/Driver/aarch64-outliner.c 
b/clang/test/Driver/aarch64-outliner.c
index 42e43b433e282..06e5de11ec49e 100644
--- a/clang/test/Driver/aarch64-outliner.c
+++ b/clang/test/Driver/aarch64-outliner.c
@@ -1,7 +1,9 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang --target=aarch64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
+// RUN: %clang --target=aarch64_be -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
 // ON: "-mllvm" "-enable-machine-outliner"
 // RUN: %clang --target=aarch64 -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
+// RUN: %clang --target=aarch64_be -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
 // OFF: "-mllvm" "-enable-machine-outliner=never"
 // RUN: %clang --target=x86_64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=WARN
 // WARN: warning: 'x86_64' does not support '-moutline'; flag ignored 
[-Woption-ignored]

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


[clang] [Driver][MachineOutliner] Support -moutline option for aarch64_be (PR #73223)

2023-12-06 Thread dong jianqiang via cfe-commits


@@ -2400,7 +2400,8 @@ void tools::addMachineOutlinerArgs(const Driver &D,
   // Otherwise, add the proper mllvm flags.
   if (!(Triple.isARM() || Triple.isThumb() ||
 Triple.getArch() == llvm::Triple::aarch64 ||

dongjianqiang2 wrote:

Updated, thanks.

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


[clang] [Driver] Add support for -export-dynamic which can match GCC behavior. (PR #72781)

2023-11-18 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 created 
https://github.com/llvm/llvm-project/pull/72781

clang splits -export-dynamic into "-e" and "xport-dynamic", and gets ld 
warning: cannot find entry symbol xport-dynamic; defaulting to , which is 
unexpected from user.

Adjust the driver to support -export-dynamic, which can match GCC behavior.

>From 4eb84135489b28f3b06085693dc79928b7b7e3ff Mon Sep 17 00:00:00 2001
From: Dong JianQiang 
Date: Sun, 19 Nov 2023 11:23:31 +0800
Subject: [PATCH] [Driver] Add support for -export-dynamic which can match GCC
 behavior.

clang splits -export-dynamic into "-e" and "xport-dynamic", and gets
ld warning: cannot find entry symbol xport-dynamic; defaulting to ,
which is unexpected from user.

Adjust the driver to support -export-dynamic, which can match GCC behavior.
---
 clang/include/clang/Driver/Options.td | 1 +
 clang/test/Driver/dynamic-linker.c| 6 ++
 2 files changed, 7 insertions(+)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index df12ba8fbcb296a..3bb764a1e46ab8a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1453,6 +1453,7 @@ def extract_api_ignores_EQ: CommaJoined<["--"], 
"extract-api-ignores=">,
 HelpText<"Comma separated list of files containing a new line separated 
list of API symbols to ignore when extracting API information.">,
 MarshallingInfoStringVector>;
 def e : JoinedOrSeparate<["-"], "e">, Flags<[LinkerInput]>, Group;
+def export_dynamic : Flag<["-"], "export-dynamic">, Flags<[LinkerInput]>, 
Group;
 def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">,
diff --git a/clang/test/Driver/dynamic-linker.c 
b/clang/test/Driver/dynamic-linker.c
index 978907e0adee697..d202f537b44fb98 100644
--- a/clang/test/Driver/dynamic-linker.c
+++ b/clang/test/Driver/dynamic-linker.c
@@ -23,6 +23,12 @@
 // RUN: %clang -target powerpc64-unknown-linux-gnu -### -static /dev/null -o 
/dev/null 2>&1 | FileCheck -check-prefix CHECK-STATIC %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -### -static /dev/null -o 
/dev/null 2>&1 | FileCheck -check-prefix CHECK-STATIC %s
 
+// RUN: %clang -target armv7-unknown-linux-gnueabi -### -export-dynamic 
/dev/null -o /dev/null 2>&1 | FileCheck -check-prefix CHECK-RDYNAMIC %s
+// RUN: %clang -target i386-unknown-linux-gnu -### -export-dynamic /dev/null 
-o /dev/null 2>&1 | FileCheck -check-prefix CHECK-RDYNAMIC %s
+// RUN: %clang -target mips64-unknown-linux-gnu -### -export-dynamic /dev/null 
-o /dev/null 2>&1 | FileCheck -check-prefix CHECK-RDYNAMIC %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu -### -export-dynamic 
/dev/null -o /dev/null 2>&1 | FileCheck -check-prefix CHECK-RDYNAMIC %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -### -export-dynamic /dev/null 
-o /dev/null 2>&1 | FileCheck -check-prefix CHECK-RDYNAMIC %s
+
 // CHECK-SHARED: "-shared"
 // CHECK-RDYNAMIC: "-export-dynamic"
 // CHECK-STATIC: "-{{B?}}static"

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


[clang] [Driver] Add support for -export-dynamic which can match GCC behavior. (PR #72781)

2023-11-19 Thread dong jianqiang via cfe-commits

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


[clang] [Driver] Add support for -export-dynamic which can match GCC behavior. (PR #72781)

2023-11-19 Thread dong jianqiang via cfe-commits

dongjianqiang2 wrote:

> GCC's default spec file for Linux does not say how `-export-dynamic` 
> translates to ld `-export-dynamic`.
> 
> I think ld `--export-dynamic` is exclusively caused by `-Wl,--export-dynamic` 
> or `-rdynamic`. Do you have any example of `gcc -export-dynamic` uses?
> 
> > clang splits -export-dynamic into "-e" and "xport-dynamic"
> 
> This behavior simulates GCC but the uses seem extremely rare or not used at 
> all. We probably should just reject `-exxx`: #72804



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


[clang] [Driver] Add support for -export-dynamic which can match GCC behavior. (PR #72781)

2023-11-19 Thread dong jianqiang via cfe-commits

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


[clang] [Driver] Add support for -export-dynamic which can match GCC behavior. (PR #72781)

2023-11-19 Thread dong jianqiang via cfe-commits

dongjianqiang2 wrote:

@MaskRay the reason for adding this option is that gcc supports it. please 
refer to https://godbolt.org/z/54sE6zTa1

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


[clang] [Driver] Add support for -export-dynamic which can match GCC behavior. (PR #72781)

2023-11-20 Thread dong jianqiang via cfe-commits

dongjianqiang2 wrote:

> > @MaskRay the reason for adding this option is that gcc supports it. please 
> > refer to [godbolt.org/z/54sE6zTa1](https://godbolt.org/z/54sE6zTa1)
> 
> This doesn't answer my question. GCC has a lot of options that Clang doesn't 
> support. An option supported by GCC does not mean that Clang needs to support 
> it. This option has perfect replacement, which makes it even questionable 
> (since to the best of my knowledge `-export-dynamic` driver option is not 
> used) See my previous comment:
> 
> > GCC's default spec file for Linux does not say how -export-dynamic 
> > translates to ld -export-dynamic.
> > I think ld --export-dynamic is exclusively caused by -Wl,--export-dynamic 
> > or -rdynamic.
> > Do you have any example of gcc -export-dynamic uses?

This is historically undocumented option. and yes, it can be repalced by 
-rdynamic. See [PR47390](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47390). 
The purpose of this pull request is to ensure consistency between the two 
compilers. If you think it's unnecessary to support it, I'm fine with it. : )

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


[clang] [Driver] Default Generic_GCC aarch64_be to -fasynchronous-unwind-tables (PR #72971)

2023-11-21 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 created 
https://github.com/llvm/llvm-project/pull/72971

This patch defaults Generic_GCC aarch64_be to use -fasynchronous-unwind-tables 
and ensures consistent behavior with aarch64 little endian.

>From f8adcd49a4627926ac8009c595c6b0103589e600 Mon Sep 17 00:00:00 2001
From: Dong JianQiang 
Date: Tue, 21 Nov 2023 16:15:52 +0800
Subject: [PATCH] [Driver] Default Generic_GCC aarch64_be to
 -fasynchronous-unwind-tables

This patch defaults Generic_GCC aarch64_be to use -fasynchronous-unwind-tables.
---
 clang/lib/Driver/ToolChains/Gnu.cpp  | 1 +
 clang/test/Driver/aarch64-features.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 2b1e8f02cf66388..782618236ff8982 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2937,6 +2937,7 @@ ToolChain::UnwindTableLevel
 Generic_GCC::getDefaultUnwindTableLevel(const ArgList &Args) const {
   switch (getArch()) {
   case llvm::Triple::aarch64:
+  case llvm::Triple::aarch64_be:
   case llvm::Triple::ppc:
   case llvm::Triple::ppcle:
   case llvm::Triple::ppc64:
diff --git a/clang/test/Driver/aarch64-features.c 
b/clang/test/Driver/aarch64-features.c
index a797cc0cf9084c2..d2075c91314a8b2 100644
--- a/clang/test/Driver/aarch64-features.c
+++ b/clang/test/Driver/aarch64-features.c
@@ -1,4 +1,5 @@
 // RUN: %clang --target=aarch64-none-linux-gnu -### %s -fsyntax-only 2>&1 | 
FileCheck %s
+// RUN: %clang --target=aarch64_be-none-linux-gnu -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 // RUN: %clang --target=arm64-none-linux-gnu -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 
 // CHECK: "-funwind-tables=2"

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


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-11-21 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 created 
https://github.com/llvm/llvm-project/pull/73077

Adds a warning, issued by the clang semantic analysis. The patch warns on 
switch which don't have the default branch.

This is a counterpart of gcc's Wswitch-default.

>From 7962e1ffc6bb5ab8873f391f5030199ba62c1345 Mon Sep 17 00:00:00 2001
From: dong jianqiang 
Date: Wed, 22 Nov 2023 11:06:00 +0800
Subject: [PATCH] [clang][Sema] Add -Wswitch-default warning option

Adds a warning, issued by the clang semantic analysis. The patch warns on switch
which don't have the default branch.

This is a counterpart of gcc's Wswitch-default.
---
 clang/include/clang/Basic/DiagnosticGroups.td   |  2 +-
 .../include/clang/Basic/DiagnosticSemaKinds.td  |  2 ++
 clang/lib/Sema/SemaStmt.cpp |  3 +++
 clang/test/Sema/switch-default.c| 17 +
 4 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Sema/switch-default.c

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index ff028bbbf74261e..12b11527b30571a 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -632,7 +632,7 @@ def ShadowAll : DiagGroup<"shadow-all", [Shadow, 
ShadowFieldInConstructor,
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
 def : DiagGroup<"sign-promo">;
 def SignCompare : DiagGroup<"sign-compare">;
-def : DiagGroup<"switch-default">;
+def SwitchDefault  : DiagGroup<"switch-default">;
 def : DiagGroup<"synth">;
 def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
 def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 990692c06d7d3a8..17c9627910bb6ce 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10044,6 +10044,8 @@ def warn_missing_case : Warning<"%plural{"
   "3:enumeration values %1, %2, and %3 not handled in switch|"
   ":%0 enumeration values not handled in switch: %1, %2, %3...}0">,
   InGroup;
+def warn_switch_default : Warning<"switch missing default case">,
+  InGroup, DefaultIgnore;
 
 def warn_unannotated_fallthrough : Warning<
   "unannotated fall-through between switch labels">,
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 2b45aa5dff7be7c..63348d27a8c94a1 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1327,6 +1327,9 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 }
   }
 
+  if (!TheDefaultStmt)
+Diag(SwitchLoc, diag::warn_switch_default);
+
   if (!HasDependentValue) {
 // If we don't have a default statement, check whether the
 // condition is constant.
diff --git a/clang/test/Sema/switch-default.c b/clang/test/Sema/switch-default.c
new file mode 100644
index 000..3f2e21693303378
--- /dev/null
+++ b/clang/test/Sema/switch-default.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-default %s
+
+int f1(int a) {
+  switch (a) {// expected-warning {{switch missing default 
case}}
+case 1: a++; break;
+case 2: a += 2; break;
+  }
+  return a;
+}
+
+int f2(int a) {
+  switch (a) {// no-warning
+default:
+  ;
+  }
+  return a;
+}

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


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-11-21 Thread dong jianqiang via cfe-commits

dongjianqiang2 wrote:

> There is one clang-tidy check (bugprone-switch-missing-default-case) also for 
> this feature.

Thank you for your reply. It may be a more convenient and straightforward way 
if can be identified during compile time. 
On the other hand, it it more compatibile with GCC's hehavior. : )

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


[clang] [Driver] Add support for -export-dynamic which can match GCC behavior. (PR #72781)

2023-11-21 Thread dong jianqiang via cfe-commits

dongjianqiang2 wrote:

> > > > @MaskRay the reason for adding this option is that gcc supports it. 
> > > > please refer to 
> > > > [godbolt.org/z/54sE6zTa1](https://godbolt.org/z/54sE6zTa1)
> > > 
> > > 
> > > This doesn't answer my question. GCC has a lot of options that Clang 
> > > doesn't support. An option supported by GCC does not mean that Clang 
> > > needs to support it. This option has perfect replacement, which makes it 
> > > even questionable (since to the best of my knowledge `-export-dynamic` 
> > > driver option is not used) See my previous comment:
> > > > GCC's default spec file for Linux does not say how -export-dynamic 
> > > > translates to ld -export-dynamic.
> > > > I think ld --export-dynamic is exclusively caused by 
> > > > -Wl,--export-dynamic or -rdynamic.
> > > > Do you have any example of gcc -export-dynamic uses?
> > 
> > 
> > This is historically undocumented option. and yes, it can be repalced by 
> > -rdynamic. See 
> > [PR47390](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47390). The purpose 
> > of this pull request is to ensure consistency between the two compilers. If 
> > you think it's unnecessary to support it, I'm fine with it. : )
> 
> Thank you for digging this up. So `-export-dynamic` is the only special 
> `-exxx` option GCC supports. Except this gawk issue (2011) which likely gets 
> fixed long ago, `gcc -export-dynamic` seems to have no use. This doesn't 
> justify driver adding an option (that we know is not a good thing) special 
> case.
> 
> Note that `clang -e xxx` or `clang -exxx` did not work before 2020-07, so 
> even all `-exxx` `-e xxx` all probably rarely used. We should consider 
> [#72804 
> (comment)](https://github.com/llvm/llvm-project/pull/72804#issuecomment-1820321163)

Currently, we are switching to the llvm compiler in embedded system. In some 
scenarios, the -e option is used to specify the program entry address.  gcc 
supportes both `-e xxx` and `-exxx`, so it may not be a good idea to support 
'-e xxx' only. So far, I've only encountered this particular -export-dynamic 
scenario, the program got native exception due to the wrong entry address. 
When looking back at the logs. I found this warning "cannot find entry symbol 
xport-dynamic; defaulting to ". 

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


[clang] [Driver][MachineOutliner] Support -moutline option for aarch64_be (PR #73223)

2023-11-23 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 created 
https://github.com/llvm/llvm-project/pull/73223

This patch propagates the -moutline flag when target is aarch64_be, 
fix warning: 'aarch64_be' does not support '-moutline'; flag ignored 
[-Woption-ignored]

>From 1492725fb3bb60f400264f718972ce249ec3eda8 Mon Sep 17 00:00:00 2001
From: dong jianqiang 
Date: Thu, 23 Nov 2023 16:58:11 +0800
Subject: [PATCH] [Driver][MachineOutliner] Support outlining option with LTO
 for aarch64_be

This patch propagates the -moutline flag when target is aarch64_be,
fix warning: 'aarch64_be' does not support '-moutline'; flag ignored 
[-Woption-ignored]
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 3 ++-
 clang/test/Driver/aarch64-outliner.c   | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 5d2cd1959b06925..078f2ff80a21939 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2436,7 +2436,8 @@ void tools::addMachineOutlinerArgs(const Driver &D,
   // Otherwise, add the proper mllvm flags.
   if (!(Triple.isARM() || Triple.isThumb() ||
 Triple.getArch() == llvm::Triple::aarch64 ||
-Triple.getArch() == llvm::Triple::aarch64_32)) {
+Triple.getArch() == llvm::Triple::aarch64_32 ||
+Triple.getArch() == llvm::Triple::aarch64_be)) {
 D.Diag(diag::warn_drv_moutline_unsupported_opt) << 
Triple.getArchName();
   } else {
 addArg(Twine("-enable-machine-outliner"));
diff --git a/clang/test/Driver/aarch64-outliner.c 
b/clang/test/Driver/aarch64-outliner.c
index 42e43b433e282d3..06e5de11ec49ecd 100644
--- a/clang/test/Driver/aarch64-outliner.c
+++ b/clang/test/Driver/aarch64-outliner.c
@@ -1,7 +1,9 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang --target=aarch64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
+// RUN: %clang --target=aarch64_be -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
 // ON: "-mllvm" "-enable-machine-outliner"
 // RUN: %clang --target=aarch64 -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
+// RUN: %clang --target=aarch64_be -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
 // OFF: "-mllvm" "-enable-machine-outliner=never"
 // RUN: %clang --target=x86_64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=WARN
 // WARN: warning: 'x86_64' does not support '-moutline'; flag ignored 
[-Woption-ignored]

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


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-12-18 Thread dong jianqiang via cfe-commits

dongjianqiang2 wrote:

> ```
> enum class test
> {
>   err1,
>   err2,
>   ok
> };
> 
> int check_err (test v)
> {
>   switch (v)
> {
>   case test::err1:
> return 1;
>   case test::err2:
> return 2;
>   case test::ok:
> break;
> }
>   return 0;
> }
> ```
> 
> report: main.cxx:40:3: error: 'switch' missing 'default' label 
> [-Werror,-Wswitch-default]
> 
> how to solve for enum class? try to build libfmt project with 
> fmt/include/fmt/format.h:3878:3: error: 'switch' missing 'default' label 
> [-Werror,-Wswitch-default] and other errors

Hi, -Wswitch-default is a warning option on switch which don't have the default 
branch, the option is disabled by default, You can check whether 
-Wswitch-default is added in the build script.

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


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-12-19 Thread dong jianqiang via cfe-commits


@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-default %s
+
+int f1(int a) {
+  switch (a) {// expected-warning {{'switch' missing 'default' 
label}}
+case 1: a++; break;
+case 2: a += 2; break;
+  }
+  return a;
+}

dongjianqiang2 wrote:

See PR([#75900](https://github.com/llvm/llvm-project/pull/75900) )

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


[clang] [Clang][Wswitch-default] Warning for enum even completely covered the cases (PR #75900)

2023-12-19 Thread dong jianqiang via cfe-commits

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

LGTM

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


[clang] [Clang][Wswitch-default] Warning for enum even completely covered the cases (PR #75900)

2023-12-19 Thread dong jianqiang via cfe-commits

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


[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-19 Thread dong jianqiang via cfe-commits

dongjianqiang2 wrote:

thanks for correcting this.

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


[clang] [Driver] Add support for -export-dynamic which can match GCC behavior. (PR #72781)

2023-11-23 Thread dong jianqiang via cfe-commits

dongjianqiang2 wrote:

> export-dynamic

In that case, we have got to change `-exxx` to `-e xxx`, and `-export-dynamic` 
to `-rdynamic`. LGTM, and it follows GCC's official documented spec : )

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


[clang] [Driver] Allow -e entry but reject -eentry (PR #72804)

2023-11-23 Thread dong jianqiang via cfe-commits

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

LGTM.

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


[clang] [Driver][MachineOutliner] Support -moutline option for aarch64_be (PR #73223)

2023-11-23 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 updated 
https://github.com/llvm/llvm-project/pull/73223

>From 5742f71b9077a038cfefe4c74290d7e9d2f42d3f Mon Sep 17 00:00:00 2001
From: dong jianqiang 
Date: Thu, 23 Nov 2023 16:58:11 +0800
Subject: [PATCH] [Driver][MachineOutliner] Support outlining option with LTO
 for aarch64_be

This patch propagates the -moutline option when target is aarch64_be,
fix warning: 'aarch64_be' does not support '-moutline'; flag ignored 
[-Woption-ignored]
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 3 ++-
 clang/test/Driver/aarch64-outliner.c   | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 5d2cd1959b06925..078f2ff80a21939 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2436,7 +2436,8 @@ void tools::addMachineOutlinerArgs(const Driver &D,
   // Otherwise, add the proper mllvm flags.
   if (!(Triple.isARM() || Triple.isThumb() ||
 Triple.getArch() == llvm::Triple::aarch64 ||
-Triple.getArch() == llvm::Triple::aarch64_32)) {
+Triple.getArch() == llvm::Triple::aarch64_32 ||
+Triple.getArch() == llvm::Triple::aarch64_be)) {
 D.Diag(diag::warn_drv_moutline_unsupported_opt) << 
Triple.getArchName();
   } else {
 addArg(Twine("-enable-machine-outliner"));
diff --git a/clang/test/Driver/aarch64-outliner.c 
b/clang/test/Driver/aarch64-outliner.c
index 42e43b433e282d3..06e5de11ec49ecd 100644
--- a/clang/test/Driver/aarch64-outliner.c
+++ b/clang/test/Driver/aarch64-outliner.c
@@ -1,7 +1,9 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang --target=aarch64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
+// RUN: %clang --target=aarch64_be -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
 // ON: "-mllvm" "-enable-machine-outliner"
 // RUN: %clang --target=aarch64 -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
+// RUN: %clang --target=aarch64_be -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
 // OFF: "-mllvm" "-enable-machine-outliner=never"
 // RUN: %clang --target=x86_64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=WARN
 // WARN: warning: 'x86_64' does not support '-moutline'; flag ignored 
[-Woption-ignored]

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


[clang] [Driver] Allow -e entry but reject -eentry (PR #72804)

2023-11-26 Thread dong jianqiang via cfe-commits

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


[clang] [Driver][MachineOutliner] Support -moutline option for aarch64_be (PR #73223)

2023-11-26 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 updated 
https://github.com/llvm/llvm-project/pull/73223

>From 2a90faa84bd4a47a291f0631f26b87e7ee60ce63 Mon Sep 17 00:00:00 2001
From: dong jianqiang 
Date: Thu, 23 Nov 2023 16:58:11 +0800
Subject: [PATCH] [Driver][MachineOutliner] Support outlining option with LTO
 for aarch64_be

This patch propagates the -moutline option when target is aarch64_be,
fix warning: 'aarch64_be' does not support '-moutline'; flag ignored 
[-Woption-ignored]
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 3 ++-
 clang/test/Driver/aarch64-outliner.c   | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 5d2cd1959b06925..078f2ff80a21939 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2436,7 +2436,8 @@ void tools::addMachineOutlinerArgs(const Driver &D,
   // Otherwise, add the proper mllvm flags.
   if (!(Triple.isARM() || Triple.isThumb() ||
 Triple.getArch() == llvm::Triple::aarch64 ||
-Triple.getArch() == llvm::Triple::aarch64_32)) {
+Triple.getArch() == llvm::Triple::aarch64_32 ||
+Triple.getArch() == llvm::Triple::aarch64_be)) {
 D.Diag(diag::warn_drv_moutline_unsupported_opt) << 
Triple.getArchName();
   } else {
 addArg(Twine("-enable-machine-outliner"));
diff --git a/clang/test/Driver/aarch64-outliner.c 
b/clang/test/Driver/aarch64-outliner.c
index 42e43b433e282d3..06e5de11ec49ecd 100644
--- a/clang/test/Driver/aarch64-outliner.c
+++ b/clang/test/Driver/aarch64-outliner.c
@@ -1,7 +1,9 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang --target=aarch64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
+// RUN: %clang --target=aarch64_be -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
 // ON: "-mllvm" "-enable-machine-outliner"
 // RUN: %clang --target=aarch64 -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
+// RUN: %clang --target=aarch64_be -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
 // OFF: "-mllvm" "-enable-machine-outliner=never"
 // RUN: %clang --target=x86_64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=WARN
 // WARN: warning: 'x86_64' does not support '-moutline'; flag ignored 
[-Woption-ignored]

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


[clang] [Driver][MachineOutliner] Support -moutline option for aarch64_be (PR #73223)

2023-11-26 Thread dong jianqiang via cfe-commits

https://github.com/dongjianqiang2 updated 
https://github.com/llvm/llvm-project/pull/73223

>From b58489a05f97dcb6cf31ce9527ff0e7a16a9f56e Mon Sep 17 00:00:00 2001
From: dong jianqiang 
Date: Thu, 23 Nov 2023 16:58:11 +0800
Subject: [PATCH] [Driver][MachineOutliner] Support outlining option with LTO
 for aarch64_be

This patch propagates the -moutline option when target is aarch64_be,
fix warning: 'aarch64_be' does not support '-moutline'; flag ignored 
[-Woption-ignored]
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 3 ++-
 clang/test/Driver/aarch64-outliner.c   | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1f31c6395206ee8..fb92a6dfbc0e26d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2400,7 +2400,8 @@ void tools::addMachineOutlinerArgs(const Driver &D,
   // Otherwise, add the proper mllvm flags.
   if (!(Triple.isARM() || Triple.isThumb() ||
 Triple.getArch() == llvm::Triple::aarch64 ||
-Triple.getArch() == llvm::Triple::aarch64_32)) {
+Triple.getArch() == llvm::Triple::aarch64_32 ||
+Triple.getArch() == llvm::Triple::aarch64_be)) {
 D.Diag(diag::warn_drv_moutline_unsupported_opt) << 
Triple.getArchName();
   } else {
 addArg(Twine("-enable-machine-outliner"));
diff --git a/clang/test/Driver/aarch64-outliner.c 
b/clang/test/Driver/aarch64-outliner.c
index 42e43b433e282d3..06e5de11ec49ecd 100644
--- a/clang/test/Driver/aarch64-outliner.c
+++ b/clang/test/Driver/aarch64-outliner.c
@@ -1,7 +1,9 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang --target=aarch64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
+// RUN: %clang --target=aarch64_be -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
 // ON: "-mllvm" "-enable-machine-outliner"
 // RUN: %clang --target=aarch64 -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
+// RUN: %clang --target=aarch64_be -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
 // OFF: "-mllvm" "-enable-machine-outliner=never"
 // RUN: %clang --target=x86_64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=WARN
 // WARN: warning: 'x86_64' does not support '-moutline'; flag ignored 
[-Woption-ignored]

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


[clang] [Driver] Add support for -export-dynamic which can match GCC behavior. (PR #72781)

2023-11-30 Thread dong jianqiang via cfe-commits

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


[clang] [Clang][Sema] Fix Wswitch-default bad warning in template (PR #76007)

2023-12-20 Thread dong jianqiang via cfe-commits

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

LGTM, thanks

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