[clang] 7542e72 - Use llvm::is_contained (NFC)

2022-08-07 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-07T00:16:17-07:00
New Revision: 7542e72188cb05b22523cc58ea4223951399520d

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

LOG: Use llvm::is_contained (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaOpenMP.cpp
lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index 399e393a36fdd..f1b78883aece7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -1512,12 +1512,10 @@ static bool isIgnoredParameter(const TheCheck &Check, 
const ParmVarDecl *Node) {
   << "' is ignored.\n");
 
   if (!Node->getIdentifier())
-return llvm::find(Check.IgnoredParameterNames, "\"\"") !=
-   Check.IgnoredParameterNames.end();
+return llvm::is_contained(Check.IgnoredParameterNames, "\"\"");
 
   StringRef NodeName = Node->getName();
-  if (llvm::find(Check.IgnoredParameterNames, NodeName) !=
-  Check.IgnoredParameterNames.end()) {
+  if (llvm::is_contained(Check.IgnoredParameterNames, NodeName)) {
 LLVM_DEBUG(llvm::dbgs() << "\tName ignored.\n");
 return true;
   }
@@ -1584,7 +1582,7 @@ bool lazyMapOfSetsIntersectionExists(const MapTy &Map, 
const ElemTy &E1,
 return false;
 
   for (const auto &E1SetElem : E1Iterator->second)
-if (llvm::find(E2Iterator->second, E1SetElem) != E2Iterator->second.end())
+if (llvm::is_contained(E2Iterator->second, E1SetElem))
   return true;
 
   return false;
@@ -1746,8 +1744,8 @@ class Returned {
   }
 
   bool operator()(const ParmVarDecl *Param1, const ParmVarDecl *Param2) const {
-return llvm::find(ReturnedParams, Param1) != ReturnedParams.end() &&
-   llvm::find(ReturnedParams, Param2) != ReturnedParams.end();
+return llvm::is_contained(ReturnedParams, Param1) &&
+   llvm::is_contained(ReturnedParams, Param2);
   }
 };
 

diff  --git 
a/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp 
b/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
index 1165eb9a38a56..d35ddd021401b 100644
--- a/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
@@ -112,7 +112,7 @@ void ProperlySeededRandomGeneratorCheck::checkSeed(
 
   const std::string SeedType(
   Func->getArg(0)->IgnoreCasts()->getType().getAsString());
-  if (llvm::find(DisallowedSeedTypes, SeedType) != DisallowedSeedTypes.end()) {
+  if (llvm::is_contained(DisallowedSeedTypes, SeedType)) {
 diag(Func->getExprLoc(),
  "random number generator seeded with a disallowed source of seed "
  "value will generate a predictable sequence of values");

diff  --git a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
index e818237954891..3cd019d0c386b 100644
--- a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
@@ -60,7 +60,7 @@ template  class 
ImmutableSmallSet {
   size_type count(const T &V) const {
 if (isSmall()) {
   // Since the collection is small, just do a linear search.
-  return llvm::find(Vector, V) == Vector.end() ? 0 : 1;
+  return llvm::is_contained(Vector, V) ? 1 : 0;
 }
 
 return Set.count(V);
@@ -106,7 +106,7 @@ template  class 
SmartSmallSetVector {
   size_type count(const T &V) const {
 if (isSmall()) {
   // Since the collection is small, just do a linear search.
-  return llvm::find(Vector, V) == Vector.end() ? 0 : 1;
+  return llvm::is_contained(Vector, V) ? 1 : 0;
 }
 // Look-up in the Set.
 return Set.count(V);

diff  --git 
a/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
index 9815952f81759..22a4e4eeec6d7 100644
--- a/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/Dup

[PATCH] D131345: [RISC-V][HWASAN] Enable HWASAN for RISC-V architecture

2022-08-07 Thread Alexey Baturo via Phabricator via cfe-commits
smd created this revision.
Herald added subscribers: Enna1, sunshaoce, VincentWu, luke957, vkmr, 
luismarques, sameer.abuasal, s.egerton, Jim, PkmX, rogfer01, shiva0217, 
kito-cheng, simoncook, arichardson, mgorny.
Herald added a project: All.
smd edited the summary of this revision.
smd added reviewers: eugenis, vitalybuka, luismarques.
smd published this revision for review.
Herald added subscribers: Sanitizers, cfe-commits, pcwang-thead, MaskRay.
Herald added projects: clang, Sanitizers.

[7/7] patch series to port ASAN for riscv64

These changes allow using HWASAN on RISCV64 architecture.

The majority of existing tests are passing with a few exceptions(see below).
The tests were run on QEMU, since currently there're no hardware with support
for J-extension.

For this feature to work the system must support PR_{SET,GET}_TAGGED_ADDR_CTRL
syscall. For now this is only available for a patched Linux kernel and QEMU with
enabled experimental J-extension.

Results of running HWASAN lit tests for RISC-V:

  Unsupported  :  5
  Passed   : 73
  Expectedly Failed:  9

Current RISC-V code models and existing relocation symbols don't allow us to
tag global variables. This will be addressed in further patches.
These tests are marked as expected to fail since they check tagging globals:

  HWAddressSanitizer-riscv64 :: TestCases/Linux/create-thread-stress.cpp (3 of 
87)
  HWAddressSanitizer-riscv64 :: TestCases/print-memory-usage.c (23 of 87)
  HWAddressSanitizer-riscv64 :: TestCases/Linux/atfork.cpp (24 of 87)
  HWAddressSanitizer-riscv64 :: TestCases/thread-uaf.c (25 of 87)
  HWAddressSanitizer-riscv64 :: TestCases/exported-tagged-global.c (39 of 87)
  HWAddressSanitizer-riscv64 :: TestCases/many-threads-uaf.c (42 of 87)
  HWAddressSanitizer-riscv64 :: TestCases/pthread_create.c (69 of 87)
  HWAddressSanitizer-riscv64 :: TestCases/global.c (75 of 87)
  HWAddressSanitizer-riscv64 :: TestCases/global-with-reduction.c (76 of 87)

Depends On D131344 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131345

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake


Index: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
===
--- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -55,7 +55,7 @@
   ${PPC64} ${S390X} ${RISCV64} ${HEXAGON})
 endif()
 set(ALL_MSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X})
-set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64})
+set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -765,8 +765,10 @@
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch ||
   IsPowerPC64 || IsHexagon)
 Res |= SanitizerKind::Scudo;
-  if (IsX86_64 || IsAArch64) {
+  if (IsX86_64 || IsAArch64 || IsRISCV64) {
 Res |= SanitizerKind::HWAddress;
+  }
+  if (IsX86_64 || IsAArch64) {
 Res |= SanitizerKind::KernelHWAddress;
   }
   return Res;


Index: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
===
--- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -55,7 +55,7 @@
   ${PPC64} ${S390X} ${RISCV64} ${HEXAGON})
 endif()
 set(ALL_MSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X})
-set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64})
+set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} ${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -765,8 +765,10 @@
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch ||
   IsPowerPC64 || IsHexagon)
 Res |= SanitizerKind::Scudo;
-  if (IsX86_64 || IsAArch64) {
+  if (IsX86_64 || IsAArch64 || IsRISCV64) {
 Res |= SanitizerKind::HWAddress;
+  }
+  if (IsX86_64 || IsAArch64) {
 Res |= SanitizerKind::KernelHWAddress;
   }
   return Res;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131282: [mlir] fix `add_tablegen()` macro to allow installing mlir-pdll

2022-08-07 Thread Ashay Rane via Phabricator via cfe-commits
ashay-github updated this revision to Diff 450614.
ashay-github added a comment.
Herald added subscribers: cfe-commits, sdasgup3, wenzhicui, wrengr, cota, 
teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, 
Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, nicolasvasilache, 
antiagainst, shauheen, mehdi_amini.
Herald added projects: clang, MLIR.

Added optional `DESTINATION` argument to `add_tablegen()`.  Also updated all
invocations of the macro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131282

Files:
  clang/utils/TableGen/CMakeLists.txt
  llvm/cmake/modules/TableGen.cmake
  llvm/utils/TableGen/CMakeLists.txt
  mlir/tools/mlir-pdll/CMakeLists.txt
  mlir/tools/mlir-tblgen/CMakeLists.txt


Index: mlir/tools/mlir-tblgen/CMakeLists.txt
===
--- mlir/tools/mlir-tblgen/CMakeLists.txt
+++ mlir/tools/mlir-tblgen/CMakeLists.txt
@@ -4,7 +4,7 @@
   TableGen
 )
 
-add_tablegen(mlir-tblgen MLIR
+add_tablegen(mlir-tblgen MLIR DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   AttrOrTypeDefGen.cpp
   AttrOrTypeFormatGen.cpp
   CodeGenHelpers.cpp
Index: mlir/tools/mlir-pdll/CMakeLists.txt
===
--- mlir/tools/mlir-pdll/CMakeLists.txt
+++ mlir/tools/mlir-pdll/CMakeLists.txt
@@ -12,7 +12,7 @@
   MLIRPDLLParser
   )
 
-add_tablegen(mlir-pdll MLIR_PDLL
+add_tablegen(mlir-pdll MLIR_PDLL DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   mlir-pdll.cpp
 
   DEPENDS
Index: llvm/utils/TableGen/CMakeLists.txt
===
--- llvm/utils/TableGen/CMakeLists.txt
+++ llvm/utils/TableGen/CMakeLists.txt
@@ -2,7 +2,7 @@
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_tablegen(llvm-tblgen LLVM
+add_tablegen(llvm-tblgen LLVM DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
   AsmMatcherEmitter.cpp
   AsmWriterEmitter.cpp
   AsmWriterInst.cpp
Index: llvm/cmake/modules/TableGen.cmake
===
--- llvm/cmake/modules/TableGen.cmake
+++ llvm/cmake/modules/TableGen.cmake
@@ -140,6 +140,12 @@
 endfunction()
 
 macro(add_tablegen target project)
+  set(options "")
+  set(oneValueArgs "DESTINATION")
+  set(multiValueArgs "")
+  cmake_parse_arguments(ADD_TABLEGEN "${options}" "${oneValueArgs}"
+"${multiValueArgs}" ${ARGN})
+
   set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
   set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
 
@@ -149,7 +155,8 @@
 set(LLVM_ENABLE_OBJLIB ON)
   endif()
 
-  add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
+  add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB
+${ADD_TABLEGEN_UNPARSED_ARGUMENTS})
   set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS})
 
   set(${project}_TABLEGEN "${target}" CACHE
@@ -186,7 +193,7 @@
 endif()
   endif()
 
-  if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT 
LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS)
+  if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND 
LLVM_BUILD_UTILS)
 set(export_to_llvmexports)
 if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
 NOT LLVM_DISTRIBUTION_COMPONENTS)
