[clang] 4667821 - [NFC] Typo fix in ARCMTActions.h

2022-09-18 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2022-09-18T12:34:24+05:30
New Revision: 46678211512238159199a5857e9f9d774016060c

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

LOG: [NFC] Typo fix in ARCMTActions.h

Added: 


Modified: 
clang/include/clang/ARCMigrate/ARCMTActions.h
clang/lib/ARCMigrate/ARCMTActions.cpp

Removed: 




diff  --git a/clang/include/clang/ARCMigrate/ARCMTActions.h 
b/clang/include/clang/ARCMigrate/ARCMTActions.h
index 641c259b38677..714f4b33db446 100644
--- a/clang/include/clang/ARCMigrate/ARCMTActions.h
+++ b/clang/include/clang/ARCMigrate/ARCMTActions.h
@@ -43,7 +43,7 @@ class MigrateSourceAction : public ASTFrontendAction {
 class MigrateAction : public WrapperFrontendAction {
   std::string MigrateDir;
   std::string PlistOut;
-  bool EmitPremigrationARCErros;
+  bool EmitPremigrationARCErrors;
 protected:
   bool BeginInvocation(CompilerInstance &CI) override;
 

diff  --git a/clang/lib/ARCMigrate/ARCMTActions.cpp 
b/clang/lib/ARCMigrate/ARCMTActions.cpp
index d72f53806e37b..0805d90d25aa6 100644
--- a/clang/lib/ARCMigrate/ARCMTActions.cpp
+++ b/clang/lib/ARCMigrate/ARCMTActions.cpp
@@ -39,7 +39,7 @@ ModifyAction::ModifyAction(std::unique_ptr 
WrappedAction)
 bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
   if (arcmt::migrateWithTemporaryFiles(
   CI.getInvocation(), getCurrentInput(), 
CI.getPCHContainerOperations(),
-  CI.getDiagnostics().getClient(), MigrateDir, 
EmitPremigrationARCErros,
+  CI.getDiagnostics().getClient(), MigrateDir, 
EmitPremigrationARCErrors,
   PlistOut))
 return false; // errors, stop the action.
 
@@ -53,7 +53,7 @@ MigrateAction::MigrateAction(std::unique_ptr 
WrappedAction,
  StringRef plistOut,
  bool emitPremigrationARCErrors)
   : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
-PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
+PlistOut(plistOut), EmitPremigrationARCErrors(emitPremigrationARCErrors) {
   if (MigrateDir.empty())
 MigrateDir = "."; // user current directory if none is given.
 }



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


[PATCH] D133329: [Driver] Add --gcc-install-dir=

2022-09-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

At a first glance, it works. I'm now building GCC:11 here to test it against 
two real installations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133329

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


[PATCH] D134105: [Docs] Add a link that refers to C++ standard modules in Clang modules doc

2022-09-18 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/docs/Modules.rst:107-108
+
+.. note::
+  This pages mainly talks about the Clang modules extension and describes some 
general module properties and semantics. Please refer to 
`StandardCPlusPlusModules `_ if you're looking 
for standard C++ modules.
+

minor suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134105

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


[PATCH] D133737: [HLSL] [clang] Add vector version of abs for HLSL

2022-09-18 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133737

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 461051.
ychen added a comment.

- address comments
- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr6xx.cpp

Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1083,13 +1083,23 @@
   // Also see dr1395.
 
   namespace temp_func_order_example2 {
-template  struct A {};
-template  void f(U, A *p = 0); // expected-note {{candidate}}
-template  int &f(U, A *p = 0); // expected-note {{candidate}}
+template  struct A1 {}; // expected-error 0-1{{C++11}}
+template  struct A2 {}; // expected-error 0-1{{C++11}}
+template  void e1(A1) = delete; // expected-error 0-2{{C++11}}
+template  void e1(A1);
+template  void e2(A2) = delete; // expected-error 0-2{{C++11}}
+template  void e2(A2);
+template  void f(U, A1 *p = 0) = delete; // expected-note {{candidate}} expected-error 0-1{{C++11}}
+template  int &f(U, A1 *p = 0); // expected-note {{candidate}}
 template  void g(T, T = T()); // expected-note {{candidate}}
 template  void g(T, U...); // expected-note {{candidate}} expected-error 0-1{{C++11}}
 void h() {
-  int &r = f(42, (A *)0);
+  A1 a;
+  int &r = f(42, &a);
+  A1 b1;
+  e1(b1);
+  A2 b2;
+  e2(b2);
   f(42); // expected-error {{ambiguous}}
   g(42); // expected-error {{ambiguous}}
 }
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5196,6 +5196,38 @@
   return FT1;
   }
 
+  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
+  bool ClangABICompat15 =
+  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
+  if (!ClangABICompat15) {
+for (int i = 0, e = std::min(NumParams1, NumParams2); i < e; ++i) {
+  QualType T1 = FD1->getParamDecl(i)->getType().getCanonicalType();
+  QualType T2 = FD2->getParamDecl(i)->getType().getCanonicalType();
+  auto *TST1 = dyn_cast(T1);
+  auto *TST2 = dyn_cast(T2);
+  if (!TST1 || !TST2)
+continue;
+  const TemplateArgument &TA1 = TST1->template_arguments().back();
+  if (TA1.getKind() == TemplateArgument::Pack) {
+assert(TST1->getNumArgs() == TST2->getNumArgs());
+const TemplateArgument &TA2 = TST2->template_arguments().back();
+assert(TA2.getKind() == TemplateArgument::Pack);
+unsigned PackSize1 = TA1.pack_size();
+unsigned PackSize2 = TA2.pack_size();
+bool IsPackExpansion1 =
+PackSize1 && TA1.pack_elements().back().isPackExpansion();
+bool IsPackExpansion2 =
+PackSize2 && TA2.pack_elements().back().isPackExpansion();
+if (PackSize1 != PackSize2 && IsPackExpansion1 != IsPackExpansion2) {
+  if (PackSize1 > PackSize2 && IsPackExpansion1)
+return FT2;
+  if (PackSize1 < PackSize2 && IsPackExpansion2)
+return FT1;
+}
+  }
+}
+  }
+
   return JudgeByConstraints();
 }
 
@@ -5431,30 +5463,28 @@
 return nullptr;
 
   if (Better1 && Better2) {
+// Consider this a fix for CWG1432. Similar to the fix for CWG1395.
 bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
 LangOptions::ClangABI::Ver15;
 if (!ClangABICompat15) {
-  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
-  auto *TST1 = T1->castAs();
-  auto *TST2 = T2->castAs();
-  if (TST1->getNumArgs()) {
-const TemplateArgument &TA1 = TST1->template_arguments().back();
-if (TA1.getKind() == TemplateArgument::Pack) {
-  assert(TST1->getNumArgs() == TST2->getNumArgs());
-  const TemplateArgument &TA2 = TST2->template_arguments().back();
-  assert(TA2.getKind() == TemplateArgument::Pack);
-  unsigned PackSize1 = TA1.pack_size();
-  unsigned PackSize2 = TA2.pack_size();
-  bool IsPackExpansion1 =
-  PackSize1 && TA1.pack_elements().back().isPackExpansion();
-  bool IsPackExpansion2 =
-  PackSize2 && TA2.pack_elements().back().isPackExpansion();
-  if (PackSize1 != PackSize2 && IsPackExpansion1 != IsPackExpansion2) {
-if (PackSize1 > PackSize2 && IsPackExpansion1)
-  return GetP2()(P1, P2);
-if (PackSize1 < PackSize2 && IsPackExpansion2)
-  return P1;
-  }
+  auto *TST1 = cast(T1);
+  auto *TST2 = cast(T2);
+  const TemplateArgument &TA1 = TST1->template_arguments().back();
+  if (TA1.getKind() == TemplateArgument::Pack) {
+assert(TST1->getNumArgs() == TST

[PATCH] D134127: [ARM] Check target feature support for __builtin_arm_crc*

2022-09-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: DavidSpickett, dmgreen, john.brawn.
Herald added subscribers: StephenFan, kristof.beyls.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`__builtin_arm_crc*` requires the target feature crc which is available on armv8
and above. Calling the fuctions for armv7 leads to a SelectionDAG crash.

  % clang -c --target=armv7-unknown-linux-gnueabi -c a.c
  fatal error: error in backend: Cannot select: intrinsic %llvm.arm.crc32b
  PLEASE submit a bug report to ...

Add `TARGET_BUILTIN` and define required features for these builtins to
report an error in Sema. The problem is quite widespread.
I will add `TARGET_BUILTIN` for more builtins later.

Fix https://github.com/llvm/llvm-project/issues/57802


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134127

Files:
  clang/include/clang/Basic/BuiltinsARM.def
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/CodeGen/arm-crc32.c


Index: clang/test/CodeGen/arm-crc32.c
===
--- clang/test/CodeGen/arm-crc32.c
+++ clang/test/CodeGen/arm-crc32.c
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -triple armv8-none-linux-gnueabi \
+// RUN: %clang_cc1 -triple armv8-none-linux-gnueabi -target-feature +crc \
 // RUN:  -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck 
%s
+// RUN: %clang_cc1 -verify -emit-llvm -triple armv7-none-linux-gnueabi %s
 
 int crc32b(int a, char b)
 {
+// expected-error@+1 {{'__builtin_arm_crc32b' needs target feature crc}}
 return __builtin_arm_crc32b(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
 // CHECK: call i32 @llvm.arm.crc32b(i32 %a, i32 [[T0]])
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -979,6 +979,8 @@
   {#ID, TYPE, ATTRS, nullptr, LANG, nullptr},
 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER)
\
   {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   
\
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
 #define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) 
\
   {#ID, TYPE, ATTRS, HEADER, LANGS, FEATURE},
 #include "clang/Basic/BuiltinsARM.def"
Index: clang/include/clang/Basic/BuiltinsARM.def
===
--- clang/include/clang/Basic/BuiltinsARM.def
+++ clang/include/clang/Basic/BuiltinsARM.def
@@ -17,6 +17,10 @@
 #   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#  define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 #if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN)
 #  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) 
BUILTIN(ID, TYPE, ATTRS)
 #endif
@@ -157,14 +161,14 @@
 BUILTIN(__builtin_arm_mrrc2, "LLUiUIiUIiUIi", "")
 
 // CRC32
-BUILTIN(__builtin_arm_crc32b, "UiUiUc", "nc")
-BUILTIN(__builtin_arm_crc32cb, "UiUiUc", "nc")
-BUILTIN(__builtin_arm_crc32h, "UiUiUs", "nc")
-BUILTIN(__builtin_arm_crc32ch, "UiUiUs", "nc")
-BUILTIN(__builtin_arm_crc32w, "UiUiUi", "nc")
-BUILTIN(__builtin_arm_crc32cw, "UiUiUi", "nc")
-BUILTIN(__builtin_arm_crc32d, "UiUiLLUi", "nc")
-BUILTIN(__builtin_arm_crc32cd, "UiUiLLUi", "nc")
+TARGET_BUILTIN(__builtin_arm_crc32b, "UiUiUc", "nc", "crc")
+TARGET_BUILTIN(__builtin_arm_crc32cb, "UiUiUc", "nc", "crc")
+TARGET_BUILTIN(__builtin_arm_crc32h, "UiUiUs", "nc", "crc")
+TARGET_BUILTIN(__builtin_arm_crc32ch, "UiUiUs", "nc", "crc")
+TARGET_BUILTIN(__builtin_arm_crc32w, "UiUiUi", "nc", "crc")
+TARGET_BUILTIN(__builtin_arm_crc32cw, "UiUiUi", "nc", "crc")
+TARGET_BUILTIN(__builtin_arm_crc32d, "UiUiLLUi", "nc", "crc")
+TARGET_BUILTIN(__builtin_arm_crc32cd, "UiUiLLUi", "nc", "crc")
 
 // ARMv8-M Security Extensions a.k.a CMSE
 BUILTIN(__builtin_arm_cmse_TT, "Uiv*", "n")


Index: clang/test/CodeGen/arm-crc32.c
===
--- clang/test/CodeGen/arm-crc32.c
+++ clang/test/CodeGen/arm-crc32.c
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -triple armv8-none-linux-gnueabi \
+// RUN: %clang_cc1 -triple armv8-none-linux-gnueabi -target-feature +crc \
 // RUN:  -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -verify -emit-llvm -triple armv7-none-linux-gnueabi %s
 
 int crc32b(int a, char b)
 {
+// expected-error@+1 {{'__builtin_arm_crc32b' needs target feature crc}}
 return __builtin_arm_crc32b(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
 // CHECK: call i32 @llvm.arm.crc32b(i32 %a, i32 [[T0]])
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/

[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5455-5456
 if (!ClangABICompat15) {
-  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
   auto *TST1 = T1->castAs();
   auto *TST2 = T2->castAs();
+  const TemplateArgument &TA1 = TST1->template_arguments().back();

ychen wrote:
> mizvekov wrote:
> > This is a bug, T1 and T2 are not in general canonical types for this 
> > function, and this castAs can pick up an alias template, and these should 
> > never participate in deduction.
> > 
> > (Also, can you please add a test for that?)
> > 
> > You should not need to keep sugar here, everything being tested below is 
> > present on the canonical type, so this is simple to solve, as suggested.
> I see. I'll add a test.
Looking more closely, `T1`/`T2` is mostly returned by 
`ASTContext::getTemplateSpecializationType` and for injected template 
specialization, always unqualified   
https://github.com/llvm/llvm-project/blob/52dce8900c46d5842a021619537ede598983dfde/clang/include/clang/AST/Type.h#L5431-L5432
 , it does not seem possible to have aliase template involved? I could've 
missed something though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D109621: [clang] [Driver] Fall back to default.cfg when calling clang w/o prefix

2022-09-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 461054.
mgorny added a comment.

Fix documentation formatting. While at it, fix a doc mistake that referenced 
`x86_64-cl.cfg` instead of the correct `x86_64-clang-cl.cfg`.


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

https://reviews.llvm.org/D109621

Files:
  clang/docs/UsersManual.rst
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/config-file3.c

Index: clang/test/Driver/config-file3.c
===
--- clang/test/Driver/config-file3.c
+++ clang/test/Driver/config-file3.c
@@ -21,6 +21,10 @@
 // RUN: ln -s %clang %t/testdmode/qqq-clang-g++
 // RUN: echo "-Wundefined-func-template" > %t/testdmode/qqq-clang-g++.cfg
 // RUN: echo "-Werror" > %t/testdmode/qqq.cfg
+// RUN: ln -s %clang %t/testdmode/clang-g++
+// RUN: ln -s %clang %t/testdmode/clang
+// RUN: : > %t/testdmode/default-clang.cfg
+// RUN: : > %t/testdmode/default.cfg
 // RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix FULL-NAME
 //
 // FULL-NAME: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
@@ -41,6 +45,16 @@
 //
 // CHECK-EXPLICIT: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg
 
+//--- Invoking clang falls back to default-clang.cfg.
+// RUN: %t/testdmode/clang --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix DEFAULT-CLANG
+//
+// DEFAULT-CLANG: Configuration file: {{.*}}/testdmode/default-clang.cfg
+
+//--- Invoking clang-g++ falls back to default.cfg.
+// RUN: %t/testdmode/clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix DEFAULT
+//
+// DEFAULT: Configuration file: {{.*}}/testdmode/default.cfg
+
 //--- --no-default-config disables config search.
 //
 // RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%t/testdmode --no-default-config -c -### %s 2>&1 | FileCheck %s -check-prefix NO-DEFAULT-CONFIG
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1024,18 +1024,21 @@
 }
   }
 
-  if (!(CLOptions && CLOptions->hasArg(options::OPT_no_default_config))) {
+  if (CfgFileName.empty()) {
+if (CLOptions && CLOptions->hasArg(options::OPT_no_default_config))
+  return false;
+
 // If config file is not specified explicitly, try to deduce configuration
 // from executable name. For instance, an executable 'armv7l-clang' will
-// search for config file 'armv7l-clang.cfg'.
-if (CfgFileName.empty() && !ClangNameParts.TargetPrefix.empty())
+// search for config file 'armv7l-clang.cfg'. If we are called without
+// a specific prefix, use e.g. 'default-clang.cfg' instead.
+if (!ClangNameParts.TargetPrefix.empty())
   CfgFileName =
   ClangNameParts.TargetPrefix + '-' + ClangNameParts.ModeSuffix;
+else
+  CfgFileName = "default-" + ClangNameParts.ModeSuffix;
   }
 
-  if (CfgFileName.empty())
-return false;
-
   // Determine architecture part of the file name, if it is present.
   StringRef CfgFileArch = CfgFileName;
   size_t ArchPrefixLen = CfgFileArch.find('-');
@@ -1093,9 +1096,9 @@
 return readConfigFile(CfgFilePath);
 
   // Finally try removing driver mode part: 'x86_64-clang.cfg' -> 'x86_64.cfg'.
-  if (!ClangNameParts.ModeSuffix.empty() &&
-  !ClangNameParts.TargetPrefix.empty()) {
-CfgFileName.assign(ClangNameParts.TargetPrefix);
+  if (!FileSpecifiedExplicitly && !ClangNameParts.ModeSuffix.empty()) {
+CfgFileName.resize(CfgFileName.size() - ClangNameParts.ModeSuffix.size() -
+   5);
 CfgFileName.append(".cfg");
 if (searchForFile(CfgFilePath, CfgFileSearchDirs, CfgFileName, getVFS()))
   return readConfigFile(CfgFilePath);
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -883,7 +883,7 @@
 example, to collect options required to tune compilation for particular
 target, such as -L, -I, -l, --sysroot, codegen options, etc.
 
-The command line option `--config` can be used to specify configuration
+The command line option ``--config`` can be used to specify configuration
 file in a Clang invocation. For example:
 
 ::
@@ -906,17 +906,19 @@
 
 If no explicit configuration file is specified, Clang searches for a default
 configuration file following the rules described in the next paragraphs.
-To disable this behavior, `--no-default-config` flag can be used.
+To disable this behavior, ``--no-default-config`` flag can be used.
 
 Another way to specify a configuration file is to encode it in executable name.
-For example, if the Clang executable is named `armv7l-clang` (it may be a
-symbolic link to `clang`), then Clang will search for file `armv7l

[PATCH] D133329: [Driver] Add --gcc-install-dir=

2022-09-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

Ok, this works fine for me (though I haven't run the tests yet). If D109621 
 and this one lands, I think the old Gentoo 
logic can be removed. We'll still have to update `gcc-config` to keep updating 
the config files but I'm pretty sure we can do that in time for 16.0.0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133329

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


[clang] 7629621 - [Modules] Don't judge if we're compiling a module unit by LangOpts::CurrentModule.empty()

2022-09-18 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-09-18T16:43:30+08:00
New Revision: 762962174e3adab1a0d744fe2636d4d9fb373c53

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

LOG: [Modules] Don't judge if we're compiling a module unit by 
LangOpts::CurrentModule.empty()

Closing https://github.com/llvm/llvm-project/issues/57778.

Previously it judge if we're compiling a module unit by
LangOpts::CurrentModule.empty(). But it is not true since we can specify
the module name by `-fmodule-name` option for arbitrary module unit.
Then this patch adjuest the judgement properly.

Added: 
clang/test/SemaCXX/PR57778.cpp

Modified: 
clang/include/clang/Basic/LangOptions.h
clang/lib/Parse/ParseAST.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index dd2a7920a5f1..9facfb0beba2 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -113,7 +113,7 @@ class LangOptions : public LangOptionsBase {
 /// Compiling a module header unit.
 CMK_HeaderUnit,
 
-/// Compiling a C++ modules TS module interface unit.
+/// Compiling a C++ modules interface unit.
 CMK_ModuleInterface,
   };
 
@@ -495,11 +495,16 @@ class LangOptions : public LangOptionsBase {
   void set##Name(Type Value) { Name = static_cast(Value); }
 #include "clang/Basic/LangOptions.def"
 
-  /// Are we compiling a module interface (.cppm or module map)?
+  /// Are we compiling a module?
   bool isCompilingModule() const {
 return getCompilingModule() != CMK_None;
   }
 
+  /// Are we compiling a standard c++ module interface?
+  bool isCompilingModuleInterface() const {
+return getCompilingModule() == CMK_ModuleInterface;
+  }
+
   /// Do we need to track the owning module for a local declaration?
   bool trackLocalOwningModule() const {
 return isCompilingModule() || ModulesLocalVisibility;

diff  --git a/clang/lib/Parse/ParseAST.cpp b/clang/lib/Parse/ParseAST.cpp
index 5fca029a4266..2e6d7eea4677 100644
--- a/clang/lib/Parse/ParseAST.cpp
+++ b/clang/lib/Parse/ParseAST.cpp
@@ -177,7 +177,7 @@ void clang::ParseAST(Sema &S, bool PrintStats, bool 
SkipFunctionBodies) {
 
   // At this point, we should know if we are building a non-header C++20 
module.
   if (S.getLangOpts().CPlusPlusModules && !S.getLangOpts().IsHeaderFile &&
-  !S.getLangOpts().CurrentModule.empty()) {
+  S.getLangOpts().isCompilingModuleInterface()) {
 // If we are building the module from source, then the top level module
 // will be here.
 Module *CodegenModule = S.getCurrentModule();

diff  --git a/clang/test/SemaCXX/PR57778.cpp b/clang/test/SemaCXX/PR57778.cpp
new file mode 100644
index ..260dd7c97976
--- /dev/null
+++ b/clang/test/SemaCXX/PR57778.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -std=c++20 -fmodule-name=test -fsyntax-only %s -verify
+// expected-no-diagnostics
+
+// Ensure that we won't crash if we specified `-fmodule-name` in `c++20`
+// for a non module unit.
+int a;



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


[PATCH] D134128: Resubmit an implemention for constrained template template parameters [P0857R0 Part B]

2022-09-18 Thread Liming Liu via Phabricator via cfe-commits
lime created this revision.
lime added reviewers: aaron.ballman, h-vetinari, erichkeane, cor3ntin, 
tahonermann.
lime added a project: clang.
Herald added a project: All.
lime requested review of this revision.
Herald added a subscriber: cfe-commits.

This function had been submitted by @erichkeane long time ago 
. However, he has not been 

 working on it. So I submit a new patch with some minor differences.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134128

Files:
  clang/lib/Parse/ParseTemplate.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
  clang/test/SemaTemplate/concepts.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -912,11 +912,7 @@
 

 https://wg21.link/p0857r0";>P0857R0
-
-  Partial
-Constraining template template parameters is not yet supported.
-  
-
+Clang 16
   

 https://wg21.link/p1084r2";>P1084R2
Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -59,11 +59,10 @@
 x.operator()(); // expected-error {{no matching member function}}
   }
 
-  // FIXME: This is valid under P0857R0.
   template concept C = true;
-  template requires C typename U> struct X {}; // expected-error {{requires 'class'}} expected-error 0+{{}}
+  template requires C typename U> struct X {};
   template requires C struct Y {};
-  X xy; // expected-error {{no template named 'X'}}
+  X xy;
 }
 
 namespace PR50306 {
Index: clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
===
--- clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
+++ clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp
@@ -1,17 +1,17 @@
 // RUN:  %clang_cc1 -std=c++2a -frelaxed-template-template-args -verify %s
 
 template concept C = T::f();
-// expected-note@-1{{similar constraint}}
+// expected-note@-1 2{{similar constraint}}
 template concept D = C && T::g();
 template concept F = T::f();
-// expected-note@-1{{similar constraint expressions not considered equivalent}}
+// expected-note@-1 2{{similar constraint expressions not considered equivalent}}
 template class P> struct S1 { }; // expected-note 2{{'P' declared here}}
 
 template struct X { };
 
-template struct Y { }; // expected-note{{'Y' declared here}}
+template struct Y { }; // expected-note 2{{'Y' declared here}}
 template struct Z { };
-template struct W { }; // expected-note{{'W' declared here}}
+template struct W { }; // expected-note 2{{'W' declared here}}
 
 S1 s11;
 S1 s12; // expected-error{{template template argument 'Y' is more constrained than template template parameter 'P'}}
@@ -32,3 +32,19 @@
 
 using s31 = S3;
 using s32 = S3;
+
+template requires C class P> struct S4 { }; // expected-note 2{{'P' declared here}}
+
+S4 s41;
+S4 s42; // expected-error{{template template argument 'Y' is more constrained than template template parameter 'P'}}
+S4 s43;
+S4 s44; // expected-error{{template template argument 'W' is more constrained than template template parameter 'P'}}
+
+template requires C typename U> struct S5 {
+  template static U V;
+};
+
+struct Nothing {};
+
+// FIXME: Wait the standard to clarify the intent.
+template<> template<> Z S5::V;
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -874,27 +874,39 @@
 /// template parameters.
 ///
 ///   type-parameter:[C++ temp.param]
-/// 'template' '<' template-parameter-list '>' type-parameter-key
-///  ...[opt] identifier[opt]
-/// 'template' '<' template-parameter-list '>' type-parameter-key
-///  identifier[opt] = id-expression
+/// template-head type-parameter-key ...[opt] identifier[opt]
+/// template-head type-parameter-key identifier[opt] = id-expression
 ///   type-parameter-key:
 /// 'class'
 /// 'typename'   [C++1z]
-NamedDecl *
-Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
+///   template-head: [C++2a]
+/// 'template' '<' template-parameter-list '>'
+/// requires-clause[opt]
+NamedDecl *Parser::ParseTemplateTemplateParameter(unsigned Depth,
+  unsigned Position) {
   assert(Tok.is(tok::kw_template) && "Expected 'template' keyword");
 
   // Handle the template <...> part.
   SourceLocation TemplateLoc = ConsumeToken();
   SmallVector TemplateParams

[PATCH] D134128: Resubmit an implemention for constrained template template parameters [P0857R0 Part B]

2022-09-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Thanks for working on this.
I'll be honest though, I still have absolutely no understanding what the use 
cases or intents of this features are. I think we were waiting for core to 
clarify and I'm not sure they did.
This does seem to implement the wording though...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134128

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


[clang] 490de4a - [Clang][NFC] update obsolete check predicate

2022-09-18 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2022-09-18T18:00:36+08:00
New Revision: 490de4ab47c8e22f7a48d9da785390e23df9e25f

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

LOG: [Clang][NFC] update obsolete check predicate

Added: 


Modified: 
clang/test/CodeGen/microsoft-call-conv.c

Removed: 




diff  --git a/clang/test/CodeGen/microsoft-call-conv.c 
b/clang/test/CodeGen/microsoft-call-conv.c
index 763d443f8e86e..517435d017ac5 100644
--- a/clang/test/CodeGen/microsoft-call-conv.c
+++ b/clang/test/CodeGen/microsoft-call-conv.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple i386-pc-linux -Wno-strict-prototypes -emit-llvm < 
%s | FileCheck %s
 // RUN: %clang_cc1 -triple i386-pc-linux -Wno-strict-prototypes -emit-llvm 
-mrtd < %s | FileCheck %s
-// RUN: %clang_cc1 -triple i386-pc-linux -Wno-strict-prototypes -emit-llvm 
-fms-compatibility < %s
+// RUN: %clang_cc1 -triple i386-pc-linux -Wno-strict-prototypes -emit-llvm 
-fms-compatibility < %s | FileCheck %s
 
 void __fastcall f1(void);
 void __stdcall f2(void);
@@ -61,8 +61,8 @@ void f8(void) {
 
 // PR12535
 void __fastcall f9(int x, int y) {};
-// WIN: define{{.*}} x86_fastcallcc void @f9({{.*}})
+// CHECK: define{{.*}} x86_fastcallcc void @f9({{.*}})
 void __fastcall f10(int x, ...) {};
-// WIN: define{{.*}} void @f10({{.*}})
+// CHECK: define{{.*}} void @f10({{.*}})
 void __stdcall f11(int x, ...) {};
-// WIN: define{{.*}} void @f11({{.*}})
+// CHECK: define{{.*}} void @f11({{.*}})



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


[PATCH] D133329: [Driver] Add --gcc-install-dir=

2022-09-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny requested changes to this revision.
mgorny added a comment.
This revision now requires changes to proceed.

Unfortunately, we have some test failures after this change, e.g.:

  FAIL: Clang :: CodeGenHLSL/basic_types.hlsl (6525 of 15795)
   TEST 'Clang :: CodeGenHLSL/basic_types.hlsl' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
/var/tmp/portage/sys-devel/clang-16.0.0_pre20220915/work/x/y/clang-abi_x86_32.x86/bin/clang
 --driver-mode=dxc  -Tlib_6_7 -fcgl -Fo - 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20220915/work/clang/test/CodeGenHLSL/basic_types.hlsl
 | /usr/lib/llvm/16/bin/FileCheck 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20220915/work/clang/test/CodeGenHLSL/basic_types.hlsl
  --
  Exit Code: 2
  
  Command Output (stderr):
  --
  + : 'RUN: at line 1'
  + /usr/lib/llvm/16/bin/FileCheck 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20220915/work/clang/test/CodeGenHLSL/basic_types.hlsl
  + 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20220915/work/x/y/clang-abi_x86_32.x86/bin/clang
 --driver-mode=dxc -Tlib_6_7 -fcgl -Fo - 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20220915/work/clang/test/CodeGenHLSL/basic_types.hlsl
  clang-16: error: unknown argument: 
'--gcc-install-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1'
  FileCheck error: '' is empty.
  FileCheck command line:  /usr/lib/llvm/16/bin/FileCheck 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20220915/work/clang/test/CodeGenHLSL/basic_types.hlsl
  
  --
  
  

Unfortunately, within the current config framework, it's impossible to set 
options per `--driver-mode=...` (and i'm not convinced we really want to pursue 
keeping a bunch of config files to figure out which driver modes use GCC and 
which do not). Would it be feasible to add this option (and other similar 
options — e.g. `-rtlib`, `-unwindlib`, `-stdlib`) to all drivers, and make them 
emit `argument unused` warnings like `-fuse-ld`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133329

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


[clang] 303526e - [Docs] Add a link that refers to C++ standard modules in Clang modules doc

2022-09-18 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-09-18T18:31:49+08:00
New Revision: 303526ef3aa211c1930be2885deae15eeeda3b18

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

LOG: [Docs] Add a link that refers to C++ standard modules in Clang modules doc

Currently there're two pages that both talk about "Modules" in clang, but
they're different. The one that describes C++ standard modules explicitly
spells out the difference but the other one which targeting Clang modules
doesn't.

This patch adds a link that refers to the C++ standard modules
one in Clang modules doc, as you usually got the later page when
googling. I believe this will make newcomers less confused.

Signed-off-by: Jun Zhang 

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

Added: 


Modified: 
clang/docs/Modules.rst

Removed: 




diff  --git a/clang/docs/Modules.rst b/clang/docs/Modules.rst
index d85a60e881837..825d8722c4d53 100644
--- a/clang/docs/Modules.rst
+++ b/clang/docs/Modules.rst
@@ -102,6 +102,11 @@ Using Modules
 =
 To enable modules, pass the command-line flag ``-fmodules``. This will make 
any modules-enabled software libraries available as modules as well as 
introducing any modules-specific syntax. Additional `command-line parameters`_ 
are described in a separate section later.
 
+Standard C++ Modules
+
+.. note::
+  Modules are adopted into C++20 Standard. And its semantic and command line 
interface are very 
diff erent from the Clang C++ modules. See `StandardCPlusPlusModules 
`_ for details.
+
 Objective-C Import declaration
 --
 Objective-C provides syntax for importing a module via an *@import 
declaration*, which imports the named module:



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


[PATCH] D134105: [Docs] Add a link that refers to C++ standard modules in Clang modules doc

2022-09-18 Thread Jun Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG303526ef3aa2: [Docs] Add a link that refers to C++ standard 
modules in Clang modules doc (authored by junaire).

Changed prior to commit:
  https://reviews.llvm.org/D134105?vs=461040&id=461058#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134105

Files:
  clang/docs/Modules.rst


Index: clang/docs/Modules.rst
===
--- clang/docs/Modules.rst
+++ clang/docs/Modules.rst
@@ -102,6 +102,11 @@
 =
 To enable modules, pass the command-line flag ``-fmodules``. This will make 
any modules-enabled software libraries available as modules as well as 
introducing any modules-specific syntax. Additional `command-line parameters`_ 
are described in a separate section later.
 
+Standard C++ Modules
+
+.. note::
+  Modules are adopted into C++20 Standard. And its semantic and command line 
interface are very different from the Clang C++ modules. See 
`StandardCPlusPlusModules `_ for details.
+
 Objective-C Import declaration
 --
 Objective-C provides syntax for importing a module via an *@import 
declaration*, which imports the named module:


Index: clang/docs/Modules.rst
===
--- clang/docs/Modules.rst
+++ clang/docs/Modules.rst
@@ -102,6 +102,11 @@
 =
 To enable modules, pass the command-line flag ``-fmodules``. This will make any modules-enabled software libraries available as modules as well as introducing any modules-specific syntax. Additional `command-line parameters`_ are described in a separate section later.
 
+Standard C++ Modules
+
+.. note::
+  Modules are adopted into C++20 Standard. And its semantic and command line interface are very different from the Clang C++ modules. See `StandardCPlusPlusModules `_ for details.
+
 Objective-C Import declaration
 --
 Objective-C provides syntax for importing a module via an *@import declaration*, which imports the named module:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134130: [clangd] Add doxygen parsing for Hover [1/3]

2022-09-18 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
tom-anders added reviewers: nridge, sammccall, kadircet.
tom-anders published this revision for review.
Herald added subscribers: cfe-commits, llvm-commits, MaskRay, ilya-biryukov.
Herald added projects: LLVM, clang-tools-extra.

1/3: Add SymbolDocumentation class to parse Doxygen comments

This commit just adds and tests the a new class for doxygen parsing.
Consumption in Hover and Index will be added in a follow-up commit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134130

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/SymbolDocumentation.cpp
  clang-tools-extra/clangd/SymbolDocumentation.h
  clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
  clang-tools-extra/clangd/unittests/SymbolDocumentationMatchers.h
  llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clangd/BUILD.gn
@@ -117,6 +117,7 @@
 "SemanticHighlighting.cpp",
 "SemanticSelection.cpp",
 "SourceCode.cpp",
+"SymbolDocumentation.cpp"
 "TUScheduler.cpp",
 "TidyProvider.cpp",
 "URI.cpp",
Index: clang-tools-extra/clangd/unittests/SymbolDocumentationMatchers.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/SymbolDocumentationMatchers.h
@@ -0,0 +1,51 @@
+//===-- SymbolDocumentationMatchers.h ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// GMock matchers for the SymbolDocumentation class
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SYMBOLDOCUMENTATION_MATCHERS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SYMBOLDOCUMENTATION_MATCHERS_H
+#include "SymbolDocumentation.h"
+#include "gmock/gmock.h"
+
+namespace clang {
+namespace clangd {
+
+template 
+testing::Matcher>
+matchesDoc(const SymbolDocumentation &Expected) {
+  using namespace ::testing;
+
+  std::vector>> ParamMatchers;
+  for (const auto &P : Expected.Parameters)
+ParamMatchers.push_back(
+AllOf(Field("Name", &ParameterDocumentation::Name, P.Name),
+  Field("Description", &ParameterDocumentation::Description,
+P.Description)));
+
+  return AllOf(
+  Field("Brief", &SymbolDocumentation::Brief, Expected.Brief),
+  Field("Returns", &SymbolDocumentation::Returns, Expected.Returns),
+  Field("Notes", &SymbolDocumentation::Notes,
+ElementsAreArray(Expected.Notes)),
+  Field("Warnings", &SymbolDocumentation::Warnings,
+ElementsAreArray(Expected.Warnings)),
+  Field("Parameters", &SymbolDocumentation::Parameters,
+ElementsAreArray(ParamMatchers)),
+  Field("Description", &SymbolDocumentation::Description,
+Expected.Description),
+  Field("CommentText", &SymbolDocumentation::CommentText,
+Expected.CommentText));
+}
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "CodeCompletionStrings.h"
+#include "SymbolDocumentationMatchers.h"
 #include "TestTU.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "gmock/gmock.h"
@@ -65,6 +66,90 @@
 getDeclComment(AST.getASTContext(), findDecl(AST, "X")));
 }
 
+TEST_F(CompletionStringTest, DoxygenParsing) {
+  struct {
+const char *const Code;
+const std::function ExpectedBuilder;
+  } Cases[] = {
+  {R"cpp(
+// Hello world
+void foo();
+)cpp",
+   [](SymbolDocumentationOwned &Doc) { Doc.Description = "Hello world"; }},
+  {R"cpp(
+/*! 
+ * \brief brief
+ * \details details
+ */
+void foo();
+)cpp",
+   [](SymbolDocumentationOwned &Doc) {
+ Doc.Brief = "brief";
+ Doc.Description = "\\details details";
+   }},
+  {R"cpp(
+/** 
+ * @brief brief
+ * @details details
+ * @see somewhere else
+ */
+void foo();
+)cpp",
+   [](SymbolDocumentationOwned &Doc) {
+ Doc.Brief = "brief";
+ Doc.Description = "@details detail

[PATCH] D133329: [Driver] Add --gcc-install-dir=

2022-09-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Hmm, apparently this could be achieved by making it a "CoreOption".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133329

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


[PATCH] D134131: [clangd] Use doxygen parsing for Hover [2/3]

2022-09-18 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
tom-anders added reviewers: nridge, sammccall, kadircet.
tom-anders published this revision for review.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Only for AST-based results, storage in the index is implemented in [3/3]


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134131

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeCompletionStrings.cpp
  clang-tools-extra/clangd/CodeCompletionStrings.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -10,6 +10,7 @@
 #include "Annotations.h"
 #include "Config.h"
 #include "Hover.h"
+#include "SymbolDocumentationMatchers.h"
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
@@ -43,7 +44,8 @@
  HI.NamespaceScope = "";
  HI.Name = "foo";
  HI.Kind = index::SymbolKind::Function;
- HI.Documentation = "Best foo ever.";
+ HI.Documentation =
+ SymbolDocumentationOwned::descriptionOnly("Best foo ever.");
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
  HI.Type = "void ()";
@@ -60,7 +62,8 @@
  HI.NamespaceScope = "ns1::ns2::";
  HI.Name = "foo";
  HI.Kind = index::SymbolKind::Function;
- HI.Documentation = "Best foo ever.";
+ HI.Documentation =
+ SymbolDocumentationOwned::descriptionOnly("Best foo ever.");
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
  HI.Type = "void ()";
@@ -148,8 +151,8 @@
[](HoverInfo &HI) {
  HI.Name = "__func__";
  HI.Kind = index::SymbolKind::Variable;
- HI.Documentation =
- "Name of the current function (predefined variable)";
+ HI.Documentation = SymbolDocumentationOwned::descriptionOnly(
+ "Name of the current function (predefined variable)");
  HI.Value = "\"foo\"";
  HI.Type = "const char[4]";
}},
@@ -162,8 +165,8 @@
[](HoverInfo &HI) {
  HI.Name = "__func__";
  HI.Kind = index::SymbolKind::Variable;
- HI.Documentation =
- "Name of the current function (predefined variable)";
+ HI.Documentation = SymbolDocumentationOwned::descriptionOnly(
+ "Name of the current function (predefined variable)");
  HI.Type = "const char[]";
}},
   // Anon namespace and local scope.
@@ -741,7 +744,8 @@
  HI.Definition = "template <> class Foo";
  // FIXME: Maybe force instantiation to make use of real template
  // pattern.
- HI.Documentation = "comment from primary";
+ HI.Documentation =
+ SymbolDocumentationOwned::descriptionOnly("comment from primary");
}},
   {// Template Type Parameter
R"cpp(
@@ -793,7 +797,8 @@
  HI.NamespaceScope = "";
  HI.Definition = "float y()";
  HI.LocalScope = "X::";
- HI.Documentation = "Trivial accessor for `Y`.";
+ HI.Documentation = SymbolDocumentationOwned::descriptionOnly(
+ "Trivial accessor for `Y`.");
  HI.Type = "float ()";
  HI.ReturnType = "float";
  HI.Parameters.emplace();
@@ -809,7 +814,8 @@
  HI.NamespaceScope = "";
  HI.Definition = "void setY(float v)";
  HI.LocalScope = "X::";
- HI.Documentation = "Trivial setter for `Y`.";
+ HI.Documentation = SymbolDocumentationOwned::descriptionOnly(
+ "Trivial setter for `Y`.");
  HI.Type = "void (float)";
  HI.ReturnType = "void";
  HI.Parameters.emplace();
@@ -828,7 +834,8 @@
  HI.NamespaceScope = "";
  HI.Definition = "X &setY(float v)";
  HI.LocalScope = "X::";
- HI.Documentation = "Trivial setter for `Y`.";
+ HI.Documentation = SymbolDocumentationOwned::descriptionOnly(
+ "Trivial setter for `Y`.");
  HI.Type = "X &(float)";
  HI.ReturnType = "X &";
  HI.Parameters.emplace();
@@ -848,7 +855,8 @@
  HI.NamespaceScope = "";
  HI.Definition = "void setY(float v)";
  HI.LocalScope = "X::";
- HI.Documentation = "Trivial setter for `Y`.";
+ HI.Documentation = SymbolDocumentationOwned::descriptionOnly(
+ "Trivial setter for `Y`.");
  HI.Type = "void (float)";
  HI.ReturnType = "void";
  HI.Parameters.empl

[PATCH] D134132: [clangd] Add doxygen parsing for Hover [3/3]

2022-09-18 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders created this revision.
Herald added subscribers: wenlei, kadircet, arphaman.
Herald added a project: All.
tom-anders added reviewers: nridge, sammccall, kadircet.
tom-anders published this revision for review.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This stores SymbolDocumentation in the index and uses it in Hover.
CodeCompletion and SignatureHelp still use the unparsed comment for now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134132

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/Symbol.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -50,7 +50,7 @@
   return (arg.Name + arg.Signature).str() == Label;
 }
 MATCHER_P(returnType, D, "") { return arg.ReturnType == D; }
-MATCHER_P(doc, D, "") { return arg.Documentation == D; }
+MATCHER_P(doc, D, "") { return arg.Documentation.CommentText == D; }
 MATCHER_P(snippet, S, "") {
   return (arg.Name + arg.CompletionSnippetSuffix).str() == S;
 }
Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -8,6 +8,7 @@
 
 #include "Headers.h"
 #include "RIFF.h"
+#include "SymbolDocumentationMatchers.h"
 #include "index/Serialization.h"
 #include "support/Logger.h"
 #include "clang/Tooling/CompilationDatabase.h"
@@ -48,7 +49,22 @@
 Line: 1
 Column: 1
 Flags:129
-Documentation:'Foo doc'
+Documentation:
+  Brief:   'Foo brief'
+  Returns: 'Foo returns'
+  Description: 'Foo description'
+  Notes:
+- 'Foo note 1'
+- 'Foo note 2'
+  Warnings:
+- 'Foo warning 1'
+- 'Foo warning 2'
+  Parameters:
+- Name: 'param1'
+  Description: 'Foo param 1'
+- Name: 'param2'
+  Description: 'Foo param 2'
+  CommentText: 'Full text would be here'
 ReturnType:'int'
 IncludeHeaders:
   - Header:'include1'
@@ -141,7 +157,20 @@
 
   EXPECT_THAT(Sym1, qName("clang::Foo1"));
   EXPECT_EQ(Sym1.Signature, "");
-  EXPECT_EQ(Sym1.Documentation, "Foo doc");
+
+  SymbolDocumentationRef ExpectedDocumentation;
+  ExpectedDocumentation.Brief = "Foo brief";
+  ExpectedDocumentation.Returns = "Foo returns";
+  ExpectedDocumentation.Description = "Foo description";
+  ExpectedDocumentation.Notes = {"Foo note 1", "Foo note 2"};
+  ExpectedDocumentation.Warnings = {"Foo warning 1", "Foo warning 2"};
+  ExpectedDocumentation.Parameters = {
+  {"param1", "Foo param 1"},
+  {"param2", "Foo param 2"},
+  };
+  ExpectedDocumentation.CommentText = "Full text would be here";
+  EXPECT_THAT(Sym1.Documentation, matchesDoc(ExpectedDocumentation));
+
   EXPECT_EQ(Sym1.ReturnType, "int");
   EXPECT_EQ(StringRef(Sym1.CanonicalDeclaration.FileURI), "file:///path/foo.h");
   EXPECT_EQ(Sym1.Origin, SymbolOrigin::Static);
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "Annotations.h"
+#include "SymbolDocumentationMatchers.h"
 #include "SyncAPI.h"
 #include "TestIndex.h"
 #include "TestTU.h"
@@ -391,7 +392,7 @@
   R.References = 2;
   L.Signature = "()";   // present in left only
   R.CompletionSnippetSuffix = "{$1:0}"; // present in right only
-  R.Documentation = "--doc--";
+  R.Documentation = SymbolDocumentationRef::descriptionOnly("--doc--");
   L.Origin = SymbolOrigin::Preamble;
   R.Origin = SymbolOrigin::Static;
   R.Type = "expectedType";
@@ -402,7 +403,8 @@
   EXPECT_EQ(M.References, 3u);
   EXPECT_EQ(M.Signature, "()");
   EXPECT_EQ(M.CompletionSnippetSuffix, "{$1:0}");
-  EXPECT_EQ(M.Documentation, "--doc--");
+  EXPECT_THAT(M.Documentation,
+  matchesDoc(SymbolDocumentationRef::descriptionOnly("--doc--")));
   EXPECT_EQ(M.Type

[PATCH] D131853: [clangd] Add doxygen parsing for Hover

2022-09-18 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders abandoned this revision.
tom-anders added a comment.

Split up into 3 smaller patches: https://reviews.llvm.org/D134130, 
https://reviews.llvm.org/D134131 and https://reviews.llvm.org/D134132


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131853

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


[PATCH] D134112: [clang] Update ReleaseNotes about a crash fix (Issue 53628)

2022-09-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134112

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


[PATCH] D133436: Ground work for cuda-related checks in clang-tidy

2022-09-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stddef.h:12
+
+using size_t = long long unsigned;
+

barcisz wrote:
> njames93 wrote:
> > If this is all the file is used for, and it's only used for this one test 
> > file, can probably remove this header and inline the definition.
> > I also feel this definition may be fragile on certain platforms.
> I wanted to add it in a separate header for future proofness; as for the 
> definition, I cannot really use uint64_t here since I cannot include the real 
> stddef.h
`using size_t = decltype(sizeof(0));` is a better way to spell this, and I'd 
probably inline it rather than add a new header file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133436

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


[PATCH] D134128: Resubmit an implemention for constrained template template parameters [P0857R0 Part B]

2022-09-18 Thread Liming Liu via Phabricator via cfe-commits
lime added a comment.

In D134128#3798127 , @cor3ntin wrote:

> Thanks for working on this.
> I'll be honest though, I still have absolutely no understanding what the use 
> cases or intents of this features are. I think we were waiting for core to 
> clarify and I'm not sure they did.
> This does seem to implement the wording though...

Perhaps, the intents of this feature are a little confusing, so I add `S5` in 
the file `p3-2a.cpp`. If it was necessary to check the constains on the 
template template parameter, we could expect an error there.

But one intent might be a mend of the tailing syntax about constains, as a 
template parameter like `template  typename` is already accepted by Clang.




Comment at: clang/lib/Parse/ParseTemplate.cpp:882
 /// 'typename'   [C++1z]
-NamedDecl *
-Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
+///   template-head: [C++2a]
+/// 'template' '<' template-parameter-list '>'

This is copied from `Parser::ParseTemplateDeclarationOrSpecialization`.



Comment at: clang/lib/Parse/ParseTemplate.cpp:909
+  }
+}
   }

It is fine to skip the check for the language option of C++20. The parser will 
emit an error here and complain the lack of `class` or `typename`, if the 
option is not provided.



Comment at: clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp:36
+
+template requires C class P> struct S4 { }; // 
expected-note 2{{'P' declared here}}
+

Test whether Clang behaves the same here as it is on `S1`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134128

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


[clang] 2f8a4ac - [Clang][NFC] update predicate and reduce redundant check

2022-09-18 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2022-09-18T21:56:31+08:00
New Revision: 2f8a4acf1ad7790a82619932b198b7b7d07cd027

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

LOG: [Clang][NFC] update predicate and reduce redundant check

Added: 


Modified: 
clang/test/CodeGen/regcall.c
clang/test/CodeGen/vectorcall.c

Removed: 




diff  --git a/clang/test/CodeGen/regcall.c b/clang/test/CodeGen/regcall.c
index 55cebcb1a0d0..a20671f606f4 100644
--- a/clang/test/CodeGen/regcall.c
+++ b/clang/test/CodeGen/regcall.c
@@ -1,120 +1,96 @@
-// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -ffreestanding 
-triple=i386-pc-win32   | FileCheck %s --check-prefix=Win32
-// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -ffreestanding 
-triple=x86_64-pc-win32 | FileCheck %s --check-prefix=Win64
-// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -ffreestanding 
-triple=i386-pc-linux-gnu   | FileCheck %s --check-prefix=Lin32
-// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -ffreestanding 
-triple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=Lin64
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -ffreestanding 
-triple=i386-pc-win32   | FileCheck %s --check-prefixes=X86,Win32
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -ffreestanding 
-triple=x86_64-pc-win32 | FileCheck %s --check-prefixes=X64,Win64
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -ffreestanding 
-triple=i386-pc-linux-gnu   | FileCheck %s --check-prefixes=X86,Lin32
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -ffreestanding 
-triple=x86_64-pc-linux-gnu | FileCheck %s --check-prefixes=X64,Lin64
 
 #include 
 
 void __regcall v1(int a, int b) {}
-// Win32: define dso_local x86_regcallcc void @__regcall3__v1(i32 inreg 
noundef %a, i32 inreg noundef %b)
-// Win64: define dso_local x86_regcallcc void @__regcall3__v1(i32 noundef %a, 
i32 noundef %b)
-// Lin32: define{{.*}} x86_regcallcc void @__regcall3__v1(i32 inreg noundef 
%a, i32 inreg noundef %b)
-// Lin64: define{{.*}} x86_regcallcc void @__regcall3__v1(i32 noundef %a, i32 
noundef %b)
+// X86: define dso_local x86_regcallcc void @__regcall3__v1(i32 inreg noundef 
%a, i32 inreg noundef %b)
+// X64: define dso_local x86_regcallcc void @__regcall3__v1(i32 noundef %a, 
i32 noundef %b)
 
 void __attribute__((regcall)) v1b(int a, int b) {}
-// Win32: define dso_local x86_regcallcc void @__regcall3__v1b(i32 inreg 
noundef %a, i32 inreg noundef %b)
-// Win64: define dso_local x86_regcallcc void @__regcall3__v1b(i32 noundef %a, 
i32 noundef %b)
-// Lin32: define{{.*}} x86_regcallcc void @__regcall3__v1b(i32 inreg noundef 
%a, i32 inreg noundef %b)
-// Lin64: define{{.*}} x86_regcallcc void @__regcall3__v1b(i32 noundef %a, i32 
noundef %b)
+// X86: define dso_local x86_regcallcc void @__regcall3__v1b(i32 inreg noundef 
%a, i32 inreg noundef %b)
+// X64: define dso_local x86_regcallcc void @__regcall3__v1b(i32 noundef %a, 
i32 noundef %b)
 
 void __regcall v2(char a, char b) {}
-// Win32: define dso_local x86_regcallcc void @__regcall3__v2(i8 inreg noundef 
signext %a, i8 inreg noundef signext %b)
+// X86: define dso_local x86_regcallcc void @__regcall3__v2(i8 inreg noundef 
signext %a, i8 inreg noundef signext %b)
 // Win64: define dso_local x86_regcallcc void @__regcall3__v2(i8 noundef %a, 
i8 noundef %b)
-// Lin32: define{{.*}} x86_regcallcc void @__regcall3__v2(i8 inreg noundef 
signext %a, i8 inreg noundef signext %b)
-// Lin64: define{{.*}} x86_regcallcc void @__regcall3__v2(i8 noundef signext 
%a, i8 noundef signext %b)
+// Lin64: define dso_local x86_regcallcc void @__regcall3__v2(i8 noundef 
signext %a, i8 noundef signext %b)
 
 struct Small { int x; };
 void __regcall v3(int a, struct Small b, int c) {}
 // Win32: define dso_local x86_regcallcc void @__regcall3__v3(i32 inreg 
noundef %a, i32 %b.0, i32 inreg noundef %c)
-// Win64: define dso_local x86_regcallcc void @__regcall3__v3(i32 noundef %a, 
i32 %b.coerce, i32 noundef %c)
-// Lin32: define{{.*}} x86_regcallcc void @__regcall3__v3(i32 inreg noundef 
%a, i32 inreg %0, i32 %b.0, i32 inreg noundef %c)
-// Lin64: define{{.*}} x86_regcallcc void @__regcall3__v3(i32 noundef %a, i32 
%b.coerce, i32 noundef %c)
+// Lin32: define dso_local x86_regcallcc void @__regcall3__v3(i32 inreg 
noundef %a, i32 inreg %0, i32 %b.0, i32 inreg noundef %c)
+// X64: define dso_local x86_regcallcc void @__regcall3__v3(i32 noundef %a, 
i32 %b.coerce, i32 noundef %c)
 
 struct Large { int a[5]; };
 void __regcall v4(int a, struct Large b, int c) {}
 // Win32: define dso_local x86_regcallcc void @__regcall3__v4(i32 inreg 
noundef %a, %struct.Large* noundef byval(%struct.Large) align 4 %b, i32 inreg 
noundef %c)
+// Lin32: define dso_local x86_regcallcc void @__re

[PATCH] D133920: [X86][fastcall][vectorcall] Move capability check before free register update

2022-09-18 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 461071.
pengfei added a comment.

Address review comments. Thanks @rnk!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133920

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/mangle-windows.c
  clang/test/CodeGen/regcall.c
  clang/test/CodeGen/stdcall-fastcall.c
  clang/test/CodeGen/vectorcall.c

Index: clang/test/CodeGen/vectorcall.c
===
--- clang/test/CodeGen/vectorcall.c
+++ clang/test/CodeGen/vectorcall.c
@@ -19,6 +19,10 @@
 // X86: define dso_local x86_vectorcallcc void @"\01v4@@28"(i32 inreg noundef %a, %struct.Large* noundef byval(%struct.Large) align 4 %b, i32 inreg noundef %c)
 // X64: define dso_local x86_vectorcallcc void @"\01v4@@40"(i32 noundef %a, %struct.Large* noundef %b, i32 noundef %c)
 
+void __vectorcall v5(long long a, int b, int c) {}
+// X86: define dso_local x86_vectorcallcc void @"\01v5@@16"(i64 noundef %a, i32 inreg noundef %b, i32 inreg noundef %c)
+// X64: define dso_local x86_vectorcallcc void @"\01v5@@24"(i64 noundef %a, i32 noundef %b, i32 noundef %c)
+
 struct HFA2 { double x, y; };
 struct HFA4 { double w, x, y, z; };
 struct HFA5 { double v, w, x, y, z; };
Index: clang/test/CodeGen/stdcall-fastcall.c
===
--- clang/test/CodeGen/stdcall-fastcall.c
+++ clang/test/CodeGen/stdcall-fastcall.c
@@ -144,3 +144,10 @@
   // CHECK: call x86_fastcallcc void @foo12(float %{{.*}}, i32 inreg noundef %
   foo12(y, x);
 }
+
+void __attribute__((fastcall)) foo13(long long a, int b, int c);
+void bar13(long long a, int b, int c) {
+  // CHECK-LABEL: define{{.*}} void @bar13
+  // CHECK: call x86_fastcallcc void @foo13(i64 noundef %{{.*}}, i32 inreg noundef %{{.*}}, i32 inreg noundef %
+  foo13(a, b, c);
+}
Index: clang/test/CodeGen/regcall.c
===
--- clang/test/CodeGen/regcall.c
+++ clang/test/CodeGen/regcall.c
@@ -31,6 +31,10 @@
 // Win64: define dso_local x86_regcallcc void @__regcall3__v4(i32 noundef %a, %struct.Large* noundef %b, i32 noundef %c)
 // Lin64: define dso_local x86_regcallcc void @__regcall3__v4(i32 noundef %a, [5 x i32] %b.coerce, i32 noundef %c)
 
+void __regcall v5(long long a, int b, int c) {}
+// X86: define dso_local x86_regcallcc void @__regcall3__v5(i64 noundef %a, i32 inreg noundef %b, i32 inreg noundef %c)
+// X64: define dso_local x86_regcallcc void @__regcall3__v5(i64 noundef %a, i32 noundef %b, i32 noundef %c)
+
 struct HFA2 { double x, y; };
 struct HFA4 { double w, x, y, z; };
 struct HFA5 { double v, w, x, y, z; };
Index: clang/test/CodeGen/mangle-windows.c
===
--- clang/test/CodeGen/mangle-windows.c
+++ clang/test/CodeGen/mangle-windows.c
@@ -47,7 +47,7 @@
 // X64: define dso_local void @f8(
 
 void __fastcall f9(long long a, char b, char c, short d) {}
-// CHECK: define dso_local x86_fastcallcc void @"\01@f9@20"(i64 noundef %a, i8 noundef signext %b, i8 noundef signext %c, i16 noundef signext %d)
+// CHECK: define dso_local x86_fastcallcc void @"\01@f9@20"(i64 noundef %a, i8 inreg noundef signext %b, i8 inreg noundef signext %c, i16 noundef signext %d)
 // X64: define dso_local void @f9(
 
 void f12(void) {}
@@ -81,3 +81,6 @@
 void __vectorcall v6(char a, char b) {}
 // CHECK: define dso_local x86_vectorcallcc void @"\01v6@@8"(
 // X64: define dso_local x86_vectorcallcc void @"\01v6@@16"(
+
+void __vectorcall v7(long long a, char b, char c, short d) {}
+// CHECK: define dso_local x86_vectorcallcc void @"\01v7@@20"(i64 noundef %a, i8 inreg noundef signext %b, i8 inreg noundef signext %c, i16 noundef signext %d)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1771,23 +1771,22 @@
 }
 
 bool X86_32ABIInfo::shouldPrimitiveUseInReg(QualType Ty, CCState &State) const {
-  if (!updateFreeRegs(Ty, State))
-return false;
+  bool IsPtrOrInt = (getContext().getTypeSize(Ty) <= 32) &&
+(Ty->isIntegralOrEnumerationType() || Ty->isPointerType() ||
+ Ty->isReferenceType());
 
-  if (IsMCUABI)
+  if (!IsPtrOrInt && (State.CC == llvm::CallingConv::X86_FastCall ||
+  State.CC == llvm::CallingConv::X86_VectorCall))
 return false;
 
-  if (State.CC == llvm::CallingConv::X86_FastCall ||
-  State.CC == llvm::CallingConv::X86_VectorCall ||
-  State.CC == llvm::CallingConv::X86_RegCall) {
-if (getContext().getTypeSize(Ty) > 32)
-  return false;
+  if (!updateFreeRegs(Ty, State))
+return false;
 
-return (Ty->isIntegralOrEnumerationType() || Ty->isPointerType() ||
-Ty->isReferenceType());
-  }
+  if (!IsPtrOrInt && State.CC == llvm::Ca

[PATCH] D133920: [X86][fastcall][vectorcall] Move capability check before free register update

2022-09-18 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 461072.
pengfei added a comment.

Missing a `!`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133920

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/mangle-windows.c
  clang/test/CodeGen/regcall.c
  clang/test/CodeGen/stdcall-fastcall.c
  clang/test/CodeGen/vectorcall.c

Index: clang/test/CodeGen/vectorcall.c
===
--- clang/test/CodeGen/vectorcall.c
+++ clang/test/CodeGen/vectorcall.c
@@ -19,6 +19,10 @@
 // X86: define dso_local x86_vectorcallcc void @"\01v4@@28"(i32 inreg noundef %a, %struct.Large* noundef byval(%struct.Large) align 4 %b, i32 inreg noundef %c)
 // X64: define dso_local x86_vectorcallcc void @"\01v4@@40"(i32 noundef %a, %struct.Large* noundef %b, i32 noundef %c)
 
+void __vectorcall v5(long long a, int b, int c) {}
+// X86: define dso_local x86_vectorcallcc void @"\01v5@@16"(i64 noundef %a, i32 inreg noundef %b, i32 inreg noundef %c)
+// X64: define dso_local x86_vectorcallcc void @"\01v5@@24"(i64 noundef %a, i32 noundef %b, i32 noundef %c)
+
 struct HFA2 { double x, y; };
 struct HFA4 { double w, x, y, z; };
 struct HFA5 { double v, w, x, y, z; };
Index: clang/test/CodeGen/stdcall-fastcall.c
===
--- clang/test/CodeGen/stdcall-fastcall.c
+++ clang/test/CodeGen/stdcall-fastcall.c
@@ -144,3 +144,10 @@
   // CHECK: call x86_fastcallcc void @foo12(float %{{.*}}, i32 inreg noundef %
   foo12(y, x);
 }
+
+void __attribute__((fastcall)) foo13(long long a, int b, int c);
+void bar13(long long a, int b, int c) {
+  // CHECK-LABEL: define{{.*}} void @bar13
+  // CHECK: call x86_fastcallcc void @foo13(i64 noundef %{{.*}}, i32 inreg noundef %{{.*}}, i32 inreg noundef %
+  foo13(a, b, c);
+}
Index: clang/test/CodeGen/regcall.c
===
--- clang/test/CodeGen/regcall.c
+++ clang/test/CodeGen/regcall.c
@@ -31,6 +31,10 @@
 // Win64: define dso_local x86_regcallcc void @__regcall3__v4(i32 noundef %a, %struct.Large* noundef %b, i32 noundef %c)
 // Lin64: define dso_local x86_regcallcc void @__regcall3__v4(i32 noundef %a, [5 x i32] %b.coerce, i32 noundef %c)
 
+void __regcall v5(long long a, int b, int c) {}
+// X86: define dso_local x86_regcallcc void @__regcall3__v5(i64 noundef %a, i32 inreg noundef %b, i32 inreg noundef %c)
+// X64: define dso_local x86_regcallcc void @__regcall3__v5(i64 noundef %a, i32 noundef %b, i32 noundef %c)
+
 struct HFA2 { double x, y; };
 struct HFA4 { double w, x, y, z; };
 struct HFA5 { double v, w, x, y, z; };
Index: clang/test/CodeGen/mangle-windows.c
===
--- clang/test/CodeGen/mangle-windows.c
+++ clang/test/CodeGen/mangle-windows.c
@@ -47,7 +47,7 @@
 // X64: define dso_local void @f8(
 
 void __fastcall f9(long long a, char b, char c, short d) {}
-// CHECK: define dso_local x86_fastcallcc void @"\01@f9@20"(i64 noundef %a, i8 noundef signext %b, i8 noundef signext %c, i16 noundef signext %d)
+// CHECK: define dso_local x86_fastcallcc void @"\01@f9@20"(i64 noundef %a, i8 inreg noundef signext %b, i8 inreg noundef signext %c, i16 noundef signext %d)
 // X64: define dso_local void @f9(
 
 void f12(void) {}
@@ -81,3 +81,6 @@
 void __vectorcall v6(char a, char b) {}
 // CHECK: define dso_local x86_vectorcallcc void @"\01v6@@8"(
 // X64: define dso_local x86_vectorcallcc void @"\01v6@@16"(
+
+void __vectorcall v7(long long a, char b, char c, short d) {}
+// CHECK: define dso_local x86_vectorcallcc void @"\01v7@@20"(i64 noundef %a, i8 inreg noundef signext %b, i8 inreg noundef signext %c, i16 noundef signext %d)
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1771,23 +1771,22 @@
 }
 
 bool X86_32ABIInfo::shouldPrimitiveUseInReg(QualType Ty, CCState &State) const {
-  if (!updateFreeRegs(Ty, State))
-return false;
+  bool IsPtrOrInt = (getContext().getTypeSize(Ty) <= 32) &&
+(Ty->isIntegralOrEnumerationType() || Ty->isPointerType() ||
+ Ty->isReferenceType());
 
-  if (IsMCUABI)
+  if (!IsPtrOrInt && (State.CC == llvm::CallingConv::X86_FastCall ||
+  State.CC == llvm::CallingConv::X86_VectorCall))
 return false;
 
-  if (State.CC == llvm::CallingConv::X86_FastCall ||
-  State.CC == llvm::CallingConv::X86_VectorCall ||
-  State.CC == llvm::CallingConv::X86_RegCall) {
-if (getContext().getTypeSize(Ty) > 32)
-  return false;
+  if (!updateFreeRegs(Ty, State))
+return false;
 
-return (Ty->isIntegralOrEnumerationType() || Ty->isPointerType() ||
-Ty->isReferenceType());
-  }
+  if (!IsPtrOrInt && State.CC == llvm::CallingConv::X86_RegCall)

[PATCH] D134136: [Clang] Support constexpr for builtin fmax, fmin, ilogb, logb, scalbn

2022-09-18 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron created this revision.
Izaron added reviewers: cor3ntin, aaron.ballman.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Izaron requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Support constexpr versions of __builtin_fmax, __builtin_fmin,
__builtin_ilogb, __builtin_logb, __builtin_scalbn and their
variations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134136

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/Sema/constant-builtins-math.cpp
  llvm/include/llvm/ADT/APFloat.h
  llvm/lib/Support/APFloat.cpp

Index: llvm/lib/Support/APFloat.cpp
===
--- llvm/lib/Support/APFloat.cpp
+++ llvm/lib/Support/APFloat.cpp
@@ -4198,6 +4198,19 @@
   return Normalized.exponent - SignificandBits;
 }
 
+IEEEFloat logb(const IEEEFloat &Arg) {
+  IEEEFloat Result(Arg.getSemantics());
+  if (Arg.isNaN())
+Result.makeNaN();
+  else if (Arg.isZero())
+Result.makeInf(/* Negative = */ true);
+  else if (Arg.isInfinity())
+Result.makeInf(/* Negative = */ false);
+  else
+Result = IEEEFloat(static_cast(ilogb(Arg)));
+  return Result;
+}
+
 IEEEFloat scalbn(IEEEFloat X, int Exp, IEEEFloat::roundingMode RoundingMode) {
   auto MaxExp = X.getSemantics().maxExponent;
   auto MinExp = X.getSemantics().minExponent;
Index: llvm/include/llvm/ADT/APFloat.h
===
--- llvm/include/llvm/ADT/APFloat.h
+++ llvm/include/llvm/ADT/APFloat.h
@@ -592,6 +592,7 @@
 
 hash_code hash_value(const IEEEFloat &Arg);
 int ilogb(const IEEEFloat &Arg);
+IEEEFloat logb(const IEEEFloat &Arg);
 IEEEFloat scalbn(IEEEFloat X, int Exp, IEEEFloat::roundingMode);
 IEEEFloat frexp(const IEEEFloat &Val, int &Exp, IEEEFloat::roundingMode RM);
 
@@ -1248,6 +1249,9 @@
 
   friend hash_code hash_value(const APFloat &Arg);
   friend int ilogb(const APFloat &Arg) { return ilogb(Arg.getIEEE()); }
+  friend APFloat logb(const APFloat &Arg) {
+return APFloat(logb(Arg.getIEEE()), Arg.getSemantics());
+  }
   friend APFloat scalbn(APFloat X, int Exp, roundingMode RM);
   friend APFloat frexp(const APFloat &X, int &Exp, roundingMode RM);
   friend IEEEFloat;
Index: clang/test/Sema/constant-builtins-math.cpp
===
--- /dev/null
+++ clang/test/Sema/constant-builtins-math.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+static_assert(__builtin_fmax(12.34, 56.78) == 56.78);
+static_assert(__builtin_fmaxf(12.34f, 56.78f) == 56.78f);
+static_assert(__builtin_fmaxl(12.34, 56.78) == 56.78);
+static_assert(__builtin_fmaxf16(12.0, 56.0) == 56.0);
+static_assert(__builtin_fmaxf128(12.34, 56.78) == 56.78);
+
+static_assert(__builtin_fmin(12.34, 56.78) == 12.34);
+static_assert(__builtin_fminf(12.34f, 56.78f) == 12.34f);
+static_assert(__builtin_fminl(12.34, 56.78) == 12.34);
+static_assert(__builtin_fminf16(12.0, 56.0) == 12.0);
+static_assert(__builtin_fminf128(12.34, 56.78) == 12.34);
+
+// TODO: investigate why this is `INT_MIN + 1` instead of `INT_MIN`
+static_assert(__builtin_ilogb(0.0) == -2147483647);
+static_assert(__builtin_ilogb(__builtin_inf()) == 2147483647);
+static_assert(__builtin_ilogb(__builtin_nan("")) == -2147483648);
+static_assert(__builtin_ilogb(1.0) == 0);
+static_assert(__builtin_ilogb(32.0) == 5);
+static_assert(__builtin_ilogb(1024.0) == 10);
+static_assert(__builtin_ilogb(-1024.0) == 10);
+static_assert(__builtin_ilogb(0.1) == -4);
+static_assert(__builtin_ilogb(0.1) == -44);
+
+static_assert(__builtin_logb(0.0) == -__builtin_inf());
+static_assert(__builtin_logb(__builtin_inf()) == __builtin_inf());
+static_assert(__builtin_isnan(__builtin_logb(__builtin_nan("";
+static_assert(__builtin_logb(1.0) == 0.0);
+static_assert(__builtin_logb(32.0) == 5.0);
+static_assert(__builtin_logb(1024.0) == 10.0);
+static_assert(__builtin_logb(-1024.0) == 10.0);
+static_assert(__builtin_logb(0.1) == -4.0);
+static_assert(__builtin_logb(0.1) == -44.0);
+
+static_assert(__builtin_scalbn(12.5, 0) == 12.5);
+static_assert(__builtin_scalbn(12.5, 1) == 25);
+static_assert(__builtin_scalbn(12.5, 3) == 100.0);
+static_assert(__builtin_scalbn(0.0, 100) == 0);
+static_assert(__builtin_scalbn(__builtin_inf(), 100) == __builtin_inf());
+static_assert(__builtin_isnan(__builtin_scalbn(__builtin_nan(""), 100)));
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -12410,6 +12410,19 @@
   return false;
 return Success(DidOverflow, E);
   }
+
+  case Builtin::BI__builtin_ilogb:
+  case Builtin::BI__builtin_ilogbf:
+  case Builtin::BI__builtin_ilogbl:
+  case Builtin::BI__builtin_ilogbf128: {
+APFloat F(0.0);
+if (!EvaluateF

[PATCH] D134136: [Clang] Support constexpr for builtin fmax, fmin, ilogb, logb, scalbn

2022-09-18 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added a comment.

libc++ doesn't support constexpr-related patches from C++20 in ``: see 
issue https://github.com/llvm/llvm-project/issues/55370

I reviewed the code in `` and found out that since we use a dozen of 
math functions, we need to support more constexpr builtin math function.

I implemented constexpr versions for five functions. This will be enough to 
implement a 2017 paper: 
https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0415r1.html (in a new 
pull request)

(Also there is a 2019 paper with more constexpr functions for ``: 
https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2019/p1383r0.pdf)

Also builtin implementations will be useful for new C++23 constexpr functions: 
for example https://en.cppreference.com/w/cpp/numeric/math/scalbn


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134136

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


[PATCH] D134136: [Clang] Support constexpr for builtin fmax, fmin, ilogb, logb, scalbn

2022-09-18 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added inline comments.



Comment at: clang/test/Sema/constant-builtins-math.cpp:16-17
+
+// TODO: investigate why this is `INT_MIN + 1` instead of `INT_MIN`
+static_assert(__builtin_ilogb(0.0) == -2147483647);
+static_assert(__builtin_ilogb(__builtin_inf()) == 2147483647);

runtime version of `__builtin_ilogb/std::ilogb` returns `INT_MIN` 
(`-2147483647`) on this argument, while constexpr version returns `INT_MIN+1` 🤔 

This constant is here:
https://llvm.org/doxygen/APFloat_8cpp_source.html#l04187
https://llvm.org/doxygen/APFloat_8h_source.html#l00229
(I guess we shouldn't change this)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134136

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


[PATCH] D134136: [Clang] Support constexpr for builtin fmax, fmin, ilogb, logb, scalbn

2022-09-18 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added inline comments.



Comment at: clang/test/Sema/constant-builtins-math.cpp:16-17
+
+// TODO: investigate why this is `INT_MIN + 1` instead of `INT_MIN`
+static_assert(__builtin_ilogb(0.0) == -2147483647);
+static_assert(__builtin_ilogb(__builtin_inf()) == 2147483647);

Izaron wrote:
> runtime version of `__builtin_ilogb/std::ilogb` returns `INT_MIN` 
> (`-2147483647`) on this argument, while constexpr version returns `INT_MIN+1` 
> 🤔 
> 
> This constant is here:
> https://llvm.org/doxygen/APFloat_8cpp_source.html#l04187
> https://llvm.org/doxygen/APFloat_8h_source.html#l00229
> (I guess we shouldn't change this)
quick fix: `INT_MIN` is `-2147483648`, `INT_MIN+1` is `2147483647`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134136

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-18 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5455-5456
 if (!ClangABICompat15) {
-  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
   auto *TST1 = T1->castAs();
   auto *TST2 = T2->castAs();
+  const TemplateArgument &TA1 = TST1->template_arguments().back();

ychen wrote:
> ychen wrote:
> > mizvekov wrote:
> > > This is a bug, T1 and T2 are not in general canonical types for this 
> > > function, and this castAs can pick up an alias template, and these should 
> > > never participate in deduction.
> > > 
> > > (Also, can you please add a test for that?)
> > > 
> > > You should not need to keep sugar here, everything being tested below is 
> > > present on the canonical type, so this is simple to solve, as suggested.
> > I see. I'll add a test.
> Looking more closely, `T1`/`T2` is mostly returned by 
> `ASTContext::getTemplateSpecializationType` and for injected template 
> specialization, always unqualified   
> https://github.com/llvm/llvm-project/blob/52dce8900c46d5842a021619537ede598983dfde/clang/include/clang/AST/Type.h#L5431-L5432
>  , it does not seem possible to have aliase template involved? I could've 
> missed something though.
Yeah you are right, I missed that all the uses of this function, those types 
either come from an Injected TST, or a dependent TST created on the spot.

But yeah, the change to a simple `cast` instead of `castAs` makes this more 
clear.

Otherwise, if there could have been any sugar node on top of the TST, that 
sugar could have easily been an alias TST,
and I think it's very unlikely one wouldn't care, as they are very different 
things.

So I tend to view these as potential bugs, a simple `getAs` and `castAs` on 
TSTs, which does not check or keeps digging through alias templates is highly 
suspicious :)

Thanks for taking a look at this though!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D134137: [clangd] Return earlier when snippet is empty

2022-09-18 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
tom-anders requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Fixes github.com/clangd/clangd/issues/1216

If the Snippet string is empty, Snippet.front() would trigger a crash.
Move the Snippet->empty() check up a few lines to avoid this. Should not
break any existing behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134137

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1014,6 +1014,23 @@
   EXPECT_THAT(Results.Completions, Not(Contains(labeled("clang::";
 }
 
+TEST(CompletionTests, EmptySnippetDoesNotCrash) {
+// See https://github.com/clangd/clangd/issues/1216
+auto Results = completions(R"cpp(
+int main() {
+  auto w = [&](auto &&f) { return f(f); };
+  auto f = w([&](auto &&f) {
+return [&](auto &&n) {
+  if (n == 0) {
+return 1;
+  }
+  return n * ^(f)(n - 1);
+};
+  })(10);
+}
+)cpp");
+}
+
 TEST(CompletionTest, BacktrackCrashes) {
   // Sema calls code completion callbacks twice in these cases.
   auto Results = completions(R"cpp(
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -491,6 +491,9 @@
   // we need to complete 'forward<$1>($0)'.
   return "($0)";
 
+if (Snippet->empty())
+  return "";
+
 bool MayHaveArgList = Completion.Kind == CompletionItemKind::Function ||
   Completion.Kind == CompletionItemKind::Method ||
   Completion.Kind == CompletionItemKind::Constructor ||
@@ -529,8 +532,6 @@
   return *Snippet;
 
 // Replace argument snippets with a simplified pattern.
-if (Snippet->empty())
-  return "";
 if (MayHaveArgList) {
   // Functions snippets can be of 2 types:
   // - containing only function arguments, e.g.


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1014,6 +1014,23 @@
   EXPECT_THAT(Results.Completions, Not(Contains(labeled("clang::";
 }
 
+TEST(CompletionTests, EmptySnippetDoesNotCrash) {
+// See https://github.com/clangd/clangd/issues/1216
+auto Results = completions(R"cpp(
+int main() {
+  auto w = [&](auto &&f) { return f(f); };
+  auto f = w([&](auto &&f) {
+return [&](auto &&n) {
+  if (n == 0) {
+return 1;
+  }
+  return n * ^(f)(n - 1);
+};
+  })(10);
+}
+)cpp");
+}
+
 TEST(CompletionTest, BacktrackCrashes) {
   // Sema calls code completion callbacks twice in these cases.
   auto Results = completions(R"cpp(
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -491,6 +491,9 @@
   // we need to complete 'forward<$1>($0)'.
   return "($0)";
 
+if (Snippet->empty())
+  return "";
+
 bool MayHaveArgList = Completion.Kind == CompletionItemKind::Function ||
   Completion.Kind == CompletionItemKind::Method ||
   Completion.Kind == CompletionItemKind::Constructor ||
@@ -529,8 +532,6 @@
   return *Snippet;
 
 // Replace argument snippets with a simplified pattern.
-if (Snippet->empty())
-  return "";
 if (MayHaveArgList) {
   // Functions snippets can be of 2 types:
   // - containing only function arguments, e.g.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133662: [Clang] Change -ftime-trace storing path and support multiple compilation jobs

2022-09-18 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser added a comment.

I had an email exchange with @dongjunduo about this situation.  He was a GSoC 
student that @Whitney and I were mentoring for the past summer.  He agrees that 
your approach is cleaner.  There appears to be two parts to your work.  First, 
you implemented the determining and passing of the options differently, and 
secondly, you improved the handling of off-loading and system specific file 
handling.  Based on your earlier response, we proposed to him the following and 
he agrees that it seems appropriate.  Could you please add comments to 
https://reviews.llvm.org/D131469 and he will work with you to change his code 
to reflect searching for -o and using the virtual functions.  Then, if @MaskRay 
agrees, he can land his code and finish up his GSoC work.  You can then add 
your extensions of off-loading and file-handling.  Is this acceptable to you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133662

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-18 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5179-5231
   if (!Better1 && !Better2) // Neither is better than the other
 return JudgeByConstraints();
 
   // C++ [temp.deduct.partial]p11:
   //   ... and if G has a trailing function parameter pack for which F does not
   //   have a corresponding parameter, and if F does not have a trailing
   //   function parameter pack, then F is more specialized than G.

One thing I have been thinking about all of these "more constrained" checks, is 
whether we should actually be performing them over the results of the 
deductions for the least constrained checks.

Ie especially with regards to this new check and the one for 
`[temp.deduct.partial]p11:`, it seems that we should be instead considering as 
more constrained the deduction which deduced a lesser amount of template 
parameters, including ones in packs. Or something along this line.

This way, we do one sweeping general rule to handle all these cases, instead of 
just appending these ad-hoc tie-breaking rules which look more like workarounds.

What do you think about that?

But this is a big change and I don't want to block you on that. Because 
otherwise, this new change is keeping in line with other workarounds that have 
already been added here, so this is within existing practice.

Since this patch was submitted quite recently and it's a speculative fix, I 
would let this patch marinate a little more and wait for any other reviewers.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5199
 
+  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
+  bool ClangABICompat15 =

I would make it more clear in this comment that this is a speculative fix, that 
there is no wording or even resolution for this issue.



Comment at: clang/test/CXX/drs/dr6xx.cpp:1104
   f(42); // expected-error {{ambiguous}}
   g(42); // expected-error {{ambiguous}}
 }

I would expect the call to `g` not to be ambiguous here, in the same vein of 
keeping with the spirit of the rules.

If you agree, can we at least add a FIXME to make a note of that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5455-5456
 if (!ClangABICompat15) {
-  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
   auto *TST1 = T1->castAs();
   auto *TST2 = T2->castAs();
+  const TemplateArgument &TA1 = TST1->template_arguments().back();

mizvekov wrote:
> ychen wrote:
> > ychen wrote:
> > > mizvekov wrote:
> > > > This is a bug, T1 and T2 are not in general canonical types for this 
> > > > function, and this castAs can pick up an alias template, and these 
> > > > should never participate in deduction.
> > > > 
> > > > (Also, can you please add a test for that?)
> > > > 
> > > > You should not need to keep sugar here, everything being tested below 
> > > > is present on the canonical type, so this is simple to solve, as 
> > > > suggested.
> > > I see. I'll add a test.
> > Looking more closely, `T1`/`T2` is mostly returned by 
> > `ASTContext::getTemplateSpecializationType` and for injected template 
> > specialization, always unqualified   
> > https://github.com/llvm/llvm-project/blob/52dce8900c46d5842a021619537ede598983dfde/clang/include/clang/AST/Type.h#L5431-L5432
> >  , it does not seem possible to have aliase template involved? I could've 
> > missed something though.
> Yeah you are right, I missed that all the uses of this function, those types 
> either come from an Injected TST, or a dependent TST created on the spot.
> 
> But yeah, the change to a simple `cast` instead of `castAs` makes this more 
> clear.
> 
> Otherwise, if there could have been any sugar node on top of the TST, that 
> sugar could have easily been an alias TST,
> and I think it's very unlikely one wouldn't care, as they are very different 
> things.
> 
> So I tend to view these as potential bugs, a simple `getAs` and `castAs` on 
> TSTs, which does not check or keeps digging through alias templates is highly 
> suspicious :)
> 
> Thanks for taking a look at this though!
Thanks for the explanation. Yeah, `castAs` looks misleading indeed. I wasn't 
aware of the subtle difference between `cast` and `castAs`. BTW, are you 
comfortable accepting this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-18 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5455-5456
 if (!ClangABICompat15) {
-  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
   auto *TST1 = T1->castAs();
   auto *TST2 = T2->castAs();
+  const TemplateArgument &TA1 = TST1->template_arguments().back();

ychen wrote:
> mizvekov wrote:
> > ychen wrote:
> > > ychen wrote:
> > > > mizvekov wrote:
> > > > > This is a bug, T1 and T2 are not in general canonical types for this 
> > > > > function, and this castAs can pick up an alias template, and these 
> > > > > should never participate in deduction.
> > > > > 
> > > > > (Also, can you please add a test for that?)
> > > > > 
> > > > > You should not need to keep sugar here, everything being tested below 
> > > > > is present on the canonical type, so this is simple to solve, as 
> > > > > suggested.
> > > > I see. I'll add a test.
> > > Looking more closely, `T1`/`T2` is mostly returned by 
> > > `ASTContext::getTemplateSpecializationType` and for injected template 
> > > specialization, always unqualified   
> > > https://github.com/llvm/llvm-project/blob/52dce8900c46d5842a021619537ede598983dfde/clang/include/clang/AST/Type.h#L5431-L5432
> > >  , it does not seem possible to have aliase template involved? I could've 
> > > missed something though.
> > Yeah you are right, I missed that all the uses of this function, those 
> > types either come from an Injected TST, or a dependent TST created on the 
> > spot.
> > 
> > But yeah, the change to a simple `cast` instead of `castAs` makes this more 
> > clear.
> > 
> > Otherwise, if there could have been any sugar node on top of the TST, that 
> > sugar could have easily been an alias TST,
> > and I think it's very unlikely one wouldn't care, as they are very 
> > different things.
> > 
> > So I tend to view these as potential bugs, a simple `getAs` and `castAs` on 
> > TSTs, which does not check or keeps digging through alias templates is 
> > highly suspicious :)
> > 
> > Thanks for taking a look at this though!
> Thanks for the explanation. Yeah, `castAs` looks misleading indeed. I wasn't 
> aware of the subtle difference between `cast` and `castAs`. BTW, are you 
> comfortable accepting this patch?
I hope I answered that in my other comment, but since this is a speculative 
wording fix, I think it's more reasonable to wait more than a week for other 
reviewers, specially since folks can be on time off and such.

But lacking interest from other folks in reviewing this, yeah sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5179-5231
   if (!Better1 && !Better2) // Neither is better than the other
 return JudgeByConstraints();
 
   // C++ [temp.deduct.partial]p11:
   //   ... and if G has a trailing function parameter pack for which F does not
   //   have a corresponding parameter, and if F does not have a trailing
   //   function parameter pack, then F is more specialized than G.

mizvekov wrote:
> One thing I have been thinking about all of these "more constrained" checks, 
> is whether we should actually be performing them over the results of the 
> deductions for the least constrained checks.
> 
> Ie especially with regards to this new check and the one for 
> `[temp.deduct.partial]p11:`, it seems that we should be instead considering 
> as more constrained the deduction which deduced a lesser amount of template 
> parameters, including ones in packs. Or something along this line.
> 
> This way, we do one sweeping general rule to handle all these cases, instead 
> of just appending these ad-hoc tie-breaking rules which look more like 
> workarounds.
> 
> What do you think about that?
> 
> But this is a big change and I don't want to block you on that. Because 
> otherwise, this new change is keeping in line with other workarounds that 
> have already been added here, so this is within existing practice.
> 
> Since this patch was submitted quite recently and it's a speculative fix, I 
> would let this patch marinate a little more and wait for any other reviewers.
> Ie especially with regards to this new check and the one for 
> [temp.deduct.partial]p11:, it seems that we should be instead considering as 
> more constrained the deduction which deduced a lesser amount of template 
> parameters, including ones in packs. Or something along this line.
>
>This way, we do one sweeping general rule to handle all these cases, instead 
>of just appending these ad-hoc tie-breaking rules which look more like 
>workarounds.
>
> What do you think about that?

I think you meant the cases that for a  `P`/`A` deduction pair, either `P`/`A` 
is pack and the other is not empty, right? If so, it already works that way. 
https://eel.is/c++draft/temp.deduct#type-9

If neither `P`/`A` is pack and either is empty, then they wouldn't get into the 
stage of partial ordering at all because the function arguments list can only 
have one length,  `P`/`A` would not be in the same candidate sets.

Here handles the case that either  `P`/`A` is pack and the other is empty. Then 
the deduction rule could not kick in because one of the `P`/`A`pair is none. So 
we have to tie-break after the deduction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-18 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5179-5231
   if (!Better1 && !Better2) // Neither is better than the other
 return JudgeByConstraints();
 
   // C++ [temp.deduct.partial]p11:
   //   ... and if G has a trailing function parameter pack for which F does not
   //   have a corresponding parameter, and if F does not have a trailing
   //   function parameter pack, then F is more specialized than G.

ychen wrote:
> mizvekov wrote:
> > One thing I have been thinking about all of these "more constrained" 
> > checks, is whether we should actually be performing them over the results 
> > of the deductions for the least constrained checks.
> > 
> > Ie especially with regards to this new check and the one for 
> > `[temp.deduct.partial]p11:`, it seems that we should be instead considering 
> > as more constrained the deduction which deduced a lesser amount of template 
> > parameters, including ones in packs. Or something along this line.
> > 
> > This way, we do one sweeping general rule to handle all these cases, 
> > instead of just appending these ad-hoc tie-breaking rules which look more 
> > like workarounds.
> > 
> > What do you think about that?
> > 
> > But this is a big change and I don't want to block you on that. Because 
> > otherwise, this new change is keeping in line with other workarounds that 
> > have already been added here, so this is within existing practice.
> > 
> > Since this patch was submitted quite recently and it's a speculative fix, I 
> > would let this patch marinate a little more and wait for any other 
> > reviewers.
> > Ie especially with regards to this new check and the one for 
> > [temp.deduct.partial]p11:, it seems that we should be instead considering 
> > as more constrained the deduction which deduced a lesser amount of template 
> > parameters, including ones in packs. Or something along this line.
> >
> >This way, we do one sweeping general rule to handle all these cases, instead 
> >of just appending these ad-hoc tie-breaking rules which look more like 
> >workarounds.
> >
> > What do you think about that?
> 
> I think you meant the cases that for a  `P`/`A` deduction pair, either 
> `P`/`A` is pack and the other is not empty, right? If so, it already works 
> that way. https://eel.is/c++draft/temp.deduct#type-9
> 
> If neither `P`/`A` is pack and either is empty, then they wouldn't get into 
> the stage of partial ordering at all because the function arguments list can 
> only have one length,  `P`/`A` would not be in the same candidate sets.
> 
> Here handles the case that either  `P`/`A` is pack and the other is empty. 
> Then the deduction rule could not kick in because one of the `P`/`A`pair is 
> none. So we have to tie-break after the deduction.
I understand we need to tie break after the at-least-as-specialized check, but 
I was wondering if we could come up with one sweeping rule / mechanism, which 
incorporates not only these two cases but also the concept more-constrained 
check, instead of appending multiple completely separate tie breakers.

Otherwise, I think this gets pretty hard to incorporate into your mental model 
of what overload resolution should pick up and such.

For example, even the order which we tie break seems arbitrary, and this makes 
it harder for folks to learn / memorize them and for them to actually be 
useful, instead of just programming traps. But this is C++ so I may be barking 
at the wrong tree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[clang] 5e5a6c5 - Use std::conditional_t (NFC)

2022-09-18 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-09-18T10:25:06-07:00
New Revision: 5e5a6c5b076046f546323dad68a3438b0c89a9e9

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

LOG: Use std::conditional_t (NFC)

Added: 


Modified: 
clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
llvm/include/llvm/ADT/Bitfields.h
llvm/include/llvm/ADT/DenseMap.h
llvm/include/llvm/ADT/FunctionExtras.h
llvm/lib/Transforms/Vectorize/VPlan.h
mlir/lib/Dialect/Linalg/Transforms/Loops.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h 
b/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
index e6ebaea5248ad..33194c401ea14 100644
--- a/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
+++ b/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
@@ -94,9 +94,9 @@ void visitRefactoringOptions(
 /// A type trait that returns true when the given type list has at least one
 /// type whose base is the given base type.
 template 
-struct HasBaseOf : std::conditional::value ||
-HasBaseOf::value,
-std::true_type, std::false_type>::type {};
+struct HasBaseOf : std::conditional_t::value ||
+  HasBaseOf::value,
+  std::true_type, std::false_type> {};
 
 template 
 struct HasBaseOf : std::is_base_of {};
@@ -104,9 +104,9 @@ struct HasBaseOf : std::is_base_of {};
 /// A type trait that returns true when the given type list contains types that
 /// derive from Base.
 template 
-struct AreBaseOf : std::conditional::value &&
-AreBaseOf::value,
-std::true_type, std::false_type>::type {};
+struct AreBaseOf : std::conditional_t::value &&
+  AreBaseOf::value,
+  std::true_type, std::false_type> {};
 
 template 
 struct AreBaseOf : std::is_base_of {};

diff  --git a/llvm/include/llvm/ADT/Bitfields.h 
b/llvm/include/llvm/ADT/Bitfields.h
index 18555e676e9d3..aaf876d896d4c 100644
--- a/llvm/include/llvm/ADT/Bitfields.h
+++ b/llvm/include/llvm/ADT/Bitfields.h
@@ -203,7 +203,7 @@ template  struct ResolveUnderlyingType {
 template <> struct ResolveUnderlyingType {
   /// In case sizeof(bool) != 1, replace `void` by an additionnal
   /// std::conditional.
-  using type = std::conditional::type;
+  using type = std::conditional_t;
 };
 
 } // namespace bitfields_details

diff  --git a/llvm/include/llvm/ADT/DenseMap.h 
b/llvm/include/llvm/ADT/DenseMap.h
index c22a1f8a76e0e..7adc6710cfa86 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -1197,8 +1197,7 @@ class DenseMapIterator : DebugEpochBase::HandleBase {
 
 public:
   using 
diff erence_type = ptr
diff _t;
-  using value_type =
-  typename std::conditional::type;
+  using value_type = std::conditional_t;
   using pointer = value_type *;
   using reference = value_type &;
   using iterator_category = std::forward_iterator_tag;

diff  --git a/llvm/include/llvm/ADT/FunctionExtras.h 
b/llvm/include/llvm/ADT/FunctionExtras.h
index 35e160fc63ad5..8f04277cdf0e5 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -99,11 +99,11 @@ template  class 
UniqueFunctionBase {
   template  struct AdjustedParamTBase {
 static_assert(!std::is_reference::value,
   "references should be handled by template specialization");
-using type = typename std::conditional<
+using type = std::conditional_t<
 llvm::is_trivially_copy_constructible::value &&
 llvm::is_trivially_move_constructible::value &&
 IsSizeLessThanThresholdT::value,
-T, T &>::type;
+T, T &>;
   };
 
   // This specialization ensures that 'AdjustedParam&>' or

diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index 09429ae599be6..803a376b5bdf7 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2887,9 +2887,8 @@ class VPBlockUtils {
   template 
   static auto blocksOnly(const T &Range) {
 // Create BaseTy with correct const-ness based on BlockTy.
-using BaseTy =
-typename std::conditional::value,
-  const VPBlockBase, VPBlockBase>::type;
+using BaseTy = std::conditional_t::value,
+  const VPBlockBase, VPBlockBase>;
 
 // We need to first create an iterator range over (const) BlocktTy & 
instead
 // of (const) BlockTy * for filter_range to work properly.

d

[clang-tools-extra] 3e720fa - Use std::decay_t (NFC)

2022-09-18 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-09-18T10:25:08-07:00
New Revision: 3e720fa9dce6cf4020c498c1e75be4c94dd5075d

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

LOG: Use std::decay_t (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/support/Context.h
llvm/include/llvm/ADT/ScopeExit.h
llvm/include/llvm/Support/thread.h

Removed: 




diff  --git a/clang-tools-extra/clangd/support/Context.h 
b/clang-tools-extra/clangd/support/Context.h
index a33a9ff8fffa7..926add18d88aa 100644
--- a/clang-tools-extra/clangd/support/Context.h
+++ b/clang-tools-extra/clangd/support/Context.h
@@ -116,33 +116,31 @@ class Context {
   /// It is safe to move or destroy a parent context after calling derive().
   /// The child will keep its parent alive, and its data remains accessible.
   template 
-  Context derive(const Key &Key,
- typename std::decay::type Value) const & {
+  Context derive(const Key &Key, std::decay_t Value) const & {
 return Context(std::make_shared(
 Data{/*Parent=*/DataPtr, &Key,
- std::make_unique::type>>(
+ std::make_unique>>(
  std::move(Value))}));
   }
 
   template 
-  Context
-  derive(const Key &Key,
- typename std::decay::type Value) && /* takes ownership */ {
+  Context derive(const Key &Key,
+ std::decay_t Value) && /* takes ownership */ {
 return Context(std::make_shared(
 Data{/*Parent=*/std::move(DataPtr), &Key,
- std::make_unique::type>>(
+ std::make_unique>>(
  std::move(Value))}));
   }
 
   /// Derives a child context, using an anonymous key.
   /// Intended for objects stored only for their destructor's side-effect.
   template  Context derive(Type &&Value) const & {
-static Key::type> Private;
+static Key> Private;
 return derive(Private, std::forward(Value));
   }
 
   template  Context derive(Type &&Value) && {
-static Key::type> Private;
+static Key> Private;
 return std::move(*this).derive(Private, std::forward(Value));
   }
 

diff  --git a/llvm/include/llvm/ADT/ScopeExit.h 
b/llvm/include/llvm/ADT/ScopeExit.h
index e2a19db1686d1..2f13fb65d34d8 100644
--- a/llvm/include/llvm/ADT/ScopeExit.h
+++ b/llvm/include/llvm/ADT/ScopeExit.h
@@ -55,10 +55,9 @@ template  class scope_exit {
 //
 // Interface is specified by p0052r2.
 template 
-[[nodiscard]] detail::scope_exit::type>
+[[nodiscard]] detail::scope_exit>
 make_scope_exit(Callable &&F) {
-  return detail::scope_exit::type>(
-  std::forward(F));
+  return detail::scope_exit>(std::forward(F));
 }
 
 } // end namespace llvm

diff  --git a/llvm/include/llvm/Support/thread.h 
b/llvm/include/llvm/Support/thread.h
index 66a55db592033..660d31573a866 100644
--- a/llvm/include/llvm/Support/thread.h
+++ b/llvm/include/llvm/Support/thread.h
@@ -129,9 +129,7 @@ thread::id llvm_thread_get_current_id_impl();
 template 
 thread::thread(llvm::Optional StackSizeInBytes, Function &&f,
Args &&...args) {
-  typedef std::tuple::type,
- typename std::decay::type...>
-  CalleeTuple;
+  typedef std::tuple, std::decay_t...> 
CalleeTuple;
   std::unique_ptr Callee(
   new CalleeTuple(std::forward(f), std::forward(args)...));
 



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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a subscriber: hubert.reinterpretcast.
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5455-5456
 if (!ClangABICompat15) {
-  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
   auto *TST1 = T1->castAs();
   auto *TST2 = T2->castAs();
+  const TemplateArgument &TA1 = TST1->template_arguments().back();

mizvekov wrote:
> ychen wrote:
> > mizvekov wrote:
> > > ychen wrote:
> > > > ychen wrote:
> > > > > mizvekov wrote:
> > > > > > This is a bug, T1 and T2 are not in general canonical types for 
> > > > > > this function, and this castAs can pick up an alias template, and 
> > > > > > these should never participate in deduction.
> > > > > > 
> > > > > > (Also, can you please add a test for that?)
> > > > > > 
> > > > > > You should not need to keep sugar here, everything being tested 
> > > > > > below is present on the canonical type, so this is simple to solve, 
> > > > > > as suggested.
> > > > > I see. I'll add a test.
> > > > Looking more closely, `T1`/`T2` is mostly returned by 
> > > > `ASTContext::getTemplateSpecializationType` and for injected template 
> > > > specialization, always unqualified   
> > > > https://github.com/llvm/llvm-project/blob/52dce8900c46d5842a021619537ede598983dfde/clang/include/clang/AST/Type.h#L5431-L5432
> > > >  , it does not seem possible to have aliase template involved? I 
> > > > could've missed something though.
> > > Yeah you are right, I missed that all the uses of this function, those 
> > > types either come from an Injected TST, or a dependent TST created on the 
> > > spot.
> > > 
> > > But yeah, the change to a simple `cast` instead of `castAs` makes this 
> > > more clear.
> > > 
> > > Otherwise, if there could have been any sugar node on top of the TST, 
> > > that sugar could have easily been an alias TST,
> > > and I think it's very unlikely one wouldn't care, as they are very 
> > > different things.
> > > 
> > > So I tend to view these as potential bugs, a simple `getAs` and `castAs` 
> > > on TSTs, which does not check or keeps digging through alias templates is 
> > > highly suspicious :)
> > > 
> > > Thanks for taking a look at this though!
> > Thanks for the explanation. Yeah, `castAs` looks misleading indeed. I 
> > wasn't aware of the subtle difference between `cast` and `castAs`. BTW, are 
> > you comfortable accepting this patch?
> I hope I answered that in my other comment, but since this is a speculative 
> wording fix, I think it's more reasonable to wait more than a week for other 
> reviewers, specially since folks can be on time off and such.
> 
> But lacking interest from other folks in reviewing this, yeah sure.
Thanks, that makes sense. I wasn't aware of your other comments when writing 
this.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5179-5231
   if (!Better1 && !Better2) // Neither is better than the other
 return JudgeByConstraints();
 
   // C++ [temp.deduct.partial]p11:
   //   ... and if G has a trailing function parameter pack for which F does not
   //   have a corresponding parameter, and if F does not have a trailing
   //   function parameter pack, then F is more specialized than G.

mizvekov wrote:
> ychen wrote:
> > mizvekov wrote:
> > > One thing I have been thinking about all of these "more constrained" 
> > > checks, is whether we should actually be performing them over the results 
> > > of the deductions for the least constrained checks.
> > > 
> > > Ie especially with regards to this new check and the one for 
> > > `[temp.deduct.partial]p11:`, it seems that we should be instead 
> > > considering as more constrained the deduction which deduced a lesser 
> > > amount of template parameters, including ones in packs. Or something 
> > > along this line.
> > > 
> > > This way, we do one sweeping general rule to handle all these cases, 
> > > instead of just appending these ad-hoc tie-breaking rules which look more 
> > > like workarounds.
> > > 
> > > What do you think about that?
> > > 
> > > But this is a big change and I don't want to block you on that. Because 
> > > otherwise, this new change is keeping in line with other workarounds that 
> > > have already been added here, so this is within existing practice.
> > > 
> > > Since this patch was submitted quite recently and it's a speculative fix, 
> > > I would let this patch marinate a little more and wait for any other 
> > > reviewers.
> > > Ie especially with regards to this new check and the one for 
> > > [temp.deduct.partial]p11:, it seems that we should be instead considering 
> > > as more constrained the deduction which deduced a lesser amount of 
> > > template parameters, including ones in packs. Or something along this 
> > > line.
> > >
> > >This way, we do one sweeping general rule to handle all these cases, 
> > >instead of just appending these ad-hoc tie-breaking rules which look more 

[PATCH] D133329: [Driver] Add --gcc-install-dir=

2022-09-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D133329#3798166 , @mgorny wrote:

> Hmm, apparently this could be achieved by making it a "CoreOption".

I don't think it is appropriate to have `CoreOption`. The Windows dxc support 
appears to have nothing to do with gcc installation unless I am mistaken.
It's for configuration file support to figure out how to work with 
`--driver-mode`, not this patch which causes no test failure if you don't place 
`--driver-mode` in a default config file (which isn't a supported case).

In general I am not sure we can reasonably support placing arbitrary options 
into a default config and expect all test suite to pass.
For `--rtlib=` `--unwindlib=` `--stdlib=` etc, yeah, we currently add the 
option to fix many parameters, but it is infeasible to control all the 
variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133329

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


[clang] abbe9c5 - [clang] Use x.empty() instead of llvm::empty(x) (NFC)

2022-09-18 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-09-18T11:07:50-07:00
New Revision: abbe9c561db3abccd00936f6b2fc5a8b7b5486bb

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

LOG: [clang] Use x.empty() instead of llvm::empty(x) (NFC)

I'm planning to deprecate and eventually remove llvm::empty.

Note that no use of llvm::empty requires the ability of llvm::empty to
determine the emptiness from begin/end only.

Added: 


Modified: 
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaStmt.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index c80605ba7f5a7..c8eac7b06b652 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -1231,8 +1231,8 @@ static OverloadCompare compareOverloads(const 
CXXMethodDecl &Candidate,
 if (Candidate.parameters()[I]->getType().getCanonicalType() !=
 Incumbent.parameters()[I]->getType().getCanonicalType())
   return OverloadCompare::BothViable;
-  if (!llvm::empty(Candidate.specific_attrs()) ||
-  !llvm::empty(Incumbent.specific_attrs()))
+  if (!Candidate.specific_attrs().empty() ||
+  !Incumbent.specific_attrs().empty())
 return OverloadCompare::BothViable;
   // At this point, we know calls can't pick one or the other based on
   // arguments, so one of the two must win. (Or both fail, handled elsewhere).

diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 802e9cd8f364a..9d1f506ef5847 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1499,7 +1499,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 // If switch has default case, then ignore it.
 if (!CaseListIsErroneous && !CaseListIsIncomplete && !HasConstantCond &&
 ET && ET->getDecl()->isCompleteDefinition() &&
-!empty(ET->getDecl()->enumerators())) {
+!ET->getDecl()->enumerators().empty()) {
   const EnumDecl *ED = ET->getDecl();
   EnumValsTy EnumVals;
 



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


[PATCH] D134049: [clang-format] Disallow trailing return arrows to be operators

2022-09-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Would you like to get commit access? See 
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134049

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


[clang] 93fcc80 - [clang-format] Skip token annotation in passes that don't need it

2022-09-18 Thread via cfe-commits

Author: owenca
Date: 2022-09-18T11:19:40-07:00
New Revision: 93fcc80d1ceba3a28f1aff402a91e1a427e66688

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

LOG: [clang-format] Skip token annotation in passes that don't need it

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnalyzer.cpp
clang/lib/Format/TokenAnalyzer.h

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 8197fccd2f3e3..0327a7ccb22ea 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3273,13 +3273,13 @@ reformat(const FormatStyle &Style, StringRef Code,
 
 if (Style.InsertBraces) {
   Passes.emplace_back([&](const Environment &Env) {
-return BracesInserter(Env, Expanded).process();
+return BracesInserter(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
 if (Style.RemoveBracesLLVM) {
   Passes.emplace_back([&](const Environment &Env) {
-return BracesRemover(Env, Expanded).process();
+return BracesRemover(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
@@ -3305,7 +3305,7 @@ reformat(const FormatStyle &Style, StringRef Code,
   if (Style.isJavaScript() &&
   Style.JavaScriptQuotes != FormatStyle::JSQS_Leave) {
 Passes.emplace_back([&](const Environment &Env) {
-  return JavaScriptRequoter(Env, Expanded).process();
+  return JavaScriptRequoter(Env, 
Expanded).process(/*SkipAnnotation=*/true);
 });
   }
 

diff  --git a/clang/lib/Format/TokenAnalyzer.cpp 
b/clang/lib/Format/TokenAnalyzer.cpp
index 0a775c0a87eda..77e403581a0d5 100644
--- a/clang/lib/Format/TokenAnalyzer.cpp
+++ b/clang/lib/Format/TokenAnalyzer.cpp
@@ -97,7 +97,8 @@ TokenAnalyzer::TokenAnalyzer(const Environment &Env, const 
FormatStyle &Style)
   << "\n");
 }
 
-std::pair TokenAnalyzer::process() {
+std::pair
+TokenAnalyzer::process(bool SkipAnnotation) {
   tooling::Replacements Result;
   llvm::SpecificBumpPtrAllocator Allocator;
   IdentifierTable IdentTable(getFormattingLangOpts(Style));
@@ -121,7 +122,8 @@ std::pair 
TokenAnalyzer::process() {
 TokenAnnotator Annotator(Style, Lex.getKeywords());
 for (const UnwrappedLine &Line : Lines) {
   AnnotatedLines.push_back(new AnnotatedLine(Line));
-  Annotator.annotate(*AnnotatedLines.back());
+  if (!SkipAnnotation)
+Annotator.annotate(*AnnotatedLines.back());
 }
 
 std::pair RunResult =

diff  --git a/clang/lib/Format/TokenAnalyzer.h 
b/clang/lib/Format/TokenAnalyzer.h
index aaca518df41f3..e5cc1287c6167 100644
--- a/clang/lib/Format/TokenAnalyzer.h
+++ b/clang/lib/Format/TokenAnalyzer.h
@@ -89,7 +89,8 @@ class TokenAnalyzer : public UnwrappedLineConsumer {
 public:
   TokenAnalyzer(const Environment &Env, const FormatStyle &Style);
 
-  std::pair process();
+  std::pair
+  process(bool SkipAnnotation = false);
 
 protected:
   virtual std::pair



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


[PATCH] D134103: [clang-format] Skip token annotation in passes that don't need it

2022-09-18 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG93fcc80d1ceb: [clang-format] Skip token annotation in passes 
that don't need it (authored by owenpan).

Changed prior to commit:
  https://reviews.llvm.org/D134103?vs=460966&id=461086#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134103

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnalyzer.cpp
  clang/lib/Format/TokenAnalyzer.h


Index: clang/lib/Format/TokenAnalyzer.h
===
--- clang/lib/Format/TokenAnalyzer.h
+++ clang/lib/Format/TokenAnalyzer.h
@@ -89,7 +89,8 @@
 public:
   TokenAnalyzer(const Environment &Env, const FormatStyle &Style);
 
-  std::pair process();
+  std::pair
+  process(bool SkipAnnotation = false);
 
 protected:
   virtual std::pair
Index: clang/lib/Format/TokenAnalyzer.cpp
===
--- clang/lib/Format/TokenAnalyzer.cpp
+++ clang/lib/Format/TokenAnalyzer.cpp
@@ -97,7 +97,8 @@
   << "\n");
 }
 
-std::pair TokenAnalyzer::process() {
+std::pair
+TokenAnalyzer::process(bool SkipAnnotation) {
   tooling::Replacements Result;
   llvm::SpecificBumpPtrAllocator Allocator;
   IdentifierTable IdentTable(getFormattingLangOpts(Style));
@@ -121,7 +122,8 @@
 TokenAnnotator Annotator(Style, Lex.getKeywords());
 for (const UnwrappedLine &Line : Lines) {
   AnnotatedLines.push_back(new AnnotatedLine(Line));
-  Annotator.annotate(*AnnotatedLines.back());
+  if (!SkipAnnotation)
+Annotator.annotate(*AnnotatedLines.back());
 }
 
 std::pair RunResult =
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3273,13 +3273,13 @@
 
 if (Style.InsertBraces) {
   Passes.emplace_back([&](const Environment &Env) {
-return BracesInserter(Env, Expanded).process();
+return BracesInserter(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
 if (Style.RemoveBracesLLVM) {
   Passes.emplace_back([&](const Environment &Env) {
-return BracesRemover(Env, Expanded).process();
+return BracesRemover(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
@@ -3305,7 +3305,7 @@
   if (Style.isJavaScript() &&
   Style.JavaScriptQuotes != FormatStyle::JSQS_Leave) {
 Passes.emplace_back([&](const Environment &Env) {
-  return JavaScriptRequoter(Env, Expanded).process();
+  return JavaScriptRequoter(Env, 
Expanded).process(/*SkipAnnotation=*/true);
 });
   }
 


Index: clang/lib/Format/TokenAnalyzer.h
===
--- clang/lib/Format/TokenAnalyzer.h
+++ clang/lib/Format/TokenAnalyzer.h
@@ -89,7 +89,8 @@
 public:
   TokenAnalyzer(const Environment &Env, const FormatStyle &Style);
 
-  std::pair process();
+  std::pair
+  process(bool SkipAnnotation = false);
 
 protected:
   virtual std::pair
Index: clang/lib/Format/TokenAnalyzer.cpp
===
--- clang/lib/Format/TokenAnalyzer.cpp
+++ clang/lib/Format/TokenAnalyzer.cpp
@@ -97,7 +97,8 @@
   << "\n");
 }
 
-std::pair TokenAnalyzer::process() {
+std::pair
+TokenAnalyzer::process(bool SkipAnnotation) {
   tooling::Replacements Result;
   llvm::SpecificBumpPtrAllocator Allocator;
   IdentifierTable IdentTable(getFormattingLangOpts(Style));
@@ -121,7 +122,8 @@
 TokenAnnotator Annotator(Style, Lex.getKeywords());
 for (const UnwrappedLine &Line : Lines) {
   AnnotatedLines.push_back(new AnnotatedLine(Line));
-  Annotator.annotate(*AnnotatedLines.back());
+  if (!SkipAnnotation)
+Annotator.annotate(*AnnotatedLines.back());
 }
 
 std::pair RunResult =
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3273,13 +3273,13 @@
 
 if (Style.InsertBraces) {
   Passes.emplace_back([&](const Environment &Env) {
-return BracesInserter(Env, Expanded).process();
+return BracesInserter(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
 if (Style.RemoveBracesLLVM) {
   Passes.emplace_back([&](const Environment &Env) {
-return BracesRemover(Env, Expanded).process();
+return BracesRemover(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
@@ -3305,7 +3305,7 @@
   if (Style.isJavaScript() &&
   Style.JavaScriptQuotes != FormatStyle::JSQS_Leave) {
 Passes.emplace_back([&](const Environment &Env) {
-  return JavaScriptRequoter(Env, Expanded).process();
+  return JavaScriptRequoter(Env, Expanded).process(/*SkipAnnotation=*/true);
 });

[PATCH] D133662: [Clang] Change -ftime-trace storing path and support multiple compilation jobs

2022-09-18 Thread Mészáros Gergely via Phabricator via cfe-commits
Maetveis added a comment.

In D133662#3798276 , @jamieschmeiser 
wrote:

> I had an email exchange with @dongjunduo about this situation.  He was a GSoC 
> student that @Whitney and I were mentoring for the past summer.  He agrees 
> that your approach is cleaner.  There appears to be two parts to your work.  
> First, you implemented the determining and passing of the options 
> differently, and secondly, you improved the handling of off-loading and 
> system specific file handling.  Based on your earlier response, we proposed 
> to him the following and he agrees that it seems appropriate.  Could you 
> please add comments to https://reviews.llvm.org/D131469 and he will work with 
> you to change his code to reflect searching for -o and using the virtual 
> functions.  Then, if @MaskRay agrees, he can land his code and finish up his 
> GSoC work.  You can then add your extensions of off-loading and 
> file-handling.  Is this acceptable to you?

Yes, I can gladly do that.

I'm sorry for the confusion this must have caused for you and @dongjunduo, my 
intention was not judgment on the code he posted, rather seeing his code 
motivated me to post my own changes, that I've been working on beforehand., 
Some of his code gave me the right ideas, so I'm happy to share the credit for 
it. Let's make this contribution better together!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133662

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


[PATCH] D133329: [Driver] Add --gcc-install-dir=

2022-09-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I think you misunderstood me. The aforementioned tests fail if I put 
`--gcc-install-dir=` in the config file. There is no way to put it in the 
config file that wouldn't affect these tests right now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133329

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


[PATCH] D133052: [clang] Avoid crash when expanding conversion templates in concepts.

2022-09-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D133052#3792121 , @ilya-biryukov 
wrote:

> It seems wrong to change semantics of initialization when instantiating 
> concept requirements. It implies that semantic checking may behave 
> differently inside requires expressions, this is a red flag.
> Clang has a mechanism 
> 
>  to prevent recursion when considering user-defined conversion for copy 
> initialization.
>
> Currently the intention of the Clang code path that handles this case is to:
>
> 1. Deduce `TO` to be `Deferred`
> 2. Try to check `Numeric`,
> 3. Check conversions during overload resolution for `foo(a)`. Go to step 1, 
> 
> 4.  Check 
> 
>  that conversion operator converts the type to itself and mark the candidate 
> as failed.
>
> If move the check in step 4 to happen before step 3 (even if we need to 
> duplicate the check), we will get the desired semantics.
>
> Does that look reasonable?

I think the direction we sould go is not to keep this "semantics" (I'm not sure 
it should be regarded as semantics because the standard wording does not 
describe any language-level behavior, instead, just say the constructor should 
not be used in certain cases).  Because the bug report and user experience are 
that this behavior is surprising and no references in the language require it 
so it is hard to reason about. I guess that's the reason the original 
implementation describe it as a "workaround". I'd only consider this workaround 
(i.e, hoist an certain overload resolution rule to avoid recursion) if you're 
blocked by this and needs a quick fix.

Ideally, I think we should implement this copy elision elsewhere like CodGen to 
avoid this unexpected semantic (conversion functions become candidate).

> Clang will currently cut this out because the template instantiation depth is 
> too high, whereas GCC will provide a useful diagnostics that says concept 
> satisfaction computation is recursive.
> We probably want a more informative error message too. Probably worth 
> investigating separately from that particular change.

Agreed. That requires either walking or maintaining extra states in the 
template instantiation stack and detects cycle, which would make this patch 
unnecessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133052

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


[PATCH] D132990: [Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()

2022-09-18 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 461088.
shafik marked an inline comment as done.
shafik added a comment.

- Update wording in release note.


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

https://reviews.llvm.org/D132990

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaTemplate/gh57362.cpp
  clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp


Index: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wpre-c++17-compat %s
+
+template  // expected-warning {{non-type template parameters 
declared with 'decltype(auto)' are incompatible with C++ standards before 
C++17}}
+struct B{};
+
+template  // expected-warning {{non-type template parameters declared 
with 'auto' are incompatible with C++ standards before C++17}}
+struct A{};
Index: clang/test/SemaTemplate/gh57362.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/gh57362.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -Wpre-c++17-compat %s
+// expected-no-diagnostics
+
+namespace GH57362 {
+template 
+class TemplateClass {};
+
+template  // ok, no diagnostic expected
+void func() {}
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1531,11 +1531,11 @@
 
   CheckValidDeclSpecifiers();
 
-  if (TInfo->getType()->isUndeducedType()) {
-Diag(D.getIdentifierLoc(),
- diag::warn_cxx14_compat_template_nontype_parm_auto_type)
-  << QualType(TInfo->getType()->getContainedAutoType(), 0);
-  }
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);
 
   assert(S->isTemplateParamScope() &&
  "Non-type template parameter not in template parameter scope!");
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -146,6 +146,11 @@
 - A SubstTemplateTypeParmType can now represent the pack index for a
   substitution from an expanded pack.
   `Issue 56099 `_
+- Fix `-Wpre-c++17-compat` crashing Clang when compiling C++20 code which
+  contains deduced template specializations. This Fixes
+  `Issue 57369 `_
+  `Issue 57643 `_
+  `Issue 57793 `_
 
 
 Improvements to Clang's diagnostics


Index: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wpre-c++17-compat %s
+
+template  // expected-warning {{non-type template parameters declared with 'decltype(auto)' are incompatible with C++ standards before C++17}}
+struct B{};
+
+template  // expected-warning {{non-type template parameters declared with 'auto' are incompatible with C++ standards before C++17}}
+struct A{};
Index: clang/test/SemaTemplate/gh57362.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/gh57362.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -Wpre-c++17-compat %s
+// expected-no-diagnostics
+
+namespace GH57362 {
+template 
+class TemplateClass {};
+
+template  // ok, no diagnostic expected
+void func() {}
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1531,11 +1531,11 @@
 
   CheckValidDeclSpecifiers();
 
-  if (TInfo->getType()->isUndeducedType()) {
-Diag(D.getIdentifierLoc(),
- diag::warn_cxx14_compat_template_nontype_parm_auto_type)
-  << QualType(TInfo->getType()->getContainedAutoType(), 0);
-  }
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);
 
   assert(S->isTemplateParamScope() &&
  "Non-type template parameter not in template parameter scope!");
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/Release

[PATCH] D134049: [clang-format] Disallow trailing return arrows to be operators

2022-09-18 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added a comment.

In D134049#3798366 , @owenpan wrote:

> Would you like to get commit access? See 
> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.

I must humbly say that I do not think I qualify under "a track record of 
submitting high quality patches", I've only done incidental bug fixes that are 
in easily approachable places. Do you disagree with my self-assessment? (I also 
understand that I've made lots of extremely tiny patches that are probably a 
little annoying to manage)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134049

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


[clang] f8a37a6 - [Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()

2022-09-18 Thread Shafik Yaghmour via cfe-commits

Author: Shafik Yaghmour
Date: 2022-09-18T11:54:32-07:00
New Revision: f8a37a6ce67470f9f6b3a4dacb65c637c2958b8d

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

LOG: [Clang] Fix compat diagnostic to detect a nontype template parameter has a 
placeholder type using getContainedAutoType()

Based on the changes introduced by 15361a21e01026e74cb17011b702c7d1c881ae94 it
looks like C++17 compatibility diagnostic should have been checking
getContainedAutoType().

This fixes: https://github.com/llvm/llvm-project/issues/57369
  https://github.com/llvm/llvm-project/issues/57643
  https://github.com/llvm/llvm-project/issues/57793

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

Added: 
clang/test/SemaTemplate/gh57362.cpp
clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplate.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 403d50b1c9d47..035536d18d9b8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -146,6 +146,11 @@ Bug Fixes
 - A SubstTemplateTypeParmType can now represent the pack index for a
   substitution from an expanded pack.
   `Issue 56099 `_
+- Fix `-Wpre-c++17-compat` crashing Clang when compiling C++20 code which
+  contains deduced template specializations. This Fixes
+  `Issue 57369 `_
+  `Issue 57643 `_
+  `Issue 57793 `_
 
 
 Improvements to Clang's diagnostics

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 6e565ebf6..adca91b0ae63e 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1531,11 +1531,11 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope 
*S, Declarator &D,
 
   CheckValidDeclSpecifiers();
 
-  if (TInfo->getType()->isUndeducedType()) {
-Diag(D.getIdentifierLoc(),
- diag::warn_cxx14_compat_template_nontype_parm_auto_type)
-  << QualType(TInfo->getType()->getContainedAutoType(), 0);
-  }
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);
 
   assert(S->isTemplateParamScope() &&
  "Non-type template parameter not in template parameter scope!");

diff  --git a/clang/test/SemaTemplate/gh57362.cpp 
b/clang/test/SemaTemplate/gh57362.cpp
new file mode 100644
index 0..87bd8da0a91da
--- /dev/null
+++ b/clang/test/SemaTemplate/gh57362.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -Wpre-c++17-compat %s
+// expected-no-diagnostics
+
+namespace GH57362 {
+template 
+class TemplateClass {};
+
+template  // ok, no diagnostic expected
+void func() {}
+}

diff  --git a/clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp 
b/clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
new file mode 100644
index 0..6afe143d7c30a
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wpre-c++17-compat %s
+
+template  // expected-warning {{non-type template parameters 
declared with 'decltype(auto)' are incompatible with C++ standards before 
C++17}}
+struct B{};
+
+template  // expected-warning {{non-type template parameters declared 
with 'auto' are incompatible with C++ standards before C++17}}
+struct A{};



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


[PATCH] D132990: [Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()

2022-09-18 Thread Shafik Yaghmour via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8a37a6ce674: [Clang] Fix compat diagnostic to detect a 
nontype template parameter has a… (authored by shafik).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132990

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaTemplate/gh57362.cpp
  clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp


Index: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wpre-c++17-compat %s
+
+template  // expected-warning {{non-type template parameters 
declared with 'decltype(auto)' are incompatible with C++ standards before 
C++17}}
+struct B{};
+
+template  // expected-warning {{non-type template parameters declared 
with 'auto' are incompatible with C++ standards before C++17}}
+struct A{};
Index: clang/test/SemaTemplate/gh57362.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/gh57362.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -Wpre-c++17-compat %s
+// expected-no-diagnostics
+
+namespace GH57362 {
+template 
+class TemplateClass {};
+
+template  // ok, no diagnostic expected
+void func() {}
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1531,11 +1531,11 @@
 
   CheckValidDeclSpecifiers();
 
-  if (TInfo->getType()->isUndeducedType()) {
-Diag(D.getIdentifierLoc(),
- diag::warn_cxx14_compat_template_nontype_parm_auto_type)
-  << QualType(TInfo->getType()->getContainedAutoType(), 0);
-  }
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);
 
   assert(S->isTemplateParamScope() &&
  "Non-type template parameter not in template parameter scope!");
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -146,6 +146,11 @@
 - A SubstTemplateTypeParmType can now represent the pack index for a
   substitution from an expanded pack.
   `Issue 56099 `_
+- Fix `-Wpre-c++17-compat` crashing Clang when compiling C++20 code which
+  contains deduced template specializations. This Fixes
+  `Issue 57369 `_
+  `Issue 57643 `_
+  `Issue 57793 `_
 
 
 Improvements to Clang's diagnostics


Index: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wpre-c++17-compat %s
+
+template  // expected-warning {{non-type template parameters declared with 'decltype(auto)' are incompatible with C++ standards before C++17}}
+struct B{};
+
+template  // expected-warning {{non-type template parameters declared with 'auto' are incompatible with C++ standards before C++17}}
+struct A{};
Index: clang/test/SemaTemplate/gh57362.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/gh57362.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -Wpre-c++17-compat %s
+// expected-no-diagnostics
+
+namespace GH57362 {
+template 
+class TemplateClass {};
+
+template  // ok, no diagnostic expected
+void func() {}
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1531,11 +1531,11 @@
 
   CheckValidDeclSpecifiers();
 
-  if (TInfo->getType()->isUndeducedType()) {
-Diag(D.getIdentifierLoc(),
- diag::warn_cxx14_compat_template_nontype_parm_auto_type)
-  << QualType(TInfo->getType()->getContainedAutoType(), 0);
-  }
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);
 
   assert(S->isTemplateParamScope() &&
  "Non

[PATCH] D134049: [clang-format] Disallow trailing return arrows to be operators

2022-09-18 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D134049#3798389 , @rymiel wrote:

> In D134049#3798366 , @owenpan wrote:
>
>> Would you like to get commit access? See 
>> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.
>
> I must humbly say that I do not think I qualify under "a track record of 
> submitting high quality patches", I've only done incidental bug fixes that 
> are in easily approachable places. Do you disagree with my self-assessment? 
> (I also understand that I've made lots of extremely tiny patches that are 
> probably a little annoying to manage)

Yes you do, I had far less when I got my commit access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134049

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-18 Thread Mészáros Gergely via Phabricator via cfe-commits
Maetveis requested changes to this revision.
Maetveis added a comment.

As discussed with @jamieschmeiser on D133662 
, I have left suggestions regarding the 
approach I took for handling `-o` and passing the option to the jobs.

I'm really happy to see this area getting attention, and I'm sorry for the 
confusion I must have caused.




Comment at: clang/lib/Driver/Driver.cpp:4531-4548
+// Get linking executable file's parent path as TracePath's parent path,
+// default is ".". Filename may be determined and added into TracePath 
then.
+//
+// e.g. executable file's path: /usr/local/a.out
+//  its parent's path:  /usr/local
+for (auto &J : C.getJobs()) {
+  if (J.getSource().getKind() == Action::LinkJobClass) {

Instead of looking for linking jobs, to determine the folder to store the 
traces, you could use the output location from `-o ` (if specified).
This is already available in `Driver::BuildJobs` as `FinalOutput` (see on line 
4605), it will be `nullptr` if no `-o` option was given.



Comment at: clang/lib/Driver/Driver.cpp:4552-4596
+  // Add or replace the modified -ftime-trace=` to all clang jobs
+  for (auto &J : C.getJobs()) {
+if (J.getSource().getKind() == Action::AssembleJobClass ||
+J.getSource().getKind() == Action::BackendJobClass ||
+J.getSource().getKind() == Action::CompileJobClass) {
+  SmallString<128> TracePathReal = TracePath;
+  SmallString<128> OutputPath(J.getOutputFilenames()[0].c_str());

Instead of rewriting job command lines after they have been created, I think it 
would be cleaner split handling of `-ftime-trace` to two parts:
- Infer the folder where the traces are stored
- For each job that supports time trace, communicate the path of where it 
should be stored to it, so it can be used during building the command line.

For the first I think this function is already fine together with the other 
suggestions, but it must be called before job command lines are created i.e. 
before `BuildJobsForAction` is called.

The inferred folder will have to be stored to be used for building the final 
json locations, In my changes I have stored it as a member in `Compilation`. 
Ultimately it would be used in `BuildJobsForActionNoCache` called by 
`BuildJobsForAction` so it could also be passed through as a function argument.

Then `Tool`s (initially this should be just Clang) which support 
`-ftime-trace`, can signal it using a method added to `Tool` (Tools already 
provide all kinds of information about themselves through their interface.)

If such a tool is selected during building a job for an action 
(`BuildJobsForActionNoCache` after `Tool` has been selected), then the location 
should be prepared and communicated to it. In my patch I have again used a 
member in `Compilation` for this as it's already part of the interface, but 
this feels at least a little bit hacky, so if you or the other reviewers have 
better ideas. then go for it.

Based on the discussion on D133662, we want to keep this patch to the basic 
functionality to be extended later, so It should be fine to select the file 
names based on the output names. In `BuildJobsForActionNoCache` that is 
available as `Result`, you could use it with the logic you already have in the 
current second part of `inferTimeTracePath`.



Comment at: clang/lib/Driver/Driver.cpp:4562-4564
+  // /xxx/yyy.o => /xxx/yyy.json
+  llvm::sys::path::replace_extension(OutputPath, "json");
+  arg += OutputPath;

I think it would be better to fallback to the current working directory instead 
of the location of the object file.
- It is consistent with e.g. if no `-o` is given then the executable will be 
stored to `a.out` in the current working directory.
- It is a more discoverable location for users than the object file, which is 
often in `/temp`, when multiple jobs are involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D134143: [clang] Misc type sugar preservation improvements

2022-09-18 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a project: All.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

WIP - Not ready for review

Missing standalone tests.

Signed-off-by: Matheus Izvekov 

Depends on D134115 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134143

Files:
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp

Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -9138,6 +9138,56 @@
   return Context.getTypeOfExprType(E);
 }
 
+static QualType getSameReferencedType(ASTContext &Context, QualType VT,
+  QualType ET) {
+  assert(!ET->isReferenceType());
+  if (const auto *VTL = VT->getAs())
+ET = Context.getLValueReferenceType(ET, VTL->isSpelledAsLValue());
+  else if (VT->isRValueReferenceType())
+ET = Context.getRValueReferenceType(ET);
+
+  if (!Context.hasSameUnqualifiedType(ET, VT)) {
+ET.dump();
+VT.dump();
+assert(false && "!hasSameUnqualifiedType");
+  }
+
+  Qualifiers ToAdd = VT.getQualifiers(), ToRemove = ET.getQualifiers();
+  (void)Qualifiers::removeCommonQualifiers(ToAdd, ToRemove);
+
+  SplitQualType Split = ET.split();
+  while (!ToRemove.empty()) {
+(void)Qualifiers::removeCommonQualifiers(Split.Quals, ToRemove);
+if (ToRemove.empty())
+  break;
+QualType Next;
+switch (ET->getTypeClass()) {
+#define ABSTRACT_TYPE(Class, Parent)
+#define TYPE(Class, Parent)\
+  case Type::Class: {  \
+const auto *ty = cast(ET);\
+if (!ty->isSugared())  \
+  goto done;   \
+Next = ty->desugar();  \
+break; \
+  }
+#include "clang/AST/TypeNodes.inc"
+}
+Split = Next.split();
+  }
+done:
+  assert(ToRemove.empty());
+  Split.Quals += ToAdd;
+  ET = Context.getQualifiedType(Split);
+
+  if (!Context.hasSameType(ET, VT)) {
+ET.dump();
+VT.dump();
+assert(false && "!hasSameType");
+  }
+  return ET;
+}
+
 /// getDecltypeForExpr - Given an expr, will return the decltype for
 /// that expression, according to the rules in C++11
 /// [dcl.type.simple]p4 and C++11 [expr.lambda.prim]p18.
@@ -9170,18 +9220,20 @@
   // We apply the same rules for Objective-C ivar and property references.
   if (const auto *DRE = dyn_cast(IDExpr)) {
 const ValueDecl *VD = DRE->getDecl();
-QualType T = VD->getType();
+QualType T = getSameReferencedType(Context, VD->getType(), DRE->getType());
 return isa(VD) ? T.getUnqualifiedType() : T;
   }
   if (const auto *ME = dyn_cast(IDExpr)) {
 if (const auto *VD = ME->getMemberDecl())
   if (isa(VD) || isa(VD))
-return VD->getType();
+return getSameReferencedType(Context, VD->getType(), ME->getType());
   } else if (const auto *IR = dyn_cast(IDExpr)) {
+// FIXME: Sugar these. Breaks Modules/odr_hash.mm.
 return IR->getDecl()->getType();
   } else if (const auto *PR = dyn_cast(IDExpr)) {
 if (PR->isExplicitProperty())
-  return PR->getExplicitProperty()->getType();
+  return getSameReferencedType(
+  Context, PR->getExplicitProperty()->getType(), PR->getType());
   } else if (const auto *PE = dyn_cast(IDExpr)) {
 return PE->getType();
   }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14375,8 +14375,24 @@
 if (isa(MD))
   Diag(OpLoc, diag::err_typecheck_addrof_dtor) << op->getSourceRange();
 
-QualType MPTy = Context.getMemberPointerType(
-op->getType(), Context.getTypeDeclType(MD->getParent()).getTypePtr());
+const CXXRecordDecl *Cls = MD->getParent();
+const Type *ClsType = nullptr;
+if (const NestedNameSpecifier *NNS = DRE->getQualifier()) {
+  const Type *Type = NNS->getAsType();
+  const CXXRecordDecl *ClsAsWritten =
+  Type ? Type->getAsCXXRecordDecl() : NNS->getAsRecordDecl();
+  assert(ClsAsWritten != nullptr);
+  if (declaresSameEntity(Cls, ClsAsWritten))
+ClsType =
+Type ? Type : Context.getTypeDeclType(ClsAsWritten).getTypePtr();
+  else
+// FIXME: Can we do better here?
+assert(ClsAsWritten->isDerivedFrom(Cls));
+}
+if (!ClsType)
+  ClsType = Context.getTypeDeclType(Cls).getTypePtr();
+
+QualType MPTy = Context.getMemberPointerType(op->getType(), ClsType);
 // Under the MS ABI, lock down the inherit

[PATCH] D134127: [ARM] Check target feature support for __builtin_arm_crc*

2022-09-18 Thread Dave Green via Phabricator via cfe-commits
dmgreen added reviewers: danielkiss, ilinpv.
dmgreen added a comment.

This looks like a subset of D133359 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134127

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


[PATCH] D134145: [Clang] Implement fix for DR2628

2022-09-18 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Implement suggested fix for DR2628. Coulnd't update the DR docs because there 
hasn't been a new DRs index, but the tests still run.

Note: I only transfer the constructor constraints, not the struct constraints. 
I think that's OK because the struct constraints are the same
for all constructors so they don't affect the overload resolution, and if they 
deduce to something that doesn't pass the constraints
we catch it anyway. So that should be more efficient without (hopefully) 
sacrificing correctness.

Closes:
https://github.com/llvm/llvm-project/issues/57646
https://github.com/llvm/llvm-project/issues/43829


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134145

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/drs/dr26xx.cpp


Index: clang/test/CXX/drs/dr26xx.cpp
===
--- /dev/null
+++ clang/test/CXX/drs/dr26xx.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify
+
+namespace dr2628 { // dr2628: yes
+
+template 
+struct foo {
+  constexpr foo() requires (!A && !B) = delete; // expected-note {{marked 
deleted here}}
+  constexpr foo() requires (A || B) = delete;
+};
+
+void f() {
+  foo fooable; // expected-error {{call to deleted}}
+}
+
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2445,6 +2445,8 @@
   TInfo->getType(), TInfo, LocEnd, Ctor);
 Guide->setImplicit();
 Guide->setParams(Params);
+if (Ctor && Ctor->getTrailingRequiresClause())
+  Guide->setTrailingRequiresClause(Ctor->getTrailingRequiresClause());
 
 for (auto *Param : Params)
   Param->setDeclContext(Guide);


Index: clang/test/CXX/drs/dr26xx.cpp
===
--- /dev/null
+++ clang/test/CXX/drs/dr26xx.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify
+
+namespace dr2628 { // dr2628: yes
+
+template 
+struct foo {
+  constexpr foo() requires (!A && !B) = delete; // expected-note {{marked deleted here}}
+  constexpr foo() requires (A || B) = delete;
+};
+
+void f() {
+  foo fooable; // expected-error {{call to deleted}}
+}
+
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2445,6 +2445,8 @@
   TInfo->getType(), TInfo, LocEnd, Ctor);
 Guide->setImplicit();
 Guide->setParams(Params);
+if (Ctor && Ctor->getTrailingRequiresClause())
+  Guide->setTrailingRequiresClause(Ctor->getTrailingRequiresClause());
 
 for (auto *Param : Params)
   Param->setDeclContext(Guide);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134049: [clang-format] Disallow trailing return arrows to be operators

2022-09-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D134049#3798389 , @rymiel wrote:

> In D134049#3798366 , @owenpan wrote:
>
>> Would you like to get commit access? See 
>> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.
>
> I must humbly say that I do not think I qualify under "a track record of 
> submitting high quality patches", I've only done incidental bug fixes that 
> are in easily approachable places. Do you disagree with my self-assessment?

I think you should have commit access based on the patches you have submitted 
and wouldn't have asked otherwise.

> (I also understand that I've made lots of extremely tiny patches that are 
> probably a little annoying to manage)

Tiny patches, when appropriate, are actually more manageable. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134049

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


[PATCH] D134146: [clang-format] Update removed brace's next token's WhitespaceRange

2022-09-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, curdeius.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134146

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -26006,6 +26006,17 @@
"}",
Style);
 
+  verifyFormat("while (0)\n"
+   "  if (a)\n"
+   "return b;\n"
+   "return a;",
+   "while (0) {\n"
+   "  if (a) {\n"
+   "return b;\n"
+   "}}\n"
+   "return a;",
+   Style);
+
   Style.ColumnLimit = 65;
   verifyFormat("if (condition) {\n"
"  ff(Indices,\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1918,10 +1918,13 @@
 assert(Next || Token == Line->Last);
 if (!Next && NextLine)
   Next = NextLine->First;
-const auto Start =
-Next && Next->NewlinesBefore == 0 && Next->isNot(tok::eof)
-? Token->Tok.getLocation()
-: Token->WhitespaceRange.getBegin();
+SourceLocation Start;
+if (Next && Next->NewlinesBefore == 0 && Next->isNot(tok::eof)) {
+  Start = Token->Tok.getLocation();
+  Next->WhitespaceRange = Token->WhitespaceRange;
+} else {
+  Start = Token->WhitespaceRange.getBegin();
+}
 const auto Range =
 CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
 cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -26006,6 +26006,17 @@
"}",
Style);
 
+  verifyFormat("while (0)\n"
+   "  if (a)\n"
+   "return b;\n"
+   "return a;",
+   "while (0) {\n"
+   "  if (a) {\n"
+   "return b;\n"
+   "}}\n"
+   "return a;",
+   Style);
+
   Style.ColumnLimit = 65;
   verifyFormat("if (condition) {\n"
"  ff(Indices,\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1918,10 +1918,13 @@
 assert(Next || Token == Line->Last);
 if (!Next && NextLine)
   Next = NextLine->First;
-const auto Start =
-Next && Next->NewlinesBefore == 0 && Next->isNot(tok::eof)
-? Token->Tok.getLocation()
-: Token->WhitespaceRange.getBegin();
+SourceLocation Start;
+if (Next && Next->NewlinesBefore == 0 && Next->isNot(tok::eof)) {
+  Start = Token->Tok.getLocation();
+  Next->WhitespaceRange = Token->WhitespaceRange;
+} else {
+  Start = Token->WhitespaceRange.getBegin();
+}
 const auto Range =
 CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
 cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134136: [Clang] Support constexpr for builtin fmax, fmin, ilogb, logb, scalbn

2022-09-18 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: llvm/lib/Support/APFloat.cpp:4206
+  else if (Arg.isZero())
+Result.makeInf(/* Negative = */ true);
+  else if (Arg.isInfinity())

This is the format as documented by clang-tidy bugprone argument comment see 
here: 
https://clang.llvm.org/extra/clang-tidy/checks/bugprone/argument-comment.html

IIRC it depends on strict mode but I would just avoid the whitespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134136

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


[PATCH] D133737: [HLSL] [clang] Add vector version of abs for HLSL

2022-09-18 Thread Xiang Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGedbf36c5e9e8: [HLSL] [clang] Add vector version of abs for 
HLSL (authored by python3kgae).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133737

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/abs.hlsl

Index: clang/test/CodeGenHLSL/builtins/abs.hlsl
===
--- clang/test/CodeGenHLSL/builtins/abs.hlsl
+++ clang/test/CodeGenHLSL/builtins/abs.hlsl
@@ -1,57 +1,138 @@
 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
-// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefix=NO_HALF
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
 
 
-float abs_float(float X) {
-  return abs(X);
+// CHECK: define noundef signext i16 @
+// FIXME: int16_t is promoted to i32 now. Change to abs.i16 once it is fixed.
+// CHECK: call i32 @llvm.abs.i32(
+int16_t test_abs_int16_t ( int16_t p0 ) {
+  return abs ( p0 );
 }
-
-// CHECK: define noundef float @"?abs_float@@YAMM@Z"(
-// CHECK: call float @llvm.fabs.f32(float %0)
-
-double abs_double(double X) {
-  return abs(X);
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.abs.v2i16(
+int16_t2 test_abs_int16_t2 ( int16_t2 p0 ) {
+  return abs ( p0 );
 }
-
-// CHECK: define noundef double @"?abs_double@@YANN@Z"(
-// CHECK: call double @llvm.fabs.f64(double %0)
-
-half abs_half(half X) {
-  return abs(X);
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.abs.v3i16(
+int16_t3 test_abs_int16_t3 ( int16_t3 p0 ) {
+  return abs ( p0 );
 }
-
-// CHECK: define noundef half @"?abs_half@@YA$f16@$f16@@Z"(
-// CHECK: call half @llvm.fabs.f16(half %0)
-// NO_HALF: define noundef float @"?abs_half@@YA$halff@$halff@@Z"(
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.abs.v4i16(
+int16_t4 test_abs_int16_t4 ( int16_t4 p0 ) {
+  return abs ( p0 );
+}
+// CHECK: define noundef half @
+// CHECK: call half @llvm.fabs.f16(
+// NO_HALF: define noundef float @"?test_abs_half@@YA$halff@$halff@@Z"(
 // NO_HALF: call float @llvm.fabs.f32(float %0)
-
-int abs_int(int X) {
-  return abs(X);
+half test_abs_half ( half p0 ) {
+  return abs ( p0 );
 }
-
-// NO_HALF: define noundef i32 @"?abs_int@@YAHH@Z"(i32
-// CHECK: define noundef i32 @"?abs_int@@YAHH@Z"(i32
-// CHECK: [[A_ADDR:%.*]] = alloca i32, align 4
-// CHECK-NEXT:store i32 [[A:%.*]], ptr [[A_ADDR]], align 4
-// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
-// CHECK-NEXT:[[NEG:%.*]] = sub nsw i32 0, [[TMP0]]
-// CHECK-NEXT:[[ABSCOND:%.*]] = icmp slt i32 [[TMP0]], 0
-// CHECK-NEXT:[[ABS:%.*]] = select i1 [[ABSCOND]], i32 [[NEG]], i32 [[TMP0]]
-// CHECK-NEXT:ret i32 [[ABS]]
-
-int64_t abs_int64(int64_t X) {
-  return abs(X);
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.fabs.v2f16(
+// NO_HALF: define noundef <2 x float> @"?test_abs_half2@@YAT?$__vector@$halff@$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x float> @llvm.fabs.v2f32(
+half2 test_abs_half2 ( half2 p0 ) {
+  return abs ( p0 );
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.fabs.v3f16(
+// NO_HALF: define noundef <3 x float> @"?test_abs_half3@@YAT?$__vector@$halff@$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x float> @llvm.fabs.v3f32(
+half3 test_abs_half3 ( half3 p0 ) {
+  return abs ( p0 );
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.fabs.v4f16(
+// NO_HALF: define noundef <4 x float> @"?test_abs_half4@@YAT?$__vector@$halff@$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x float> @llvm.fabs.v4f32(
+half4 test_abs_half4 ( half4 p0 ) {
+  return abs ( p0 );
+}
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.abs.i32(
+// NO_HALF: define noundef i32 @"?test_abs_int@@YAHH@Z"
+int test_abs_int ( int p0 ) {
+  return abs ( p0 );
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.abs.v2i32(
+int2 test_abs_int2 ( int2 p0 ) {
+  return abs ( p0 );
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.abs.v3i32(
+int3 test_abs_int3 ( int3 p0 ) {
+  return abs ( p0 );
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.abs.v4i32(
+int4 test_abs_int4 ( int4 p0 ) {
+  return abs ( p0 );
+}
+// CHECK: define noundef float @
+// CHECK: call float @llvm.fabs.f32(
+float test_abs_float ( float p0 ) {
+  return abs ( p0 );
+}
+// CHECK: define noundef <2 x float> @
+// CHEC

[clang] edbf36c - [HLSL] [clang] Add vector version of abs for HLSL

2022-09-18 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-09-18T14:59:30-07:00
New Revision: edbf36c5e9e84bb0e70ddbcacc20b14217688cba

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

LOG: [HLSL] [clang] Add vector version of abs for HLSL

Add vector version of abs as
```
__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
int2 abs (int2 );
__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
int3 abs (int3 );
```
To make this work.
Allowed custom type checking builtins to be recelareable.

Reviewed By: RKSimon

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/Headers/hlsl/hlsl_intrinsics.h
clang/test/CodeGenHLSL/builtins/abs.hlsl

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 387a782c4b792..ab141789416ca 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -9050,6 +9050,10 @@ TypedefDecl *ASTContext::getBuiltinMSVaListDecl() const {
 }
 
 bool ASTContext::canBuiltinBeRedeclared(const FunctionDecl *FD) const {
+  // Allow redecl custom type checking builtin for HLSL.
+  if (LangOpts.HLSL && FD->getBuiltinID() != Builtin::NotBuiltin &&
+  BuiltinInfo.hasCustomTypechecking(FD->getBuiltinID()))
+return true;
   return BuiltinInfo.canBeRedeclared(FD->getBuiltinID());
 }
 

diff  --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index ab1aa74a4c5de..02db79a2bc37d 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -13,13 +13,51 @@ __attribute__((availability(shadermodel, introduced = 6.0)))
 __attribute__((clang_builtin_alias(__builtin_hlsl_wave_active_count_bits))) 
uint
 WaveActiveCountBits(bool bBit);
 
-__attribute__((clang_builtin_alias(__builtin_abs))) int abs(int In);
-__attribute__((clang_builtin_alias(__builtin_labs))) int64_t abs(int64_t In);
-__attribute__((clang_builtin_alias(__builtin_fabsf))) float abs(float In);
-__attribute__((clang_builtin_alias(__builtin_fabs))) double abs(double In);
-
 #ifdef __HLSL_ENABLE_16_BIT
-__attribute__((clang_builtin_alias(__builtin_fabsf16))) half abs(half In);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+int16_t abs(int16_t);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+int16_t2 abs(int16_t2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+int16_t3 abs(int16_t3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+int16_t4 abs(int16_t4);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs))) half abs(half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+half2 abs(half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+half3 abs(half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+half4 abs(half4);
 #endif
 
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs))) int abs(int);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs))) int2 abs(int2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs))) int3 abs(int3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs))) int4 abs(int4);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs))) float
+abs(float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+float2 abs(float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+float3 abs(float3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+float4 abs(float4);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+int64_t abs(int64_t);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+int64_t2 abs(int64_t2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+int64_t3 abs(int64_t3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+int64_t4 abs(int64_t4);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs))) double
+abs(double);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+double2 abs(double2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+double3 abs(double3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
+double4 abs(double4);
+
 #endif //_HLSL_HLSL_INTRINSICS_H_

diff  --git a/clang/test/CodeGenHLSL/builtins/abs.hlsl 
b/clang/test/CodeGenHLSL/builtins/abs.hlsl
index 6578475f40170..30b0bcb8837ca 100644
--- a/clang/test/CodeGenHLSL/builtins/abs.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/abs.hlsl
@@ -1,57 +1,138 @@
 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
-// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+// RUN:   -

[PATCH] D134049: [clang-format] Disallow trailing return arrows to be operators

2022-09-18 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added a comment.

Thank you for the vote of confidence!! It went way more quickly than I 
expected; I now already have commit access!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134049

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


[clang] 0bf63f0 - [clang-format] Disallow trailing return arrows to be operators

2022-09-18 Thread Emilia Dreamer via cfe-commits

Author: Emilia Dreamer
Date: 2022-09-19T04:04:31+03:00
New Revision: 0bf63f0d1b6b860a7134d668d3a28104c5c9afc1

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

LOG: [clang-format] Disallow trailing return arrows to be operators

In the following construction:
`template  requires Foo || Bar auto func() -> int;`

The `->` of the trailing return type was actually considered as an
operator as part of the binary operation in the requires clause, with
the precedence level of `PrecedenceArrowAndPeriod`, leading to fake
parens being inserted in strange locations, that would never be closed.

Fixes one part of https://github.com/llvm/llvm-project/issues/56213
(the rest will probably be in a separate patch)

Reviewed By: HazardyKnusperkeks, owenpan

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index d18adc308efb0..a81bbb99f5d9e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2611,8 +2611,10 @@ class ExpressionParser {
   }
   if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
 return Current->getPrecedence();
-  if (Current->isOneOf(tok::period, tok::arrow))
+  if (Current->isOneOf(tok::period, tok::arrow) &&
+  Current->isNot(TT_TrailingReturnArrow)) {
 return PrecedenceArrowAndPeriod;
+  }
   if ((Style.Language == FormatStyle::LK_Java || Style.isJavaScript()) &&
   Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements,
Keywords.kw_throws)) {

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 1fe8bece722c4..f3007f85e91b0 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -440,6 +440,15 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsRequiresClausesAndConcepts) {
   ASSERT_EQ(Tokens.size(), 18u) << Tokens;
   EXPECT_TOKEN(Tokens[11], tok::kw_requires, TT_RequiresClause);
 
+  Tokens = annotate("template \n"
+"requires Bar || Baz\n"
+"auto foo(T) -> int;");
+  ASSERT_EQ(Tokens.size(), 24u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
+  EXPECT_EQ(Tokens[11]->FakeLParens.size(), 0u);
+  EXPECT_TRUE(Tokens[14]->ClosesRequiresClause);
+  EXPECT_TOKEN(Tokens[20], tok::arrow, TT_TrailingReturnArrow);
+
   Tokens = annotate("template \n"
 "struct S {\n"
 "  void foo() const requires Bar;\n"



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


[clang] 8dab452 - [clang-format] Disallow requires clauses to become function declarations

2022-09-18 Thread Emilia Dreamer via cfe-commits

Author: Emilia Dreamer
Date: 2022-09-19T04:04:31+03:00
New Revision: 8dab452740007e03c963b349e716068eac2b25a0

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

LOG: [clang-format] Disallow requires clauses to become function declarations

There already exists logic to disallow requires *expressions* to be
treated as function declarations, but this expands it to include
requires *clauses*, when they happen to also be parenthesized.

Previously, in the following case:

```
template 
  requires(Foo)
T foo();
```

The line with the requires clause was actually being considered as the
line with the function declaration due to the parentheses, and the
*real* function declaration on the next line became a trailing
annotation

(Together with https://reviews.llvm.org/D134049) Fixes 
https://github.com/llvm/llvm-project/issues/56213

Reviewed By: HazardyKnusperkeks, owenpan

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index a81bbb99f5d9e..e530120fa4454 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1110,7 +1110,7 @@ class AnnotatingParser {
   !Contexts.back().IsExpression && !Line.startsWith(TT_ObjCProperty) &&
   !Tok->isOneOf(TT_TypeDeclarationParen, TT_RequiresExpressionLParen) 
&&
   (!Tok->Previous ||
-   !Tok->Previous->isOneOf(tok::kw___attribute,
+   !Tok->Previous->isOneOf(tok::kw___attribute, TT_RequiresClause,
TT_LeadingJavaAnnotation))) {
 Line.MightBeFunctionDecl = true;
   }

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index f3007f85e91b0..d27c176415c83 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -737,6 +737,16 @@ TEST_F(TokenAnnotatorTest, 
RequiresDoesNotChangeParsingOfTheRest) {
   BaseTokenCount = 26;
   TestRequires(__LINE__);
 
+  BaseCode = "template\n"
+ "T foo();";
+  ConstrainedCode = "template\n"
+"  requires(Foo)\n"
+"T foo();";
+  BaseTokenCount = 11;
+  RequiresTokenCount = 7;
+  PrefixTokenCount = 5;
+  TestRequires(__LINE__);
+
   BaseCode = "template\n"
  "Bar(T) -> Bar;";
   ConstrainedCode = "template\n"



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


[PATCH] D134049: [clang-format] Disallow trailing return arrows to be operators

2022-09-18 Thread Emilia Dreamer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0bf63f0d1b6b: [clang-format] Disallow trailing return arrows 
to be operators (authored by rymiel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134049

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -440,6 +440,15 @@
   ASSERT_EQ(Tokens.size(), 18u) << Tokens;
   EXPECT_TOKEN(Tokens[11], tok::kw_requires, TT_RequiresClause);
 
+  Tokens = annotate("template \n"
+"requires Bar || Baz\n"
+"auto foo(T) -> int;");
+  ASSERT_EQ(Tokens.size(), 24u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
+  EXPECT_EQ(Tokens[11]->FakeLParens.size(), 0u);
+  EXPECT_TRUE(Tokens[14]->ClosesRequiresClause);
+  EXPECT_TOKEN(Tokens[20], tok::arrow, TT_TrailingReturnArrow);
+
   Tokens = annotate("template \n"
 "struct S {\n"
 "  void foo() const requires Bar;\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2611,8 +2611,10 @@
   }
   if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
 return Current->getPrecedence();
-  if (Current->isOneOf(tok::period, tok::arrow))
+  if (Current->isOneOf(tok::period, tok::arrow) &&
+  Current->isNot(TT_TrailingReturnArrow)) {
 return PrecedenceArrowAndPeriod;
+  }
   if ((Style.Language == FormatStyle::LK_Java || Style.isJavaScript()) &&
   Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements,
Keywords.kw_throws)) {


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -440,6 +440,15 @@
   ASSERT_EQ(Tokens.size(), 18u) << Tokens;
   EXPECT_TOKEN(Tokens[11], tok::kw_requires, TT_RequiresClause);
 
+  Tokens = annotate("template \n"
+"requires Bar || Baz\n"
+"auto foo(T) -> int;");
+  ASSERT_EQ(Tokens.size(), 24u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
+  EXPECT_EQ(Tokens[11]->FakeLParens.size(), 0u);
+  EXPECT_TRUE(Tokens[14]->ClosesRequiresClause);
+  EXPECT_TOKEN(Tokens[20], tok::arrow, TT_TrailingReturnArrow);
+
   Tokens = annotate("template \n"
 "struct S {\n"
 "  void foo() const requires Bar;\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2611,8 +2611,10 @@
   }
   if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
 return Current->getPrecedence();
-  if (Current->isOneOf(tok::period, tok::arrow))
+  if (Current->isOneOf(tok::period, tok::arrow) &&
+  Current->isNot(TT_TrailingReturnArrow)) {
 return PrecedenceArrowAndPeriod;
+  }
   if ((Style.Language == FormatStyle::LK_Java || Style.isJavaScript()) &&
   Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements,
Keywords.kw_throws)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134052: [clang-format] Disallow requires clauses to become function declarations

2022-09-18 Thread Emilia Dreamer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8dab45274000: [clang-format] Disallow requires clauses to 
become function declarations (authored by rymiel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134052

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -737,6 +737,16 @@
   BaseTokenCount = 26;
   TestRequires(__LINE__);
 
+  BaseCode = "template\n"
+ "T foo();";
+  ConstrainedCode = "template\n"
+"  requires(Foo)\n"
+"T foo();";
+  BaseTokenCount = 11;
+  RequiresTokenCount = 7;
+  PrefixTokenCount = 5;
+  TestRequires(__LINE__);
+
   BaseCode = "template\n"
  "Bar(T) -> Bar;";
   ConstrainedCode = "template\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1110,7 +1110,7 @@
   !Contexts.back().IsExpression && !Line.startsWith(TT_ObjCProperty) &&
   !Tok->isOneOf(TT_TypeDeclarationParen, TT_RequiresExpressionLParen) 
&&
   (!Tok->Previous ||
-   !Tok->Previous->isOneOf(tok::kw___attribute,
+   !Tok->Previous->isOneOf(tok::kw___attribute, TT_RequiresClause,
TT_LeadingJavaAnnotation))) {
 Line.MightBeFunctionDecl = true;
   }


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -737,6 +737,16 @@
   BaseTokenCount = 26;
   TestRequires(__LINE__);
 
+  BaseCode = "template\n"
+ "T foo();";
+  ConstrainedCode = "template\n"
+"  requires(Foo)\n"
+"T foo();";
+  BaseTokenCount = 11;
+  RequiresTokenCount = 7;
+  PrefixTokenCount = 5;
+  TestRequires(__LINE__);
+
   BaseCode = "template\n"
  "Bar(T) -> Bar;";
   ConstrainedCode = "template\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1110,7 +1110,7 @@
   !Contexts.back().IsExpression && !Line.startsWith(TT_ObjCProperty) &&
   !Tok->isOneOf(TT_TypeDeclarationParen, TT_RequiresExpressionLParen) &&
   (!Tok->Previous ||
-   !Tok->Previous->isOneOf(tok::kw___attribute,
+   !Tok->Previous->isOneOf(tok::kw___attribute, TT_RequiresClause,
TT_LeadingJavaAnnotation))) {
 Line.MightBeFunctionDecl = true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 298d08d - [NFC] Move the position of CodeGen/module-initializer*.cpp

2022-09-18 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-09-19T10:36:28+08:00
New Revision: 298d08dfa5509b5fa6595c297c7f9c878b460d29

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

LOG: [NFC] Move the position of CodeGen/module-initializer*.cpp

Previsouly the module-initializer*.cpp lives in the CodeGen dir instead
of CodeGenCXX dir, which is not consistency with other tests since
modules are features for C++.

Added: 
clang/test/CodeGenCXX/module-intializer-pmf.cpp
clang/test/CodeGenCXX/module-intializer.cpp

Modified: 


Removed: 
clang/test/CodeGen/module-intializer-pmf.cpp
clang/test/CodeGen/module-intializer.cpp



diff  --git a/clang/test/CodeGen/module-intializer-pmf.cpp 
b/clang/test/CodeGenCXX/module-intializer-pmf.cpp
similarity index 100%
rename from clang/test/CodeGen/module-intializer-pmf.cpp
rename to clang/test/CodeGenCXX/module-intializer-pmf.cpp

diff  --git a/clang/test/CodeGen/module-intializer.cpp 
b/clang/test/CodeGenCXX/module-intializer.cpp
similarity index 100%
rename from clang/test/CodeGen/module-intializer.cpp
rename to clang/test/CodeGenCXX/module-intializer.cpp



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


[PATCH] D134007: [Clang][CUDA][NFC] Rename 'addDeviceDepences' to 'addDeviceDependences' in DeviceActionBuilder.

2022-09-18 Thread WangLian via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ed25e4df6a7: [CUDA][NFC] Rename 
'addDeviceDepences' to 'addDeviceDependences' in… (authored 
by Jimerlife).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134007

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2736,7 +2736,7 @@
 
 /// Update the state to include the provided host action \a HostAction as a
 /// dependency of the current device action. By default it is inactive.
-virtual ActionBuilderReturnCode addDeviceDepences(Action *HostAction) {
+virtual ActionBuilderReturnCode addDeviceDependences(Action *HostAction) {
   return ABRT_Inactive;
 }
 
@@ -2824,7 +2824,7 @@
   Action::OffloadKind OFKind)
 : DeviceActionBuilder(C, Args, Inputs, OFKind) {}
 
-ActionBuilderReturnCode addDeviceDepences(Action *HostAction) override {
+ActionBuilderReturnCode addDeviceDependences(Action *HostAction) override {
   // While generating code for CUDA, we only depend on the host input 
action
   // to trigger the creation of all the CUDA device actions.
 
@@ -3603,7 +3603,7 @@
   if (!SB->isValid())
 continue;
 
-  auto RetCode = SB->addDeviceDepences(HostAction);
+  auto RetCode = SB->addDeviceDependences(HostAction);
 
   // Host dependences for device actions are not compatible with that same
   // action being ignored.


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2736,7 +2736,7 @@
 
 /// Update the state to include the provided host action \a HostAction as a
 /// dependency of the current device action. By default it is inactive.
-virtual ActionBuilderReturnCode addDeviceDepences(Action *HostAction) {
+virtual ActionBuilderReturnCode addDeviceDependences(Action *HostAction) {
   return ABRT_Inactive;
 }
 
@@ -2824,7 +2824,7 @@
   Action::OffloadKind OFKind)
 : DeviceActionBuilder(C, Args, Inputs, OFKind) {}
 
-ActionBuilderReturnCode addDeviceDepences(Action *HostAction) override {
+ActionBuilderReturnCode addDeviceDependences(Action *HostAction) override {
   // While generating code for CUDA, we only depend on the host input action
   // to trigger the creation of all the CUDA device actions.
 
@@ -3603,7 +3603,7 @@
   if (!SB->isValid())
 continue;
 
-  auto RetCode = SB->addDeviceDepences(HostAction);
+  auto RetCode = SB->addDeviceDependences(HostAction);
 
   // Host dependences for device actions are not compatible with that same
   // action being ignored.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5ed25e4 - [CUDA][NFC] Rename 'addDeviceDepences' to 'addDeviceDependences' in DeviceActionBuilder.

2022-09-18 Thread via cfe-commits

Author: wanglian
Date: 2022-09-19T10:43:09+08:00
New Revision: 5ed25e4df6a705d63b4e81c274f8385a0a1188f9

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

LOG: [CUDA][NFC] Rename 'addDeviceDepences' to 'addDeviceDependences' in 
DeviceActionBuilder.

Reviewed By: tra

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d8b13730f588..a67cf3615244 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2736,7 +2736,7 @@ class OffloadingActionBuilder final {
 
 /// Update the state to include the provided host action \a HostAction as a
 /// dependency of the current device action. By default it is inactive.
-virtual ActionBuilderReturnCode addDeviceDepences(Action *HostAction) {
+virtual ActionBuilderReturnCode addDeviceDependences(Action *HostAction) {
   return ABRT_Inactive;
 }
 
@@ -2824,7 +2824,7 @@ class OffloadingActionBuilder final {
   Action::OffloadKind OFKind)
 : DeviceActionBuilder(C, Args, Inputs, OFKind) {}
 
-ActionBuilderReturnCode addDeviceDepences(Action *HostAction) override {
+ActionBuilderReturnCode addDeviceDependences(Action *HostAction) override {
   // While generating code for CUDA, we only depend on the host input 
action
   // to trigger the creation of all the CUDA device actions.
 
@@ -3603,7 +3603,7 @@ class OffloadingActionBuilder final {
   if (!SB->isValid())
 continue;
 
-  auto RetCode = SB->addDeviceDepences(HostAction);
+  auto RetCode = SB->addDeviceDependences(HostAction);
 
   // Host dependences for device actions are not compatible with that same
   // action being ignored.



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


[clang] b76da14 - [C++] [Modules] Generate the initializer for modules if we compile a

2022-09-18 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-09-19T11:30:34+08:00
New Revision: b76da14b3bfc1768d3dc9478b167b402a9ec308f

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

LOG: [C++] [Modules] Generate the initializer for modules if we compile a
module unit directly

Previously we lack a test which ensures that the module unit will
generate initializer if it is compiled directly (instead of from a pcm
file). Now we add the test back.

Added: 


Modified: 
clang/lib/Parse/ParseAST.cpp
clang/test/CodeGenCXX/module-intializer.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseAST.cpp b/clang/lib/Parse/ParseAST.cpp
index 2e6d7eea4677..f442b6213836 100644
--- a/clang/lib/Parse/ParseAST.cpp
+++ b/clang/lib/Parse/ParseAST.cpp
@@ -176,23 +176,21 @@ void clang::ParseAST(Sema &S, bool PrintStats, bool 
SkipFunctionBodies) {
   // and to be able to use a name based on the module name.
 
   // At this point, we should know if we are building a non-header C++20 
module.
-  if (S.getLangOpts().CPlusPlusModules && !S.getLangOpts().IsHeaderFile &&
-  S.getLangOpts().isCompilingModuleInterface()) {
+  if (S.getLangOpts().CPlusPlusModules) {
 // If we are building the module from source, then the top level module
 // will be here.
 Module *CodegenModule = S.getCurrentModule();
 bool Interface = true;
 if (CodegenModule)
-  // We only use module initializers for interfaces (including partition
-  // implementation units).
+  // We only use module initializers for importable module (including
+  // partition implementation units).
   Interface = S.currentModuleIsInterface();
-else
+else if (S.getLangOpts().isCompilingModuleInterface())
   // If we are building the module from a PCM file, then the module can be
   // found here.
   CodegenModule = S.getPreprocessor().getCurrentModule();
-// If neither. then 
-assert(CodegenModule && "codegen for a module, but don't know which?");
-if (Interface)
+
+if (Interface && CodegenModule)
   S.getASTContext().setModuleForCodeGen(CodegenModule);
   }
   Consumer->HandleTranslationUnit(S.getASTContext());

diff  --git a/clang/test/CodeGenCXX/module-intializer.cpp 
b/clang/test/CodeGenCXX/module-intializer.cpp
index 0b48e87f9ea7..e5149401b467 100644
--- a/clang/test/CodeGenCXX/module-intializer.cpp
+++ b/clang/test/CodeGenCXX/module-intializer.cpp
@@ -31,6 +31,19 @@
 // RUN: -fmodule-file=M.pcm -S -emit-llvm  -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK-IMPL
 
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 N.cpp -S -emit-llvm \
+// RUN:   -o - | FileCheck %s --check-prefix=CHECK-N
+
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 O.cpp -S -emit-llvm \
+// RUN:   -o - | FileCheck %s --check-prefix=CHECK-O
+
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M-part.cpp -S 
-emit-llvm \
+// RUN:   -o - | FileCheck %s --check-prefix=CHECK-P
+
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 M.cpp \
+// RUN:   -fmodule-file=N.pcm -fmodule-file=O.pcm -fmodule-file=M-part.pcm \
+// RUN:   -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-M
+
 //--- N-h.h
 
 struct Oink {



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


[clang] 7d88a05 - [Clang][LoongArch] Implement ABI lowering

2022-09-18 Thread Weining Lu via cfe-commits

Author: Weining Lu
Date: 2022-09-19T12:05:00+08:00
New Revision: 7d88a05cc01c8d8950d88e96fd8516af67b10b8e

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

LOG: [Clang][LoongArch] Implement ABI lowering

Reuse most of RISCV's implementation with several exceptions:

1. Assign signext/zeroext attribute to args passed in stack.
On RISCV, integer scalars passed in registers have signext/zeroext
when promoted, but are anyext if passed on the stack. This is defined
in early RISCV ABI specification. But after this change [1], integers
should also be signext/zeroext if passed on the stack. So I think
RISCV's ABI lowering should be updated [2].

While in LoongArch ABI spec, we can see that integer scalars narrower
than GRLEN bits are zero/sign-extended no matter passed in registers
or on the stack.

2. Zero-width bit fields are ignored.
This matches GCC's behavior but it hasn't been documented in ABI sepc.
See https://gcc.gnu.org/r12-8294.

3. `char` is signed by default.
There is another difference worth mentioning is that `char` is signed
by default on LoongArch while it is unsigned on RISCV.

This patch also adds `_BitInt` type support to LoongArch and handle it
in LoongArchABIInfo::classifyArgumentType.

[1] 
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/cec39a064ee0e5b0129973fffab7e3ad1710498f
[2] https://github.com/llvm/llvm-project/issues/57261

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

Added: 
clang/test/CodeGen/LoongArch/abi-lp64d.c
clang/test/CodeGenCXX/LoongArch/abi-lp64d-struct-inherit.cpp

Modified: 
clang/lib/Basic/Targets/LoongArch.h
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/ext-int-cc.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/LoongArch.h 
b/clang/lib/Basic/Targets/LoongArch.h
index 4380f149876c..5d711c6b1db4 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -55,6 +55,8 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
 
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &Info) const override;
+
+  bool hasBitIntType() const override { return true; }
 };
 
 class LLVM_LIBRARY_VISIBILITY LoongArch32TargetInfo

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 370614f65e5b..2f9adb83ffa2 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -11598,6 +11598,438 @@ class BPFTargetCodeGenInfo : public TargetCodeGenInfo 
{
 
 }
 
+// LoongArch ABI Implementation. Documented at
+// https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
+//
+//===--===//
+
+namespace {
+class LoongArchABIInfo : public DefaultABIInfo {
+private:
+  // Size of the integer ('r') registers in bits.
+  unsigned GRLen;
+  // Size of the floating point ('f') registers in bits.
+  unsigned FRLen;
+  // Number of general-purpose argument registers.
+  static const int NumGARs = 8;
+  // Number of floating-point argument registers.
+  static const int NumFARs = 8;
+  bool detectFARsEligibleStructHelper(QualType Ty, CharUnits CurOff,
+  llvm::Type *&Field1Ty,
+  CharUnits &Field1Off,
+  llvm::Type *&Field2Ty,
+  CharUnits &Field2Off) const;
+
+public:
+  LoongArchABIInfo(CodeGen::CodeGenTypes &CGT, unsigned GRLen, unsigned FRLen)
+  : DefaultABIInfo(CGT), GRLen(GRLen), FRLen(FRLen) {}
+
+  void computeInfo(CGFunctionInfo &FI) const override;
+
+  ABIArgInfo classifyArgumentType(QualType Ty, bool IsFixed, int &GARsLeft,
+  int &FARsLeft) const;
+  ABIArgInfo classifyReturnType(QualType RetTy) const;
+
+  Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const override;
+
+  ABIArgInfo extendType(QualType Ty) const;
+
+  bool detectFARsEligibleStruct(QualType Ty, llvm::Type *&Field1Ty,
+CharUnits &Field1Off, llvm::Type *&Field2Ty,
+CharUnits &Field2Off, int &NeededArgGPRs,
+int &NeededArgFPRs) const;
+  ABIArgInfo coerceAndExpandFARsEligibleStruct(llvm::Type *Field1Ty,
+   CharUnits Field1Off,
+   llvm::Type *Field2Ty,
+   CharUnits Field2Off) const;
+};
+} // end anonymous namespace
+
+void LoongArchABIInfo::computeInfo(CGFunctionInfo &FI) const {
+  QualType RetTy = FI.getReturnType();
+  if (!getCXXABI().classifyRetur

[PATCH] D132285: [Clang][LoongArch] Implement ABI lowering

2022-09-18 Thread Lu Weining via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7d88a05cc01c: [Clang][LoongArch] Implement ABI lowering 
(authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132285

Files:
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/LoongArch/abi-lp64d.c
  clang/test/CodeGen/ext-int-cc.c
  clang/test/CodeGenCXX/LoongArch/abi-lp64d-struct-inherit.cpp

Index: clang/test/CodeGenCXX/LoongArch/abi-lp64d-struct-inherit.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/LoongArch/abi-lp64d-struct-inherit.cpp
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+#include 
+
+/// Ensure that fields inherited from a parent struct are treated in the same
+/// way as fields directly in the child for the purposes of LoongArch ABI rules.
+
+struct parent1_int32_s {
+  int32_t i1;
+};
+
+struct child1_int32_s : parent1_int32_s {
+  int32_t i2;
+};
+
+// CHECK-LABEL: define{{.*}} i64 @_Z30int32_int32_struct_inheritance14child1_int32_s(i64 %a.coerce)
+struct child1_int32_s int32_int32_struct_inheritance(struct child1_int32_s a) {
+  return a;
+}
+
+struct parent2_int32_s {
+  int32_t i1;
+};
+
+struct child2_float_s : parent2_int32_s {
+  float f1;
+};
+
+// CHECK-LABEL: define{{.*}} { i32, float } @_Z30int32_float_struct_inheritance14child2_float_s(i32 %0, float %1)
+struct child2_float_s int32_float_struct_inheritance(struct child2_float_s a) {
+  return a;
+}
+
+struct parent3_float_s {
+  float f1;
+};
+
+struct child3_int64_s : parent3_float_s {
+  int64_t i1;
+};
+
+// CHECK-LABEL: define{{.*}} { float, i64 } @_Z30float_int64_struct_inheritance14child3_int64_s(float %0, i64 %1)
+struct child3_int64_s float_int64_struct_inheritance(struct child3_int64_s a) {
+  return a;
+}
+
+struct parent4_double_s {
+  double d1;
+};
+
+struct child4_double_s : parent4_double_s {
+  double d1;
+};
+
+// CHECK-LABEL: define{{.*}} { double, double } @_Z32double_double_struct_inheritance15child4_double_s(double %0, double %1)
+struct child4_double_s double_double_struct_inheritance(struct child4_double_s a) {
+  return a;
+}
+
+/// When virtual inheritance is used, the resulting struct isn't eligible for
+/// passing in registers.
+
+struct parent5_virtual_s {
+  int32_t i1;
+};
+
+struct child5_virtual_s : virtual parent5_virtual_s {
+  float f1;
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN16child5_virtual_sC1EOS_(ptr noundef nonnull align 8 dereferenceable(12) %this, ptr noundef nonnull align 8 dereferenceable(12) %0)
+struct child5_virtual_s int32_float_virtual_struct_inheritance(struct child5_virtual_s a) {
+  return a;
+}
+
+/// Check for correct lowering in the presence of diamond inheritance.
+
+struct parent6_float_s {
+  float f1;
+};
+
+struct child6a_s : parent6_float_s {
+};
+
+struct child6b_s : parent6_float_s {
+};
+
+struct grandchild_6_s : child6a_s, child6b_s {
+};
+
+// CHECK-LABEL: define{{.*}} { float, float } @_Z38float_float_diamond_struct_inheritance14grandchild_6_s(float %0, float %1)
+struct grandchild_6_s float_float_diamond_struct_inheritance(struct grandchild_6_s a) {
+  return a;
+}
Index: clang/test/CodeGen/ext-int-cc.c
===
--- clang/test/CodeGen/ext-int-cc.c
+++ clang/test/CodeGen/ext-int-cc.c
@@ -27,6 +27,8 @@
 // RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -triple arm64_32-apple-ios -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=AARCH64
 // RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -triple arm64_32-apple-ios -target-abi darwinpcs -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=AARCH64DARWIN
 // RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -triple arm -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=ARM
+// RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -triple loongarch64 -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=LA64
+// RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -triple loongarch32 -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=LA32
 
 // Make sure 128 and 64 bit versions are passed like integers.
 void ParamPassing(_BitInt(128) b, _BitInt(64) c) {}
@@ -57,6 +59,8 @@
 // AARCH64: define{{.*}} void @ParamPassing(i128 %{{.+}}, i64 %{{.+}})
 // AARCH64DARWIN: define{{.*}} void @ParamPassing(i128 %{{.+}}, i64 %{{.+}})
 // ARM: define{{.*}} arm_aapcscc void @ParamPassing(i128* byval(i128) align 8 %{{.+}}, i64 %{{.+}})
+// LA64: define{{.*}} void @ParamPassing(i128 %{{.+}}, i64 %{{.+}})
+// LA32: define{{.*}} void @ParamPassing(i128* %{{.+}}, i64 %{{.+

[PATCH] D132421: [HLSL] Support PCH for cc1 mode

2022-09-18 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 461131.
python3kgae added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132421

Files:
  clang/include/clang/Sema/HLSLExternalSemaSource.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/test/AST/HLSL/Inputs/pch.hlsl
  clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
  clang/test/AST/HLSL/pch.hlsl
  clang/test/AST/HLSL/pch_with_buf.hlsl

Index: clang/test/AST/HLSL/pch_with_buf.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/pch_with_buf.hlsl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -finclude-default-header -emit-pch -o %t %S/Inputs/pch_with_buf.hlsl
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -include-pch %t -fsyntax-only -ast-dump-all %s | FileCheck  %s
+
+// Make sure PCH works by using function declared in PCH header.
+// CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
+// Make sure buffer defined in PCH works.
+// CHECK:VarDecl 0x{{[0-9a-f]+}}  col:17 imported Buf 'RWBuffer':'hlsl::RWBuffer<>'
+// Make sure declare a RWBuffer in current file works.
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:11:1, col:23> col:23 Buf2 'hlsl::RWBuffer':'hlsl::RWBuffer<>'
+hlsl::RWBuffer Buf2;
+
+float2 bar(float2 a, float2 b) {
+// CHECK:CallExpr 0x{{[0-9a-f]+}}  'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT:ImplicitCastExpr 0x{{[0-9a-f]+}}  'float2 (*)(float2, float2)' 
+// CHECK-NEXT:`-DeclRefExpr 0x{{[0-9a-f]+}}  'float2 (float2, float2)' lvalue Function 0x[[FOO]] 'foo' 'float2 (float2, float2)'
+  return foo(a, b);
+}
Index: clang/test/AST/HLSL/pch.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/pch.hlsl
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -emit-pch -o %t %S/Inputs/pch.hlsl
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -include-pch %t -fsyntax-only -ast-dump-all %s \
+// RUN: | FileCheck  %s
+
+// Make sure PCH works by using function declared in PCH header and declare a RWBuffer in current file.
+// CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:10:1, col:23> col:23 Buffer 'hlsl::RWBuffer':'hlsl::RWBuffer<>'
+hlsl::RWBuffer Buffer;
+
+float2 bar(float2 a, float2 b) {
+// CHECK:CallExpr 0x{{[0-9a-f]+}}  'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT:ImplicitCastExpr 0x{{[0-9a-f]+}}  'float2 (*)(float2, float2)' 
+// CHECK-NEXT:`-DeclRefExpr 0x{{[0-9a-f]+}}  'float2 (float2, float2)' lvalue Function 0x[[FOO]] 'foo' 'float2 (float2, float2)'
+  return foo(a, b);
+}
Index: clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
@@ -0,0 +1,6 @@
+
+float2 foo(float2 a, float2 b) {
+  return a + b;
+}
+
+RWBuffer Buf;
Index: clang/test/AST/HLSL/Inputs/pch.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/Inputs/pch.hlsl
@@ -0,0 +1,4 @@
+
+float2 foo(float2 a, float2 b) {
+  return a + b;
+}
Index: clang/lib/Sema/HLSLExternalSemaSource.cpp
===
--- clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -30,6 +30,7 @@
 struct BuiltinTypeDeclBuilder {
   CXXRecordDecl *Record = nullptr;
   ClassTemplateDecl *Template = nullptr;
+  ClassTemplateDecl *PrevTemplate = nullptr;
   NamespaceDecl *HLSLNamespace = nullptr;
   llvm::StringMap Fields;
 
@@ -43,48 +44,46 @@
 ASTContext &AST = S.getASTContext();
 IdentifierInfo &II = AST.Idents.get(Name, tok::TokenKind::identifier);
 
+LookupResult Result(S, &II, SourceLocation(), Sema::LookupTagName);
+CXXRecordDecl *PrevDecl = nullptr;
+if (S.LookupQualifiedName(Result, HLSLNamespace)) {
+  NamedDecl *Found = Result.getFoundDecl();
+  if (auto *TD = dyn_cast(Found)) {
+PrevDecl = TD->getTemplatedDecl();
+PrevTemplate = TD;
+  } else
+PrevDecl = dyn_cast(Found);
+  assert(PrevDecl && "Unexpected lookup result type.");
+}
+
+if (PrevDecl && PrevDecl->isCompleteDefinition()) {
+  Record = PrevDecl;
+  return;
+}
+
 Record = CXXRecordDecl::Create(AST, TagDecl::TagKind::TTK_Class,
HLSLNamespace, SourceLocation(),
-   SourceLocation(), &II, nullptr, true);
+   SourceLocati

[clang] 981cbfb - [clang] Don't include StringSwitch.h (NFC)

2022-09-18 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-09-18T22:21:32-07:00
New Revision: 981cbfb5923139f7deff312ff3d2312bba0ce3d2

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

LOG: [clang] Don't include StringSwitch.h (NFC)

These files don't seem to use StringSwitch.

Added: 


Modified: 
clang/include/clang/AST/Attr.h
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/Basic/Attributes.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AVR.cpp
clang/lib/Basic/Targets/LoongArch.cpp
clang/lib/Driver/OffloadBundler.cpp
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/Arch/VE.cpp
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Tooling/InterpolatingCompilationDatabase.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index 4478c5fd91d4a..aff561371fd9d 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -24,7 +24,6 @@
 #include "clang/Basic/OpenMPKinds.h"
 #include "clang/Basic/Sanitizers.h"
 #include "clang/Basic/SourceLocation.h"
-#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/raw_ostream.h"

diff  --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h 
b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index ea80761fe31eb..fe8674ad97a2c 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -20,7 +20,6 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/StringSwitch.h"
 #include 
 #include 
 #include 

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index ae9c85e7542b3..1f063e83d6f76 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -3,7 +3,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Lex/Lexer.h"
-#include "llvm/ADT/StringSwitch.h"
 
 using namespace clang;
 

diff  --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index 960c9773d192a..a961e68f4ac1c 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -2,7 +2,6 @@
 #include "clang/Basic/AttrSubjectMatchRules.h"
 #include "clang/Basic/AttributeCommonInfo.h"
 #include "clang/Basic/IdentifierTable.h"
-#include "llvm/ADT/StringSwitch.h"
 using namespace clang;
 
 int clang::hasAttribute(AttributeCommonInfo::Syntax Syntax,

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 2a80ec01296ef..1c42bbec837c2 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -16,7 +16,6 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
-#include "llvm/ADT/StringSwitch.h"
 
 using namespace clang;
 using namespace clang::targets;

diff  --git a/clang/lib/Basic/Targets/AVR.cpp b/clang/lib/Basic/Targets/AVR.cpp
index 67e27ebd58def..9855b6eca5c9d 100644
--- a/clang/lib/Basic/Targets/AVR.cpp
+++ b/clang/lib/Basic/Targets/AVR.cpp
@@ -12,7 +12,6 @@
 
 #include "AVR.h"
 #include "clang/Basic/MacroBuilder.h"
-#include "llvm/ADT/StringSwitch.h"
 
 using namespace clang;
 using namespace clang::targets;

diff  --git a/clang/lib/Basic/Targets/LoongArch.cpp 
b/clang/lib/Basic/Targets/LoongArch.cpp
index 34d8bdbe1dbdc..d87d8e841c4b3 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -14,7 +14,6 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
-#include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
 

diff  --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index 4a73d2c021209..4a87942934ff9 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -22,7 +22,6 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/ArchiveWriter.h"

diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index 35faa6d2199a5..8317bf5fbe9d3 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -14,7 +14,6 @@
 #include "clang/Driver/Opti

[PATCH] D134157: [LoongArch] Add inline asm support for constraints f/l/I/K

2022-09-18 Thread Lu Weining via Phabricator via cfe-commits
SixWeining created this revision.
SixWeining added reviewers: xen0n, MaskRay, xry111, rengolin, myhsu, wangleiat, 
gonglingqin.
Herald added subscribers: StephenFan, JDevlieghere, hiraditya.
Herald added a project: All.
SixWeining requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch adds support for constraints `f`, `l`, `I`, `K` according
to [1]. The remain constraints (`k`, `m`, `ZB`, `ZC`) will be added
later as they are a little more complex than the others.
f: A floating-point register (if available).
l: A signed 16-bit constant.
I: A signed 12-bit constant (for arithmetic instructions).
K: An unsigned 12-bit constant (for logic instructions).

For now, no need to support register alias (e.g. `$a0`) in llvm as
clang will correctly decode the usage of register name aliases into
their official names. And AFAIK, the not yet upstreamed `rustc` for
LoongArch will always use official register names (e.g. `$r4`).

[1] https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134157

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/test/CodeGen/LoongArch/inline-asm-constraints-error.c
  clang/test/CodeGen/LoongArch/inline-asm-constraints.c
  clang/test/CodeGen/LoongArch/inline-asm-gcc-regs-error.c
  clang/test/CodeGen/LoongArch/inline-asm-gcc-regs.c
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/test/CodeGen/LoongArch/inline-asm-clobbers.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-error.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-f.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint.ll
  llvm/test/CodeGen/LoongArch/inline-asm-reg-names-error.ll
  llvm/test/CodeGen/LoongArch/inline-asm-reg-names-f-error.ll
  llvm/test/CodeGen/LoongArch/inline-asm-reg-names-f.ll
  llvm/test/CodeGen/LoongArch/inline-asm-reg-names.ll

Index: llvm/test/CodeGen/LoongArch/inline-asm-reg-names.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/inline-asm-reg-names.ll
@@ -0,0 +1,109 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc --mtriple=loongarch32 --verify-machineinstrs < %s \
+; RUN:   | FileCheck --check-prefix=LA32 %s
+; RUN: llc --mtriple=loongarch64 --verify-machineinstrs < %s \
+; RUN:   | FileCheck --check-prefix=LA64 %s
+
+;; These test that we can use architectural names ($r*) refer to registers in
+;; inline asm constraint lists. In each case, the named register should be used
+;; for the source register of the `addi.w`. It is very likely that `$a0` will
+;; be chosen as the designation register, but this is left to the compiler to
+;; choose.
+;;
+;; Parenthesised registers in comments are the other aliases for this register.
+
+;; NOTE: This test has to pass in 0 to the inline asm, because that's the only
+;; value `$r0` (`$zero`) can take.
+define i32 @register_r0() nounwind {
+; LA32-LABEL: register_r0:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:addi.w $a0, $zero, 0
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: register_r0:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:addi.w $a0, $zero, 0
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = tail call i32 asm "addi.w $0, $1, 0", "=r,{$r0}"(i32 0)
+  ret i32 %1
+}
+
+define i32 @register_r4(i32 %a) nounwind {
+; LA32-LABEL: register_r4:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:addi.w $a0, $a0, 1
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: register_r4:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:addi.w $a0, $a0, 1
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = tail call i32 asm "addi.w $0, $1, 1", "=r,{$r4}"(i32 %a)
+  ret i32 %1
+}
+
+;; NOTE: This test uses `$r22` (`$s9`, `$fp`) as an input, so it should be saved.
+define i32 @register_r22(i32 %a) nounwind {
+; LA32-LABEL: register_r22:
+; LA32:   # %bb.0:
+; LA32-NEXT:addi.w $sp, $sp, -16
+; LA32-NEXT:st.w $fp, $sp, 12 # 4-byte Folded Spill
+; LA32-NEXT:move $fp, $a0
+; LA32-NEXT:#APP
+; LA32-NEXT:addi.w $a0, $fp, 1
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ld.w $fp, $sp, 12 # 4-byte Folded Reload
+; LA32-NEXT:addi.w $sp, $sp, 16
+; LA32-NEXT:ret
+;
+; LA64-LABEL: register_r22:
+; LA64:   # %bb.0:
+; LA64-NEXT:addi.d $sp, $sp, -16
+; LA64-NEXT:st.d $fp, $sp, 8 # 8-byte Folded Spill
+; LA64-NEXT:move $fp, $a0
+; LA64-NEXT:#APP
+; LA64-NEXT:addi.w $a0, $fp, 1
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ld.d $fp, $sp, 8 # 8-byte Folded Reload
+; LA64-NEXT:addi.d $sp, $sp, 16
+; LA64-NEXT:ret
+  %1 = tail call i32 asm "addi.w $0, $1, 1", "=r,{$r22}"(i32 %a)
+  ret i32 %1
+}
+
+;; 

[PATCH] D131799: [HLSL] clang codeGen for HLSLNumThreadsAttr

2022-09-18 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 461146.
python3kgae added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131799

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/test/CodeGenHLSL/entry.hlsl


Index: clang/test/CodeGenHLSL/entry.hlsl
===
--- clang/test/CodeGenHLSL/entry.hlsl
+++ clang/test/CodeGenHLSL/entry.hlsl
@@ -4,9 +4,10 @@
 
 // Make sure not mangle entry.
 // CHECK:define void @foo()
-// Make sure add function attribute.
+// Make sure add function attribute and numthreads attribute.
+// CHECK:"hlsl.numthreads"="16,8,1"
 // CHECK:"hlsl.shader"="compute"
-[numthreads(1,1,1)]
+[numthreads(16,8,1)]
 void foo() {
 
 }
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -19,6 +19,7 @@
 #include "llvm/IR/IntrinsicsDirectX.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/FormatVariadic.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -107,6 +108,13 @@
   const StringRef ShaderAttrKindStr = "hlsl.shader";
   Fn->addFnAttr(ShaderAttrKindStr,
 ShaderAttr->ConvertShaderTypeToStr(ShaderAttr->getType()));
+  if (HLSLNumThreadsAttr *NumThreadsAttr = FD->getAttr()) {
+const StringRef NumThreadsKindStr = "hlsl.numthreads";
+std::string NumThreadsStr =
+formatv("{0},{1},{2}", NumThreadsAttr->getX(), NumThreadsAttr->getY(),
+NumThreadsAttr->getZ());
+Fn->addFnAttr(NumThreadsKindStr, NumThreadsStr);
+  }
 }
 
 llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> &B,


Index: clang/test/CodeGenHLSL/entry.hlsl
===
--- clang/test/CodeGenHLSL/entry.hlsl
+++ clang/test/CodeGenHLSL/entry.hlsl
@@ -4,9 +4,10 @@
 
 // Make sure not mangle entry.
 // CHECK:define void @foo()
-// Make sure add function attribute.
+// Make sure add function attribute and numthreads attribute.
+// CHECK:"hlsl.numthreads"="16,8,1"
 // CHECK:"hlsl.shader"="compute"
-[numthreads(1,1,1)]
+[numthreads(16,8,1)]
 void foo() {
 
 }
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -19,6 +19,7 @@
 #include "llvm/IR/IntrinsicsDirectX.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/FormatVariadic.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -107,6 +108,13 @@
   const StringRef ShaderAttrKindStr = "hlsl.shader";
   Fn->addFnAttr(ShaderAttrKindStr,
 ShaderAttr->ConvertShaderTypeToStr(ShaderAttr->getType()));
+  if (HLSLNumThreadsAttr *NumThreadsAttr = FD->getAttr()) {
+const StringRef NumThreadsKindStr = "hlsl.numthreads";
+std::string NumThreadsStr =
+formatv("{0},{1},{2}", NumThreadsAttr->getX(), NumThreadsAttr->getY(),
+NumThreadsAttr->getZ());
+Fn->addFnAttr(NumThreadsKindStr, NumThreadsStr);
+  }
 }
 
 llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> &B,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2022-09-18 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 2 inline comments as done.
pmatos added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:954
 10, // wasm_externref,
+20, // wasm_funcref
 };

aaron.ballman wrote:
> pmatos wrote:
> > aaron.ballman wrote:
> > > Where did this value come from?
> > Unsure what you mean here. This is the address space number we also use on 
> > the LLVM side.
> > Unsure what you mean here. This is the address space number we also use on 
> > the LLVM side.
> 
> That's exactly what I was looking for -- I wanted to make sure this agreed 
> with the LLVM side of things and any public documentation about address 
> spaces for WASM.
> > Unsure what you mean here. This is the address space number we also use on 
> > the LLVM side.
> 
> That's exactly what I was looking for -- I wanted to make sure this agreed 
> with the LLVM side of things and any public documentation about address 
> spaces for WASM.

Sure! Marking as done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2022-09-18 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked an inline comment as done.
pmatos added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:952-953
+12, // ptr64
+1,  // wasm_var
+10, // wasm_externref,
 };

aaron.ballman wrote:
> How did you arrive at these values?
> How did you arrive at these values?

Same as for funcref, this is the same in the LLVM side of things.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

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