[clang] ee7fb36 - [Driver] Fix -f[no-]inline to override -f[no-]inline-functions/-finline-hint-functions

2022-04-10 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-04-10T00:15:12-07:00
New Revision: ee7fb36ba03a75e404d1030666883e050052c5a1

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

LOG: [Driver] Fix -f[no-]inline to override 
-f[no-]inline-functions/-finline-hint-functions

Fix two cases to match GCC:

* -fno-inline -finline => (no cc1 option)
* -fno-inline -finline-functions => -fno-inline

Added: 
clang/test/Driver/finline.c

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

Removed: 
clang/test/Driver/noinline.c



diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1601dba171d26..1cb73f89e081d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6509,12 +6509,15 @@ void Clang::ConstructJob(Compilation &C, const 
JobAction &JA,
false))
 CmdArgs.push_back("-fgnu89-inline");
 
-  if (Args.hasArg(options::OPT_fno_inline))
-CmdArgs.push_back("-fno-inline");
-
-  Args.AddLastArg(CmdArgs, options::OPT_finline_functions,
-  options::OPT_finline_hint_functions,
-  options::OPT_fno_inline_functions);
+  const Arg *InlineArg = Args.getLastArg(options::OPT_finline_functions,
+ options::OPT_finline_hint_functions,
+ options::OPT_fno_inline_functions);
+  if (Arg *A = Args.getLastArg(options::OPT_finline, options::OPT_fno_inline)) 
{
+if (A->getOption().matches(options::OPT_fno_inline))
+  A->render(Args, CmdArgs);
+  } else if (InlineArg) {
+InlineArg->render(Args, CmdArgs);
+  }
 
   // FIXME: Find a better way to determine whether the language has modules
   // support by default, or just assume that all languages do.

diff  --git a/clang/test/Driver/finline.c b/clang/test/Driver/finline.c
new file mode 100644
index 0..8eacd5e923ef0
--- /dev/null
+++ b/clang/test/Driver/finline.c
@@ -0,0 +1,15 @@
+/// -fno-inline overrides -finline-functions/-finline-hint-functions.
+// RUN: %clang -### -c --target=x86_64-apple-darwin10 -O2 -fno-inline 
-fno-inline-functions %s 2>&1 | FileCheck %s --check-prefix=NOINLINE
+// RUN: %clang -### -c --target=x86_64 -O2 -finline -fno-inline 
-finline-functions %s 2>&1 | FileCheck %s --check-prefix=NOINLINE
+// NOINLINE-NOT: "-finline-functions"
+// NOINLINE: "-fno-inline"
+// NOINLINE-NOT: "-finline-functions"
+
+/// -finline overrides -finline-functions.
+// RUN: %clang -### -c --target=x86_64 -O2 -fno-inline -finline 
-finline-functions %s 2>&1 | FileCheck %s --check-prefix=INLINE
+// INLINE-NOT: "-finline-functions"
+// INLINE-NOT: "-fno-inline"
+// INLINE-NOT: "-finline"
+
+// RUN: %clang -### -c --target=aarch64 -O2 -finline-functions %s 2>&1 | 
FileCheck %s --check-prefix=INLINE-FUNCTIONS
+// INLINE-FUNCTIONS: "-finline-functions"

diff  --git a/clang/test/Driver/noinline.c b/clang/test/Driver/noinline.c
deleted file mode 100644
index 70f950cf52970..0
--- a/clang/test/Driver/noinline.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Make sure the driver is correctly passing -fno-inline-functions
-// rdar://10972766
-
-// RUN: %clang -target x86_64-apple-darwin10 \
-// RUN:   -fno-inline -fno-inline-functions -### -fsyntax-only %s 2> %t
-// RUN: FileCheck < %t %s
-
-// CHECK: clang
-// CHECK: "-fno-inline"
-// CHECK: "-fno-inline-functions"



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


[PATCH] D123064: [Clang][C++23] P2071 Named universal character escapes

2022-04-10 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 421769.
cor3ntin added a comment.

Fix linking on windows.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123064/new/

https://reviews.llvm.org/D123064

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Lex/Lexer.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/FixIt/fixit-unicode-named-escape-sequences.c
  clang/test/Lexer/char-escapes-delimited.c
  clang/test/Lexer/unicode.c
  clang/test/Parser/cxx11-user-defined-literals.cpp
  clang/test/Preprocessor/ucn-pp-identifier.c
  clang/test/Sema/ucn-identifiers.c
  llvm/CMakeLists.txt
  llvm/include/llvm/ADT/StringExtras.h
  llvm/include/llvm/Support/ScopedPrinter.h
  llvm/include/llvm/Support/Unicode.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/ScopedPrinter.cpp
  llvm/lib/Support/StringExtras.cpp
  llvm/lib/Support/UnicodeNameToCodepoint.cpp
  llvm/lib/Support/UnicodeNameToCodepointGenerated.cpp
  llvm/unittests/Support/UnicodeTest.cpp
  llvm/utils/UnicodeData/CMakeLists.txt
  llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp

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


[clang] d74039f - [Frontend] Simplify -finline* handling. NFC

2022-04-10 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-04-10T00:31:25-07:00
New Revision: d74039fa8e4d3f3d9e10fd67f312d4410cc0f53d

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

LOG: [Frontend] Simplify -finline* handling. NFC

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 5181999203b1e..bbc6df546941e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1613,23 +1613,22 @@ bool 
CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
 
   // At O0 we want to fully disable inlining outside of cases marked with
   // 'alwaysinline' that are required for correctness.
-  Opts.setInlining((Opts.OptimizationLevel == 0)
-   ? CodeGenOptions::OnlyAlwaysInlining
-   : CodeGenOptions::NormalInlining);
-  // Explicit inlining flags can disable some or all inlining even at
-  // optimization levels above zero.
-  if (Arg *InlineArg = Args.getLastArg(
-  options::OPT_finline_functions, options::OPT_finline_hint_functions,
-  options::OPT_fno_inline_functions, options::OPT_fno_inline)) {
-if (Opts.OptimizationLevel > 0) {
-  const Option &InlineOpt = InlineArg->getOption();
-  if (InlineOpt.matches(options::OPT_finline_functions))
-Opts.setInlining(CodeGenOptions::NormalInlining);
-  else if (InlineOpt.matches(options::OPT_finline_hint_functions))
-Opts.setInlining(CodeGenOptions::OnlyHintInlining);
-  else
-Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining);
-}
+  if (Opts.OptimizationLevel == 0) {
+Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining);
+  } else if (const Arg *A = Args.getLastArg(options::OPT_finline_functions,
+
options::OPT_finline_hint_functions,
+options::OPT_fno_inline_functions,
+options::OPT_fno_inline)) {
+// Explicit inlining flags can disable some or all inlining even at
+// optimization levels above zero.
+if (A->getOption().matches(options::OPT_finline_functions))
+  Opts.setInlining(CodeGenOptions::NormalInlining);
+else if (A->getOption().matches(options::OPT_finline_hint_functions))
+  Opts.setInlining(CodeGenOptions::OnlyHintInlining);
+else
+  Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining);
+  } else {
+Opts.setInlining(CodeGenOptions::NormalInlining);
   }
 
   // PIC defaults to -fno-direct-access-external-data while non-PIC defaults to



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


[PATCH] D123064: [Clang][C++23] P2071 Named universal character escapes

2022-04-10 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 421771.
cor3ntin added a comment.

Formatting


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123064/new/

https://reviews.llvm.org/D123064

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Lex/Lexer.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/FixIt/fixit-unicode-named-escape-sequences.c
  clang/test/Lexer/char-escapes-delimited.c
  clang/test/Lexer/unicode.c
  clang/test/Parser/cxx11-user-defined-literals.cpp
  clang/test/Preprocessor/ucn-pp-identifier.c
  clang/test/Sema/ucn-identifiers.c
  llvm/CMakeLists.txt
  llvm/include/llvm/ADT/StringExtras.h
  llvm/include/llvm/Support/ScopedPrinter.h
  llvm/include/llvm/Support/Unicode.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/ScopedPrinter.cpp
  llvm/lib/Support/StringExtras.cpp
  llvm/lib/Support/UnicodeNameToCodepoint.cpp
  llvm/lib/Support/UnicodeNameToCodepointGenerated.cpp
  llvm/unittests/Support/UnicodeTest.cpp
  llvm/utils/UnicodeData/CMakeLists.txt
  llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp

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


[clang] 30b1c1f - [Driver] Simplify -f[no-]diagnostics-color handling. NFC

2022-04-10 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-04-10T01:07:44-07:00
New Revision: 30b1c1f23d4d58c3220eac6aee35fd23f109b35c

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

LOG: [Driver] Simplify -f[no-]diagnostics-color handling. NFC

Make them aliases for -f[no-]color-diagnostics.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 98443b2757c93..81d47b2517d02 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1342,8 +1342,8 @@ def fclang_abi_compat_EQ : Joined<["-"], 
"fclang-abi-compat=">, Group;
-def fdiagnostics_color : Flag<["-"], "fdiagnostics-color">, Group,
-  Flags<[CoreOption, NoXarchOption]>;
+def : Flag<["-"], "fdiagnostics-color">, Group, Flags<[CoreOption]>, 
Alias;
+def : Flag<["-"], "fno-diagnostics-color">, Group, 
Flags<[CoreOption]>, Alias;
 def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, 
Group;
 def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group,
   Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for 