@@ -196,7 +203,7 @@
 install(TARGETS ${target}
 ${export_to_llvmexports}
 COMPONENT ${target}
-RUNTIME DESTINATION "${${project}_TOOLS_INSTALL_DIR}")
+RUNTIME DESTINATION "${ADD_TABLEGEN_DESTINATION}")
 if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets("install-${target}"
DEPENDS ${target}
Index: clang/utils/TableGen/CMakeLists.txt
===
--- clang/utils/TableGen/CMakeLists.txt
+++ clang/utils/TableGen/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-add_tablegen(clang-tblgen CLANG
+add_tablegen(clang-tblgen CLANG DESTINATION "${CLANG_TOOLS_INSTALL_DIR}"
   ASTTableGen.cpp
   ClangASTNodesEmitter.cpp
   ClangASTPropertiesEmitter.cpp


Index: mlir/tools/mlir-tblgen/CMakeLists.txt
===
--- mlir/tools/mlir-tblgen/CMakeLists.txt
+++ mlir/tools/mlir-tblgen/CMakeLists.txt
@@ -4,7 +4,7 @@
   TableGen
 )
 
-add_tablegen(mlir-tblgen MLIR
+add_tablegen(mlir-tblgen MLIR DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   AttrOrTypeDefGen.cpp
   AttrOrTypeFormatGen.cpp
   CodeGenHelpers.cpp
Index: mlir/tools/mlir-pdll/CMakeLists.txt
===
--- mlir/tools/mlir-pdll/CMakeLists.txt
+++ mlir/tools/mlir-pdll/CMakeLists.txt
@@ -12,7 +12,7 @@
   MLIRPDLLParser
   )
 
-add_tablegen(mlir-pdll MLIR_PDLL
+add_tablegen(mlir-pdll MLIR_PDLL DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   mlir-pdll.cpp
 
   DEPENDS
Index: llvm/utils/TableGen/CMakeLists.txt
===

[PATCH] D131282: [mlir] fix `add_tablegen()` macro to allow installing mlir-pdll

2022-08-07 Thread Ashay Rane via Phabricator via cfe-commits
ashay-github marked an inline comment as done.
ashay-github added inline comments.



Comment at: llvm/cmake/modules/TableGen.cmake:199
 COMPONENT ${target}
 RUNTIME DESTINATION "${${project}_TOOLS_INSTALL_DIR}")
 if(NOT LLVM_ENABLE_IDE)

nikic wrote:
> Hm, a problem is that this line is going to look for 
> `${MLIR_PDLL_TOOLS_INSTALL_DIR}`, so that variable would have to be set 
> (presumably to `${MLIR_TOOLS_INSTALL_DIR}`), otherwise this will end up in 
> some kind of default location. The same problem would exist for 
> `(LLDB|LIBC|LLVM_LIBC)_TOOLS_INSTALL_DIR`, all the other ones already define 
> the variable.
> 
> Defining MLIR_PDLL_TOOLS_INSTALL_DIR is possible, but does seem somewhat 
> ugly. A possibility would be to accept the install path as an argument (and 
> skip installing if not provided):
> ```
> add_tablegen(mlir-pdll MLIR_PDLL ... DESTINATION ${MLIR_TOOLS_INSTALL_DIR})
> ```
Thanks, that seems a lot more elegant than what I had before! Updated in the 
most recent version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131282

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


[PATCH] D131282: [mlir] fix `add_tablegen()` macro to allow installing mlir-pdll

2022-08-07 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: llvm/cmake/modules/TableGen.cmake:147
+  cmake_parse_arguments(ADD_TABLEGEN "${options}" "${oneValueArgs}"
+"${multiValueArgs}" ${ARGN})
+

I think it would be fine to write this as just 
`cmake_parse_arguments(ADD_TABLEGEN "" "OPTIONS" "" ${ARGN})`, but don't feel 
strongly about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131282

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


[PATCH] D131351: [C] Default implicit function pointer conversions diagnostic to be an error

2022-08-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: erichkeane, jyknight, efriedma, 
clang-language-wg.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

Implicitly converting between incompatible function pointers in C is currently 
a default-on warning (it is an error in C++). However, this is very poor 
security posture. A mismatch in parameters or return types, or a mismatch in 
calling conventions, etc can lead to exploitable security vulnerabilities. 
Rather than allow this unsafe practice with a warning, this patch strengthens 
the warning to be an error (while still allowing users the ability to disable 
the error or the warning entirely to ease migration). Users should either 
ensure the signatures are correctly compatible or they should use an explicit 
cast if they believe that's more reasonable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/CodeGen/attributes.c
  clang/test/CodeGen/overloadable.c
  clang/test/Sema/aarch64-svepcs.c
  clang/test/Sema/aarch64-vpcs.c
  clang/test/Sema/arm-cmse.c
  clang/test/Sema/attr-nocf_check.c
  clang/test/Sema/block-return.c
  clang/test/Sema/c2x-func-prototype.c
  clang/test/Sema/callingconv-ms_abi.c
  clang/test/Sema/callingconv-sysv_abi.c
  clang/test/Sema/callingconv.c
  clang/test/Sema/incompatible-function-pointer-types.c
  clang/test/Sema/initialize-noreturn.c
  clang/test/Sema/noescape.c
  clang/test/Sema/overloadable.c
  clang/test/Sema/pass-object-size.c
  clang/test/Sema/preserve-call-conv.c
  clang/test/SemaObjC/comptypes-legal.m

Index: clang/test/SemaObjC/comptypes-legal.m
===
--- clang/test/SemaObjC/comptypes-legal.m
+++ clang/test/SemaObjC/comptypes-legal.m
@@ -31,9 +31,9 @@
 
 void foo(void)
 {
-  // GCC currently allows this (it has some fiarly new support for covariant return types and contravariant argument types).
+  // GCC currently allows this (it has some fairly new support for covariant return types and contravariant argument types).
   // Since registerFunc: expects a Derived object as it's second argument, I don't know why this would be legal.
-  [Derived registerFunc: ExternFunc];  // expected-warning{{incompatible function pointer types sending 'NSObject *(NSObject *, NSObject *)' to parameter of type 'FuncSignature *' (aka 'id (*)(NSObject *, Derived *)')}}
+  [Derived registerFunc: ExternFunc];  // expected-error{{incompatible function pointer types sending 'NSObject *(NSObject *, NSObject *)' to parameter of type 'FuncSignature *' (aka 'id (*)(NSObject *, Derived *)')}}
 }
 
 // rdar://10751015
Index: clang/test/Sema/preserve-call-conv.c
===
--- clang/test/Sema/preserve-call-conv.c
+++ clang/test/Sema/preserve-call-conv.c
@@ -14,8 +14,8 @@
 
 void (__attribute__((preserve_most)) *pfoo1)(void *) = foo;
 
-void (__attribute__((cdecl)) *pfoo2)(void *) = foo; // expected-warning {{incompatible function pointer types initializing 'void (*)(void *) __attribute__((cdecl))' with an expression of type 'void (void *) __attribute__((preserve_most))'}}
-void (*pfoo3)(void *) = foo; // expected-warning {{incompatible function pointer types initializing 'void (*)(void *)' with an expression of type 'void (void *) __attribute__((preserve_most))'}}
+void (__attribute__((cdecl)) *pfoo2)(void *) = foo; // expected-error {{incompatible function pointer types initializing 'void (*)(void *) __attribute__((cdecl))' with an expression of type 'void (void *) __attribute__((preserve_most))'}}
+void (*pfoo3)(void *) = foo; // expected-error {{incompatible function pointer types initializing 'void (*)(void *)' with an expression of type 'void (void *) __attribute__((preserve_most))'}}
 
 typedef_fun_t typedef_fun_foo; // expected-note {{previous declaration is here}}
 void __attribute__((preserve_most)) typedef_fun_foo(int x) { } // expected-error {{function declared 'preserve_most' here was previously declared without calling convention}}
@@ -30,8 +30,8 @@
 
 void (__attribute__((preserve_all)) *pboo1)(void *) = boo;
 
-void (__attribute__((cdecl)) *pboo2)(void *) = boo; // expected-warning {{incompatible function pointer types initializing 'void (*)(void *) __attribute__((cdecl))' with an expression of type 'void (void *) __attribute__((preserve_all))'}}
-void (*pboo3)(void *) = boo; // expected-warning {{incompatible function pointer types initializing 'void (*)(void *)' with an expression of type 'void (void *) __attribute__((preserve_all))'}}
+void (__attribute__((cdecl)) *pboo2)(void *) = boo; // expected-error {{incompatible function pointer types initializing 'void (*)(void *) __attribute__((cdecl))' with an expression of type 'void (void *) __attribute__((preserve_all))'}}
+void (*

[PATCH] D131351: [C] Default implicit function pointer conversions diagnostic to be an error

2022-08-07 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

LGTM.
I agree that this address potential security issues. I'm curious how many 
people will be affected, but hopefully by doing that early in the clang 16 
cycle we might find out!
Thanks for working on this Aarron.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8178
+def ext_typecheck_convert_incompatible_function_pointer : ExtWarn<
+  err_typecheck_convert_incompatible_function_pointer.Text>,
+  InGroup, DefaultError;

Fancy!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131351

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


[clang-tools-extra] 82439b2 - [clang-tidy] Fix a forwarding-reference-overload crash after the

2022-08-07 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-08-07T16:53:56+02:00
New Revision: 82439b201a01707fd18f0d34a4b625132b9c7304

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

LOG: [clang-tidy] Fix a forwarding-reference-overload crash after the
ElaboratedType change.

After 15f3cd6bfc670ba6106184a903eb04be059e5977, the nss of
ElaboratedType can be null.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
index 568f139bdb856..2f9946a7cc1b2 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
@@ -44,11 +44,12 @@ AST_MATCHER(QualType, isEnableIf) {
   if (CheckTemplate(BaseType->getAs()))
 return true; // Case: enable_if_t< >.
   if (const auto *Elaborated = BaseType->getAs()) {
-if (const auto *Qualifier = Elaborated->getQualifier()->getAsType()) {
-  if (CheckTemplate(Qualifier->getAs())) {
-return true; // Case: enable_if< >::type.
+if (const auto *Q = Elaborated->getQualifier())
+  if (const auto *Qualifier = Q->getAsType()) {
+if (CheckTemplate(Qualifier->getAs())) {
+  return true; // Case: enable_if< >::type.
+}
   }
-}
   }
   return false;
 }

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp
index 920029b56e55d..38b0691bc9f1e 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp
@@ -240,3 +240,14 @@ class Test9 {
   Test9(const Test9 &other) = default;
   Test9(Test9 &&other) = default;
 };
+
+
+template 
+class Test10 {
+public:
+  enum E {};
+  E e;
+
+  Test10(T &&Item, E e)
+  : e(e){}
+};



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


[PATCH] D130394: [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

2022-08-07 Thread Roman Rusyaev via Phabricator via cfe-commits
rusyaev-roman accepted this revision.
rusyaev-roman added a comment.
This revision is now accepted and ready to land.

LGTM. Maybe in the future it's better to use SwiftABIInfo as mix-in like this

  class ARMABIInfo : public ABIInfo, public SwiftABIInfo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130394

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


[PATCH] D130394: [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

2022-08-07 Thread YingChi Long via Phabricator via cfe-commits
inclyc accepted this revision.
inclyc added a comment.

(Not a serious review) It seems like that your patch has already been accepted, 
so that I can commit this patch for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130394

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


[clang] 87dc7d4 - [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

2022-08-07 Thread YingChi Long via cfe-commits

Author: Sergei Barannikov
Date: 2022-08-08T00:23:23+08:00
New Revision: 87dc7d4b619d9823b4d5d33bbc3ff3a193b9da2f

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

LOG: [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

Swift calling conventions stands out in the way that they are lowered in
mostly target-independent manner, with very few customization points.
As such, swift-related methods of ABIInfo do not reference the rest of
ABIInfo and vice versa.
This change follows interface segregation principle; it removes
dependency of SwiftABIInfo on ABIInfo. Targets must now implement
SwiftABIInfo separately if they support Swift calling conventions.

Almost all targets implemented `shouldPassIndirectly` the same way. This
de-facto default implementation has been moved into the base class.

`isSwiftErrorInRegister` used to be virtual, now it is not. It didn't
accept any arguments which could have an effect on the returned value.
This is now a static property of the target ABI.

Reviewed By: rusyaev-roman, inclyc

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

Added: 


Modified: 
clang/lib/CodeGen/ABIInfo.h
clang/lib/CodeGen/SwiftCallingConv.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/CodeGen/TargetInfo.h

Removed: 




diff  --git a/clang/lib/CodeGen/ABIInfo.h b/clang/lib/CodeGen/ABIInfo.h
index c1eb8a975796..755d2aaa7beb 100644
--- a/clang/lib/CodeGen/ABIInfo.h
+++ b/clang/lib/CodeGen/ABIInfo.h
@@ -33,7 +33,6 @@ namespace CodeGen {
   class CGFunctionInfo;
   class CodeGenFunction;
   class CodeGenTypes;
-  class SwiftABIInfo;
 
   // FIXME: All of this stuff should be part of the target interface
   // somehow. It is currently here because it is not clear how to factor
@@ -44,9 +43,8 @@ namespace CodeGen {
   /// ABIInfo - Target specific hooks for defining how a type should be
   /// passed or returned from functions.
   class ABIInfo {
-  public:
-CodeGen::CodeGenTypes &CGT;
   protected:
+CodeGen::CodeGenTypes &CGT;
 llvm::CallingConv::ID RuntimeCC;
   public:
 ABIInfo(CodeGen::CodeGenTypes &cgt)
@@ -54,8 +52,6 @@ namespace CodeGen {
 
 virtual ~ABIInfo();
 
-virtual bool supportsSwift() const { return false; }
-
 virtual bool allowBFloatArgsAndRet() const { return false; }
 
 CodeGen::CGCXXABI &getCXXABI() const;
@@ -114,33 +110,33 @@ namespace CodeGen {
 
 CodeGen::ABIArgInfo
 getNaturalAlignIndirectInReg(QualType Ty, bool Realign = false) const;
-
-
   };
 
-  /// A refining implementation of ABIInfo for targets that support swiftcall.
-  ///
-  /// If we find ourselves wanting multiple such refinements, they'll probably
-  /// be independent refinements, and we should probably find another way
-  /// to do it than simple inheritance.
-  class SwiftABIInfo : public ABIInfo {
-  public:
-SwiftABIInfo(CodeGen::CodeGenTypes &cgt) : ABIInfo(cgt) {}
+  /// Target specific hooks for defining how a type should be passed or 
returned
+  /// from functions with one of the Swift calling conventions.
+  class SwiftABIInfo {
+  protected:
+CodeGenTypes &CGT;
+bool SwiftErrorInRegister;
 
-bool supportsSwift() const final { return true; }
+  public:
+SwiftABIInfo(CodeGen::CodeGenTypes &CGT, bool SwiftErrorInRegister)
+: CGT(CGT), SwiftErrorInRegister(SwiftErrorInRegister) {}
 
-virtual bool shouldPassIndirectlyForSwift(ArrayRef types,
-  bool asReturnValue) const = 0;
+virtual ~SwiftABIInfo();
 
-virtual bool isLegalVectorTypeForSwift(CharUnits totalSize,
-   llvm::Type *eltTy,
-   unsigned elts) const;
+/// Returns true if an aggregate which expands to the given type sequence
+/// should be passed / returned indirectly.
+virtual bool shouldPassIndirectly(ArrayRef ComponentTys,
+  bool AsReturnValue) const;
 
-virtual bool isSwiftErrorInRegister() const = 0;
+/// Returns true if the given vector type is legal from Swift's calling
+/// convention perspective.
+virtual bool isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
+   unsigned NumElts) const;
 
-static bool classof(const ABIInfo *info) {
-  return info->supportsSwift();
-}
+/// Returns true if swifterror is lowered to a register by the target ABI.
+bool isSwiftErrorInRegister() const { return SwiftErrorInRegister; };
   };
 }  // end namespace CodeGen
 }  // end namespace clang

diff  --git a/clang/lib/CodeGen/SwiftCallingConv.cpp 
b/clang/lib/CodeGen/SwiftCallingConv.cpp
index 8fb24fcecf53..e42859af05a2 100644
--- a/clang/lib/CodeGen/SwiftCallingConv.cpp
+++ b/clang/lib/CodeGen/Sw

[PATCH] D130394: [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

2022-08-07 Thread YingChi Long 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 rG87dc7d4b619d: [clang][CodeGen] Factor out Swift ABI hooks 
(NFCI) (authored by barannikov88, committed by inclyc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130394

Files:
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -38,6 +38,7 @@
 class CallArgList;
 class CodeGenFunction;
 class CGBlockInfo;
+class SwiftABIInfo;
 
 /// TargetCodeGenInfo - This class organizes various target-specific
 /// codegeneration issues, like target-specific attributes, builtins and so
@@ -45,6 +46,12 @@
 class TargetCodeGenInfo {
   std::unique_ptr Info;
 
+protected:
+  // Target hooks supporting Swift calling conventions. The target must
+  // initialize this field if it claims to support these calling conventions
+  // by returning true from TargetInfo::checkCallingConvention for them.
+  std::unique_ptr SwiftInfo;
+
 public:
   TargetCodeGenInfo(std::unique_ptr Info);
   virtual ~TargetCodeGenInfo();
@@ -52,6 +59,12 @@
   /// getABIInfo() - Returns ABI info helper for the target.
   const ABIInfo &getABIInfo() const { return *Info; }
 
+  /// Returns Swift ABI info helper for the target.
+  const SwiftABIInfo &getSwiftABIInfo() const {
+assert(SwiftInfo && "Swift ABI info has not been initialized");
+return *SwiftInfo;
+  }
+
   /// setTargetAttributes - Provides a convenient hook to handle extra
   /// target-specific attributes for the given global.
   virtual void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -23,7 +23,6 @@
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
-#include "clang/CodeGen/SwiftCallingConv.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -117,7 +116,9 @@
   return false;
 }
 
-ABIInfo::~ABIInfo() {}
+ABIInfo::~ABIInfo() = default;
+
+SwiftABIInfo::~SwiftABIInfo() = default;
 
 /// Does the given lowering require more than the given number of
 /// registers when expanded?
@@ -151,12 +152,16 @@
   return (intCount + fpCount > maxAllRegisters);
 }
 
-bool SwiftABIInfo::isLegalVectorTypeForSwift(CharUnits vectorSize,
- llvm::Type *eltTy,
- unsigned numElts) const {
+bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
+bool AsReturnValue) const {
+  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+}
+
+bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
+ unsigned NumElts) const {
   // The default implementation of this assumes that the target guarantees
   // 128-bit SIMD support but nothing more.
-  return (vectorSize.getQuantity() > 8 && vectorSize.getQuantity() <= 16);
+  return (VectorSize.getQuantity() > 8 && VectorSize.getQuantity() <= 16);
 }
 
 static CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT,
@@ -814,7 +819,7 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 //===--===//
 
-class WebAssemblyABIInfo final : public SwiftABIInfo {
+class WebAssemblyABIInfo final : public ABIInfo {
 public:
   enum ABIKind {
 MVP = 0,
@@ -827,7 +832,7 @@
 
 public:
   explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes &CGT, ABIKind Kind)
-  : SwiftABIInfo(CGT), defaultInfo(CGT), Kind(Kind) {}
+  : ABIInfo(CGT), defaultInfo(CGT), Kind(Kind) {}
 
 private:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
@@ -845,22 +850,16 @@
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override;
-
-  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
-bool asReturnValue) const override {
-return occupiesMoreThan(CGT, scalars, /*total*/ 4);
-  }
-
-  bool isSwiftErrorInRegister() const override {
-return false;
-  }
 };
 
 class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
 public:
   explicit WebAssemblyTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
 WebAssemblyABIInfo::ABIKind K)
-  : TargetCodeGenInfo(std::make_unique(CGT, K)) {}
+  : TargetCodeGenInfo(std::make_unique(CGT, K)) {
+   

[PATCH] D130394: [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

2022-08-07 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D130394#3705047 , @inclyc wrote:

> (Not a serious review) It seems like that your patch has already been 
> accepted, so that I can commit this patch for you.

It was very nice of you, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130394

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


[PATCH] D130394: [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

2022-08-07 Thread YingChi Long via Phabricator via cfe-commits
inclyc added a comment.

I think in fact you are now fully qualified to apply for commit access. Don't 
worry, Lattner generally trusts all developers willing to contribute to LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130394

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


[PATCH] D131360: [clang-format] Fixes crash in QualifierOrder

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

Prevent Null Token from causing a crash

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


https://reviews.llvm.org/D131360

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -930,5 +930,15 @@
"TemplateType t;", Style);
 }
 
+TEST_F(QualifierFixerTest, ConstVolatile) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Left;
+  Style.QualifierOrder = { "const", "volatile", "type" };
+
+  verifyFormat("bool empty() const volatile { return true; }",
+   "bool empty() const volatile { return true; }",
+   Style);
+}
+
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -303,6 +303,9 @@
 
   if (LastQual && Qual != LastQual && Qual->is(QualifierType)) {
 rotateTokens(SourceMgr, Fixes, Tok, Qual, /*Left=*/true);
+if (!Qual->Next) {
+  return Qual;
+}
 Tok = Qual->Next;
   } else if (Tok->startsSequence(tok::identifier, QualifierType)) {
 if (Tok->Next->Next && Tok->Next->Next->isOneOf(tok::identifier, tok::star,
@@ -320,11 +323,11 @@
   Tok = Closer;
 }
   }
-  if (Tok->is(TT_TemplateOpener) && Tok->Next &&
+  if (Tok && Tok->is(TT_TemplateOpener) && Tok->Next &&
   (Tok->Next->is(tok::identifier) || Tok->Next->isSimpleTypeSpecifier()) &&
   Tok->Next->Next && Tok->Next->Next->is(QualifierType))
 rotateTokens(SourceMgr, Fixes, Tok->Next, Tok->Next->Next, /*Left=*/true);
-  if (Tok->startsSequence(tok::identifier) && Tok->Next) {
+  if (Tok && Tok->startsSequence(tok::identifier) && Tok->Next) {
 if (Tok->Previous &&
 Tok->Previous->isOneOf(tok::star, tok::ampamp, tok::amp))
   return Tok;


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -930,5 +930,15 @@
"TemplateType t;", Style);
 }
 
+TEST_F(QualifierFixerTest, ConstVolatile) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Left;
+  Style.QualifierOrder = { "const", "volatile", "type" };
+
+  verifyFormat("bool empty() const volatile { return true; }",
+   "bool empty() const volatile { return true; }",
+   Style);
+}
+
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -303,6 +303,9 @@
 
   if (LastQual && Qual != LastQual && Qual->is(QualifierType)) {
 rotateTokens(SourceMgr, Fixes, Tok, Qual, /*Left=*/true);
+if (!Qual->Next) {
+  return Qual;
+}
 Tok = Qual->Next;
   } else if (Tok->startsSequence(tok::identifier, QualifierType)) {
 if (Tok->Next->Next && Tok->Next->Next->isOneOf(tok::identifier, tok::star,
@@ -320,11 +323,11 @@
   Tok = Closer;
 }
   }
-  if (Tok->is(TT_TemplateOpener) && Tok->Next &&
+  if (Tok && Tok->is(TT_TemplateOpener) && Tok->Next &&
   (Tok->Next->is(tok::identifier) || Tok->Next->isSimpleTypeSpecifier()) &&
   Tok->Next->Next && Tok->Next->Next->is(QualifierType))
 rotateTokens(SourceMgr, Fixes, Tok->Next, Tok->Next->Next, /*Left=*/true);
-  if (Tok->startsSequence(tok::identifier) && Tok->Next) {
+  if (Tok && Tok->startsSequence(tok::identifier) && Tok->Next) {
 if (Tok->Previous &&
 Tok->Previous->isOneOf(tok::star, tok::ampamp, tok::amp))
   return Tok;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-07 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

This seems to have been more disruptive than expected, since an existing 
CMakeCache.txt can make LLVM compile in previous C++14 configuration. This 
seems to make some of the bots fail in a way that makes the patches making use 
of C++17 features seem at fault.

See:
https://github.com/llvm/llvm-project/commit/ede96de751224487aea122af8bfb4e82bc54840b#commitcomment-80507826
https://reviews.llvm.org/rG32fd0b7fd5ab

How would you feel about adding something like

  #if defined(__cplusplus) && __cplusplus < 201703L
  #error "LLVM requires at least C++17"
  #endif

to some central header, to make this switch more visible?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-07 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3705131 , @royjacobson 
wrote:

> This seems to have been more disruptive than expected, since an existing 
> CMakeCache.txt can make LLVM compile in previous C++14 configuration. This 
> seems to make some of the bots fail in a way that makes the patches making 
> use of C++17 features seem at fault.
>
> See:
> https://github.com/llvm/llvm-project/commit/ede96de751224487aea122af8bfb4e82bc54840b#commitcomment-80507826
> https://reviews.llvm.org/rG32fd0b7fd5ab
>
> How would you feel about adding something like
>
>   #if defined(__cplusplus) && __cplusplus < 201703L
>   #error "LLVM requires at least C++17"
>   #endif
>
> to some central header, to make this switch more visible?

I am not opposed to that directly. But this seems a bit dangerous where bots 
retain the cmakecache - there must be other cases where we can't really protect 
in this way.

Another approach would be to unset CMAKE_CXX_STANDARD if it's below 17 in cmake 
directly.

But in general - I am not a huge fan of CI / bots trying to keep the cache 
around - many weird issues can arise from this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D131282: [mlir] fix `add_tablegen()` macro to allow installing mlir-pdll

2022-08-07 Thread Ashay Rane via Phabricator via cfe-commits
ashay-github updated this revision to Diff 450661.
ashay-github marked an inline comment as done.
ashay-github added a comment.

Simply invocation of `cmake_parse_arguments()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131282

Files:
  clang/utils/TableGen/CMakeLists.txt
  llvm/cmake/modules/TableGen.cmake
  llvm/utils/TableGen/CMakeLists.txt
  mlir/tools/mlir-pdll/CMakeLists.txt
  mlir/tools/mlir-tblgen/CMakeLists.txt


Index: mlir/tools/mlir-tblgen/CMakeLists.txt
===
--- mlir/tools/mlir-tblgen/CMakeLists.txt
+++ mlir/tools/mlir-tblgen/CMakeLists.txt
@@ -4,7 +4,7 @@
   TableGen
 )
 
-add_tablegen(mlir-tblgen MLIR
+add_tablegen(mlir-tblgen MLIR DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   AttrOrTypeDefGen.cpp
   AttrOrTypeFormatGen.cpp
   CodeGenHelpers.cpp
Index: mlir/tools/mlir-pdll/CMakeLists.txt
===
--- mlir/tools/mlir-pdll/CMakeLists.txt
+++ mlir/tools/mlir-pdll/CMakeLists.txt
@@ -12,7 +12,7 @@
   MLIRPDLLParser
   )
 
-add_tablegen(mlir-pdll MLIR_PDLL
+add_tablegen(mlir-pdll MLIR_PDLL DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   mlir-pdll.cpp
 
   DEPENDS
Index: llvm/utils/TableGen/CMakeLists.txt
===
--- llvm/utils/TableGen/CMakeLists.txt
+++ llvm/utils/TableGen/CMakeLists.txt
@@ -2,7 +2,7 @@
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_tablegen(llvm-tblgen LLVM
+add_tablegen(llvm-tblgen LLVM DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
   AsmMatcherEmitter.cpp
   AsmWriterEmitter.cpp
   AsmWriterInst.cpp
Index: llvm/cmake/modules/TableGen.cmake
===
--- llvm/cmake/modules/TableGen.cmake
+++ llvm/cmake/modules/TableGen.cmake
@@ -140,6 +140,8 @@
 endfunction()
 
 macro(add_tablegen target project)
+  cmake_parse_arguments(ADD_TABLEGEN "" "DESTINATION" "" ${ARGN})
+
   set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
   set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
 
@@ -149,7 +151,8 @@
 set(LLVM_ENABLE_OBJLIB ON)
   endif()
 
-  add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
+  add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB
+${ADD_TABLEGEN_UNPARSED_ARGUMENTS})
   set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS})
 
   set(${project}_TABLEGEN "${target}" CACHE
@@ -186,7 +189,7 @@
 endif()
   endif()
 
-  if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT 
LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS)
+  if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND 
LLVM_BUILD_UTILS)
 set(export_to_llvmexports)
 if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
 NOT LLVM_DISTRIBUTION_COMPONENTS)
@@ -196,7 +199,7 @@
 install(TARGETS ${target}
 ${export_to_llvmexports}
 COMPONENT ${target}
-RUNTIME DESTINATION "${${project}_TOOLS_INSTALL_DIR}")
+RUNTIME DESTINATION "${ADD_TABLEGEN_DESTINATION}")
 if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets("install-${target}"
DEPENDS ${target}
Index: clang/utils/TableGen/CMakeLists.txt
===
--- clang/utils/TableGen/CMakeLists.txt
+++ clang/utils/TableGen/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-add_tablegen(clang-tblgen CLANG
+add_tablegen(clang-tblgen CLANG DESTINATION "${CLANG_TOOLS_INSTALL_DIR}"
   ASTTableGen.cpp
   ClangASTNodesEmitter.cpp
   ClangASTPropertiesEmitter.cpp


Index: mlir/tools/mlir-tblgen/CMakeLists.txt
===
--- mlir/tools/mlir-tblgen/CMakeLists.txt
+++ mlir/tools/mlir-tblgen/CMakeLists.txt
@@ -4,7 +4,7 @@
   TableGen
 )
 
-add_tablegen(mlir-tblgen MLIR
+add_tablegen(mlir-tblgen MLIR DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   AttrOrTypeDefGen.cpp
   AttrOrTypeFormatGen.cpp
   CodeGenHelpers.cpp
Index: mlir/tools/mlir-pdll/CMakeLists.txt
===
--- mlir/tools/mlir-pdll/CMakeLists.txt
+++ mlir/tools/mlir-pdll/CMakeLists.txt
@@ -12,7 +12,7 @@
   MLIRPDLLParser
   )
 
-add_tablegen(mlir-pdll MLIR_PDLL
+add_tablegen(mlir-pdll MLIR_PDLL DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   mlir-pdll.cpp
 
   DEPENDS
Index: llvm/utils/TableGen/CMakeLists.txt
===
--- llvm/utils/TableGen/CMakeLists.txt
+++ llvm/utils/TableGen/CMakeLists.txt
@@ -2,7 +2,7 @@
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_tablegen(llvm-tblgen LLVM
+add_tablegen(llvm-tblgen LLVM DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
   AsmMatcherEmitter.cpp
   AsmWriterEmitter.cpp
   AsmWriterInst.cpp
Index: llvm/cmake/modules/TableGen.cmake
=

[PATCH] D131282: [mlir] fix `add_tablegen()` macro to allow installing mlir-pdll

2022-08-07 Thread Ashay Rane via Phabricator via cfe-commits
ashay-github added inline comments.



Comment at: llvm/cmake/modules/TableGen.cmake:147
+  cmake_parse_arguments(ADD_TABLEGEN "${options}" "${oneValueArgs}"
+"${multiValueArgs}" ${ARGN})
+

nikic wrote:
> I think it would be fine to write this as just 
> `cmake_parse_arguments(ADD_TABLEGEN "" "OPTIONS" "" ${ARGN})`, but don't feel 
> strongly about that.
Thanks! Rewrote it as `cmake_parse_arguments(ADD_TABLEGEN "" "DESTINATION" "" 
${ARGN})`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131282

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-07 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

In D130689#3705145 , @thieta wrote:

> In D130689#3705131 , @royjacobson 
> wrote:
>
>> This seems to have been more disruptive than expected, since an existing 
>> CMakeCache.txt can make LLVM compile in previous C++14 configuration. This 
>> seems to make some of the bots fail in a way that makes the patches making 
>> use of C++17 features seem at fault.
>>
>> See:
>> https://github.com/llvm/llvm-project/commit/ede96de751224487aea122af8bfb4e82bc54840b#commitcomment-80507826
>> https://reviews.llvm.org/rG32fd0b7fd5ab
>>
>> How would you feel about adding something like
>>
>>   #if defined(__cplusplus) && __cplusplus < 201703L
>>   #error "LLVM requires at least C++17"
>>   #endif
>>
>> to some central header, to make this switch more visible?
>
> I am not opposed to that directly. But this seems a bit dangerous where bots 
> retain the cmakecache - there must be other cases where we can't really 
> protect in this way.
>
> Another approach would be to unset CMAKE_CXX_STANDARD if it's below 17 in 
> cmake directly.
>
> But in general - I am not a huge fan of CI / bots trying to keep the cache 
> around - many weird issues can arise from this.

This affects people on their work branches as well, and it's not obvious that 
it's a configuration error and not a broken master.

The CMake approach sounds cleaner to me, but I don't know CMake well enough to 
do it - if you could post a follow up patch I think it would be quite helpful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-07 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3705236 , @royjacobson 
wrote:

> This affects people on their work branches as well, and it's not obvious that 
> it's a configuration error and not a broken master.
>
> The CMake approach sounds cleaner to me, but I don't know CMake well enough 
> to do it - if you could post a follow up patch I think it would be quite 
> helpful.

Good point - I tried a few things and came up with an approach that works here: 
https://reviews.llvm.org/D131367 - have a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D131368: [Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}

2022-08-07 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

MapEntryOptionalStorage is an underlying storage class for
OptionalStorage.

This patch deprecates:

  OptionalStorage::hasValue
  OptionalStorage::getValue

as there is no known users of these two methods.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131368

Files:
  clang/include/clang/Basic/DirectoryEntry.h


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -131,13 +131,15 @@
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
+  [[deprecated("Use has_value instead.")]] bool hasValue() const {
+return MaybeRef.hasOptionalValue();
+  }
 
   RefTy &value() & {
 assert(has_value());
 return MaybeRef;
   }
-  RefTy &getValue() & {
+  [[deprecated("Use value instead.")]] RefTy &getValue() & {
 assert(has_value());
 return MaybeRef;
   }
@@ -145,7 +147,7 @@
 assert(has_value());
 return MaybeRef;
   }
-  RefTy const &getValue() const & {
+  [[deprecated("Use value instead.")]] RefTy const &getValue() const & {
 assert(has_value());
 return MaybeRef;
   }
@@ -153,7 +155,7 @@
 assert(has_value());
 return std::move(MaybeRef);
   }
-  RefTy &&getValue() && {
+  [[deprecated("Use value instead.")]] RefTy &&getValue() && {
 assert(has_value());
 return std::move(MaybeRef);
   }


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -131,13 +131,15 @@
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
+  [[deprecated("Use has_value instead.")]] bool hasValue() const {
+return MaybeRef.hasOptionalValue();
+  }
 
   RefTy &value() & {
 assert(has_value());
 return MaybeRef;
   }
-  RefTy &getValue() & {
+  [[deprecated("Use value instead.")]] RefTy &getValue() & {
 assert(has_value());
 return MaybeRef;
   }
@@ -145,7 +147,7 @@
 assert(has_value());
 return MaybeRef;
   }
-  RefTy const &getValue() const & {
+  [[deprecated("Use value instead.")]] RefTy const &getValue() const & {
 assert(has_value());
 return MaybeRef;
   }
@@ -153,7 +155,7 @@
 assert(has_value());
 return std::move(MaybeRef);
   }
-  RefTy &&getValue() && {
+  [[deprecated("Use value instead.")]] RefTy &&getValue() && {
 assert(has_value());
 return std::move(MaybeRef);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131360: [clang-format] Fixes crash in QualifierOrder

2022-08-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

It seems rG492cb7bf9164 
 also 
fixed this.


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

https://reviews.llvm.org/D131360

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


[PATCH] D131360: [clang-format] Fixes crash in QualifierOrder

2022-08-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Maybe I didn’t rebase correctly, let me retry and I’ll abandon if necessary, 
Thanks @owenpan for the pointer


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

https://reviews.llvm.org/D131360

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


[PATCH] D129926: [clang-format] Handle constructor invocations after new operator in C# correct

2022-08-07 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

Can we land this for you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129926

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


[clang] d1bb301 - [mlir] fix `add_tablegen()` macro to allow installing mlir-pdll

2022-08-07 Thread Ashay Rane via cfe-commits

Author: Ashay Rane
Date: 2022-08-07T15:48:38-07:00
New Revision: d1bb3016ddc8331a96048eda37ab13bf412c7749

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

LOG: [mlir] fix `add_tablegen()` macro to allow installing mlir-pdll

Prior to this patch, the `add_tablegen()` macro in
llvm/cmake/modules/TableGen.cmake added the install rule only if
`project` matched `LLVM` or `MLIR`.  This patch adds an optional
`DESTINATION` argument, which, if non-empty, decides whether (and where)
to install the tablegen tool, thus eliminating the need for
project-specific overrides.  This patch also updates all other
invocations of the `add_tablegen()` macro.

Reviewed By: nikic

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

Added: 


Modified: 
clang/utils/TableGen/CMakeLists.txt
llvm/cmake/modules/TableGen.cmake
llvm/utils/TableGen/CMakeLists.txt
mlir/tools/mlir-pdll/CMakeLists.txt
mlir/tools/mlir-tblgen/CMakeLists.txt

Removed: 




diff  --git a/clang/utils/TableGen/CMakeLists.txt 
b/clang/utils/TableGen/CMakeLists.txt
index 04aa72cde03e3..d2cb29dd23a30 100644
--- a/clang/utils/TableGen/CMakeLists.txt
+++ b/clang/utils/TableGen/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-add_tablegen(clang-tblgen CLANG
+add_tablegen(clang-tblgen CLANG DESTINATION "${CLANG_TOOLS_INSTALL_DIR}"
   ASTTableGen.cpp
   ClangASTNodesEmitter.cpp
   ClangASTPropertiesEmitter.cpp

diff  --git a/llvm/cmake/modules/TableGen.cmake 
b/llvm/cmake/modules/TableGen.cmake
index 4711456776c86..172621d377485 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -140,6 +140,8 @@ function(add_public_tablegen_target target)
 endfunction()
 
 macro(add_tablegen target project)
+  cmake_parse_arguments(ADD_TABLEGEN "" "DESTINATION" "" ${ARGN})
+
   set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
   set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
 
@@ -149,7 +151,8 @@ macro(add_tablegen target project)
 set(LLVM_ENABLE_OBJLIB ON)
   endif()
 
-  add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
+  add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB
+${ADD_TABLEGEN_UNPARSED_ARGUMENTS})
   set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS})
 
   set(${project}_TABLEGEN "${target}" CACHE
@@ -186,7 +189,7 @@ macro(add_tablegen target project)
 endif()
   endif()
 
-  if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT 
LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS)
+  if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND 
LLVM_BUILD_UTILS)
 set(export_to_llvmexports)
 if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
 NOT LLVM_DISTRIBUTION_COMPONENTS)
@@ -196,7 +199,7 @@ macro(add_tablegen target project)
 install(TARGETS ${target}
 ${export_to_llvmexports}
 COMPONENT ${target}
-RUNTIME DESTINATION "${${project}_TOOLS_INSTALL_DIR}")
+RUNTIME DESTINATION "${ADD_TABLEGEN_DESTINATION}")
 if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets("install-${target}"
DEPENDS ${target}

diff  --git a/llvm/utils/TableGen/CMakeLists.txt 
b/llvm/utils/TableGen/CMakeLists.txt
index 725c99b8e08ef..bf4d51b8dca44 100644
--- a/llvm/utils/TableGen/CMakeLists.txt
+++ b/llvm/utils/TableGen/CMakeLists.txt
@@ -2,7 +2,7 @@ add_subdirectory(GlobalISel)
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_tablegen(llvm-tblgen LLVM
+add_tablegen(llvm-tblgen LLVM DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
   AsmMatcherEmitter.cpp
   AsmWriterEmitter.cpp
   AsmWriterInst.cpp

diff  --git a/mlir/tools/mlir-pdll/CMakeLists.txt 
b/mlir/tools/mlir-pdll/CMakeLists.txt
index b195d62dfd076..6acee39e875cd 100644
--- a/mlir/tools/mlir-pdll/CMakeLists.txt
+++ b/mlir/tools/mlir-pdll/CMakeLists.txt
@@ -12,7 +12,7 @@ set(LIBS
   MLIRPDLLParser
   )
 
-add_tablegen(mlir-pdll MLIR_PDLL
+add_tablegen(mlir-pdll MLIR_PDLL DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   mlir-pdll.cpp
 
   DEPENDS

diff  --git a/mlir/tools/mlir-tblgen/CMakeLists.txt 
b/mlir/tools/mlir-tblgen/CMakeLists.txt
index e3e3ed91515dd..85f9207f723b1 100644
--- a/mlir/tools/mlir-tblgen/CMakeLists.txt
+++ b/mlir/tools/mlir-tblgen/CMakeLists.txt
@@ -4,7 +4,7 @@ set(LLVM_LINK_COMPONENTS
   TableGen
 )
 
-add_tablegen(mlir-tblgen MLIR
+add_tablegen(mlir-tblgen MLIR DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   AttrOrTypeDefGen.cpp
   AttrOrTypeFormatGen.cpp
   CodeGenHelpers.cpp



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


[PATCH] D131282: [mlir] fix `add_tablegen()` macro to allow installing mlir-pdll

2022-08-07 Thread Ashay Rane 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 rGd1bb3016ddc8: [mlir] fix `add_tablegen()` macro to allow 
installing mlir-pdll (authored by ashay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131282

Files:
  clang/utils/TableGen/CMakeLists.txt
  llvm/cmake/modules/TableGen.cmake
  llvm/utils/TableGen/CMakeLists.txt
  mlir/tools/mlir-pdll/CMakeLists.txt
  mlir/tools/mlir-tblgen/CMakeLists.txt


Index: mlir/tools/mlir-tblgen/CMakeLists.txt
===
--- mlir/tools/mlir-tblgen/CMakeLists.txt
+++ mlir/tools/mlir-tblgen/CMakeLists.txt
@@ -4,7 +4,7 @@
   TableGen
 )
 
-add_tablegen(mlir-tblgen MLIR
+add_tablegen(mlir-tblgen MLIR DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   AttrOrTypeDefGen.cpp
   AttrOrTypeFormatGen.cpp
   CodeGenHelpers.cpp
Index: mlir/tools/mlir-pdll/CMakeLists.txt
===
--- mlir/tools/mlir-pdll/CMakeLists.txt
+++ mlir/tools/mlir-pdll/CMakeLists.txt
@@ -12,7 +12,7 @@
   MLIRPDLLParser
   )
 
-add_tablegen(mlir-pdll MLIR_PDLL
+add_tablegen(mlir-pdll MLIR_PDLL DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   mlir-pdll.cpp
 
   DEPENDS
Index: llvm/utils/TableGen/CMakeLists.txt
===
--- llvm/utils/TableGen/CMakeLists.txt
+++ llvm/utils/TableGen/CMakeLists.txt
@@ -2,7 +2,7 @@
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_tablegen(llvm-tblgen LLVM
+add_tablegen(llvm-tblgen LLVM DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
   AsmMatcherEmitter.cpp
   AsmWriterEmitter.cpp
   AsmWriterInst.cpp
Index: llvm/cmake/modules/TableGen.cmake
===
--- llvm/cmake/modules/TableGen.cmake
+++ llvm/cmake/modules/TableGen.cmake
@@ -140,6 +140,8 @@
 endfunction()
 
 macro(add_tablegen target project)
+  cmake_parse_arguments(ADD_TABLEGEN "" "DESTINATION" "" ${ARGN})
+
   set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
   set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
 
@@ -149,7 +151,8 @@
 set(LLVM_ENABLE_OBJLIB ON)
   endif()
 
-  add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
+  add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB
+${ADD_TABLEGEN_UNPARSED_ARGUMENTS})
   set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS})
 
   set(${project}_TABLEGEN "${target}" CACHE
@@ -186,7 +189,7 @@
 endif()
   endif()
 
-  if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT 
LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS)
+  if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND 
LLVM_BUILD_UTILS)
 set(export_to_llvmexports)
 if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
 NOT LLVM_DISTRIBUTION_COMPONENTS)
@@ -196,7 +199,7 @@
 install(TARGETS ${target}
 ${export_to_llvmexports}
 COMPONENT ${target}
-RUNTIME DESTINATION "${${project}_TOOLS_INSTALL_DIR}")
+RUNTIME DESTINATION "${ADD_TABLEGEN_DESTINATION}")
 if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets("install-${target}"
DEPENDS ${target}
Index: clang/utils/TableGen/CMakeLists.txt
===
--- clang/utils/TableGen/CMakeLists.txt
+++ clang/utils/TableGen/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-add_tablegen(clang-tblgen CLANG
+add_tablegen(clang-tblgen CLANG DESTINATION "${CLANG_TOOLS_INSTALL_DIR}"
   ASTTableGen.cpp
   ClangASTNodesEmitter.cpp
   ClangASTPropertiesEmitter.cpp


Index: mlir/tools/mlir-tblgen/CMakeLists.txt
===
--- mlir/tools/mlir-tblgen/CMakeLists.txt
+++ mlir/tools/mlir-tblgen/CMakeLists.txt
@@ -4,7 +4,7 @@
   TableGen
 )
 
-add_tablegen(mlir-tblgen MLIR
+add_tablegen(mlir-tblgen MLIR DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   AttrOrTypeDefGen.cpp
   AttrOrTypeFormatGen.cpp
   CodeGenHelpers.cpp
Index: mlir/tools/mlir-pdll/CMakeLists.txt
===
--- mlir/tools/mlir-pdll/CMakeLists.txt
+++ mlir/tools/mlir-pdll/CMakeLists.txt
@@ -12,7 +12,7 @@
   MLIRPDLLParser
   )
 
-add_tablegen(mlir-pdll MLIR_PDLL
+add_tablegen(mlir-pdll MLIR_PDLL DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
   mlir-pdll.cpp
 
   DEPENDS
Index: llvm/utils/TableGen/CMakeLists.txt
===
--- llvm/utils/TableGen/CMakeLists.txt
+++ llvm/utils/TableGen/CMakeLists.txt
@@ -2,7 +2,7 @@
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_tablegen(llvm-tblgen LLVM
+add_tablegen(llvm-tblgen LLVM DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
   AsmMatcherEmitter.cpp
   AsmWriterEmitter.cpp
   AsmWriterInst.cpp
Index: 

[PATCH] D131307: [Clang] Allow downgrading to a warning the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2022-08-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D131307#3704709 , @thakis wrote:

> It's already an error, but it's a warning default-mapped to an error. You can 
> -Wno-error=name to downgrade it into a warning, but that requires an explicit 
> action. So people are unlikely to miss it.
>
> This is how we usually handle these breaking changes.
>
> Maybe there could be a test for the -Wno-error= case? But this looks roughly 
> right to me overall. I haven't looked in detail.

Right, but we also want people to understand that the downgrade possibility 
will be going away in the next release (i.e. it'll always be an error and 
there's nothing you can do about that), so they really do want to deal with 
this as a priority.


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

https://reviews.llvm.org/D131307

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


[PATCH] D130867: [clang] adds builtin `std::invoke` and `std::invoke_r`

2022-08-07 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5726-5731
+  FirstArgType = S.BuiltinAddReference(
+  dyn_cast(
+  dyn_cast(FirstArgType)->getNamedType())
+  ->getArg(0)
+  .getAsType(),
+  Sema::UTTKind::AddLvalueReference, {});




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130867

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


[PATCH] D129824: [RISCV] Set triple based on -march flag which can be deduced in more generic way

2022-08-07 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.

In D129824#3699911 , @kito-cheng 
wrote:

> Just realized the problem is trying to fixed the default value of `-mabi=`, 
> currently `clang -target riscv32-elf -march=rv64gc 
> -mabi=lp64d`/`riscv32-elf-clang -march=rv64gc -mabi=lp64d` is work, and match 
> the behavior of GCC did, `riscv32-elf-gcc -march=rv64gc -mabi=lp64d`.
>
> And this patch is trying to make following two command work: `clang -target 
> riscv32-elf -march=rv64gc`/`riscv32-elf-clang -march=rv64gc`, specify 
> `-march` and `-target` but no `-mabi`.
>
> That is different story now, GCC isn't deduce the default abi from either 
> target triple or abi, so if you invoke gcc with `riscv32-elf-gcc 
> -march=rv64gc` or `riscv64-elf-gcc -march=rv32gc`, you will got error message 
> like that: `cc1: error: ABI requires '-march=rv32'` or `cc1: error: ABI 
> requires '-march=rv64'`.
>
> So that's not compatible issue with GCC, that's sort of clang driver specify 
> issue, and I don't have strong opinion on this.
>
> ---
>
> As a GNU toolchain developer, I would say, we are not intend to change the 
> behavior of default value of `-mabi` or `-march`, the consensus among RISC-V 
> GNU toolchain maintainer is user should explicitly specify the `-march` and 
> `-mabi` if you are not using default `-march` and `-mabi`.

This patch is not about default value of mabi. It just tries to deduce march 
when -march option is not provided explicitly. 
It fixes the conflict between target triple and march about 32-bit/64-bit 
(riscv32 or riscv64) issue as before. Before this patch, this conflict only can 
be solved by specifying -march option explicitly.


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

https://reviews.llvm.org/D129824

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-07 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

We are seeing an additional failure on an internal linux bot due to the change 
to using C++17 by default when using GNU ld:

  [3/7] Generating GwpAsan-x86_64-Test
  FAILED: projects/compiler-rt/lib/gwp_asan/tests/GwpAsan-x86_64-Test 
  cd 
/home/jenkins/j/w/workspace/opensource/opensource_build/build/projects/compiler-rt/lib/gwp_asan/tests
 && /home/jenkins/j/w/workspace/opensource/opensource_build/build/./bin/clang++ 
GwpAsanTestObjects.printf_sanitizer_common.cpp.x86_64.o 
GwpAsanTestObjects.alignment.cpp.x86_64.o 
GwpAsanTestObjects.backtrace.cpp.x86_64.o GwpAsanTestObjects.basic.cpp.x86_64.o 
GwpAsanTestObjects.compression.cpp.x86_64.o 
GwpAsanTestObjects.iterate.cpp.x86_64.o 
GwpAsanTestObjects.crash_handler_api.cpp.x86_64.o 
GwpAsanTestObjects.driver.cpp.x86_64.o 
GwpAsanTestObjects.mutex_test.cpp.x86_64.o 
GwpAsanTestObjects.slot_reuse.cpp.x86_64.o 
GwpAsanTestObjects.thread_contention.cpp.x86_64.o 
GwpAsanTestObjects.harness.cpp.x86_64.o 
GwpAsanTestObjects.enable_disable.cpp.x86_64.o 
GwpAsanTestObjects.late_init.cpp.x86_64.o 
GwpAsanTestObjects.options.cpp.x86_64.o 
GwpAsanTestObjects.gtest-all.cc.x86_64.o 
/home/jenkins/j/w/workspace/opensource/opensource_build/build/projects/compiler-rt/lib/gwp_asan/tests/libRTGwpAsanTest.x86_64.a
 -o 
/home/jenkins/j/w/workspace/opensource/opensource_build/build/projects/compiler-rt/lib/gwp_asan/tests/./GwpAsan-x86_64-Test
 -ldl -lstdc++ --driver-mode=g++ -pthread -m64
  /usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x25
  GwpAsanTestObjects.backtrace.cpp.x86_64.o: in function 
`Backtrace_ExceedsStorableLength_Test::TestBody()':
  backtrace.cpp:(.text+0xce6): undefined reference to 
`gwp_asan::AllocationMetadata::kMaxTraceLengthToCollect'
  clang-16: error: linker command failed with exit code 1 (use -v to see 
invocation)

And it seems at least one buildbot is also hitting the same issue:
https://lab.llvm.org/staging/#/builders/180/builds/7174

  [165/1101] Generating GwpAsan-x86_64-Test
  FAILED: projects/compiler-rt/lib/gwp_asan/tests/GwpAsan-x86_64-Test 
  cd 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/projects/compiler-rt/lib/gwp_asan/tests
 && 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/./bin/clang++
 GwpAsanTestObjects.printf_sanitizer_common.cpp.x86_64.o 
GwpAsanTestObjects.alignment.cpp.x86_64.o 
GwpAsanTestObjects.backtrace.cpp.x86_64.o GwpAsanTestObjects.basic.cpp.x86_64.o 
GwpAsanTestObjects.compression.cpp.x86_64.o 
GwpAsanTestObjects.iterate.cpp.x86_64.o 
GwpAsanTestObjects.crash_handler_api.cpp.x86_64.o 
GwpAsanTestObjects.driver.cpp.x86_64.o 
GwpAsanTestObjects.mutex_test.cpp.x86_64.o 
GwpAsanTestObjects.slot_reuse.cpp.x86_64.o 
GwpAsanTestObjects.thread_contention.cpp.x86_64.o 
GwpAsanTestObjects.harness.cpp.x86_64.o 
GwpAsanTestObjects.enable_disable.cpp.x86_64.o 
GwpAsanTestObjects.late_init.cpp.x86_64.o 
GwpAsanTestObjects.options.cpp.x86_64.o 
GwpAsanTestObjects.gtest-all.cc.x86_64.o 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/projects/compiler-rt/lib/gwp_asan/tests/libRTGwpAsanTest.x86_64.a
 -o 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/projects/compiler-rt/lib/gwp_asan/tests/./GwpAsan-x86_64-Test
 -ldl -lstdc++ --driver-mode=g++ -pthread -m64
  /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: 
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: DWARF 
error: invalid or unhandled FORM value: 0x23
  GwpAsanTestObjects.backtrace.cpp.x86_64.o: in function 
`Backtrace_ExceedsStorableLength_Test::TestBody()':
  backtrace.cpp:(.text+0xca6): undefined reference to 
`gwp_asan::AllocationMetadata::kMaxTraceLengthToCollect'
  clang-16: error: linker command failed with exit code 1 (use -v to see 
invocation)

Switching between BFD ld and gold still fails (although gold fails for a 
slightly different reason). Superficially it seems that switching to C++17 for 
some reason might be causing the compiler to emit debug info that these older 
non-lld linkers cannot understand for some reason?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D131062: [docs] Add "C++20 Modules"

2022-08-07 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a reviewer: h-vetinari.
ChuanqiXu marked 45 inline comments as done.
ChuanqiXu added a comment.

In D131062#3704017 , @h-vetinari 
wrote:

>> It would be greatly welcome for such comments!
>
> OK, here goes. Sorry for the large volume of comments. In addition to typos 
> and stylistic improvements, I've had a few questions where the content wasn't 
> clear to me (but note I'm not experienced with modules at all, so this may be 
> obvious to others). I've also added a few line breaks where Phab was 
> awkwardly overflowing. The position of the linebreaks is obviously 
> irrelevant, but I thought it might help further review.

Many thanks for the though review! It is very helpful.

> I've had a few questions where the content wasn't clear to me (but note I'm 
> not experienced with modules at all, so this may be obvious to others)

This is welcome. In fact, it is a failure if the document requires the reader 
to have experienced with modules.




Comment at: clang/docs/CPlusPlus20Modules.rst:15-16
+share a big part of codes. But from the perspective of users, their semantics 
and
+command line interfaces are very different. So it should be helpful for the 
users
+to introduce how to use C++20 modules.
+

h-vetinari wrote:
> Not 100% what the intention of the last sentence is - I presume it sets the 
> goal for this document?
The intention was to describe the motivation of the document, but we have 
stated it again in the next paragraph. So the suggestion looks fine.



Comment at: clang/docs/CPlusPlus20Modules.rst:20-21
+should be helpful to read `Clang modules `_ if you want to know
+more about the general idea of modules. Due to the C++20 modules having very
+different semantics, it might be more friendly for users who care about C++20
+modules only to create a new page.

h-vetinari wrote:
> > Due to the C++20 modules having very different semantics, it might be more 
> > friendly for users who care about C++20 modules only to create a new page.
> 
> Isn't "C++20 modules" what this page intends to do? Which new page are we 
> talking about then?
The `new page` here refers to the document. The intention here is that the 
users may be confused about `clang modules` and `c++20 modules` and there is 
already a document about `clang modules`. So I am wondering it might be helpful 
to explain why we need a new document for `C++20 Modules` instead of `clang 
modules`.



Comment at: clang/docs/CPlusPlus20Modules.rst:64-66
+Things in ``[]`` means optional. The syntax of ``module_name`` and 
``partition_name``
+in regex form should be ``[a-zA-Z_][a-zA-Z_0-9.]*``. The dot ``.`` in the name 
has
+no special meaning.

h-vetinari wrote:
> > The dot ``.`` in the name has no special meaning.
> 
> Not sure if this is intended to say that the dot in the regex is not needed, 
> or that it has no semantic significance.
> 
> Also, when wanting to match a literal "." in a regex, I'd consider it 
> beneficial for clarity to escape it ("\."), even though it does what's 
> intended in the context of [].
> Not sure if this is intended to say that the dot in the regex is not needed, 
> or that it has no semantic significance.

I mean that it has no semantic significance. For example, the user from python 
may feel like the dot `.` may be related to `hierarchy`. But it is not the case 
for C++.



Comment at: clang/docs/CPlusPlus20Modules.rst:224-226
+The file name of ``importable module unit`` must end with ``.cppm``
+(or ``.ccm``, ``.cxxm``, etc). The file name of ``module implementation unit``
+should end with ``.cpp`` (or ``.cc``, ``.cxx``, etc).

h-vetinari wrote:
> As a reader, I have no idea how to parse
> >  must end with ``.cppm`` (or ``.ccm``, ``.cxxm``, etc)
> 
> On the one hand there's a clear restriction ("must"), on the other there's an 
> open-ended list, whose contents are not clear to me.
What I want to say is for `etc` is `usual c++ source file suffix` + `m`. 
Currently, the list is `.cppm`, `.ccm`, `.cxxm` and `.c++m`. The reason why I 
put `etc` is that I am afraid of the list may goes longer in the future. But it 
looks better to state things clear now. I'll follow the suggestion.



Comment at: clang/docs/CPlusPlus20Modules.rst:228-230
+The file name of module files should end with ``.pcm``.
+The file name of the module file of a ``primary module interface unit`` should 
be ``module_name.pcm``.
+The file name of module files of ``module partition unit`` should be 
``module_name-partition_name.pcm``.

h-vetinari wrote:
> Similarly here; can we describe the origin or the restrictions should/must - 
> i.e. do they come from the standard or from the Clang implementation? Is 
> there any enforcement, or do things just error otherwise?
The comes from the clang implementation. If the user don't follow th

[PATCH] D131062: [docs] Add "C++20 Modules"

2022-08-07 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 450692.
ChuanqiXu marked 8 inline comments as done.
ChuanqiXu added a comment.

Address comments.


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

https://reviews.llvm.org/D131062

Files:
  clang/docs/CPlusPlus20Modules.rst
  clang/docs/index.rst

Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -40,6 +40,7 @@
SafeStack
ShadowCallStack
SourceBasedCodeCoverage
+   CPlusPlus20Modules
Modules
MSVCCompatibility
MisExpect
Index: clang/docs/CPlusPlus20Modules.rst
===
--- /dev/null
+++ clang/docs/CPlusPlus20Modules.rst
@@ -0,0 +1,678 @@
+=
+C++20 Modules
+=
+
+.. contents::
+   :local:
+
+Introduction
+
+
+The term ``modules`` has a lot of meanings. For the users of Clang, modules may
+refer to ``Objective-C Modules``, ``Clang C++ Modules`` (or ``Clang Header Modules``,
+etc.) or C++20 modules. The implementation of all these kinds of modules in Clang 
+has a lot of shared code, but from the perspective of users, their semantics and
+command line interfaces are very different. This document focuses on
+an introduction of how to use C++20 modules in Clang.
+
+There is already a detailed document about `Clang modules `_, it
+should be helpful to read `Clang modules `_ if you want to know
+more about the general idea of modules. Due to the C++20 modules having very
+different semantics, it might be more friendly for users who care about C++20
+modules only to create a new page.
+
+Although the term ``modules`` has a unique meaning in C++20 Language Specification,
+when people talk about C++20 modules, they may refer to another C++20 feature:
+header units. Therefore, this document will try to cover header units as well.
+
+C++20 Modules
+=
+
+This document was intended to be a manual first and foremost, however, we consider it helpful to
+introduce some language background here for readers who are not familiar with
+the new language feature. This document is not intended to be a language
+tutorial; it will only introduce necessary concepts about the
+structure and building of the project.
+
+Background and terminology
+--
+
+Modules
+~~~
+
+In this document, the term ``Modules``/``modules`` refers to C++20 modules
+feature if it is not decorated by ``Clang``.
+
+Clang Modules
+~
+
+In this document, the term ``Clang Modules``/``Clang modules`` refer to Clang
+c++ modules extension. There are also known as ``Clang header modules``,
+``Clang module map modules`` or ``Clang c++ modules``.
+
+Module and module unit
+~~
+
+A module consists of one or more module units. A module unit is a special
+translation unit. Every module unit should have a module declaration. The syntax
+of the module declaration is:
+
+.. code-block:: c++
+
+  [export] module module_name[:partition_name];
+
+Terms enclosed in ``[]`` are optional. The syntax of ``module_name`` and ``partition_name``
+in regex form corresponds to ``[a-zA-Z_][a-zA-Z_0-9\.]*``. The dot ``.`` in the name has
+no special meaning.
+
+In this document, module units are classified into:
+
+* Primary module interface unit.
+
+* Module implementation unit.
+
+* Module partition interface unit.
+
+* Module partition implementation unit.
+
+A primary module interface unit is a module unit whose module declaration is
+``export module module_name;``. The ``module_name`` here denotes the name of the
+module. A module should have one and only one primary module interface unit.
+
+A module implementation unit is a module unit whose module declaration is
+``module module_name;``. A module could have multiple module implementation
+units with the same declaration.
+
+A module partition interface unit is a module unit whose module declaration is
+``export module module_name:partition_name;``. The ``partition_name`` should be
+unique to the module.
+
+A module partition implementation unit is a module unit whose module declaration
+is ``module module_name:partition_name;``. The ``partition_name`` should be
+unique to the module.
+
+In this document, we use the following umbrella terms:
+
+* A ``module interface unit`` refers to either a ``primary module interface unit``
+or a ``module partition interface unit``.
+
+* An ``importable module unit`` refers to either a ``module interface unit``
+or a ``module partition implementation unit``.
+
+* A ``module partition unit`` refers to either a ``module partition interface unit``
+or a ``module partition implementation unit``.
+
+Module file
+~~~
+
+A module file stands for the precompiled result of an importable module unit.
+
+Global module fragment
+~~
+
+In a module unit, the section from ``module;`` to the module declaration is called the global module fragmen

[PATCH] D131258: [Sema] Merge variable template specializations

2022-08-07 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

When I run this locally, it emits several unexpected errors:

  While building module 'library':
  In file included from :2:
  
/disk2/workspace.xuchuanqi/llvm-project-for-work/build/tools/clang/test/Modules/Output/merge-var-template-spec.cpp.tmp/var2.h:4:32:
 error: redefinition of 'zero'
  template  constexpr T zero = 0;
 ^
  
/disk2/workspace.xuchuanqi/llvm-project-for-work/build/tools/clang/test/Modules/Output/merge-var-template-spec.cpp.tmp/var1.h:4:32:
 note: previous definition is here
  template  constexpr T zero = 0;
 ^
  While building module 'library':
  In file included from :2:
  
/disk2/workspace.xuchuanqi/llvm-project-for-work/build/tools/clang/test/Modules/Output/merge-var-template-spec.cpp.tmp/var2.h:5:8:
 error: redefinition of 'Int'
  struct Int {
 ^
  
/disk2/workspace.xuchuanqi/llvm-project-for-work/build/tools/clang/test/Modules/Output/merge-var-template-spec.cpp.tmp/var1.h:5:8:
 note: previous definition is here
  struct Int {
 ^
  While building module 'library':
  In file included from :2:
  
/disk2/workspace.xuchuanqi/llvm-project-for-work/build/tools/clang/test/Modules/Output/merge-var-template-spec.cpp.tmp/var2.h:8:27:
 error: redefinition of 'zero'
  template <> constexpr int zero = {0};
^
  
/disk2/workspace.xuchuanqi/llvm-project-for-work/build/tools/clang/test/Modules/Output/merge-var-template-spec.cpp.tmp/var1.h:8:27:
 note: previous definition is here
  template <> constexpr int zero = {0};
^
  While building module 'library':
  In file included from :2:
  
/disk2/workspace.xuchuanqi/llvm-project-for-work/build/tools/clang/test/Modules/Output/merge-var-template-spec.cpp.tmp/var2.h:9:33:
 error: redefinition of 'zero'
  template  constexpr T* zero = nullptr;
  ^
  
/disk2/workspace.xuchuanqi/llvm-project-for-work/build/tools/clang/test/Modules/Output/merge-var-template-spec.cpp.tmp/var1.h:9:33:
 note: previous definition is here
  template  constexpr T* zero = nullptr;
  ^
  4 errors generated.






Comment at: clang/test/Modules/merge-var-template-spec-cxx-modules.cpp:1
+// RUN: rm -rf %t
+// RUN: mkdir %t

Maybe it is better to rename this as `merge-var-template-spec.cppm` since we 
uses the suffix `.cppm` as a note for c++20 modules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131258

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


[PATCH] D131258: [Sema] Merge variable template specializations

2022-08-07 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/test/Modules/merge-var-template-spec-cxx-modules.cpp:18-23
+template  constexpr T zero = 0; // expected-error-re 
{{declaration{{.*}}in the global module follows declaration in module var_def}}
+ // expected-note@* {{previous}}
+template <> constexpr Int zero = {0}; // expected-error-re 
{{declaration{{.*}}in the global module follows declaration in module var_def}}
+   // expected-note@* {{previous}}
+template  constexpr T* zero = nullptr; // expected-error-re 
{{declaration{{.*}}in the global module follows declaration in module var_def}}
+// expected-note@* 
{{previous}}

BTW, these errors are not expected by me since they are not in a named modules 
and they are in different TU with var_def.cppm.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131258

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-07 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan added a comment.

There is a failure on the AIX bot also:

  152.827 [4302/10/270] Linking CXX executable bin/llvm-tblgen
  FAILED: bin/llvm-tblgen 
  : && /opt/IBM/openxlC/17.1.0/bin/ibm-clang++_r  -mcmodel=large -fPIC -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -fdiagnostics-color -ffunction-sections 
-fdata-sections -O3 -DNDEBUG -Wl,-bnoipath  
utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmWriterEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmWriterInst.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/Attributes.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CallingConvEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeEmitterGen.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenDAGPatterns.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenHwModes.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenInstruction.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenMapTable.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenRegisters.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenSchedule.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenTarget.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcherEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcherGen.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcherOpt.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcher.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DecoderEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DFAEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DFAPacketizerEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DirectiveEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DisassemblerEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/DXILEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/ExegesisEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/FastISelEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/GICombinerEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/GlobalISelEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/InfoByHwMode.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/InstrInfoEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/InstrDocsEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/IntrinsicEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/OptEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/OptParserEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/OptRSTEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/PredicateExpander.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/PseudoLoweringEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CompressInstEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/RegisterBankEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/RegisterInfoEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/SDNodeProperties.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/SearchableTableEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/SubtargetEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/SubtargetFeatureInfo.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/TableGen.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/Types.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/VarLenCodeEmitterGen.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86DisassemblerTables.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86EVEX2VEXTablesEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86FoldTablesEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86MnemonicTables.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86ModRMFilters.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86RecognizableInstr.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/WebAssemblyDisassemblerEmitter.cpp.o 
utils/TableGen/CMakeFiles/llvm-tblgen.dir/CTagsEmitter.cpp.o  -o 
bin/llvm-tblgen  
-Wl,-blibpath:"\$ORIGIN/../lib:/opt/IBM/xlmass/10.1.0/lib:/usr/lib:/lib"  
lib/libLLVMSupport.a  lib/libLLVMTableGen.a  -lpthreads  
lib/libLLVMTableGenGlobalISel.a  lib/libLLVMTableGen.a  lib/libLLVMSupport.a  
-lrt  -lld  -lpthreads  -lm  /usr/lib/libcurses.a  lib/libLLVMDemangle.a && :
  ld: 0711-317 ERROR: Undefined symbol: ._ZdlPvSt11align_val_t
  ld: 0711-317 ERROR: Undefined symbol: ._ZnwmSt11align_val_t
  ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
  .orig: error: linker command failed with exit code 8 (use -v to see 
invocation)

https://lab.llvm.org/buildbot/#/builders/214/build

[PATCH] D131134: [X86] Report error if the amx enabled on the non-64-bits target

2022-08-07 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 updated this revision to Diff 450702.
LiuChen3 added a comment.

fix lit fail and handle '-march=native'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131134

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/predefined-arch-macros.c
  clang/test/Preprocessor/x86_amx_target_features.c

Index: clang/test/Preprocessor/x86_amx_target_features.c
===
--- clang/test/Preprocessor/x86_amx_target_features.c
+++ clang/test/Preprocessor/x86_amx_target_features.c
@@ -1,35 +1,35 @@
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=AMX-TILE %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=AMX-TILE %s
 
 // AMX-TILE: #define __AMXTILE__ 1
 
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-BF16 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-bf16 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-BF16 %s
 
 // AMX-BF16: #define __AMXBF16__ 1
 // AMX-BF16: #define __AMXTILE__ 1
 
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-INT8 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-int8 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-INT8 %s
 
 // AMX-INT8: #define __AMXINT8__ 1
 // AMX-INT8: #define __AMXTILE__ 1
 
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-TILE %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-TILE %s
 
 // NOAMX-TILE-NOT: #define __AMXTILE__ 1
 
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-bf16 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mno-amx-bf16 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
 
 // NOAMX-BF16-NOT: #define __AMXBF16__ 1
 
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -amx-bf16 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -amx-bf16 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
 
 // NOAMX-BF16-NOT: #define __AMXTILE__ 1
 // NOAMX-BF16-NOT: #define __AMXBF16__ 1
 
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-int8 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mno-amx-int8 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
 
 // NOAMX-INT8-NOT: #define __AMXINT8__ 1
 
-// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -amx-int8 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -amx-int8 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
 
 // NOAMX-INT8-NOT: #define __AMXTILE__ 1
 // NOAMX-INT8-NOT: #define __AMXINT8__ 1
Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -1647,9 +1647,6 @@
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M32
 // CHECK_SPR_M32: #define __AES__ 1
-// CHECK_SPR_M32: #define __AMXBF16__ 1
-// CHECK_SPR_M32: #define __AMXINT8__ 1
-// CHECK_SPR_M32: #define __AMXTILE__ 1
 // CHECK_SPR_M32: #define __AVX2__ 1
 // CHECK_SPR_M32: #define __AVX512BF16__ 1
 // CHECK_SPR_M32: #define __AVX512BITALG__ 1
@@ -1716,7 +1713,7 @@
 // CHECK_SPR_M32: #define i386 1
 
 // RUN: %clang -march=sapphirerapids -m64 -E -dM %s -o - 2>&1 \
-// RUN: -target i386-unknown-linux \
+// RUN: -target x86_64-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M64
 // CHECK_SPR_M64: #define __AES__ 1
 // CHECK_SPR_M64: #define __AMXBF16__ 1
Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -270,20 +270,26 @@
 // WIDE_KL: "-target-feature" "+widekl"
 // NO-WIDE_KL: "-target-feature" "-widekl"
 
-// RUN: %clang --target=i386 -march=i386 -mamx-tile %s -### 2>&1 | FileCheck --check-prefix=AMX-TILE %s
-// RUN: %clang --target=i386 -march=i386 -mno-amx-tile %s -### 2>&1 | FileCheck --check-pref

[PATCH] D131319: [clang-tidy] Update llvm-prefer-isa-or-dyn-cast-in-conditionals with new syntax

2022-08-07 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 450705.
njames93 marked an inline comment as done.
njames93 added a comment.

Fix documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131319

Files:
  clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-isa-or-dyn-cast-in-conditionals.rst
  
clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp
@@ -17,6 +17,8 @@
 X *dyn_cast(Y *);
 template 
 X *dyn_cast_or_null(Y *);
+template 
+X *dyn_cast_if_present(Y *);
 
 bool foo(Y *y, Z *z) {
   if (auto x = cast(y))
@@ -63,32 +65,37 @@
 
   if (y && isa(y))
 return true;
-  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred over an explicit test for null followed by calling isa<> [llvm-prefer-isa-or-dyn-cast-in-conditionals]
-  // CHECK-FIXES: if (isa_and_nonnull(y))
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_present<> is preferred over an explicit test for null followed by calling isa<> [llvm-prefer-isa-or-dyn-cast-in-conditionals]
+  // CHECK-FIXES: if (isa_and_present(y))
 
   if (z->bar() && isa(z->bar()))
 return true;
-  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning:  isa_and_nonnull<> is preferred
-  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning:  isa_and_present<> is preferred
+  // CHECK-FIXES: if (isa_and_present(z->bar()))
 
   if (z->bar() && cast(z->bar()))
 return true;
-  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
-  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_present<> is preferred
+  // CHECK-FIXES: if (isa_and_present(z->bar()))
 
   if (z->bar() && dyn_cast(z->bar()))
 return true;
-  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
-  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_present<> is preferred
+  // CHECK-FIXES: if (isa_and_present(z->bar()))
 
   if (z->bar() && dyn_cast_or_null(z->bar()))
 return true;
-  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
-  // CHECK-FIXES: if (isa_and_nonnull(z->bar()))
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_present<> is preferred
+  // CHECK-FIXES: if (isa_and_present(z->bar()))
+
+  if (z->bar() && dyn_cast_if_present(z->bar()))
+return true;
+  // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_present<> is preferred
+  // CHECK-FIXES: if (isa_and_present(z->bar()))
 
   bool b = z->bar() && cast(z->bar());
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: isa_and_nonnull<> is preferred
-  // CHECK-FIXES: bool b = isa_and_nonnull(z->bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: isa_and_present<> is preferred
+  // CHECK-FIXES: bool b = isa_and_present(z->bar());
 
   // These don't trigger a warning.
   if (auto x = cast(y)->foo())
Index: clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-isa-or-dyn-cast-in-conditionals.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-isa-or-dyn-cast-in-conditionals.rst
+++ clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-isa-or-dyn-cast-in-conditionals.rst
@@ -26,7 +26,7 @@
 
   if (var && isa(var)) {}
   // is replaced by:
-  if (isa_and_nonnull(var.foo())) {}
+  if (isa_and_present(var.foo())) {}
 
   // Other cases are ignored, e.g.:
   if (auto f = cast(y)->foo()) {}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -105,6 +105,11 @@
 Changes in existing checks
 ^^
 
+- Updated :doc:`llvm-prefer-isa-or-dyn-cast-in-conditionals
+  ` check to
+  use the ``*and_present`` and ``*if_present`` templates added in 
+  `D123901 `_.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
@@ -42,14 +42,14 @@
 
   auto CallExpression =
   callExpr(
-  allOf(
-  unless(isMacroID()), unless(cxxMemberCallExpr())

[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-07 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3705474 , @dyung wrote:

> We are seeing an additional failure on an internal linux bot due to the 
> change to using C++17 by default when using GNU ld:
> ...
> Switching between BFD ld and gold still fails (although gold fails for a 
> slightly different reason). Superficially it seems that switching to C++17 
> for some reason might be causing the compiler to emit debug info that these 
> older non-lld linkers cannot understand for some reason?

Filed this issue here: https://github.com/llvm/llvm-project/issues/56994


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-07 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

In D130689#3705579 , @Jake-Egan wrote:

> There is a failure on the AIX bot also:
> ...
> https://lab.llvm.org/buildbot/#/builders/214/builds/2707/steps/5/logs/stdio

Filed an issue here: https://github.com/llvm/llvm-project/issues/56995


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[clang-tools-extra] 1dd8a31 - [clang-tidy] Use is_contained (NFC)

2022-08-07 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-07T23:55:25-07:00
New Revision: 1dd8a318544bdf4d06b337340d678df06e4f2f0a

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

LOG: [clang-tidy] Use is_contained (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
index 90b35df09f3d..f4ff4a9a744b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
@@ -112,7 +112,7 @@ void MoveForwardingReferenceCheck::check(
   // template as the function parameter of that type. (This implies that type
   // deduction will happen on the type.)
   const TemplateParameterList *Params = FuncTemplate->getTemplateParameters();
-  if (!std::count(Params->begin(), Params->end(), TypeParmDecl))
+  if (!llvm::is_contained(*Params, TypeParmDecl))
 return;
 
   auto Diag = diag(CallMove->getExprLoc(),

diff  --git a/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp 
b/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
index fdc837704a69..e5424c98a72a 100644
--- a/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
@@ -40,9 +40,7 @@ static char ValidDatePatternChars[] = {
 bool isValidDatePattern(StringRef Pattern) {
   for (auto &PatternChar : Pattern) {
 if (isalpha(PatternChar)) {
-  if (std::find(std::begin(ValidDatePatternChars),
-std::end(ValidDatePatternChars),
-PatternChar) == std::end(ValidDatePatternChars)) {
+  if (!llvm::is_contained(ValidDatePatternChars, PatternChar)) {
 return false;
   }
 }



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