diagnostics">,
@@ -2308,8 +2308,6 @@ def fno_builtin : Flag<["-"], "fno-builtin">, 
Group, Flags<[CC1Option,
   HelpText<"Disable implicit builtin knowledge of functions">;
 def fno_builtin_ : Joined<["-"], "fno-builtin-">, Group, 
Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable implicit builtin knowledge of a specific function">;
-def fno_diagnostics_color : Flag<["-"], "fno-diagnostics-color">, 
Group,
-  Flags<[CoreOption, NoXarchOption]>;
 def fno_common : Flag<["-"], "fno-common">, Group, Flags<[CC1Option]>,
 HelpText<"Compile common globals like normal definitions">;
 defm digraphs : BoolFOption<"digraphs",

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1cb73f89e081d..0da0c75d0cc5d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3957,9 +3957,7 @@ static void RenderDiagnosticsOptions(const Driver &D, 
const ArgList &Args,
   for (const Arg *A : Args) {
 const Option &O = A->getOption();
 if (!O.matches(options::OPT_fcolor_diagnostics) &&
-!O.matches(options::OPT_fdiagnostics_color) &&
 !O.matches(options::OPT_fno_color_diagnostics) &&
-!O.matches(options::OPT_fno_diagnostics_color) &&
 !O.matches(options::OPT_fdiagnostics_color_EQ))
   continue;
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index bbc6df546941e..6aa85586df069 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2123,11 +2123,9 @@ static bool parseShowColorsArgs(const ArgList &Args, 
bool DefaultColor) {
   } ShowColors = DefaultColor ? Colors_Auto : Colors_Off;
   for (auto *A : Args) {
 const Option &O = A->getOption();
-if (O.matches(options::OPT_fcolor_diagnostics) ||
-O.matches(options::OPT_fdiagnostics_color)) {
+if (O.matches(options::OPT_fcolor_diagnostics)) {
   ShowColors = Colors_On;
-} else if (O.matches(options::OPT_fno_color_diagnostics) ||
-   O.matches(options::OPT_fno_diagnostics_color)) {
+} else if (O.matches(options::OPT_fno_color_diagnostics)) {
   ShowColors = Colors_Off;
 } else if (O.matches(options::OPT_fdiagnostics_color_EQ)) {
   StringRef Value(A->getValue());

diff  --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index cb94daccd157e..d1f427a15005f 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -61,11 +61,9 @@ static bool parseShowColorsArgs(
 
   for (auto *a : args) {
 const llvm::opt::Option &O = a->getOption();
-if (O.matches(clang::driver::options::OPT_fcolor_diagnostics) ||
-O.matches(clang::driver::options::OPT_fdiagnostics_color)) {
+if (O.matches(clang::driver::options::OPT_fcolor_diagnostics)) {
   ShowColors = Colors_On;
-} else if (O.matches(clang::driver::options::OPT_fno_color_diagnostics) ||
-O.matches(clang::driver::options::OPT_fno_diagnostics_color)) {
+} else if (O.matches(clang::driver::options::OPT_fno_color_diagnostics)) {
   ShowColors = Colors_Off;
 } else if (O.matches(clang::driver::options::OPT_fdiagnostics_color_EQ)) {
   llvm::StringRef value(a->getValue());



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


[clang] 8e1530b - [Driver] Simplify OPT_fcolor_diagnostics claim

2022-04-10 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-04-10T01:21:31-07:00
New Revision: 8e1530ba43f0e298c3e4821f38434479baf88227

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

LOG: [Driver] Simplify OPT_fcolor_diagnostics claim

Mostly NFC, but the diagnostic is changed to the more appropriate
err_drv_invalid_argument_to_option.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/color-diagnostics.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 0da0c75d0cc5d..c0566189ae69c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3954,20 +3954,13 @@ static void RenderDiagnosticsOptions(const Driver &D, 
const ArgList &Args,
   // re-parsed to construct this job; claim any possible color diagnostic here
   // to avoid warn_drv_unused_argument and diagnose bad
   // OPT_fdiagnostics_color_EQ values.
-  for (const Arg *A : Args) {
-const Option &O = A->getOption();
-if (!O.matches(options::OPT_fcolor_diagnostics) &&
-!O.matches(options::OPT_fno_color_diagnostics) &&
-!O.matches(options::OPT_fdiagnostics_color_EQ))
-  continue;
-
-if (O.matches(options::OPT_fdiagnostics_color_EQ)) {
-  StringRef Value(A->getValue());
-  if (Value != "always" && Value != "never" && Value != "auto")
-D.Diag(diag::err_drv_clang_unsupported)
-<< ("-fdiagnostics-color=" + Value).str();
-}
-A->claim();
+  Args.getLastArg(options::OPT_fcolor_diagnostics,
+  options::OPT_fno_color_diagnostics);
+  if (const Arg *A = Args.getLastArg(options::OPT_fdiagnostics_color_EQ)) {
+StringRef Value(A->getValue());
+if (Value != "always" && Value != "never" && Value != "auto")
+  D.Diag(diag::err_drv_invalid_argument_to_option)
+  << Value << A->getOption().getName();
   }
 
   if (D.getDiags().getDiagnosticOptions().ShowColors)

diff  --git a/clang/test/Driver/color-diagnostics.c 
b/clang/test/Driver/color-diagnostics.c
index ebf614eeb1a37..0d38a6ba2d414 100644
--- a/clang/test/Driver/color-diagnostics.c
+++ b/clang/test/Driver/color-diagnostics.c
@@ -29,7 +29,7 @@
 
 // RUN: %clang -fdiagnostics-color=foo -### -c %s 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-DCE_FOO %s
-// CHECK-DCE_FOO: error: the clang compiler does not support 
'-fdiagnostics-color=foo'
+// CHECK-DCE_FOO: error: invalid argument 'foo' to -fdiagnostics-color=
 
 // Check that the last flag wins.
 // RUN: %clang -fno-color-diagnostics -fdiagnostics-color -### -c %s 2>&1 \



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


[clang] a96cbb5 - [Driver] Prepend - to option name in err_drv_unsupported_option_argument diagnostic

2022-04-10 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-04-10T01:44:53-07:00
New Revision: a96cbb503ae3297a3e46ea4845a75f3af960d40c

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

LOG: [Driver] Prepend - to option name in err_drv_unsupported_option_argument 
diagnostic

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Driver/ToolChains/MSP430.cpp
clang/test/Driver/aarch64-sve-vector-bits.c
clang/test/Driver/arm-implicit-it.s
clang/test/Driver/arm-target-as-mimplicit-it.s
clang/test/Driver/clang_f_opts.c
clang/test/Driver/compress-noias.c
clang/test/Driver/compress.c
clang/test/Driver/fprofile-update.c
clang/test/Driver/fsanitize-address-destructor.c
clang/test/Driver/fsanitize-coverage.c
clang/test/Driver/fsanitize-use-after-return.c
clang/test/Driver/fsanitize.c
clang/test/Driver/hexagon-hvx.c
clang/test/Driver/masm.c
clang/test/Driver/masm.s
clang/test/Driver/mbig-obj.c
clang/test/Driver/msp430-hwmult.c
clang/test/Driver/windows-cross.c
clang/test/OpenMP/linking.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 1100f775ed6ab..4756edd28a925 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -19,7 +19,7 @@ def err_drv_unsupported_opt_for_target : Error<
 def err_drv_unsupported_opt_for_language_mode : Error<
   "unsupported option '%0' for language mode '%1'">;
 def err_drv_unsupported_option_argument : Error<
-  "unsupported argument '%1' to option '%0'">;
+  "unsupported argument '%1' to option '-%0'">;
 def err_drv_unknown_stdin_type : Error<
   "-E or -x required when input is from standard input">;
 def err_drv_unknown_stdin_type_clang_cl : Error<

diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index b650eed617627..a8227f1f8285e 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -234,7 +234,7 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
 SanitizerSet S;
 S.Mask = InvalidValues;
 D.Diag(diag::err_drv_unsupported_option_argument)
-<< "-fsanitize-trap" << toString(S);
+<< Arg->getOption().getName() << toString(S);
   }
   TrappingKinds |= expandSanitizerGroups(Add) & ~TrapRemove;
 } else if (Arg->getOption().matches(options::OPT_fno_sanitize_trap_EQ)) {

diff  --git a/clang/lib/Driver/ToolChains/MSP430.cpp 
b/clang/lib/Driver/ToolChains/MSP430.cpp
index 96994ba77facc..bc789853049a3 100644
--- a/clang/lib/Driver/ToolChains/MSP430.cpp
+++ b/clang/lib/Driver/ToolChains/MSP430.cpp
@@ -101,7 +101,7 @@ void msp430::getMSP430TargetFeatures(const Driver &D, const 
ArgList &Args,
 Features.push_back("+hwmultf5");
   } else {
 D.Diag(clang::diag::err_drv_unsupported_option_argument)
-<< HWMultArg->getAsString(Args) << HWMult;
+<< HWMultArg->getOption().getName() << HWMult;
   }
 }
 

diff  --git a/clang/test/Driver/aarch64-sve-vector-bits.c 
b/clang/test/Driver/aarch64-sve-vector-bits.c
index 9b011b5265e6a..40e90ba62a434 100644
--- a/clang/test/Driver/aarch64-sve-vector-bits.c
+++ b/clang/test/Driver/aarch64-sve-vector-bits.c
@@ -51,7 +51,7 @@
 // RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
 // RUN:  -msve-vector-bits=A 2>&1 | FileCheck 
--check-prefix=CHECK-BAD-VALUE-ERROR %s
 
-// CHECK-BAD-VALUE-ERROR: error: unsupported argument '{{.*}}' to option 
'msve-vector-bits='
+// CHECK-BAD-VALUE-ERROR: error: unsupported argument '{{.*}}' to option 
'-msve-vector-bits='
 
 // Error if using attribute without -msve-vector-bits= or if using 
-msve-vector-bits=+ syntax
 // 
-

diff  --git a/clang/test/Driver/arm-implicit-it.s 
b/clang/test/Driver/arm-implicit-it.s
index 48e4bdbe8c956..307b446295c2e 100644
--- a/clang/test/Driver/arm-implicit-it.s
+++ b/clang/test/Driver/arm-implicit-it.s
@@ -21,4 +21,4 @@
 // CHECK-THUMB: "-arm-implicit-it=thumb"
 // CHECK-NEVER: "-arm-implicit-it=never"
 // CHECK-ALWAYS: "-arm-implicit-it=always"
-// CHECK-INVALID: error: unsupported argument 'thisisnotavalidoption' to 
option 'mimplicit-it='
+// CHECK-INVALID: error: unsupported argument 'thisisnotavalidoption' to 
option '-mimplicit-it='

diff  --git a/clang/test/Driver/arm-target-as-mimplicit-it.s 
b/clang/test/Driver/arm-target-as-mimplicit-it.s
index b4eed3e506321..e9df1a9f4e8de 100644
--- a/clang/test/Driver/arm-target-as-mimplicit-it.s
+++ b/clang/test/Driver/arm-target-as-mimplicit-it.s
@@ -47,5 +47,5 @@
 // NEVER-NOT: "-arm-impli

[PATCH] D123345: Treat `std::move`, `forward`, and `move_if_noexcept` as builtins.

2022-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D123345#3441262 , @joerg wrote:

> As is, I think this conflicts with `-ffreestanding` assumptions or at the 
> very least the spirit.

Why? These functions are in `` which is not required in freestanding, 
but implementations are allowed to support more anyway 
(http://eel.is/c++draft/compliance#2). As the codegen doesn't emit a call to a 
library function but is purely using language facilities to reimplement the 
functionality, these don't seem to be in conflict with freestanding to me. If 
you could expound on what problems you see, that'd be helpful.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123345/new/

https://reviews.llvm.org/D123345

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


[PATCH] D123464: [analyzer] Clean checker options from bool to DefaultBool (NFC)

2022-04-10 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers created this revision.
vabridgers added reviewers: NoQ, steakhal.
Herald added subscribers: manas, ASDenysPetrov, martong, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
vabridgers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A recent review emphasized the preference to use DefaultBool instead of
bool for checker options. This change is a NFC and cleans up some of the
instances where bool was used, and could be changed to DefaultBool.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123464

Files:
  clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
  clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -44,7 +44,7 @@
 public:
   // These are going to be null if the respective check is disabled.
   mutable std::unique_ptr BT_Pure, BT_Impure;
-  bool ShowFixIts = false;
+  DefaultBool ShowFixIts;
 
   void checkBeginFunction(CheckerContext &C) const;
   void checkEndFunction(const ReturnStmt *RS, CheckerContext &C) const;
Index: 
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
===
--- clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
+++ clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
@@ -71,11 +71,11 @@
 namespace ento {
 
 struct UninitObjCheckerOptions {
-  bool IsPedantic = false;
-  bool ShouldConvertNotesToWarnings = false;
-  bool CheckPointeeInitialization = false;
+  DefaultBool IsPedantic;
+  DefaultBool ShouldConvertNotesToWarnings;
+  DefaultBool CheckPointeeInitialization;
   std::string IgnoredRecordsWithFieldPattern;
-  bool IgnoreGuardedFields = false;
+  DefaultBool IgnoreGuardedFields;
 };
 
 /// A lightweight polymorphic wrapper around FieldRegion *. We'll use this
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -566,9 +566,9 @@
   DefaultBool ChecksEnabled[CK_NumCheckKinds];
   CheckerNameRef CheckNames[CK_NumCheckKinds];
 
-  bool DisplayLoadedSummaries = false;
-  bool ModelPOSIX = false;
-  bool ShouldAssumeControlledEnvironment = false;
+  DefaultBool DisplayLoadedSummaries;
+  DefaultBool ModelPOSIX;
+  DefaultBool ShouldAssumeControlledEnvironment;
 
 private:
   Optional findFunctionSummary(const FunctionDecl *FD,
Index: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
===
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
@@ -267,13 +267,13 @@
   static std::unique_ptr CastFailTag;
 
   /// Track Objective-C and CoreFoundation objects.
-  bool TrackObjCAndCFObjects = false;
+  DefaultBool TrackObjCAndCFObjects;
 
   /// Track sublcasses of OSObject.
-  bool TrackOSObjects = false;
+  DefaultBool TrackOSObjects;
 
   /// Track initial parameters (for the entry point) for NS/CF objects.
-  bool TrackNSCFStartParam = false;
+  DefaultBool TrackNSCFStartParam;
 
   RetainCountChecker() {};
 
Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -120,7 +120,7 @@
 namespace {
 class DeadStoresChecker : public Checker {
 public:
-  bool ShowFixIts = false;
+  DefaultBool ShowFixIts;
   bool WarnForDeadNestedAssignments = true;
 
   void checkASTCodeBody(const Decl *D, AnalysisManager &Mgr,
Index: clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -30,7 +30,7 @@
 public:
   // Checker options.
   int MinComplexity;
-  bool ReportNormalClones;
+  DefaultBool ReportNormalClones;
   StringRef IgnoredFilesPattern;
 
 private:


Index: clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
==

[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

2022-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 421786.
aaron.ballman added a comment.

Rebased


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122983/new/

https://reviews.llvm.org/D122983

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/ARCMT/objcmt-arc-cf-annotations.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
  clang/test/Analysis/OSAtomic_mac.c
  clang/test/Analysis/ObjCProperties.m
  clang/test/Analysis/PR49642.c
  clang/test/Analysis/diagnostics/no-store-func-path-notes.c
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/novoidtypecrash.c
  clang/test/Analysis/plist-macros-with-expansion.c
  clang/test/CodeGen/2002-07-14-MiscTests3.c
  clang/test/CodeGen/2002-07-31-SubregFailure.c
  clang/test/CodeGen/2003-08-18-SigSetJmp.c
  clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
  clang/test/CodeGen/2005-01-02-ConstantInits.c
  clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
  clang/test/CodeGen/2006-01-13-StackSave.c
  clang/test/CodeGen/2006-03-03-MissingInitializer.c
  clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c
  clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
  clang/test/CodeGen/2008-08-19-cast-of-typedef.c
  clang/test/CodeGen/2008-10-13-FrontendCrash.c
  clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c
  clang/test/CodeGen/X86/bmi2-builtins.c
  clang/test/CodeGen/aarch64-mops.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/attribute_constructor.c
  clang/test/CodeGen/builtins-arm-microsoft.c
  clang/test/CodeGen/builtins-arm-msvc-compat-only.c
  clang/test/CodeGen/cast-emit.c
  clang/test/CodeGen/debug-info-block-vars.c
  clang/test/CodeGen/debug-info-crash.c
  clang/test/CodeGen/decl.c
  clang/test/CodeGen/init-with-member-expr.c
  clang/test/CodeGen/misaligned-param.c
  clang/test/CodeGen/neon-crypto.c
  clang/test/CodeGen/struct-comma.c
  clang/test/CodeGen/variable-array.c
  clang/test/Frontend/warning-mapping-2.c
  clang/test/Headers/arm-cmse-header-ns.c
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/Modules/config_macros.m
  clang/test/Modules/modulemap-locations.m
  clang/test/OpenMP/declare_mapper_messages.c
  clang/test/PCH/chain-macro-override.c
  clang/test/Rewriter/rewrite-foreach-2.m
  clang/test/Rewriter/rewrite-try-catch.m
  clang/test/Sema/__try.c
  clang/test/Sema/aarch64-tme-errors.c
  clang/test/Sema/arm-no-fp16.c
  clang/test/Sema/bitfield.c
  clang/test/Sema/builtin-setjmp.c
  clang/test/Sema/builtins.c
  clang/test/Sema/cxx-as-c.c
  clang/test/Sema/implicit-builtin-decl.c
  clang/test/Sema/implicit-decl.c
  clang/test/Sema/implicit-ms-builtin-decl.c
  clang/test/Sema/typo-correction.c
  clang/test/Sema/vla.c
  clang/test/Sema/warn-strict-prototypes.c
  clang/test/VFS/module_missing_vfs.m
  compiler-rt/test/safestack/pthread-cleanup.c

Index: compiler-rt/test/safestack/pthread-cleanup.c
===
--- compiler-rt/test/safestack/pthread-cleanup.c
+++ compiler-rt/test/safestack/pthread-cleanup.c
@@ -17,6 +17,8 @@
   return buffer;
 }
 
+extern unsigned sleep(unsigned seconds);
+
 int main(int argc, char **argv)
 {
   int arg = atoi(argv[1]);
Index: clang/test/VFS/module_missing_vfs.m
===
--- clang/test/VFS/module_missing_vfs.m
+++ clang/test/VFS/module_missing_vfs.m
@@ -1,12 +1,12 @@
 // RUN: rm -rf %t && mkdir -p %t
 // RUN: echo "void funcA(void);" >> %t/a.h
 
-// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml 2>&1 | FileCheck %s -check-prefix=ERROR
+// RUN: not %clang_cc1 -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml 2>&1 | FileCheck %s -check-prefix=ERROR
 // ERROR: virtual filesystem overlay file '{{.*}}' not found
 // RUN: find %t/mcp -name "A-*.pcm" | count 1
 
 // RUN: sed -e "s@INPUT_DIR@%{/S:regex_replacement}/Inputs@g" -e "s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/MissingVFS/vfsoverlay.yaml > %t/vfs.yaml
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml
+// RUN: %clang_cc1 -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml
 // RUN: find %t/mcp -name "A-*.pcm" | count 1
 
 @import A;
Index: clang/test/Sema/warn-strict-prototypes.c
===
--- clang/test/Se

[PATCH] D123064: [Clang][C++23] P2071 Named universal character escapes

2022-04-10 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 421787.
cor3ntin added a comment.

A non-existing name could return an engaged value if the
whole string matched the node's name, even if that node had no
attached value.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123064/new/

https://reviews.llvm.org/D123064

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Lex/Lexer.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/FixIt/fixit-unicode-named-escape-sequences.c
  clang/test/Lexer/char-escapes-delimited.c
  clang/test/Lexer/unicode.c
  clang/test/Parser/cxx11-user-defined-literals.cpp
  clang/test/Preprocessor/ucn-pp-identifier.c
  clang/test/Sema/ucn-identifiers.c
  llvm/CMakeLists.txt
  llvm/include/llvm/ADT/StringExtras.h
  llvm/include/llvm/Support/ScopedPrinter.h
  llvm/include/llvm/Support/Unicode.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/ScopedPrinter.cpp
  llvm/lib/Support/StringExtras.cpp
  llvm/lib/Support/UnicodeNameToCodepoint.cpp
  llvm/lib/Support/UnicodeNameToCodepointGenerated.cpp
  llvm/unittests/Support/UnicodeTest.cpp
  llvm/utils/UnicodeData/CMakeLists.txt
  llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp

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


[PATCH] D115103: Leak Sanitizer port to Windows

2022-04-10 Thread Clemens Wasser via Phabricator via cfe-commits
clemenswasser updated this revision to Diff 421790.
clemenswasser added a comment.

I was wrong, the Problem was, that I didn't change the exit code, when a leak 
gets detected.
I now intercept ExitProcess and change the exit code in there, with this there 
are already 12 Tests passing on Windows.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115103/new/

https://reviews.llvm.org/D115103

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/lsan/CMakeLists.txt
  compiler-rt/lib/lsan/lsan.h
  compiler-rt/lib/lsan/lsan_allocator.h
  compiler-rt/lib/lsan/lsan_common.cpp
  compiler-rt/lib/lsan/lsan_common.h
  compiler-rt/lib/lsan/lsan_common_win.cpp
  compiler-rt/lib/lsan/lsan_interceptors.cpp
  compiler-rt/lib/lsan/lsan_win.cpp
  compiler-rt/lib/lsan/lsan_win.h
  compiler-rt/test/lsan/TestCases/Darwin/dispatch.mm
  compiler-rt/test/lsan/TestCases/Linux/cleanup_in_tsd_destructor.c
  compiler-rt/test/lsan/TestCases/Linux/disabler_in_tsd_destructor.c
  compiler-rt/test/lsan/TestCases/Linux/use_tls_dynamic.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_dynamic.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_static.cpp
  compiler-rt/test/lsan/TestCases/disabler.c
  compiler-rt/test/lsan/TestCases/disabler.cpp
  compiler-rt/test/lsan/TestCases/do_leak_check_override.cpp
  compiler-rt/test/lsan/TestCases/high_allocator_contention.cpp
  compiler-rt/test/lsan/TestCases/ignore_object.c
  compiler-rt/test/lsan/TestCases/large_allocation_leak.cpp
  compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp
  compiler-rt/test/lsan/TestCases/link_turned_off.cpp
  compiler-rt/test/lsan/TestCases/many_tls_keys_pthread.cpp
  compiler-rt/test/lsan/TestCases/many_tls_keys_thread.cpp
  compiler-rt/test/lsan/TestCases/pointer_to_self.cpp
  compiler-rt/test/lsan/TestCases/print_suppressions.cpp
  compiler-rt/test/lsan/TestCases/recoverable_leak_check.cpp
  compiler-rt/test/lsan/TestCases/register_root_region.cpp
  compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
  compiler-rt/test/lsan/TestCases/suppressions_default.cpp
  compiler-rt/test/lsan/TestCases/suppressions_file.cpp
  compiler-rt/test/lsan/TestCases/use_after_return.cpp
  compiler-rt/test/lsan/TestCases/use_globals_initialized.cpp
  compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cpp
  compiler-rt/test/lsan/TestCases/use_globals_unused.cpp
  compiler-rt/test/lsan/TestCases/use_poisoned_asan.cpp
  compiler-rt/test/lsan/TestCases/use_registers.cpp
  compiler-rt/test/lsan/TestCases/use_registers_extra.cpp
  compiler-rt/test/lsan/TestCases/use_stacks.cpp
  compiler-rt/test/lsan/TestCases/use_stacks_threaded.cpp
  compiler-rt/test/lsan/TestCases/use_unaligned.cpp
  compiler-rt/test/lsan/lit.common.cfg.py

Index: compiler-rt/test/lsan/lit.common.cfg.py
===
--- compiler-rt/test/lsan/lit.common.cfg.py
+++ compiler-rt/test/lsan/lit.common.cfg.py
@@ -22,7 +22,8 @@
 # Choose between standalone and LSan+ASan modes.
 lsan_lit_test_mode = get_required_attr(config, 'lsan_lit_test_mode')
 
-if lsan_lit_test_mode == "Standalone":
+# FIXME: All tests are Standalone on Windows for now. Since all win32 function calls in lsan get intercepted by asan :(
+if lsan_lit_test_mode == "Standalone" or config.host_os == 'Windows':
   config.name = "LeakSanitizer-Standalone"
   lsan_cflags = ["-fsanitize=leak"]
 elif lsan_lit_test_mode == "AddressSanitizer":
@@ -74,12 +75,13 @@
 config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) )
 
 # LeakSanitizer tests are currently supported on
-# Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
+# Windows{x86_64, x86, aarch64, arm}, Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
 supported_android = config.android and config.target_arch in ['x86_64', 'i386', 'aarch64'] and 'android-thread-properties-api' in config.available_features
 supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['aarch64', 'x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x']
 supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64']
 supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386']
-if not (supported_android or supported_linux or supported_darwin or supported_netbsd):
+supported_windows = config.host_os == 'Windows' and config.target_arch in ['x86_64', 'i386', 'aarch64', 'arm']
+if not (supported_android or supported_linux or supported_darwin or supported_netbsd or supported_windows):
   config.unsupported = True
 
 # Don't support Thumb due to broken fast unwinder
Index: compiler-rt/test/lsan/TestCases/use_unaligned.cpp
==

[PATCH] D115103: Leak Sanitizer port to Windows

2022-04-10 Thread Clemens Wasser via Phabricator via cfe-commits
clemenswasser updated this revision to Diff 421791.
clemenswasser added a comment.

The CI seems to fail because of the parent revision? Retry


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115103/new/

https://reviews.llvm.org/D115103

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/lsan/CMakeLists.txt
  compiler-rt/lib/lsan/lsan.h
  compiler-rt/lib/lsan/lsan_allocator.h
  compiler-rt/lib/lsan/lsan_common.cpp
  compiler-rt/lib/lsan/lsan_common.h
  compiler-rt/lib/lsan/lsan_common_win.cpp
  compiler-rt/lib/lsan/lsan_interceptors.cpp
  compiler-rt/lib/lsan/lsan_win.cpp
  compiler-rt/lib/lsan/lsan_win.h
  compiler-rt/test/lsan/TestCases/Darwin/dispatch.mm
  compiler-rt/test/lsan/TestCases/Linux/cleanup_in_tsd_destructor.c
  compiler-rt/test/lsan/TestCases/Linux/disabler_in_tsd_destructor.c
  compiler-rt/test/lsan/TestCases/Linux/use_tls_dynamic.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_dynamic.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_static.cpp
  compiler-rt/test/lsan/TestCases/disabler.c
  compiler-rt/test/lsan/TestCases/disabler.cpp
  compiler-rt/test/lsan/TestCases/do_leak_check_override.cpp
  compiler-rt/test/lsan/TestCases/high_allocator_contention.cpp
  compiler-rt/test/lsan/TestCases/ignore_object.c
  compiler-rt/test/lsan/TestCases/large_allocation_leak.cpp
  compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp
  compiler-rt/test/lsan/TestCases/link_turned_off.cpp
  compiler-rt/test/lsan/TestCases/many_tls_keys_pthread.cpp
  compiler-rt/test/lsan/TestCases/many_tls_keys_thread.cpp
  compiler-rt/test/lsan/TestCases/pointer_to_self.cpp
  compiler-rt/test/lsan/TestCases/print_suppressions.cpp
  compiler-rt/test/lsan/TestCases/recoverable_leak_check.cpp
  compiler-rt/test/lsan/TestCases/register_root_region.cpp
  compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
  compiler-rt/test/lsan/TestCases/suppressions_default.cpp
  compiler-rt/test/lsan/TestCases/suppressions_file.cpp
  compiler-rt/test/lsan/TestCases/use_after_return.cpp
  compiler-rt/test/lsan/TestCases/use_globals_initialized.cpp
  compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cpp
  compiler-rt/test/lsan/TestCases/use_globals_unused.cpp
  compiler-rt/test/lsan/TestCases/use_poisoned_asan.cpp
  compiler-rt/test/lsan/TestCases/use_registers.cpp
  compiler-rt/test/lsan/TestCases/use_registers_extra.cpp
  compiler-rt/test/lsan/TestCases/use_stacks.cpp
  compiler-rt/test/lsan/TestCases/use_stacks_threaded.cpp
  compiler-rt/test/lsan/TestCases/use_unaligned.cpp
  compiler-rt/test/lsan/lit.common.cfg.py

Index: compiler-rt/test/lsan/lit.common.cfg.py
===
--- compiler-rt/test/lsan/lit.common.cfg.py
+++ compiler-rt/test/lsan/lit.common.cfg.py
@@ -22,7 +22,8 @@
 # Choose between standalone and LSan+ASan modes.
 lsan_lit_test_mode = get_required_attr(config, 'lsan_lit_test_mode')
 
-if lsan_lit_test_mode == "Standalone":
+# FIXME: All tests are Standalone on Windows for now. Since all win32 function calls in lsan get intercepted by asan :(
+if lsan_lit_test_mode == "Standalone" or config.host_os == 'Windows':
   config.name = "LeakSanitizer-Standalone"
   lsan_cflags = ["-fsanitize=leak"]
 elif lsan_lit_test_mode == "AddressSanitizer":
@@ -74,12 +75,13 @@
 config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) )
 
 # LeakSanitizer tests are currently supported on
-# Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
+# Windows{x86_64, x86, aarch64, arm}, Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
 supported_android = config.android and config.target_arch in ['x86_64', 'i386', 'aarch64'] and 'android-thread-properties-api' in config.available_features
 supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['aarch64', 'x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x']
 supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64']
 supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386']
-if not (supported_android or supported_linux or supported_darwin or supported_netbsd):
+supported_windows = config.host_os == 'Windows' and config.target_arch in ['x86_64', 'i386', 'aarch64', 'arm']
+if not (supported_android or supported_linux or supported_darwin or supported_netbsd or supported_windows):
   config.unsupported = True
 
 # Don't support Thumb due to broken fast unwinder
Index: compiler-rt/test/lsan/TestCases/use_unaligned.cpp
===
--- compiler-rt/test/lsan/TestCases/use_unaligned.cpp
+++ compiler-rt/test/lsan/TestCases/use_unaligned.cpp
@@ -1,8 +1

[PATCH] D123460: [OpenMP] Make generating offloading entries more generic

2022-04-10 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 421794.
jhuber6 added a comment.

Change constant to just be a string since it's all we use.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123460/new/

https://reviews.llvm.org/D123460

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -598,6 +598,46 @@
   return Builder.saveIP();
 }
 
+void OpenMPIRBuilder::emitOffloadingEntry(Constant *Addr, StringRef Name,
+  uint64_t Size, int32_t Flags,
+  StringRef SectionName) {
+  Type *Int8PtrTy = Type::getInt8PtrTy(M.getContext());
+  Type *Int32Ty = Type::getInt32Ty(M.getContext());
+  Type *SizeTy = M.getDataLayout().getIntPtrType(M.getContext());
+
+  Constant *AddrName =
+  ConstantDataArray::getString(M.getContext(), Name);
+
+  // Create the constant string used to look up the symbol in the device.
+  auto *Str =
+  new llvm::GlobalVariable(M, AddrName->getType(), /*isConstant=*/true,
+   llvm::GlobalValue::InternalLinkage, AddrName,
+   ".omp_offloading.entry_name");
+  Str->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
+
+  // Construct the offloading entry.
+  Constant *EntryData[] = {
+  ConstantExpr::getPointerBitCastOrAddrSpaceCast(Addr, Int8PtrTy),
+  ConstantExpr::getPointerBitCastOrAddrSpaceCast(Str, Int8PtrTy),
+  ConstantInt::get(SizeTy, Size),
+  ConstantInt::get(Int32Ty, Flags),
+  ConstantInt::get(Int32Ty, 0),
+  };
+  Constant *EntryInitializer =
+  ConstantStruct::get(OpenMPIRBuilder::OffloadEntry, EntryData);
+
+  auto *Entry = new GlobalVariable(
+  M, OpenMPIRBuilder::OffloadEntry,
+  /* isConstant = */ true, GlobalValue::WeakAnyLinkage, EntryInitializer,
+  ".omp_offloading.entry." + Name, nullptr,
+  GlobalValue::NotThreadLocal,
+  M.getDataLayout().getDefaultGlobalsAddressSpace());
+
+  // The entry has to be created in the section the linker expects it to be.
+  Entry->setSection(SectionName);
+  Entry->setAlignment(Align(1));
+}
+
 void OpenMPIRBuilder::emitCancelationCheckImpl(Value *CancelFlag,
omp::Directive CanceledDirective,
FinalizeCallbackTy ExitCB) {
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -86,6 +86,8 @@
   OMP_STRUCT_TYPE(VarName, "struct." #Name, __VA_ARGS__)
 
 __OMP_STRUCT_TYPE(Ident, ident_t, Int32, Int32, Int32, Int32, Int8Ptr)
+__OMP_STRUCT_TYPE(OffloadEntry, __tgt_offload_entry, Int8Ptr, Int8Ptr, SizeTy,
+  Int32, Int32)
 __OMP_STRUCT_TYPE(AsyncInfo, __tgt_async_info, Int8Ptr)
 
 #undef __OMP_STRUCT_TYPE
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -715,6 +715,27 @@
   /// Value.
   GlobalValue *createGlobalFlag(unsigned Value, StringRef Name);
 
+  /// Create an offloading section struct used to register this global at
+  /// runtime.
+  ///
+  /// Type struct __tgt_offload_entry{
+  ///   void*addr;  // Pointer to the offload entry info.
+  ///   // (function or global)
+  ///   char*name;  // Name of the function or global.
+  ///   size_t  size;   // Size of the entry info (0 if it a function).
+  ///   int32_t flags;
+  ///   int32_t reserved;
+  /// };
+  ///
+  /// \param Addr The pointer to the global being registered.
+  /// \param Name The symbol name associated with the global.
+  /// \param Size The size in bytes of the global (0 for functions).
+  /// \param Flags Flags associated with the entry.
+  /// \param SectionName The section this entry will be placed at.
+  void emitOffloadingEntry(Constant *Addr, StringRef Name, uint64_t Size,
+   int32_t Flags,
+   StringRef SectionName = "omp_offloading_entries");
+
   /// Generate control flow and cleanup for cancellation.
   ///
   /// \param CancelFlag Flag indicating if the cancellation is performed.
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -518,15 +518,6 @@
   ///  kmp_int64 st

[PATCH] D115103: Leak Sanitizer port to Windows

2022-04-10 Thread Clemens Wasser via Phabricator via cfe-commits
clemenswasser updated this revision to Diff 421795.
clemenswasser added a comment.

Since I am currently unable to intercept the ExitProcess/TerminateProcess in 
the ucrt (`exit_or_terminate_process` in `Windows 
Kits\10\Source\10.0.22000.0\ucrt\startup\exit.cpp:143`)
I inserted a call to `Die` in `HandleLeaks` (just like on Linux). This brings 
the passing Test up to 22


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115103/new/

https://reviews.llvm.org/D115103

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/lsan/CMakeLists.txt
  compiler-rt/lib/lsan/lsan.h
  compiler-rt/lib/lsan/lsan_allocator.h
  compiler-rt/lib/lsan/lsan_common.cpp
  compiler-rt/lib/lsan/lsan_common.h
  compiler-rt/lib/lsan/lsan_common_win.cpp
  compiler-rt/lib/lsan/lsan_interceptors.cpp
  compiler-rt/lib/lsan/lsan_win.cpp
  compiler-rt/lib/lsan/lsan_win.h
  compiler-rt/test/lsan/TestCases/Darwin/dispatch.mm
  compiler-rt/test/lsan/TestCases/Linux/cleanup_in_tsd_destructor.c
  compiler-rt/test/lsan/TestCases/Linux/disabler_in_tsd_destructor.c
  compiler-rt/test/lsan/TestCases/Linux/use_tls_dynamic.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_dynamic.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_static.cpp
  compiler-rt/test/lsan/TestCases/disabler.c
  compiler-rt/test/lsan/TestCases/disabler.cpp
  compiler-rt/test/lsan/TestCases/do_leak_check_override.cpp
  compiler-rt/test/lsan/TestCases/high_allocator_contention.cpp
  compiler-rt/test/lsan/TestCases/ignore_object.c
  compiler-rt/test/lsan/TestCases/large_allocation_leak.cpp
  compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp
  compiler-rt/test/lsan/TestCases/link_turned_off.cpp
  compiler-rt/test/lsan/TestCases/many_tls_keys_pthread.cpp
  compiler-rt/test/lsan/TestCases/many_tls_keys_thread.cpp
  compiler-rt/test/lsan/TestCases/pointer_to_self.cpp
  compiler-rt/test/lsan/TestCases/print_suppressions.cpp
  compiler-rt/test/lsan/TestCases/recoverable_leak_check.cpp
  compiler-rt/test/lsan/TestCases/register_root_region.cpp
  compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
  compiler-rt/test/lsan/TestCases/suppressions_default.cpp
  compiler-rt/test/lsan/TestCases/suppressions_file.cpp
  compiler-rt/test/lsan/TestCases/use_after_return.cpp
  compiler-rt/test/lsan/TestCases/use_globals_initialized.cpp
  compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cpp
  compiler-rt/test/lsan/TestCases/use_globals_unused.cpp
  compiler-rt/test/lsan/TestCases/use_poisoned_asan.cpp
  compiler-rt/test/lsan/TestCases/use_registers.cpp
  compiler-rt/test/lsan/TestCases/use_registers_extra.cpp
  compiler-rt/test/lsan/TestCases/use_stacks.cpp
  compiler-rt/test/lsan/TestCases/use_stacks_threaded.cpp
  compiler-rt/test/lsan/TestCases/use_unaligned.cpp
  compiler-rt/test/lsan/lit.common.cfg.py

Index: compiler-rt/test/lsan/lit.common.cfg.py
===
--- compiler-rt/test/lsan/lit.common.cfg.py
+++ compiler-rt/test/lsan/lit.common.cfg.py
@@ -22,7 +22,8 @@
 # Choose between standalone and LSan+ASan modes.
 lsan_lit_test_mode = get_required_attr(config, 'lsan_lit_test_mode')
 
-if lsan_lit_test_mode == "Standalone":
+# FIXME: All tests are Standalone on Windows for now. Since all win32 function calls in lsan get intercepted by asan :(
+if lsan_lit_test_mode == "Standalone" or config.host_os == 'Windows':
   config.name = "LeakSanitizer-Standalone"
   lsan_cflags = ["-fsanitize=leak"]
 elif lsan_lit_test_mode == "AddressSanitizer":
@@ -74,12 +75,13 @@
 config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) )
 
 # LeakSanitizer tests are currently supported on
-# Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
+# Windows{x86_64, x86, aarch64, arm}, Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
 supported_android = config.android and config.target_arch in ['x86_64', 'i386', 'aarch64'] and 'android-thread-properties-api' in config.available_features
 supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['aarch64', 'x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x']
 supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64']
 supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386']
-if not (supported_android or supported_linux or supported_darwin or supported_netbsd):
+supported_windows = config.host_os == 'Windows' and config.target_arch in ['x86_64', 'i386', 'aarch64', 'arm']
+if not (supported_android or supported_linux or supported_darwin or supported_netbsd or supported_windows):
   config.unsupported = True
 
 # Don't support Thumb due to broken fast unwinder
Index: compi

[PATCH] D115103: Leak Sanitizer port to Windows

2022-04-10 Thread Clemens Wasser via Phabricator via cfe-commits
clemenswasser updated this revision to Diff 421796.
clemenswasser added a comment.

I always forget to change the line endings, sorry :(


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115103/new/

https://reviews.llvm.org/D115103

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/lsan/CMakeLists.txt
  compiler-rt/lib/lsan/lsan.h
  compiler-rt/lib/lsan/lsan_allocator.h
  compiler-rt/lib/lsan/lsan_common.cpp
  compiler-rt/lib/lsan/lsan_common.h
  compiler-rt/lib/lsan/lsan_common_win.cpp
  compiler-rt/lib/lsan/lsan_interceptors.cpp
  compiler-rt/lib/lsan/lsan_win.cpp
  compiler-rt/lib/lsan/lsan_win.h
  compiler-rt/test/lsan/TestCases/Darwin/dispatch.mm
  compiler-rt/test/lsan/TestCases/Linux/cleanup_in_tsd_destructor.c
  compiler-rt/test/lsan/TestCases/Linux/disabler_in_tsd_destructor.c
  compiler-rt/test/lsan/TestCases/Linux/use_tls_dynamic.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_dynamic.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_pthread_specific_static.cpp
  compiler-rt/test/lsan/TestCases/Linux/use_tls_static.cpp
  compiler-rt/test/lsan/TestCases/disabler.c
  compiler-rt/test/lsan/TestCases/disabler.cpp
  compiler-rt/test/lsan/TestCases/do_leak_check_override.cpp
  compiler-rt/test/lsan/TestCases/high_allocator_contention.cpp
  compiler-rt/test/lsan/TestCases/ignore_object.c
  compiler-rt/test/lsan/TestCases/large_allocation_leak.cpp
  compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp
  compiler-rt/test/lsan/TestCases/link_turned_off.cpp
  compiler-rt/test/lsan/TestCases/many_tls_keys_pthread.cpp
  compiler-rt/test/lsan/TestCases/many_tls_keys_thread.cpp
  compiler-rt/test/lsan/TestCases/pointer_to_self.cpp
  compiler-rt/test/lsan/TestCases/print_suppressions.cpp
  compiler-rt/test/lsan/TestCases/recoverable_leak_check.cpp
  compiler-rt/test/lsan/TestCases/register_root_region.cpp
  compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
  compiler-rt/test/lsan/TestCases/suppressions_default.cpp
  compiler-rt/test/lsan/TestCases/suppressions_file.cpp
  compiler-rt/test/lsan/TestCases/use_after_return.cpp
  compiler-rt/test/lsan/TestCases/use_globals_initialized.cpp
  compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cpp
  compiler-rt/test/lsan/TestCases/use_globals_unused.cpp
  compiler-rt/test/lsan/TestCases/use_poisoned_asan.cpp
  compiler-rt/test/lsan/TestCases/use_registers.cpp
  compiler-rt/test/lsan/TestCases/use_registers_extra.cpp
  compiler-rt/test/lsan/TestCases/use_stacks.cpp
  compiler-rt/test/lsan/TestCases/use_stacks_threaded.cpp
  compiler-rt/test/lsan/TestCases/use_unaligned.cpp
  compiler-rt/test/lsan/lit.common.cfg.py

Index: compiler-rt/test/lsan/lit.common.cfg.py
===
--- compiler-rt/test/lsan/lit.common.cfg.py
+++ compiler-rt/test/lsan/lit.common.cfg.py
@@ -22,7 +22,8 @@
 # Choose between standalone and LSan+ASan modes.
 lsan_lit_test_mode = get_required_attr(config, 'lsan_lit_test_mode')
 
-if lsan_lit_test_mode == "Standalone":
+# FIXME: All tests are Standalone on Windows for now. Since all win32 function calls in lsan get intercepted by asan :(
+if lsan_lit_test_mode == "Standalone" or config.host_os == 'Windows':
   config.name = "LeakSanitizer-Standalone"
   lsan_cflags = ["-fsanitize=leak"]
 elif lsan_lit_test_mode == "AddressSanitizer":
@@ -74,12 +75,13 @@
 config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) )
 
 # LeakSanitizer tests are currently supported on
-# Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
+# Windows{x86_64, x86, aarch64, arm}, Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
 supported_android = config.android and config.target_arch in ['x86_64', 'i386', 'aarch64'] and 'android-thread-properties-api' in config.available_features
 supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['aarch64', 'x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x']
 supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64']
 supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386']
-if not (supported_android or supported_linux or supported_darwin or supported_netbsd):
+supported_windows = config.host_os == 'Windows' and config.target_arch in ['x86_64', 'i386', 'aarch64', 'arm']
+if not (supported_android or supported_linux or supported_darwin or supported_netbsd or supported_windows):
   config.unsupported = True
 
 # Don't support Thumb due to broken fast unwinder
Index: compiler-rt/test/lsan/TestCases/use_unaligned.cpp
===
--- compiler-rt/test/lsan/TestCases/use_unaligned.cpp
+++ compiler-rt/test/lsan/TestCases/use_unaligned.cpp
@@ -1,8 +1,7 @@

[PATCH] D123450: [clang-format] Parse Verilog if statements

2022-04-10 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/FormatToken.h:374
+  /// Verilog we want to treat the backtick like a hash.
+  tok::TokenKind AliasToken = tok::unknown;
+

Can't we do that with a type?

I'm not very happy about the alias, because you can still call `Tok.getKind()`.



Comment at: clang/lib/Format/FormatToken.h:1157
+VerilogExtraKeywords = std::unordered_set(
+{kw_always,   kw_always_comb,  kw_always_ff,kw_always_latch,
+ kw_assert,   kw_assign,   kw_assume,   kw_automatic,

sstwcw wrote:
> Does anyone know why this part gets aligned unlike the two lists above?
Have you reformatted the other lines with the same config and revision?
If yes, my guess would be the missing comment.



Comment at: clang/lib/Format/FormatToken.h:1533
+switch (Tok.Tok.getKind()) {
+case tok::kw_case:
+case tok::kw_class:

So you have a blacklist what is not a keyword? Seems a bit non future proof, 
new C++ keywords would have to be added here.



Comment at: clang/lib/Format/FormatToken.h:1593
+
+  std::unordered_set VerilogExtraKeywords;
 };

For consistency reasons add the comment like above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123450/new/

https://reviews.llvm.org/D123450

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


[PATCH] D123468: [Driver] Simplify hasFlag pattern with addOptInFlag/addOptOutFlag helpers

2022-04-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: jkorous, dexonsmith.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123468

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/include/llvm/Option/ArgList.h
  llvm/lib/Option/ArgList.cpp

Index: llvm/lib/Option/ArgList.cpp
===
--- llvm/lib/Option/ArgList.cpp
+++ llvm/lib/Option/ArgList.cpp
@@ -95,6 +95,13 @@
   return std::vector(Values.begin(), Values.end());
 }
 
+void ArgList::addOptInFlag(ArgStringList &Output, OptSpecifier Pos,
+   OptSpecifier Neg) const {
+  if (Arg *A = getLastArg(Pos, Neg))
+if (A->getOption().matches(Pos))
+  A->render(*this, Output);
+}
+
 void ArgList::AddAllArgsExcept(ArgStringList &Output,
ArrayRef Ids,
ArrayRef ExcludeIds) const {
Index: llvm/include/llvm/Option/ArgList.h
===
--- llvm/include/llvm/Option/ArgList.h
+++ llvm/include/llvm/Option/ArgList.h
@@ -307,6 +307,16 @@
   bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
bool Default) const;
 
+  /// Given an option Pos and its negative form Neg, render the option if Pos is
+  /// present.
+  void addOptInFlag(ArgStringList &Output, OptSpecifier Pos,
+OptSpecifier Neg) const;
+  /// Render the option if Neg is present.
+  void addOptOutFlag(ArgStringList &Output, OptSpecifier Pos,
+ OptSpecifier Neg) const {
+addOptInFlag(Output, Neg, Pos);
+  }
+
   /// Render only the last argument match \p Id0, if present.
   template
   void AddLastArg(ArgStringList &Output, OptSpecifiers ...Ids) const {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3359,9 +3359,8 @@
   !EffectiveTriple.isPPC64())
 return;
 
-  if (Args.hasFlag(options::OPT_fstack_clash_protection,
-   options::OPT_fno_stack_clash_protection, false))
-CmdArgs.push_back("-fstack-clash-protection");
+  Args.addOptInFlag(CmdArgs, options::OPT_fstack_clash_protection,
+options::OPT_fno_stack_clash_protection);
 }
 
 static void RenderTrivialAutoVarInitOptions(const Driver &D,
@@ -3607,9 +3606,8 @@
 CmdArgs.push_back("-fimplicit-module-maps");
 
   // -fmodules-decluse checks that modules used are declared so (off by default)
-  if (Args.hasFlag(options::OPT_fmodules_decluse,
-   options::OPT_fno_modules_decluse, false))
-CmdArgs.push_back("-fmodules-decluse");
+  Args.addOptInFlag(CmdArgs, options::OPT_fmodules_decluse,
+options::OPT_fno_modules_decluse);
 
   // -fmodules-strict-decluse is like -fmodule-decluse, but also checks that
   // all #included headers are part of modules.
@@ -3908,15 +3906,10 @@
 options::OPT_fno_caret_diagnostics, CaretDefault))
 CmdArgs.push_back("-fno-caret-diagnostics");
 
-  // -fdiagnostics-fixit-info is default, only pass non-default.
-  if (!Args.hasFlag(options::OPT_fdiagnostics_fixit_info,
-options::OPT_fno_diagnostics_fixit_info, true))
-CmdArgs.push_back("-fno-diagnostics-fixit-info");
-
-  // Enable -fdiagnostics-show-option by default.
-  if (!Args.hasFlag(options::OPT_fdiagnostics_show_option,
-options::OPT_fno_diagnostics_show_option, true))
-CmdArgs.push_back("-fno-diagnostics-show-option");
+  Args.addOptOutFlag(CmdArgs, options::OPT_fdiagnostics_fixit_info,
+ options::OPT_fno_diagnostics_fixit_info);
+  Args.addOptOutFlag(CmdArgs, options::OPT_fdiagnostics_show_option,
+ options::OPT_fno_diagnostics_show_option);
 
   if (const Arg *A =
   Args.getLastArg(options::OPT_fdiagnostics_show_category_EQ)) {
@@ -3924,9 +3917,8 @@
 CmdArgs.push_back(A->getValue());
   }
 
-  if (Args.hasFlag(options::OPT_fdiagnostics_show_hotness,
-   options::OPT_fno_diagnostics_show_hotness, false))
-CmdArgs.push_back("-fdiagnostics-show-hotness");
+  Args.addOptInFlag(CmdArgs, options::OPT_fdiagnostics_show_hotness,
+options::OPT_fno_diagnostics_show_hotness);
 
   if (const Arg *A =
   Args.getLastArg(options::OPT_fdiagnostics_hotness_threshold_EQ)) {
@@ -5066,17 +5058,12 @@
 A->claim();
   }
 
-  if (!Args.hasFlag(options::OPT_fjump_tables, options::OPT_fno_jump_tables,
-true))
-CmdArgs.push_back("-fno-jump-tables");
-
-  if (Args.hasFlag(options::OPT_fprofile_sample_accurate,
-   options::OPT_fno_profile_sam

[PATCH] D123471: [CUDA] Create offloading entries when using the new driver

2022-04-10 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, ronlieb, yaxunl, tra.
Herald added subscribers: carlosgalvezp, dexonsmith.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a project: clang.

The changes made in D123460  generalized the 
code generation for OpenMP's
offloading entries. We can use the same scheme to register globals for
CUDA code. This patch adds the code generation to create these
offloading entries when compiling using the new offloading driver mode.
The offloading entries are simple structs that contain the information
necessary to register the global. The struct used is as follows:

  Type struct __tgt_offload_entry {
void*addr;  // Pointer to the offload entry info.
// (function or global)
char*name;  // Name of the function or global.
size_t  size;   // Size of the entry info (0 if it a function).
int32_t flags;
int32_t reserved;
  };

Currently CUDA handles RDC code generation by deferring the registration
of globals in the current TU to a callback function containing the
modules ID. Later all the module IDs will be used to register all of the
globals at once. Rather than mimic this, offloading entries allow us to
mimic the way OpenMP registers globals. That is, we create a simple
global struct for each device global to be registered. These are placed
at a special section `cuda_offloading_entires`. Because this section is
a valid C-identifier, the linker will profide a `__start` and `__stop`
pointer that we can use to iterate and register all globals at runtime.

the registration requires a flag variable to indicate which registration
function to use. I have assigned the flags somewhat arbitrarily, but
these use the following values.

Kernel: 0
Variable: 0
Managed: 1
Surface: 2
Texture: 4

Depends on D120272 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123471

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCUDARuntime.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/offloading-entries.cu

Index: clang/test/CodeGenCUDA/offloading-entries.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/offloading-entries.cu
@@ -0,0 +1,33 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu \
+// RUN:   -foffload-new-driver -emit-llvm -o - -x cuda  %s | FileCheck \
+// RUN:   --check-prefix=HOST %s
+
+#include "Inputs/cuda.h"
+
+//.
+// HOST: @x = internal global i32 undef, align 4
+// HOST: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] c"_Z3foov\00"
+// HOST: @.omp_offloading.entry._Z3foov = weak constant %struct.__tgt_offload_entry { i8* bitcast (void ()* @_Z18__device_stub__foov to i8*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.omp_offloading.entry_name, i32 0, i32 0), i64 0, i32 0, i32 0 }, section "cuda_offloading_entries", align 1
+// HOST: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [8 x i8] c"_Z3barv\00"
+// HOST: @.omp_offloading.entry._Z3barv = weak constant %struct.__tgt_offload_entry { i8* bitcast (void ()* @_Z18__device_stub__barv to i8*), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.omp_offloading.entry_name.1, i32 0, i32 0), i64 0, i32 0, i32 0 }, section "cuda_offloading_entries", align 1
+// HOST: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [2 x i8] c"x\00"
+// HOST: @.omp_offloading.entry.x = weak constant %struct.__tgt_offload_entry { i8* bitcast (i32* @x to i8*), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.omp_offloading.entry_name.2, i32 0, i32 0), i64 4, i32 0, i32 0 }, section "cuda_offloading_entries", align 1
+//.
+// HOST-LABEL: @_Z18__device_stub__foov(
+// HOST-NEXT:  entry:
+// HOST-NEXT:[[TMP0:%.*]] = call i32 @cudaLaunch(i8* bitcast (void ()* @_Z18__device_stub__foov to i8*))
+// HOST-NEXT:br label [[SETUP_END:%.*]]
+// HOST:   setup.end:
+// HOST-NEXT:ret void
+//
+__global__ void foo() {}
+// HOST-LABEL: @_Z18__device_stub__barv(
+// HOST-NEXT:  entry:
+// HOST-NEXT:[[TMP0:%.*]] = call i32 @cudaLaunch(i8* bitcast (void ()* @_Z18__device_stub__barv to i8*))
+// HOST-NEXT:br label [[SETUP_END:%.*]]
+// HOST:   setup.end:
+// HOST-NEXT:ret void
+//
+__global__ void bar() {}
+__device__ int x = 1;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6083,6 +6083,10 @@
   CmdArgs.push_back("-fno-openmp-extensions");
   }
 
+  // Forward the n

[PATCH] D114003: LiteralSupport: Don't assert() on invalid input

2022-04-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge closed this revision.
nridge added a comment.
Herald added a project: All.

This has been committed in 
https://github.com/llvm/llvm-project/commit/5a6dac66db67225e2443f4e61dfe9d2f96780611.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114003/new/

https://reviews.llvm.org/D114003

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


[PATCH] D123405: [dllexport] odr-use constexpr default args for constructor closures

2022-04-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added subscribers: aaron.ballman, rjmccall, rsmith, xbolva00.
xbolva00 added a comment.

Please wait for some proper clang reviewer

@rsmith @aaron.ballman @rjmccall


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123405/new/

https://reviews.llvm.org/D123405

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


[PATCH] D123405: [dllexport] odr-use constexpr default args for constructor closures

2022-04-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

What makes me an improper clang reviewer?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123405/new/

https://reviews.llvm.org/D123405

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


[PATCH] D123405: [dllexport] odr-use constexpr default args for constructor closures

2022-04-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

No, I mean just second look.

I believe @erichkeane is working in this area as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123405/new/

https://reviews.llvm.org/D123405

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


[clang] 4ea1d43 - [CUDA][HIP] Externalize kernels in anonymous name space

2022-04-10 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2022-04-10T21:56:28-04:00
New Revision: 4ea1d435099f992cc16127619b0feb64e070630d

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

LOG: [CUDA][HIP] Externalize kernels in anonymous name space

kernels in anonymous name space needs to have unique name
to avoid duplicate symbols.

Fixes: https://github.com/llvm/llvm-project/issues/54560

Reviewed by: Artem Belevich

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

Added: 
clang/test/CodeGenCUDA/kernel-in-anon-ns.cu

Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index b00472e30d62e..490128abb2ef2 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3289,11 +3289,11 @@ OPT_LIST(V)
   /// Return a new OMPTraitInfo object owned by this context.
   OMPTraitInfo &getNewOMPTraitInfo();
 
-  /// Whether a C++ static variable may be externalized.
-  bool mayExternalizeStaticVar(const Decl *D) const;
+  /// Whether a C++ static variable or CUDA/HIP kernel may be externalized.
+  bool mayExternalize(const Decl *D) const;
 
-  /// Whether a C++ static variable should be externalized.
-  bool shouldExternalizeStaticVar(const Decl *D) const;
+  /// Whether a C++ static variable or CUDA/HIP kernel should be externalized.
+  bool shouldExternalize(const Decl *D) const;
 
   StringRef getCUIDHash() const;
 

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index eeaff7d0c1cf6..036f970897180 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -11328,7 +11328,7 @@ static GVALinkage adjustGVALinkageForAttributes(const 
ASTContext &Context,
 // name between the host and device compilation which is the same for the
 // same compilation unit whereas 
diff erent among 
diff erent compilation
 // units.
-if (Context.shouldExternalizeStaticVar(D))
+if (Context.shouldExternalize(D))
   return GVA_StrongExternal;
   }
   return L;
@@ -12277,7 +12277,7 @@ operator<<(const StreamingDiagnostic &DB,
   return DB << "a prior #pragma section";
 }
 
-bool ASTContext::mayExternalizeStaticVar(const Decl *D) const {
+bool ASTContext::mayExternalize(const Decl *D) const {
   bool IsStaticVar =
   isa(D) && cast(D)->getStorageClass() == SC_Static;
   bool IsExplicitDeviceVar = (D->hasAttr() &&
@@ -12285,14 +12285,16 @@ bool ASTContext::mayExternalizeStaticVar(const Decl 
*D) const {
  (D->hasAttr() &&
   !D->getAttr()->isImplicit());
   // CUDA/HIP: static managed variables need to be externalized since it is
-  // a declaration in IR, therefore cannot have internal linkage.
-  return IsStaticVar &&
- (D->hasAttr() || IsExplicitDeviceVar);
+  // a declaration in IR, therefore cannot have internal linkage. Kernels in
+  // anonymous name space needs to be externalized to avoid duplicate symbols.
+  return (IsStaticVar &&
+  (D->hasAttr() || IsExplicitDeviceVar)) ||
+ (D->hasAttr() && D->isInAnonymousNamespace());
 }
 
-bool ASTContext::shouldExternalizeStaticVar(const Decl *D) const {
-  return mayExternalizeStaticVar(D) &&
- (D->hasAttr() ||
+bool ASTContext::shouldExternalize(const Decl *D) const {
+  return mayExternalize(D) &&
+ (D->hasAttr() || D->hasAttr() ||
   CUDADeviceVarODRUsedByHost.count(cast(D)));
 }
 

diff  --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 187817d0e5059..4390228297d0e 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -281,13 +281,13 @@ std::string CGNVCUDARuntime::getDeviceSideName(const 
NamedDecl *ND) {
 DeviceSideName = std::string(ND->getIdentifier()->getName());
 
   // Make unique name for device side static file-scope variable for HIP.
-  if (CGM.getContext().shouldExternalizeStaticVar(ND) &&
+  if (CGM.getContext().shouldExternalize(ND) &&
   CGM.getLangOpts().GPURelocatableDeviceCode &&
   !CGM.getLangOpts().CUID.empty()) {
 SmallString<256> Buffer;
 llvm::raw_svector_ostream Out(Buffer);
 Out << DeviceSideName;
-CGM.printPostfixForExternalizedStaticVar(Out);
+CGM.printPostfixForExternalizedDecl(Out, ND);
 DeviceSideName = std::string(Out.str());
   }
   return DeviceSideName;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index da03235c5ec4e..4efcc8447d81b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1376,10 +1376,10 @@ static st

[PATCH] D123353: [CUDA][HIP] Externalize kernels in anonymous name space

2022-04-10 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG4ea1d435099f: [CUDA][HIP] Externalize kernels in anonymous 
name space (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D123353?vs=421392&id=421820#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123353/new/

https://reviews.llvm.org/D123353

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenCUDA/kernel-in-anon-ns.cu

Index: clang/test/CodeGenCUDA/kernel-in-anon-ns.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/kernel-in-anon-ns.cu
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -cuid=abc \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu -std=c++11 -fgpu-rdc \
+// RUN:   -emit-llvm -o - -x hip %s > %t.dev
+
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -cuid=abc \
+// RUN:   -aux-triple amdgcn-amd-amdhsa -std=c++11 -fgpu-rdc \
+// RUN:   -emit-llvm -o - -x hip %s > %t.host
+
+// RUN: cat %t.dev %t.host | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: define weak_odr {{.*}}void @[[KERN:_ZN12_GLOBAL__N_16kernelEv\.anon\.b04fd23c98500190]](
+// CHECK: @[[STR:.*]] = {{.*}} c"[[KERN]]\00"
+// CHECK: call i32 @__hipRegisterFunction({{.*}}@[[STR]]
+
+namespace {
+__global__ void kernel() {
+}
+}
+
+void test() {
+  kernel<<<1, 1>>>();
+}
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1457,9 +1457,10 @@
TBAAAccessInfo *TBAAInfo = nullptr);
   bool stopAutoInit();
 
-  /// Print the postfix for externalized static variable for single source
-  /// offloading languages CUDA and HIP.
-  void printPostfixForExternalizedStaticVar(llvm::raw_ostream &OS) const;
+  /// Print the postfix for externalized static variable or kernels for single
+  /// source offloading languages CUDA and HIP.
+  void printPostfixForExternalizedDecl(llvm::raw_ostream &OS,
+   const Decl *D) const;
 
 private:
   llvm::Constant *GetOrCreateLLVMFunction(
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1376,10 +1376,10 @@
 }
 
   // Make unique name for device side static file-scope variable for HIP.
-  if (CGM.getContext().shouldExternalizeStaticVar(ND) &&
+  if (CGM.getContext().shouldExternalize(ND) &&
   CGM.getLangOpts().GPURelocatableDeviceCode &&
   CGM.getLangOpts().CUDAIsDevice && !CGM.getLangOpts().CUID.empty())
-CGM.printPostfixForExternalizedStaticVar(Out);
+CGM.printPostfixForExternalizedDecl(Out, ND);
   return std::string(Out.str());
 }
 
@@ -1446,8 +1446,7 @@
   // static device variable depends on whether the variable is referenced by
   // a host or device host function. Therefore the mangled name cannot be
   // cached.
-  if (!LangOpts.CUDAIsDevice ||
-  !getContext().mayExternalizeStaticVar(GD.getDecl())) {
+  if (!LangOpts.CUDAIsDevice || !getContext().mayExternalize(GD.getDecl())) {
 auto FoundName = MangledDeclNames.find(CanonicalGD);
 if (FoundName != MangledDeclNames.end())
   return FoundName->second;
@@ -1467,7 +1466,7 @@
   // directly between host- and device-compilations, the host- and
   // device-mangling in host compilation could help catching certain ones.
   assert(!isa(ND) || !ND->hasAttr() ||
- getLangOpts().CUDAIsDevice ||
+ getContext().shouldExternalize(ND) || getLangOpts().CUDAIsDevice ||
  (getContext().getAuxTargetInfo() &&
   (getContext().getAuxTargetInfo()->getCXXABI() !=
getContext().getTargetInfo().getCXXABI())) ||
@@ -6772,7 +6771,8 @@
   return false;
 }
 
-void CodeGenModule::printPostfixForExternalizedStaticVar(
-llvm::raw_ostream &OS) const {
-  OS << "__static__" << getContext().getCUIDHash();
+void CodeGenModule::printPostfixForExternalizedDecl(llvm::raw_ostream &OS,
+const Decl *D) const {
+  OS << (isa(D) ? "__static__" : ".anon.")
+ << getContext().getCUIDHash();
 }
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -281,13 +281,13 @@
 DeviceSideName = std::string(ND->getIdentifier()->getName());
 
   // Make unique name for device side static file-scope variable for HIP.
-  if (CGM.getContext().shouldExternalizeStat

[PATCH] D123478: [clangd] Fix incorrect operator< impl for HighlightingToken

2022-04-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added reviewers: sammccall, kadircet.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: All.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123478

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp


Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -917,7 +917,7 @@
  std::tie(R.R, R.Kind, R.Modifiers);
 }
 bool operator<(const HighlightingToken &L, const HighlightingToken &R) {
-  return std::tie(L.R, L.Kind, R.Modifiers) <
+  return std::tie(L.R, L.Kind, L.Modifiers) <
  std::tie(R.R, R.Kind, R.Modifiers);
 }
 


Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -917,7 +917,7 @@
  std::tie(R.R, R.Kind, R.Modifiers);
 }
 bool operator<(const HighlightingToken &L, const HighlightingToken &R) {
-  return std::tie(L.R, L.Kind, R.Modifiers) <
+  return std::tie(L.R, L.Kind, L.Modifiers) <
  std::tie(R.R, R.Kind, R.Modifiers);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D123478: [clangd] Fix incorrect operator< impl for HighlightingToken

2022-04-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Not sure how to write a test for this, short of writing unit tests for the 
operator< itself. The consequence of this bug is that the sort/unique pass on 
the highlighting tokens is buggy, but as of 
https://github.com/clangd/clangd/issues/1057 `resolveConflict()` fixes up that 
kind of bugginess.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123478/new/

https://reviews.llvm.org/D123478

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


[clang] d16a631 - [AVR] Merge AVRRelaxMemOperations into AVRExpandPseudoInsts

2022-04-10 Thread Ben Shi via cfe-commits

Author: Patryk Wychowaniec
Date: 2022-04-11T02:42:13Z
New Revision: d16a631c124fdc27dd33037a826804ebf21dc582

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

LOG: [AVR] Merge AVRRelaxMemOperations into AVRExpandPseudoInsts

This commit contains a refactoring that merges AVRRelaxMemOperations
into AVRExpandPseudoInsts, so that we have a single place in code that
expands the STDWPtrQRr opcode.

Seizing the day, I've also fixed a couple of potential bugs with our
previous implementation (e.g. when the destination register was killed,
the previous implementation would try to .addDef() that killed
register, crashing LLVM in the process - that's fixed now, as proved by
the test).

Reviewed By: benshi001

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

Added: 


Modified: 
clang/docs/tools/clang-formatted-files.txt
llvm/lib/Target/AVR/AVR.h
llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
llvm/lib/Target/AVR/AVRTargetMachine.cpp
llvm/lib/Target/AVR/CMakeLists.txt
llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn

Removed: 
llvm/lib/Target/AVR/AVRRelaxMemOperations.cpp
llvm/test/CodeGen/AVR/relax-mem/STDWPtrQRr.mir



diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index e0ce9b1c29228..e344c8faa7da2 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -6398,7 +6398,6 @@ llvm/lib/Target/AVR/AVRMCInstLower.cpp
 llvm/lib/Target/AVR/AVRMCInstLower.h
 llvm/lib/Target/AVR/AVRRegisterInfo.cpp
 llvm/lib/Target/AVR/AVRRegisterInfo.h
-llvm/lib/Target/AVR/AVRRelaxMemOperations.cpp
 llvm/lib/Target/AVR/AVRSelectionDAGInfo.h
 llvm/lib/Target/AVR/AVRShiftExpand.cpp
 llvm/lib/Target/AVR/AVRSubtarget.cpp

diff  --git a/llvm/lib/Target/AVR/AVR.h b/llvm/lib/Target/AVR/AVR.h
index 532a57af25157..d29dc5f70e72e 100644
--- a/llvm/lib/Target/AVR/AVR.h
+++ b/llvm/lib/Target/AVR/AVR.h
@@ -29,12 +29,10 @@ FunctionPass *createAVRISelDag(AVRTargetMachine &TM,
CodeGenOpt::Level OptLevel);
 FunctionPass *createAVRExpandPseudoPass();
 FunctionPass *createAVRFrameAnalyzerPass();
-FunctionPass *createAVRRelaxMemPass();
 FunctionPass *createAVRBranchSelectionPass();
 
 void initializeAVRShiftExpandPass(PassRegistry &);
 void initializeAVRExpandPseudoPass(PassRegistry &);
-void initializeAVRRelaxMemPass(PassRegistry &);
 
 /// Contains the AVR backend.
 namespace AVR {

diff  --git a/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp 
b/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
index de93c863abd86..22f91f98a1644 100644
--- a/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
+++ b/llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
@@ -1157,32 +1157,51 @@ bool AVRExpandPseudo::expand(Block 
&MBB, BlockIt MBBI) {
 template <>
 bool AVRExpandPseudo::expand(Block &MBB, BlockIt MBBI) {
   MachineInstr &MI = *MBBI;
-  Register SrcLoReg, SrcHiReg;
+
   Register DstReg = MI.getOperand(0).getReg();
-  Register SrcReg = MI.getOperand(2).getReg();
-  unsigned Imm = MI.getOperand(1).getImm();
   bool DstIsKill = MI.getOperand(0).isKill();
+  unsigned Imm = MI.getOperand(1).getImm();
+  Register SrcReg = MI.getOperand(2).getReg();
   bool SrcIsKill = MI.getOperand(2).isKill();
-  unsigned OpLo = AVR::STDPtrQRr;
-  unsigned OpHi = AVR::STDPtrQRr;
-  TRI->splitReg(SrcReg, SrcLoReg, SrcHiReg);
 
-  // Since we add 1 to the Imm value for the high byte below, and 63 is the
-  // highest Imm value allowed for the instruction, 62 is the limit here.
-  assert(Imm <= 62 && "Offset is out of range");
+  // STD's maximum displacement is 63, so larger stores have to be split into a
+  // set of operations
+  if (Imm >= 63) {
+if (!DstIsKill) {
+  buildMI(MBB, MBBI, AVR::PUSHWRr).addReg(DstReg);
+}
 
-  auto MIBLO = buildMI(MBB, MBBI, OpLo)
-   .addReg(DstReg)
-   .addImm(Imm)
-   .addReg(SrcLoReg, getKillRegState(SrcIsKill));
+buildMI(MBB, MBBI, AVR::SUBIWRdK)
+.addReg(DstReg, RegState::Define)
+.addReg(DstReg, RegState::Kill)
+.addImm(-Imm);
 
-  auto MIBHI = buildMI(MBB, MBBI, OpHi)
-   .addReg(DstReg, getKillRegState(DstIsKill))
-   .addImm(Imm + 1)
-   .addReg(SrcHiReg, getKillRegState(SrcIsKill));
+buildMI(MBB, MBBI, AVR::STWPtrRr)
+.addReg(DstReg, RegState::Kill)
+.addReg(SrcReg, getKillRegState(SrcIsKill));
 
-  MIBLO.setMemRefs(MI.memoperands());
-  MIBHI.setMemRefs(MI.memoperands());
+if (!DstIsKill) {
+  buildMI(MBB, MBBI, AVR::POPWRd).addDef(DstReg, RegState::Define);
+}
+  } else {
+unsigned OpLo = AVR::STDPtrQRr;
+unsigned OpHi = AVR::STDPtrQRr;
+Regi

[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-04-10 Thread Ben Shi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd16a631c124f: [AVR] Merge AVRRelaxMemOperations into 
AVRExpandPseudoInsts (authored by Patryk27, committed by benshi001).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122533/new/

https://reviews.llvm.org/D122533

Files:
  clang/docs/tools/clang-formatted-files.txt
  llvm/lib/Target/AVR/AVR.h
  llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
  llvm/lib/Target/AVR/AVRRelaxMemOperations.cpp
  llvm/lib/Target/AVR/AVRTargetMachine.cpp
  llvm/lib/Target/AVR/CMakeLists.txt
  llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
  llvm/test/CodeGen/AVR/relax-mem/STDWPtrQRr.mir
  llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn
@@ -37,7 +37,6 @@
 "AVRInstrInfo.cpp",
 "AVRMCInstLower.cpp",
 "AVRRegisterInfo.cpp",
-"AVRRelaxMemOperations.cpp",
 "AVRShiftExpand.cpp",
 "AVRSubtarget.cpp",
 "AVRTargetMachine.cpp",
Index: llvm/test/CodeGen/AVR/relax-mem/STDWPtrQRr.mir
===
--- llvm/test/CodeGen/AVR/relax-mem/STDWPtrQRr.mir
+++ /dev/null
@@ -1,31 +0,0 @@
-# RUN: llc -O0 -run-pass=avr-relax-mem %s -o - | FileCheck %s
-
 |
-  target triple = "avr--"
-  define void @test() {
-  entry:
-ret void
-  }
-...
-

-name:test
-body: |
-  bb.0.entry:
-
-; CHECK-LABEL: test
-
-; We shouldn't expand things which already have 6-bit imms.
-; CHECK: STDWPtrQRr $r29r28, 63, $r1r0
-STDWPtrQRr $r29r28, 63, $r1r0
-
-; We shouldn't expand things which already have 6-bit imms.
-; CHECK-NEXT: STDWPtrQRr $r29r28, 0, $r1r0
-STDWPtrQRr $r29r28, 0, $r1r0
-
-; CHECK-NEXT: PUSHWRr $r29r28, implicit-def $sp, implicit $sp
-; CHECK-NEXT: $r29r28 = SBCIWRdK $r29r28, -64, implicit-def $sreg, implicit $sreg
-; CHECK-NEXT: STWPtrRr $r29r28, $r1r0
-; CHECK-NEXT: $r29r28 = POPWRd implicit-def $sp, implicit $sp
-STDWPtrQRr $r29r28, 64, $r1r0
-...
Index: llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
===
--- llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
+++ llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
@@ -1,4 +1,4 @@
-# RUN: llc -O0 -run-pass=avr-expand-pseudo  %s -o - | FileCheck %s
+# RUN: llc -O0 -run-pass=avr-expand-pseudo -verify-machineinstrs %s -o - | FileCheck %s
 
 --- |
   target triple = "avr--"
@@ -15,8 +15,52 @@
 
 ; CHECK-LABEL: test
 
-; CHECK:  STDPtrQRr $r29r28, 10, $r0
-; CHECK-NEXT: STDPtrQRr $r29r28, 11, $r1
+; Small displacement (<63):
+; CHECK:  STDPtrQRr $r29r28, 3, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 4, $r1
+STDWPtrQRr $r29r28, 3, $r1r0
 
-STDWPtrQRr $r29r28, 10, $r1r0
+; Small displacement where the destination register is killed:
+; CHECK:  STDPtrQRr $r29r28, 3, $r0
+; CHECK-NEXT: STDPtrQRr killed $r29r28, 4, $r1
+STDWPtrQRr killed $r29r28, 3, $r1r0
+
+; Small displacement where the source register is killed:
+; CHECK:  STDPtrQRr $r29r28, 3, killed $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 4, killed $r1
+STDWPtrQRr $r29r28, 3, killed $r1r0
+
+; Small displacement, near the limit (=62):
+; CHECK:  STDPtrQRr $r29r28, 62, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 63, $r1
+STDWPtrQRr $r29r28, 62, $r1r0
+
+; Large displacement (>=63):
+; CHECK: PUSHRr $r28, implicit-def $sp, implicit $sp
+; CHECK-NEXT: PUSHRr $r29, implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = SUBIRdK killed $r28, 193, implicit-def $sreg
+; CHECK-NEXT: $r29 = SBCIRdK killed $r29, 255, implicit-def $sreg, implicit killed $sreg
+; CHECK-NEXT: STPtrRr $r29r28, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 1, $r1
+; CHECK-NEXT: $r29 = POPRd implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = POPRd implicit-def $sp, implicit $sp
+STDWPtrQRr $r29r28, 63, $r1r0
+
+; Large displacement where the destination register is killed:
+; CHECK: $r28 = SUBIRdK killed $r28, 193, implicit-def $sreg
+; CHECK-NEXT: $r29 = SBCIRdK killed $r29, 255, implicit-def $sreg, implicit killed $sreg
+; CHECK-NEXT: STPtrRr $r29r28, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 1, $r1
+STDWPtrQRr killed $r29r28, 63, $r1r0
+
+; Large displacement where the source register is killed:
+; CHECK: PUSHRr $r28, implicit-def $sp, implicit $sp
+; CHECK-NEXT: PUSHRr $r29, implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = SUBIRdK killed $r28, 193, implicit-def $sreg
+; CHECK-NEXT: $r29 = SBCIRdK killed $r29, 255, implicit-def $sreg, implicit killed $sreg
+; CHECK-NEXT: STPtrRr $r29r28, killed $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 1, killed $r1
+; CHE

[PATCH] D123479: [clang-tidy] Support parenthesized literals in modernize-macro-to-enum

2022-04-10 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a reviewer: aaron.ballman.
LegalizeAdulthood added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
LegalizeAdulthood requested review of this revision.

When scanning a macro expansion to examine it as a candidate enum,
first strip off arbitrary matching parentheses from the outside in,
then examine what remains to see if it is Lit, +Lit, -Lit or ~Lit.
If not, reject it as a possible enum candidate.

Fixes #54843


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123479

Files:
  clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/modernize-macro-to-enum.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize-macro-to-enum.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-macro-to-enum.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-macro-to-enum.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-macro-to-enum.cpp
@@ -137,6 +137,41 @@
 // CHECK-FIXES-NEXT: SUFFIX5 = +1ULL
 // CHECK-FIXES-NEXT: };
 
+// A limited form of constant expression is recognized: a parenthesized
+// literal or a parenthesized literal with the unary operators +, - or ~.
+#define PAREN1 (-1)
+#define PAREN2 (1)
+#define PAREN3 (+1)
+#define PAREN4 (~1)
+// CHECK-MESSAGES: :[[@LINE-4]]:1: warning: replace macro with enum
+// CHECK-MESSAGES: :[[@LINE-5]]:9: warning: macro 'PAREN1' defines an integral constant; prefer an enum instead
+// CHECK-MESSAGES: :[[@LINE-5]]:9: warning: macro 'PAREN2' defines an integral constant; prefer an enum instead
+// CHECK-MESSAGES: :[[@LINE-5]]:9: warning: macro 'PAREN3' defines an integral constant; prefer an enum instead
+// CHECK-MESSAGES: :[[@LINE-5]]:9: warning: macro 'PAREN4' defines an integral constant; prefer an enum instead
+// CHECK-FIXES: enum {
+// CHECK-FIXES-NEXT: PAREN1 = (-1),
+// CHECK-FIXES-NEXT: PAREN2 = (1),
+// CHECK-FIXES-NEXT: PAREN3 = (+1),
+// CHECK-FIXES-NEXT: PAREN4 = (~1)
+// CHECK-FIXES-NEXT: };
+
+// More complicated parenthesized expressions are excluded.
+// Expansions that are not surrounded by parentheses are excluded.
+// Nested matching parentheses are stripped.
+#define COMPLEX_PAREN1 (x+1)
+#define COMPLEX_PAREN2 (x+1
+#define COMPLEX_PAREN3 (())
+#define COMPLEX_PAREN4 ()
+#define COMPLEX_PAREN5 (+1)
+#define COMPLEX_PAREN6 ((+1))
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: replace macro with enum
+// CHECK-MESSAGES: :[[@LINE-3]]:9: warning: macro 'COMPLEX_PAREN5' defines an integral constant; prefer an enum instead
+// CHECK-MESSAGES: :[[@LINE-3]]:9: warning: macro 'COMPLEX_PAREN6' defines an integral constant; prefer an enum instead
+// CHECK-FIXES: enum {
+// CHECK-FIXES-NEXT: COMPLEX_PAREN5 = (+1),
+// CHECK-FIXES-NEXT: COMPLEX_PAREN6 = ((+1))
+// CHECK-FIXES-NEXT: };
+
 // Macros appearing in conditional expressions can't be replaced
 // by enums.
 #define USE_FOO 1
Index: clang-tools-extra/docs/clang-tidy/checks/modernize-macro-to-enum.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-macro-to-enum.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-macro-to-enum.rst
@@ -14,10 +14,13 @@
 
 Potential macros for replacement must meet the following constraints:
 
-- Macros must expand only to integral literal tokens.  The unary operators
-  plus, minus and tilde are recognized to allow for positive, negative
-  and bitwise negated integers.  More complicated integral constant
-  expressions are not currently recognized by this check.
+- Macros must expand only to integral literal tokens or simple expressions
+  of literal tokens.  The unary operators plus, minus and tilde are
+  recognized to allow for positive, negative and bitwise negated integers.
+  The above expressions may also be surrounded by a single matching pair of
+  parentheses.
+  More complicated integral constant expressions are not currently recognized
+  by this check.
 - Macros must be defined on sequential source file lines, or with
   only comment lines in between macro definitions.
 - Macros must all be defined in the same source file.
@@ -43,6 +46,7 @@
   #define GREEN 0x00FF00
   #define BLUE  0xFF
 
+  #define TM_NONE (-1) // No method selected.
   #define TM_ONE 1// Use tailored method one.
   #define TM_TWO 2// Use tailored method two.  Method two
   // is preferable to method one.
@@ -59,6 +63,7 @@
   };
 
   enum {
+  TM_NONE = (-1), // No method selected.
   TM_ONE = 1,// Use tailored method one.
   TM_TWO = 2,// Use tailored method two.  Method two
   // is preferable to method one.
Index: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
===
--- clang-tools-extra/clan

[PATCH] D116280: [clang] adds unary type trait checks as compiler built-ins

2022-04-10 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 421836.
cjdb edited the summary of this revision.
cjdb added a comment.
Herald added a project: All.

adds `__is_copy_constructible`, `__is_copy_assignable`, 
`__is_move_constructible` (WIP), and `__is_move_assignable` (incomplete)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116280/new/

https://reviews.llvm.org/D116280

Files:
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/type-traits.cpp

Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -345,11 +345,19 @@
 }
 
 typedef Enum EnumType;
+typedef EnumClass EnumClassType;
 
 void is_enum()
 {
   { int arr[T(__is_enum(Enum))]; }
   { int arr[T(__is_enum(EnumType))]; }
+  { int arr[T(__is_enum(SignedEnum))]; }
+  { int arr[T(__is_enum(UnsignedEnum))]; }
+
+  { int arr[T(__is_enum(EnumClass))]; }
+  { int arr[T(__is_enum(EnumClassType))]; }
+  { int arr[T(__is_enum(SignedEnumClass))]; }
+  { int arr[T(__is_enum(UnsignedEnumClass))]; }
 
   { int arr[F(__is_enum(int))]; }
   { int arr[F(__is_enum(Union))]; }
@@ -363,6 +371,30 @@
   { int arr[F(__is_enum(HasAnonymousUnion))]; }
 }
 
+void is_scoped_enum()
+{
+  { int arr[F(__is_scoped_enum(Enum))]; }
+  { int arr[F(__is_scoped_enum(EnumType))]; }
+  { int arr[F(__is_scoped_enum(SignedEnum))]; }
+  { int arr[F(__is_scoped_enum(UnsignedEnum))]; }
+
+  { int arr[T(__is_scoped_enum(EnumClass))]; }
+  { int arr[T(__is_scoped_enum(EnumClassType))]; }
+  { int arr[T(__is_scoped_enum(SignedEnumClass))]; }
+  { int arr[T(__is_scoped_enum(UnsignedEnumClass))]; }
+
+  { int arr[F(__is_scoped_enum(int))]; }
+  { int arr[F(__is_scoped_enum(Union))]; }
+  { int arr[F(__is_scoped_enum(Int))]; }
+  { int arr[F(__is_scoped_enum(IntAr))]; }
+  { int arr[F(__is_scoped_enum(UnionAr))]; }
+  { int arr[F(__is_scoped_enum(Derives))]; }
+  { int arr[F(__is_scoped_enum(ClassType))]; }
+  { int arr[F(__is_scoped_enum(cvoid))]; }
+  { int arr[F(__is_scoped_enum(IntArNB))]; }
+  { int arr[F(__is_scoped_enum(HasAnonymousUnion))]; }
+}
+
 struct FinalClass final {
 };
 
@@ -702,6 +734,66 @@
   int t31[F(__is_array(cvoid*))];
 }
 
+void is_bounded_array()
+{
+  int t01[T(__is_bounded_array(IntAr))];
+  int t02[F(__is_bounded_array(IntArNB))];
+  int t03[T(__is_bounded_array(UnionAr))];
+
+  int t10[F(__is_bounded_array(void))];
+  int t11[F(__is_bounded_array(cvoid))];
+  int t12[F(__is_bounded_array(float))];
+  int t13[F(__is_bounded_array(double))];
+  int t14[F(__is_bounded_array(long double))];
+  int t15[F(__is_bounded_array(bool))];
+  int t16[F(__is_bounded_array(char))];
+  int t17[F(__is_bounded_array(signed char))];
+  int t18[F(__is_bounded_array(unsigned char))];
+  int t19[F(__is_bounded_array(wchar_t))];
+  int t20[F(__is_bounded_array(short))];
+  int t21[F(__is_bounded_array(unsigned short))];
+  int t22[F(__is_bounded_array(int))];
+  int t23[F(__is_bounded_array(unsigned int))];
+  int t24[F(__is_bounded_array(long))];
+  int t25[F(__is_bounded_array(unsigned long))];
+  int t26[F(__is_bounded_array(Union))];
+  int t27[F(__is_bounded_array(Derives))];
+  int t28[F(__is_bounded_array(ClassType))];
+  int t29[F(__is_bounded_array(Enum))];
+  int t30[F(__is_bounded_array(void*))];
+  int t31[F(__is_bounded_array(cvoid*))];
+}
+
+void is_unbounded_array()
+{
+  int t01[F(__is_unbounded_array(IntAr))];
+  int t02[T(__is_unbounded_array(IntArNB))];
+  int t03[F(__is_unbounded_array(UnionAr))];
+
+  int t10[F(__is_unbounded_array(void))];
+  int t11[F(__is_unbounded_array(cvoid))];
+  int t12[F(__is_unbounded_array(float))];
+  int t13[F(__is_unbounded_array(double))];
+  int t14[F(__is_unbounded_array(long double))];
+  int t15[F(__is_unbounded_array(bool))];
+  int t16[F(__is_unbounded_array(char))];
+  int t17[F(__is_unbounded_array(signed char))];
+  int t18[F(__is_unbounded_array(unsigned char))];
+  int t19[F(__is_unbounded_array(wchar_t))];
+  int t20[F(__is_unbounded_array(short))];
+  int t21[F(__is_unbounded_array(unsigned short))];
+  int t22[F(__is_unbounded_array(int))];
+  int t23[F(__is_unbounded_array(unsigned int))];
+  int t24[F(__is_unbounded_array(long))];
+  int t25[F(__is_unbounded_array(unsigned long))];
+  int t26[F(__is_unbounded_array(Union))];
+  int t27[F(__is_unbounded_array(Derives))];
+  int t28[F(__is_unbounded_array(ClassType))];
+  int t29[F(__is_unbounded_array(Enum))];
+  int t30[F(__is_unbounded_array(void*))];
+  int t31[F(__is_unbounded_array(cvoid*))];
+}
+
 template  void tmpl_func(T&) {}
 
 template  struct type_wrapper {
@@ -934,6 +1026,43 @@
   int t34[F(__is_pointer(void (StructWithMembers::*) ()))];
 }
 
+void is_null_pointer()
+{
+  StructWithMembers x;
+
+  int t00[T(__is_nullptr(dec