[PATCH] D109818: [HIPSPV] Convert HIP kernels to SPIR-V kernels

2021-11-16 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 387506.
linjamaki added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109818

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenHIP/hipspv-kernel.cpp

Index: clang/test/CodeGenHIP/hipspv-kernel.cpp
===
--- /dev/null
+++ clang/test/CodeGenHIP/hipspv-kernel.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple spirv64 -x hip -emit-llvm -fcuda-is-device \
+// RUN:   -o - %s | FileCheck %s
+
+#define __global__ __attribute__((global))
+
+// CHECK: define {{.*}}spir_kernel void @_Z3fooPff(float addrspace(1)* {{.*}}, float {{.*}})
+__global__ void foo(float *a, float b) {
+  *a = b;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -10183,12 +10183,23 @@
 private:
   void setCCs();
 };
+
+class SPIRVABIInfo : public CommonSPIRABIInfo {
+public:
+  SPIRVABIInfo(CodeGenTypes &CGT) : CommonSPIRABIInfo(CGT) {}
+  void computeInfo(CGFunctionInfo &FI) const override;
+
+private:
+  ABIArgInfo classifyKernelArgumentType(QualType Ty) const;
+};
 } // end anonymous namespace
 namespace {
 class CommonSPIRTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   CommonSPIRTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
+  CommonSPIRTargetCodeGenInfo(std::unique_ptr ABIInfo)
+  : TargetCodeGenInfo(std::move(ABIInfo)) {}
 
   LangAS getASTAllocaAddressSpace() const override {
 return getLangASFromTargetAS(
@@ -10197,18 +10208,60 @@
 
   unsigned getOpenCLKernelCallingConv() const override;
 };
-
+class SPIRVTargetCodeGenInfo : public CommonSPIRTargetCodeGenInfo {
+public:
+  SPIRVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
+  : CommonSPIRTargetCodeGenInfo(std::make_unique(CGT)) {}
+  void setCUDAKernelCallingConvention(const FunctionType *&FT) const override;
+};
 } // End anonymous namespace.
+
 void CommonSPIRABIInfo::setCCs() {
   assert(getRuntimeCC() == llvm::CallingConv::C);
   RuntimeCC = llvm::CallingConv::SPIR_FUNC;
 }
 
+ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty) const {
+  if (getContext().getLangOpts().HIP) {
+// Coerce pointer arguments with default address space to CrossWorkGroup
+// pointers for HIPSPV. When the language mode is HIP, the SPIRTargetInfo
+// maps cuda_device to SPIR-V's CrossWorkGroup address space.
+llvm::Type *LTy = CGT.ConvertType(Ty);
+auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
+auto GlobalAS = getContext().getTargetAddressSpace(LangAS::cuda_device);
+if (LTy->isPointerTy() && LTy->getPointerAddressSpace() == DefaultAS) {
+  LTy = llvm::PointerType::get(
+  cast(LTy)->getElementType(), GlobalAS);
+  return ABIArgInfo::getDirect(LTy, 0, nullptr, false);
+}
+  }
+  return classifyArgumentType(Ty);
+}
+
+void SPIRVABIInfo::computeInfo(CGFunctionInfo &FI) const {
+  // The logic is same as in DefaultABIInfo with an exception on the kernel
+  // arguments handling.
+  llvm::CallingConv::ID CC = FI.getCallingConvention();
+
+  if (!getCXXABI().classifyReturnType(FI))
+FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+
+  for (auto &I : FI.arguments()) {
+if (CC == llvm::CallingConv::SPIR_KERNEL) {
+  I.info = classifyKernelArgumentType(I.type);
+} else {
+  I.info = classifyArgumentType(I.type);
+}
+  }
+}
+
 namespace clang {
 namespace CodeGen {
 void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI) {
-  DefaultABIInfo SPIRABI(CGM.getTypes());
-  SPIRABI.computeInfo(FI);
+  if (CGM.getTarget().getTriple().isSPIRV())
+SPIRVABIInfo(CGM.getTypes()).computeInfo(FI);
+  else
+CommonSPIRABIInfo(CGM.getTypes()).computeInfo(FI);
 }
 }
 }
@@ -10217,6 +10270,16 @@
   return llvm::CallingConv::SPIR_KERNEL;
 }
 
+void SPIRVTargetCodeGenInfo::setCUDAKernelCallingConvention(
+const FunctionType *&FT) const {
+  // Convert HIP kernels to SPIR-V kernels.
+  if (getABIInfo().getContext().getLangOpts().HIP) {
+FT = getABIInfo().getContext().adjustFunctionType(
+FT, FT->getExtInfo().withCallingConv(CC_OpenCLKernel));
+return;
+  }
+}
+
 static bool appendType(SmallStringEnc &Enc, QualType QType,
const CodeGen::CodeGenModule &CGM,
TypeStringCache &TSC);
@@ -11282,9 +11345,10 @@
 return SetCGInfo(new ARCTargetCodeGenInfo(Types));
   case llvm::Triple::spir:
   case llvm::Triple::spir64:
+return SetCGInfo(new CommonSPIRTargetCodeGenInfo(Types));
   case llvm::Triple::spirv32:
   case llvm::Triple::spirv64:
-return SetCGInfo(new CommonSPIRTargetCodeGenInfo(Types));
+return SetCGInfo(new SPIRVTargetCodeGenInfo(Types));
   case llvm::Triple::ve:
 return SetCGInfo(n

[PATCH] D110549: [HIPSPV][1/4] Refactor HIP tool chain

2021-11-16 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 387507.
linjamaki added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110549

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/HIP.h
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/lib/Driver/ToolChains/HIPAMD.h
  clang/lib/Driver/ToolChains/HIPUtility.cpp
  clang/lib/Driver/ToolChains/HIPUtility.h

Index: clang/lib/Driver/ToolChains/HIPUtility.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/HIPUtility.h
@@ -0,0 +1,35 @@
+//===--- HIPUtility.h - Common HIP Tool Chain Utilities -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPUTILITY_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPUTILITY_H
+
+#include "clang/Driver/Tool.h"
+
+namespace clang {
+namespace driver {
+namespace tools {
+namespace HIP {
+
+// Construct command for creating HIP fatbin.
+void constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
+   StringRef OutputFileName,
+   const InputInfoList &Inputs,
+   const llvm::opt::ArgList &TCArgs, const Tool &T);
+
+// Construct command for creating Object from HIP fatbin.
+void constructGenerateObjFileFromHIPFatBinary(
+Compilation &C, const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &Args, const JobAction &JA, const Tool &T);
+
+} // namespace HIP
+} // namespace tools
+} // namespace driver
+} // namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPUTILITY_H
Index: clang/lib/Driver/ToolChains/HIPUtility.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -0,0 +1,155 @@
+//===--- HIPUtility.cpp - Common HIP Tool Chain Utilities ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "HIPUtility.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Compilation.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Path.h"
+
+using namespace clang::driver;
+using namespace clang::driver::tools;
+using namespace llvm::opt;
+
+#if defined(_WIN32) || defined(_WIN64)
+#define NULL_FILE "nul"
+#else
+#define NULL_FILE "/dev/null"
+#endif
+
+namespace {
+const unsigned HIPCodeObjectAlign = 4096;
+} // namespace
+
+// Constructs a triple string for clang offload bundler.
+static std::string normalizeForBundler(const llvm::Triple &T,
+   bool HasTargetID) {
+  return HasTargetID ? (T.getArchName() + "-" + T.getVendorName() + "-" +
+T.getOSName() + "-" + T.getEnvironmentName())
+   .str()
+ : T.normalize();
+}
+
+// Construct a clang-offload-bundler command to bundle code objects for
+// different devices into a HIP fat binary.
+void HIP::constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
+StringRef OutputFileName,
+const InputInfoList &Inputs,
+const llvm::opt::ArgList &Args,
+const Tool &T) {
+  // Construct clang-offload-bundler command to bundle object files for
+  // for different GPU archs.
+  ArgStringList BundlerArgs;
+  BundlerArgs.push_back(Args.MakeArgString("-type=o"));
+  BundlerArgs.push_back(
+  Args.MakeArgString("-bundle-align=" + Twine(HIPCodeObjectAlign)));
+
+  // ToDo: Remove the dummy host binary entry which is required by
+  // clang-offload-bundler.
+  std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
+  std::string BundlerInputArg = "-inputs=" NULL_FILE;
+
+  // AMDGCN:
+  // For code object version 2 and 3, the offload kind in bundle ID is 'hip'
+  // for backward compatibility. For code object version 4 and greater, the
+  // offload kind in bundle ID is 'hipv4'.
+  std::string OffloadKind = "hip";
+  auto &TT = T.getToolChain().getTriple();
+  if (TT.isAMDGCN() && getAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
+OffloadKind = OffloadKind + "v4";
+  for (const auto &II : Inputs) {
+const auto *A = II.getA

[PATCH] D110618: [HIPSPV][2/4] Add HIPSPV tool chain

2021-11-16 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 387508.
linjamaki added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110618

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/HIPSPV.cpp
  clang/lib/Driver/ToolChains/HIPSPV.h

Index: clang/lib/Driver/ToolChains/HIPSPV.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/HIPSPV.h
@@ -0,0 +1,102 @@
+//===--- HIPSPV.h - HIP ToolChain Implementations ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPSPV_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPSPV_H
+
+#include "SPIRV.h"
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace tools {
+namespace HIPSPV {
+
+// Runs llvm-link/opt/llc/lld, which links multiple LLVM bitcode, together with
+// device library, then compiles it to SPIR-V in a shared object.
+class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
+public:
+  Linker(const ToolChain &TC) : Tool("HIPSPV::Linker", "hipspv-link", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+
+private:
+  void constructLinkAndEmitSpirvCommand(Compilation &C, const JobAction &JA,
+const InputInfoList &Inputs,
+const InputInfo &Output,
+const llvm::opt::ArgList &Args) const;
+};
+
+} // namespace HIPSPV
+} // namespace tools
+
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY HIPSPVToolChain final : public ToolChain {
+public:
+  HIPSPVToolChain(const Driver &D, const llvm::Triple &Triple,
+  const ToolChain &HostTC, const llvm::opt::ArgList &Args);
+
+  const llvm::Triple *getAuxTriple() const override {
+return &HostTC.getTriple();
+  }
+
+  void
+  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const override;
+  void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
+  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList &Args,
+  llvm::opt::ArgStringList &CC1Args) const override;
+  void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
+  llvm::SmallVector
+  getHIPDeviceLibs(const llvm::opt::ArgList &Args) const override;
+
+  SanitizerMask getSupportedSanitizers() const override;
+
+  VersionTuple
+  computeMSVCVersion(const Driver *D,
+ const llvm::opt::ArgList &Args) const override;
+
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool IsMathErrnoDefault() const override { return false; }
+  bool useIntegratedAs() const override { return true; }
+  bool isCrossCompiling() const override { return true; }
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
+return false;
+  }
+  bool isPICDefaultForced() const override { return false; }
+  bool SupportsProfiling() const override { return false; }
+
+  const ToolChain &HostTC;
+
+protected:
+  Tool *buildLinker() const override;
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HIPSPV_H
Index: clang/lib/Driver/ToolChains/HIPSPV.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/HIPSPV.cpp
@@ -0,0 +1,288 @@
+//===--- HIPSPV.cpp - HIPSPV ToolChain Implementation ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache 

[PATCH] D110622: [HIPSPV][3/4] Enable SPIR-V emission for HIP

2021-11-16 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 387509.
linjamaki added a comment.
Herald added a subscriber: asavonic.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110622

Files:
  clang/include/clang/Basic/Cuda.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/Inputs/hipspv-dev-lib/a/a.bc
  clang/test/Driver/Inputs/hipspv-dev-lib/b/b.bc
  clang/test/Driver/Inputs/hipspv-dev-lib/hipspv-spirv64.bc
  clang/test/Driver/Inputs/hipspv/bin/.hipVersion
  clang/test/Driver/Inputs/hipspv/lib/hip-device-lib/hipspv-spirv64.bc
  clang/test/Driver/Inputs/hipspv/lib/libLLVMHipSpvPasses.so
  clang/test/Driver/Inputs/pass-plugin.so
  clang/test/Driver/hipspv-device-libs.hip
  clang/test/Driver/hipspv-pass-plugin.hip
  clang/test/Driver/hipspv-toolchain-rdc.hip
  clang/test/Driver/hipspv-toolchain.hip
  clang/test/Driver/invalid-offload-options.cpp

Index: clang/test/Driver/invalid-offload-options.cpp
===
--- /dev/null
+++ clang/test/Driver/invalid-offload-options.cpp
@@ -0,0 +1,18 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -### -x hip -target x86_64-linux-gnu --offload= \
+// RUN:   --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
+// RUN: 2>&1 | FileCheck --check-prefix=INVALID-TARGET %s
+// RUN: %clang -### -x hip -target x86_64-linux-gnu --offload=foo   \
+// RUN:   --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
+// RUN: 2>&1 | FileCheck --check-prefix=INVALID-TARGET %s
+
+// INVALID-TARGET: error: Invalid or unsupported offload target: '{{.*}}'
+
+// RUN: %clang -### -x hip -target x86_64-linux-gnu --offload=foo,bar \
+// RUN:   --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
+// RUN: 2>&1 | FileCheck --check-prefix=TOO-MANY-TARGETS %s
+
+// TOO-MANY-TARGETS: error: Only one offload target is supported in HIP.
Index: clang/test/Driver/hipspv-toolchain.hip
===
--- /dev/null
+++ clang/test/Driver/hipspv-toolchain.hip
@@ -0,0 +1,37 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -### -target x86_64-linux-gnu --offload=spirv64 \
+// RUN:   --hip-path=%S/Inputs/hipspv -nohipwrapperinc %s \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "spirv64"
+// CHECK-SAME: "-aux-triple" "{{.*}}" "-emit-llvm-bc"
+// CHECK-SAME: "-fcuda-is-device"
+// CHECK-SAME: "-fcuda-allow-variadic-functions"
+// CHECK-SAME: "-mlink-builtin-bitcode" {{".*/hipspv/lib/hip-device-lib/hipspv-spirv64.bc"}}
+// CHECK-SAME: "-isystem" {{".*/hipspv/include"}}
+// CHECK-SAME: "-fhip-new-launch-api"
+// CHECK-SAME: "-o" [[DEV_BC:".*bc"]]
+// CHECK-SAME: "-x" "hip"
+
+// CHECK: {{".*llvm-link"}} [[DEV_BC]] "-o" [[LINK_BC:".*bc"]]
+
+// CHECK: {{".*opt"}} [[LINK_BC]] "-load-pass-plugin"
+// CHECK-SAME: {{".*/hipspv/lib/libLLVMHipSpvPasses.so"}}
+// CHECK-SAME: "-passes=hip-post-link-passes" "-o" [[LOWER_BC:".*bc"]]
+
+// CHECK: {{".*llvm-spirv"}} "--spirv-max-version=1.1" "--spirv-ext=+all"
+// CHECK-SAME: [[LOWER_BC]] "-o" "[[SPIRV_OUT:.*out]]"
+
+// CHECK: {{".*clang-offload-bundler"}} "-type=o" "-bundle-align=4096"
+// CHECK-SAME: "-targets=host-x86_64-unknown-linux,hip-spirv64generic"
+// CHECK-SAME: "-inputs={{.*}},[[SPIRV_OUT]]" "-outputs=[[BUNDLE:.*hipfb]]"
+
+// CHECK: [[CLANG]] "-cc1" "-triple" {{".*"}} "-aux-triple" "spirv64"
+// CHECK-SAME: "-emit-obj"
+// CHECK-SAME: "-fcuda-include-gpubinary" "[[BUNDLE]]"
+// CHECK-SAME: "-o" [[OBJ_HOST:".*o"]] "-x" "hip"
+
+// CHECK: {{".*ld.*"}} {{.*}}[[OBJ_HOST]]
Index: clang/test/Driver/hipspv-toolchain-rdc.hip
===
--- /dev/null
+++ clang/test/Driver/hipspv-toolchain-rdc.hip
@@ -0,0 +1,63 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -### -x hip -target x86_64-linux-gnu --offload=spirv64 \
+// RUN:   -fgpu-rdc --hip-path=%S/Inputs/hipspv -nohipwrapperinc \
+// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s
+
+// Emit objects for host side path
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-aux-triple" "spirv64"
+// CHECK-SAME: "-emit-obj"
+// CHECK-SAME: "-fgpu-rdc"
+// CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
+// CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
+
+// CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-aux-triple" "spirv64"
+// CHECK-S

[PATCH] D110685: [HIPSPV][4/4] Add option to use llc to emit SPIR-V

2021-11-16 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 387510.
linjamaki added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110685

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/HIPSPV.cpp
  clang/test/Driver/hipspv-options.hip


Index: clang/test/Driver/hipspv-options.hip
===
--- /dev/null
+++ clang/test/Driver/hipspv-options.hip
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -### -target x86_64-linux-gnu --offload=spirv64 \
+// RUN:   --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
+// RUN:   --spirv-use-llc=/foo/bar/llc 2>&1 | FileCheck %s
+
+// CHECK-NOT: llvm-spirv
+// CHECK: "/foo/bar/llc" "--mattr=+spirv1.1" "--filetype=obj" "{{.*}}.bc"
+// CHECK-SAME: "-o" "{{.*}}.out"
+
Index: clang/lib/Driver/ToolChains/HIPSPV.cpp
===
--- clang/lib/Driver/ToolChains/HIPSPV.cpp
+++ clang/lib/Driver/ToolChains/HIPSPV.cpp
@@ -97,6 +97,25 @@
 
   // Emit SPIR-V binary.
 
+  // Use llc. Meant for testing out LLVM SPIR-V backend. Eventually HIPSPV will
+  // switch to use in-tree SPIR-V backend for binary emission.
+  if (auto *A = Args.getLastArg(options::OPT_spirv_use_llc,
+options::OPT_spirv_use_llc_EQ)) {
+assert(A->getNumValues() <= 1);
+const char *LlcExe = nullptr;
+if (A->getNumValues() == 1 && !StringRef(A->getValue()).empty())
+  LlcExe = A->getValue();
+else
+  LlcExe = Args.MakeArgString(getToolChain().GetProgramPath("llc"));
+ArgStringList LlcArgs{"--mattr=+spirv1.1", "--filetype=obj", TempFile, 
"-o",
+  Output.getFilename()};
+C.addCommand(std::make_unique(JA, *this,
+   ResponseFileSupport::None(), LlcExe,
+   LlcArgs, Inputs, Output));
+return;
+  }
+
+  // Use SPIRV-LLVM Translator.
   llvm::opt::ArgStringList TrArgs{"--spirv-max-version=1.1",
   "--spirv-ext=+all"};
   InputInfo TrInput = InputInfo(types::TY_LLVM_BC, TempFile, "");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1539,6 +1539,14 @@
 Group, Flags<[CC1Option]>, MetaVarName<"">,
 HelpText<"Enable heap memory profiling and dump results into ">;
 
+def spirv_use_llc : Flag<["--"], "spirv-use-llc">, Flags<[HelpHidden]>,
+HelpText<"Use (in-tree) llc to emit SPIR-V. Use for development and "
+"testing only.">;
+def spirv_use_llc_EQ : Joined<["--"], "spirv-use-llc=">,
+MetaVarName<"">, Flags<[HelpHidden]>,
+HelpText<"Use speficied llc to emit SPIR-V. Use for development and "
+"testing only.">;
+
 // Begin sanitizer flags. These should all be core options exposed in all 
driver
 // modes.
 let Flags = [CC1Option, CoreOption] in {


Index: clang/test/Driver/hipspv-options.hip
===
--- /dev/null
+++ clang/test/Driver/hipspv-options.hip
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// UNSUPPORTED: system-windows
+
+// RUN: %clang -### -target x86_64-linux-gnu --offload=spirv64 \
+// RUN:   --hip-path=%S/Inputs/hipspv -nogpuinc -nogpulib %s \
+// RUN:   --spirv-use-llc=/foo/bar/llc 2>&1 | FileCheck %s
+
+// CHECK-NOT: llvm-spirv
+// CHECK: "/foo/bar/llc" "--mattr=+spirv1.1" "--filetype=obj" "{{.*}}.bc"
+// CHECK-SAME: "-o" "{{.*}}.out"
+
Index: clang/lib/Driver/ToolChains/HIPSPV.cpp
===
--- clang/lib/Driver/ToolChains/HIPSPV.cpp
+++ clang/lib/Driver/ToolChains/HIPSPV.cpp
@@ -97,6 +97,25 @@
 
   // Emit SPIR-V binary.
 
+  // Use llc. Meant for testing out LLVM SPIR-V backend. Eventually HIPSPV will
+  // switch to use in-tree SPIR-V backend for binary emission.
+  if (auto *A = Args.getLastArg(options::OPT_spirv_use_llc,
+options::OPT_spirv_use_llc_EQ)) {
+assert(A->getNumValues() <= 1);
+const char *LlcExe = nullptr;
+if (A->getNumValues() == 1 && !StringRef(A->getValue()).empty())
+  LlcExe = A->getValue();
+else
+  LlcExe = Args.MakeArgString(getToolChain().GetProgramPath("llc"));
+ArgStringList LlcArgs{"--mattr=+spirv1.1", "--filetype=obj", TempFile, "-o",
+  Output.getFilename()};
+C.addCommand(std::make_unique(JA, *this,
+   ResponseFileSupport::None(), LlcExe,
+   LlcArgs, Inputs, Output));
+return;
+  }
+
+  // Use SPIRV-LLVM Translator.
   llvm::opt::ArgStringList TrArgs{"--spirv-max-version=1.1",
 

[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-16 Thread Mahesha S via Phabricator via cfe-commits
hsmhsm added a comment.

In D110257#3133838 , @JonChesterfield 
wrote:

> Please change the commit message to say why this change is necessary / an 
> improvement on what we have now.
>
> My recollection is that the amdgpu backend crashes on some IR and this 
> decreases the probability of that IR pattern occuring, which still sounds 
> like fixing the wrong place to me. Was this the one where hoisting static 
> size alloca into the entry block near the backend would the problem?
>
> I think this patch is missing a documentation update adding the new 
> constraint that allocas must be contiguous in IR. That would help to answer 
> questions about which alloca must be contiguous and which can occur separated 
> by instructions, as currently none of them need to be adjacent. Also, is this 
> only intended to constrain the entry basic block?

The current commit message reflect semantics of the patch - there is nothing 
required to change here. The goal here is to make sure that FE keeps all the 
static allocas as one cluster at the start of the entry block, which is a good 
canonical form from the perspective of better code transformation/optimization.

This is not something specific to AMDGPU backend, but  AMDGPU backend at 
present requires this canonical form.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D111047: CUDA/HIP: Allow __int128 on the host side

2021-11-16 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 387511.
linjamaki added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111047

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCUDA/allow-int128.cu
  clang/test/SemaCUDA/spirv-int128.cu


Index: clang/test/SemaCUDA/spirv-int128.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/spirv-int128.cu
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple spirv64 -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+
+#define __device__ __attribute__((device))
+
+__int128 h_glb;
+
+__device__ __int128 d_unused;
+
+// expected-note@+1 {{'d_glb' defined here}}
+__device__ __int128 d_glb;
+
+__device__ __int128 bar() {
+  // expected-error@+1 {{'d_glb' requires 128 bit size '__int128' type 
support, but target 'spirv64' does not support it}}
+  return d_glb;
+}
Index: clang/test/SemaCUDA/allow-int128.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/allow-int128.cu
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple nvptx \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+
+// expected-no-diagnostics
+#define __device__ __attribute__((device))
+
+__int128 h_glb;
+__device__ __int128 d_unused;
+__device__ __int128 d_glb;
+__device__ __int128 bar() {
+  return d_glb;
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1496,8 +1496,8 @@
   }
   case DeclSpec::TST_int128:
 if (!S.Context.getTargetInfo().hasInt128Type() &&
-!S.getLangOpts().SYCLIsDevice &&
-!(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice))
+!(S.getLangOpts().SYCLIsDevice || S.getLangOpts().CUDAIsDevice ||
+  (S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice)))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__int128";
 if (DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned)
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1932,7 +1932,8 @@
   };
 
   auto CheckType = [&](QualType Ty, bool IsRetTy = false) {
-if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice))
+if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice) 
||
+LangOpts.CUDAIsDevice)
   CheckDeviceType(Ty);
 
 QualType UnqualTy = Ty.getCanonicalType().getUnqualifiedType();


Index: clang/test/SemaCUDA/spirv-int128.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/spirv-int128.cu
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple spirv64 -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+
+#define __device__ __attribute__((device))
+
+__int128 h_glb;
+
+__device__ __int128 d_unused;
+
+// expected-note@+1 {{'d_glb' defined here}}
+__device__ __int128 d_glb;
+
+__device__ __int128 bar() {
+  // expected-error@+1 {{'d_glb' requires 128 bit size '__int128' type support, but target 'spirv64' does not support it}}
+  return d_glb;
+}
Index: clang/test/SemaCUDA/allow-int128.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/allow-int128.cu
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple nvptx \
+// RUN:   -aux-triple x86_64-unknown-linux-gnu \
+// RUN:   -fcuda-is-device -verify -fsyntax-only %s
+
+// expected-no-diagnostics
+#define __device__ __attribute__((device))
+
+__int128 h_glb;
+__device__ __int128 d_unused;
+__device__ __int128 d_glb;
+__device__ __int128 bar() {
+  return d_glb;
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1496,8 +1496,8 @@
   }
   case DeclSpec::TST_int128:
 if (!S.Context.getTargetInfo().hasInt128Type() &&
-!S.getLangOpts().SYCLIsDevice &&
-!(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice))
+!(S.getLangOpts().SYCLIsDevice || S.getLangOpts().CUDAIsDevice ||
+  (S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice)))
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
 << "__int128";
 if (DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned)
Index: clang/lib/Sema/Sema.cpp

[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D110257#3133866 , @hsmhsm wrote:

> This is not something specific to AMDGPU backend, but  AMDGPU backend at 
> present requires this canonical form.

Undocumented and not checked by the IR verifier. Canonical form seems to be 
overstating it until at least one of those is addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-16 Thread Mahesha S via Phabricator via cfe-commits
hsmhsm added a comment.

In D110257#3133879 , @JonChesterfield 
wrote:

> In D110257#3133866 , @hsmhsm wrote:
>
>> This is not something specific to AMDGPU backend, but  AMDGPU backend at 
>> present requires this canonical form.
>
> Undocumented and not checked by the IR verifier. Canonical form seems to be 
> overstating it until at least one of those is addressed.

We already discussed that this canonical form is not something that IR verifier 
can verify, but it is good enough for better code transformation/optimization. 
Please refer llvm-dev email discussion w.r.t it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D113942: [NFC][clang] Inclusive language: replace master with main in convert_arm_neon.py

2021-11-16 Thread Kristof Beyls via Phabricator via cfe-commits
kristof.beyls accepted this revision.
kristof.beyls added a comment.
This revision is now accepted and ready to land.

LGTM, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113942

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


[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D110257#3133895 , @hsmhsm wrote:

> In D110257#3133879 , 
> @JonChesterfield wrote:
>
>> In D110257#3133866 , @hsmhsm wrote:
>>
>>> This is not something specific to AMDGPU backend, but  AMDGPU backend at 
>>> present requires this canonical form.
>>
>> Undocumented and not checked by the IR verifier. Canonical form seems to be 
>> overstating it until at least one of those is addressed.
>
> We already discussed that this canonical form is not something that IR 
> verifier can verify, but it is good enough for better code 
> transformation/optimization. Please refer llvm-dev email discussion w.r.t it.

If the new invariant is that all alloca must be adjacent to one another, that's 
a trivial thing for the verifier to check. So I guess it's something else? 
Please write down what this new invariant is intended to be, preferably in the 
documentation, perhaps of the alloca instruction.

What llvm-dev discussion do you refer to?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D113848: [clang-tidy][NFC] Refactor ClangTidyDiagnosticConsumer files

2021-11-16 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 387519.
carlosgalvezp marked 4 inline comments as done.
carlosgalvezp added a comment.

- Rebased.
- Addressed comments.


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

https://reviews.llvm.org/D113848

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/ClangTidyContext.cpp
  clang-tools-extra/clang-tidy/ClangTidyContext.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/ClangTidyError.cpp
  clang-tools-extra/clang-tidy/ClangTidyError.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -12,6 +12,7 @@
 #include "ClangTidy.h"
 #include "ClangTidyCheck.h"
 #include "ClangTidyDiagnosticConsumer.h"
+#include "ClangTidyError.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -1,6 +1,7 @@
 #include "ClangTidyOptions.h"
 #include "ClangTidyCheck.h"
 #include "ClangTidyDiagnosticConsumer.h"
+#include "ClangTidyError.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Testing/Support/Annotations.h"
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -16,6 +16,8 @@
 
 #include "ClangTidyMain.h"
 #include "../ClangTidy.h"
+#include "../ClangTidyContext.h"
+#include "../ClangTidyError.h"
 #include "../ClangTidyForceLinker.h"
 #include "../GlobList.h"
 #include "clang/Tooling/CommonOptionsParser.h"
@@ -128,10 +130,10 @@
cl::init(false), cl::cat(ClangTidyCategory));
 
 static cl::opt FixNotes("fix-notes", cl::desc(R"(
-If a warning has no fix, but a single fix can 
-be found through an associated diagnostic note, 
-apply the fix. 
-Specifying this flag will implicitly enable the 
+If a warning has no fix, but a single fix can
+be found through an associated diagnostic note,
+apply the fix.
+Specifying this flag will implicitly enable the
 '--fix' flag.
 )"),
   cl::init(false), cl::cat(ClangTidyCategory));
Index: clang-tools-extra/clang-tidy/ClangTidyError.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/ClangTidyError.h
@@ -0,0 +1,38 @@
+//===--- ClangTidyError.h - clang-tidy --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYERROR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYERROR_H
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+
+/// A detected error complete with information to display diagnostic and
+/// automatic fix.
+///
+/// This is used as an intermediate format to transport Diagnostics without a
+/// dependency on a SourceManager.
+///
+/// FIXME: Make Diagnostics flexible enough to support this directly.
+struct ClangTidyError : tooling::Diagnostic {
+  ClangTidyError(StringRef CheckName, Level DiagLevel, StringRef BuildDirectory,
+ bool IsWarningAsError);
+
+  bool IsWarningAsError;
+  std::vector EnabledDiagnosticAliases;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H
Index: clang-tools-extra/clang-tidy/ClangTidyError.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/ClangTidyError.cpp
@@ -0,0 +1,29 @@
+//===--- tools/extra/clang-tidy/ClangTidyError.cpp ---=== //
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SP

[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-16 Thread Mahesha S via Phabricator via cfe-commits
hsmhsm added a comment.

In D110257#3133934 , @JonChesterfield 
wrote:

> In D110257#3133895 , @hsmhsm wrote:
>
>> In D110257#3133879 , 
>> @JonChesterfield wrote:
>>
>>> In D110257#3133866 , @hsmhsm 
>>> wrote:
>>>
 This is not something specific to AMDGPU backend, but  AMDGPU backend at 
 present requires this canonical form.
>>>
>>> Undocumented and not checked by the IR verifier. Canonical form seems to be 
>>> overstating it until at least one of those is addressed.
>>
>> We already discussed that this canonical form is not something that IR 
>> verifier can verify, but it is good enough for better code 
>> transformation/optimization. Please refer llvm-dev email discussion w.r.t it.
>
> If the new invariant is that all alloca must be adjacent to one another, 
> that's a trivial thing for the verifier to check. So I guess it's something 
> else? Please write down what this new invariant is intended to be, preferably 
> in the documentation, perhaps of the alloca instruction.

Please check with llvm-dev.

> What llvm-dev discussion do you refer to?

I do not remember,  please search for keywords, like static allocas, and figure 
out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

So you won't articulate or document the new invariant and you think there's a 
llvm-dev discussion that says we can't verify the invariant which you won't 
reference, but means you won't add this to the verifier.

Request changes doesn't really work after you've applied the patch.

@rnk do you object to me reverting this? I don't think we can add an invariant 
to IR which is undocumented and unverified/unverifiable and the patch author 
seems opposed to fixing either omission.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D113107: Support of expression granularity for _Float16.

2021-11-16 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1315
+  if ((SrcType->isHalfType() || iSFloat16Allowed) &&
+  !CGF.getContext().getLangOpts().NativeHalfType) {
 // Cast to FP using the intrinsic if the half type itself isn't supported.

rjmccall wrote:
> pengfei wrote:
> > rjmccall wrote:
> > > pengfei wrote:
> > > > rjmccall wrote:
> > > > > Okay, this condition is pretty ridiculous to be repeating in three 
> > > > > different places across the compiler.  Especially since you're going 
> > > > > to change it when you implement the new option, right?
> > > > > 
> > > > > Can we state this condition more generally?  I'm not sure why this is 
> > > > > so narrowly restricted, and the variable name isn't telling me 
> > > > > anything, since `_Float16` must by definition be "allowed" if we have 
> > > > > an expression of `_Float16` type.
> > > > > since _Float16 must by definition be "allowed" if we have an 
> > > > > expression of _Float16 type.
> > > > 
> > > > _Float16 is allowed only on a few targets. 
> > > > https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point
> > > > By the way, we should update for X86 since it's not limited to 
> > > > avx512fp16 now.
> > > > _Float16 is allowed only on a few targets.
> > > 
> > > Yes, I know that.  But if `SrcType->isFloat16Type()` is true, we must be 
> > > on one of those targets, because the type doesn't otherwise exist.
> > I see your point now. The problem here is we want to allow the `_Float16` 
> > to be used more broadly. But the target doesn't really support it sometime. 
> > Currently full arithmatic operations are supported only on target with 
> > AVX512FP16.
> > We should cast for those targets without AVX512FP16 while avoid to do on 
> > AVX512FP16.
> I agree that many targets don't natively support arithmetic on this format, 
> but x86 is not the first one that does.  Unless I'm misunderstanding, we 
> already track this property in Clang's TargetInfo as `hasLegalHalfType()`.  
> `+avx512fp16` presumably ought to set this.
> 
> I'm not sure what the interaction with the `NativeHalfType` LangOpt is 
> supposed to be here.  My understanding is that that option is just supposed 
> to affect `__fp16`, basically turning it into a proper arithmetic type, i.e. 
> essentially `_Float16`.  Whatever effect you want to apply to `_Float16` 
> should presumably happen even if that option not set.
> 
> More broadly, I don't think your approach in this patch is correct.  The type 
> of operations on `_Float16` should not change based on whether the target 
> natively supports `_Float16`.  If we need to emulate those operations on 
> targets that don't provide them natively, we should do that at a lower level 
> than the type system.
> 
> The most appropriate place to do that is going to depend on the exact 
> semantics we want.
> 
> If we want to preserve `half` semantics exactly regardless of target, we 
> should have Clang's IR generation actually emit `half` operations.  Targets 
> that don't support those operations natively will have to lower at least some 
> of those operations into compiler-rt calls, but that's not at all 
> unprecedented.
> 
> If we're okay with playing loose for performance reasons, we can promote to 
> `float` immediately around individual arithmetic operations.  IR generation 
> is probably the most appropriate place to do that.  But I'm quite concerned 
> about that making `_Float16` feel like an unpredictable/unportable type; it 
> seems to me that software emulation is much better.
> 
> If you're proposing the latter, I think you need to raise that more widely 
> than a code review; please make a post on llvm-dev.
> we already track this property in Clang's TargetInfo as `hasLegalHalfType()`

That sounds a good approch. Thank you.

> The type of operations on `_Float16` should not change based on whether the 
> target natively supports `_Float16`. If we need to emulate those operations 
> on targets that don't provide them natively, we should do that at a lower 
> level than the type system.

Unfortunately, we can't do it at low level. The reason is (I'm not expert in 
frontend, just recalled from last disscussion with GCC folks) we have to do 
expresssion emulation to respect C/C++ semantics. GCC has option 
`-fexcess-precision=16` to match the same result with native instructions, but 
the default is `-fexcess-precision=fast` according to language semantics.

> The most appropriate place to do that is going to depend on the exact 
> semantics we want...

Note, we are not simply doing emulation in the frontend. It's backend's 
responsibility to emulate a single `half` operation. But it's frontend's 
responsibility to choose whether to emit several `half` operations or emit 
promote + several `float` operations + truncate. As described in the title, 
this patch is doing for the latter.


CHANGES SINCE LAST ACTION
  https://reviews.ll

[PATCH] D113972: [RFC] [C++20] [Module] Support module partitions initially

2021-11-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: rsmith, aaron.ballman, urnathan, 
hubert.reinterpretcast, erichkeane.
ChuanqiXu added a project: clang.
Herald added a subscriber: dexonsmith.
ChuanqiXu requested review of this revision.
Herald added a subscriber: cfe-commits.

This file intends to support: https://eel.is/c++draft/module.unit#3.

Module partition should be a special module interface which is imported by 
module units in the same module.
Note that although there is implementation module partition, it should be a 
module interface too since it could be imported by module units in the same 
module.

For a module partition `primary.module.name:partition.name`, the user should 
generate a `pcm` file with name `primary.module.name-partition.name.pcm`. 
Simply replace `:` with `-`. And when we try to import a partition with 
`partition-name` in `primary.module.name`, the compiler would try to search for 
`primary.module.name-partition.name.pcm` in the given path. The strategy to 
replace `:` with `-` keeps consistency with GCC.

The key problem I see in introducing module partitions is that the judgement 
for modules. Before, there would be only module interface unit for each module. 
But now, it would be many partitions which are belongs in the same module. The 
judgement of modules matter when the compiler want to decide whether or not a 
declaration is visible or reachable.

And my solution is to compare the prefix of the name before '-' to judge 
whether or not the two module belongs to the same module. Since '-' shouldn't 
show up in the original module name by the definition.
For example, 'X-A' and `X-B` are in the same module. But `X-A` and `Y-A` are 
not.

BTW, it would be problem if we want to import a module partition in another 
module by renaming. See 
`clang/test/CXX/module/module.unit/p3/FromWrongModule.cpp` for example.

The method looks simple and available in simple demos. I want to hear more 
opinions.

Test Plan: check-all


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113972

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Module.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/module/module.global.frag/Inputs/X-A.cppm
  clang/test/CXX/module/module.global.frag/Inputs/header.h
  clang/test/CXX/module/module.global.frag/p2.cpp
  clang/test/CXX/module/module.import/Inputs/M-Part.cppm
  clang/test/CXX/module/module.import/p8.cpp
  clang/test/CXX/module/module.private.frag/p1.cpp
  clang/test/CXX/module/module.reach/Inputs/p4/M-A.cppm
  clang/test/CXX/module/module.reach/Inputs/p4/M-B.cppm
  clang/test/CXX/module/module.reach/Inputs/p4/M.cppm
  clang/test/CXX/module/module.reach/p4/M-C.cppm
  clang/test/CXX/module/module.reach/p4/X.cpp
  clang/test/CXX/module/module.unit/Inputs/p3/X.cppm
  clang/test/CXX/module/module.unit/Inputs/p3/parta.cppm
  clang/test/CXX/module/module.unit/Inputs/p3/partb.cppm
  clang/test/CXX/module/module.unit/Inputs/p4/A-Foo.cppm
  clang/test/CXX/module/module.unit/Inputs/p4/A-Impl.cpp
  clang/test/CXX/module/module.unit/Inputs/p4/A-Internals.cppm
  clang/test/CXX/module/module.unit/Inputs/p4/A.cppm
  clang/test/CXX/module/module.unit/Inputs/p8/B-X1.cppm
  clang/test/CXX/module/module.unit/Inputs/p8/B-X2.cppm
  clang/test/CXX/module/module.unit/Inputs/p8/B-Y.cppm
  clang/test/CXX/module/module.unit/Inputs/p8/B.cppm
  clang/test/CXX/module/module.unit/p3.cpp
  clang/test/CXX/module/module.unit/p3/FromNonModule.cpp
  clang/test/CXX/module/module.unit/p3/FromWrongModule.cpp
  clang/test/CXX/module/module.unit/p3/simple.cpp
  clang/test/CXX/module/module.unit/p3/user.cpp
  clang/test/CXX/module/module.unit/p4/user.cpp
  clang/test/CXX/module/module.unit/p8.cpp
  clang/test/CXX/module/module.unit/p8/B-Impl.cppm
  clang/test/CXX/module/module.unit/p8/ImplicitImport.cpp

Index: clang/test/CXX/module/module.unit/p8/ImplicitImport.cpp
===
--- clang/test/CXX/module/module.unit/p8/ImplicitImport.cpp
+++ clang/test/CXX/module/module.unit/p8/ImplicitImport.cpp
@@ -24,12 +24,10 @@
 export module bar;
 
 #elif MODE == 4
-module foo:bar; // expected-error {{not yet supported}}
-#define IMPORTED // FIXME
+module foo:bar;
 
 #elif MODE == 5
-export module foo:bar; // expected-error {{not yet supported}} expected-error {{redefinition}} expected-note@* {{loaded from}}
-#define IMPORTED // FIXME
+export module foo:bar; 
 
 #endif
 
Index: clang/test/CXX/module/module.unit/p8/B-Impl.cppm
===
--- /dev/null
+++ clang/test/CXX/module/module.unit/p8/B-Impl.cppm
@@ -0,0 +1,12 @@
+// RUN: rm -fr %t
+// RUN: mkdir %t
+// RUN: %clang_cc1 -std=c++20 %S/../Inputs/p8/B-Y.cppm -fprebuilt-mod

[PATCH] D113974: [clangd] Put additional qualifiers to enum constants not declared as "enum class"

2021-11-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This is a cheap "fix" of the problem described in
https://github.com/clangd/clangd/issues/39. Currently, for this code:

  c++
  namespace ns {
  enum Color { Green };
  enum class Vehicle { Car };
  }

The following is true:

- `Vehicle::Car` scope is `ns::Vehicle::` - it can't be accessed without 
spelling full enum class name
- `Color::Green` scope is `ns::` because it can be accessed as `ns::Car`

However, this causes index FuzzyFind to show empty results when querying
`ns::Color::` - `Color::Green` will only show up for `ns::`.

This patch changes the behavior and makes `SymbolCollector` treat plain `enum`
the same way it does handle `enum class`. Ideally, the index would point to the
same symbol for both `ns::Green` and `ns::Color::Green` but that increases
coupling since the enum information has to be propagated to the index builder
which is logically quite far from the `SymbolCollector`.

Fixes: https://github.com/clangd/clangd/issues/39


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113974

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1232,7 +1232,7 @@
   UnorderedElementsAre(
   AllOf(QName("Red"), ForCodeCompletion(true)),
   AllOf(QName("Color"), ForCodeCompletion(true)),
-  AllOf(QName("Green"), ForCodeCompletion(true)),
+  AllOf(QName("Color::Green"), ForCodeCompletion(true)),
   AllOf(QName("Color2"), ForCodeCompletion(true)),
   AllOf(QName("Color2::Yellow"), ForCodeCompletion(false)),
   AllOf(QName("ns"), ForCodeCompletion(true)),
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -250,14 +250,15 @@
   )cpp";
   EXPECT_THAT(getSymbols(TU, "Red"), ElementsAre(QName("Red")));
   EXPECT_THAT(getSymbols(TU, "::Red"), ElementsAre(QName("Red")));
-  EXPECT_THAT(getSymbols(TU, "Green"), ElementsAre(QName("Green")));
-  EXPECT_THAT(getSymbols(TU, "Green"), ElementsAre(QName("Green")));
+  EXPECT_THAT(getSymbols(TU, "Color::Green"),
+  ElementsAre(QName("Color::Green")));
   EXPECT_THAT(getSymbols(TU, "Color2::Yellow"),
   ElementsAre(QName("Color2::Yellow")));
   EXPECT_THAT(getSymbols(TU, "Yellow"), ElementsAre(QName("Color2::Yellow")));
 
   EXPECT_THAT(getSymbols(TU, "ns::Black"), ElementsAre(QName("ns::Black")));
-  EXPECT_THAT(getSymbols(TU, "ns::Blue"), ElementsAre(QName("ns::Blue")));
+  EXPECT_THAT(getSymbols(TU, "ns::Color3::Blue"),
+  ElementsAre(QName("ns::Color3::Blue")));
   EXPECT_THAT(getSymbols(TU, "ns::Color4::White"),
   ElementsAre(QName("ns::Color4::White")));
 }
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -828,6 +828,23 @@
   // FIXME: this returns foo:bar: for objective-C methods, we prefer only foo:
   // for consistency with CodeCompletionString and a clean name/signature 
split.
   std::tie(S.Scope, S.Name) = splitQualifiedName(QName);
+  std::string Scope = S.Scope.str();
+  // Put additional qualifiers for enum constants: technically, they can be
+  // accessed without using the enum name prefix (unless declared as enum
+  // class) but it is more convenient to enhance the scope with the enum type
+  // name.
+  // FIXME: It would be better to just have the SymbolIndex look up the same
+  // enum constant both with and without enum type name but at the time the
+  // index is built the information about ND is already lost.
+  if (const auto *EnumConstant = llvm::dyn_cast(&ND)) {
+if (const auto *II = EnumConstant->getType().getBaseTypeIdentifier()) {
+  std::string EnumScope = II->getName().str() + "::";
+  // For "enum class" the qualified name already has EnumScope.
+  if (!S.Scope.endswith(EnumScope))
+Scope += EnumScope;
+}
+  }
+  S.Scope = Scope;
   std::string TemplateSpecializationArgs = printTemplateSpecializationArgs(ND);
   S.TemplateSpecializationArgs = TemplateSpecializationArgs;
 


Index

[PATCH] D113974: [clangd] Put additional qualifiers to enum constants not declared as "enum class"

2021-11-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

Actually, I'm not sure this change is worth it. Maybe the intent of not having 
`enum class` is actually making the constants discoverable from the outer scope.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113974

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


[PATCH] D112730: [clang-tidy] Add AUTOSAR module

2021-11-16 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Btw can't we just have a license disclaimer like it's done for HiCPP?

https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/hicpp/LICENSE.TXT


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

https://reviews.llvm.org/D112730

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


[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-11-16 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:49
+
+  // Find containment checks which use `count`
+  
Finder->addMatcher(implicitCastExpr(hasImplicitDestinationType(booleanType()),

Same comment about "membership" or "element" instead of "containment" here.



Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:73
+
+  // Find inverted containment checks which use `count`
+  addSimpleMatcher(

Same comment about "membership" or "element" instead of "containment" here.



Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:93
+
+  // Find containment checks based on `begin == end`
+  addSimpleMatcher(





Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:103
+void ContainerContainsCheck::check(const MatchFinder::MatchResult &Result) {
+  // Extract the ifnromation about the match
+  const auto *Call = Result.Nodes.getNodeAs("call");





Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:110
+
+  // Diagnose the issue
+  auto Diag =

I'm not sure if these comments are useful, though. The business logic flow of 
the implementation is straightforward.



Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:113
+  diag(Call->getExprLoc(),
+   "use `contains` instead of `count` to check for containment");
+

This might be a bit nitpicking, but `containment` sounds off here: it usually 
comes up with regards to superset/subset relationships. Perhaps phrasing in 
`membership` or `element` somehow would ease this.



Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:113
+  diag(Call->getExprLoc(),
+   "use `contains` instead of `count` to check for containment");
+

whisperity wrote:
> This might be a bit nitpicking, but `containment` sounds off here: it usually 
> comes up with regards to superset/subset relationships. Perhaps phrasing in 
> `membership` or `element` somehow would ease this.
We use single apostrophe (`'`) instead of backtick (`) in the diagnostics for 
symbol names.



Comment at: clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.h:19
+/// Finds usages of `container.count()` which should be replaced by a call
+/// to the `container.contains()` method introduced in C++ 20.
+///





Comment at: clang-tools-extra/docs/ReleaseNotes.rst:105-106
+
+  Finds usages of `container.count()` and `container.find() == 
container.end()` which should
+  be replaced by a call to the `container.contains()` method introduced in C++ 
20.
+

Due to RST specifics, the code examples to be rendered as such, **double** 
backticks have to be used... Single backtick renders in a different font with 
emphasis (see example, blue), while double backtick is a proper monospace 
inline code snippet (see example, red).

{F20396099}



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:106
+  Finds usages of `container.count()` and `container.find() == 
container.end()` which should
+  be replaced by a call to the `container.contains()` method introduced in C++ 
20.
+





Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-container-contains.rst:6
+
+Finds usages of `container.count()` and `container.find() == container.end()` 
which should be replaced by a call to the `container.contains()` method 
introduced in C++ 20.
+

Same comment about the backtick count and how you would like the rendering to 
be. Please build the documentation locally and verify visually, as both ways 
most likely compile without warnings or errors.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-container-contains.rst:6
+
+Finds usages of `container.count()` and `container.find() == container.end()` 
which should be replaced by a call to the `container.contains()` method 
introduced in C++ 20.
+

whisperity wrote:
> Same comment about the backtick count and how you would like the rendering to 
> be. Please build the documentation locally and verify visually, as both ways 
> most likely compile without warnings or errors.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-container-contains.cpp:33-35
+
+using namespace std;
+

Tests are to guard our future selves from breaking the system, so perhaps two 
tests that involve having `std::` typed out, and also using a different 
container that's not `std::whatever` would be useful.



Do you think it would be worthwhile to add matching any user-defined o

[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-11-16 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D112646#3104236 , @avogelsgesang 
wrote:

> So I guess the name would have to be `container-count-begin-end-contains` or 
> similar... which would be a bit much in my opinion

Yeah, that would be too much indeed.

However, consider `readability-container-use-contains`. It indicates a bit more 
that we want people to write terse code that is clear about its intentions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

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


[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-11-16 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:105-108
+  const auto *PositiveCheck = Result.Nodes.getNodeAs("positive");
+  const auto *NegativeCheck = Result.Nodes.getNodeAs("negative");
+  bool Negated = NegativeCheck != nullptr;
+  const auto *Check = Negated ? NegativeCheck : PositiveCheck;

`Comparison` instead of `Check`? These should be matching the `binaryOperator`, 
right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

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


[PATCH] D113977: [Coroutine] Warn deprecated 'std::experimental::coro' uses

2021-11-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: Quuxplusone, ldionne.
ChuanqiXu added projects: clang, libc++.
Herald added a subscriber: lxfind.
ChuanqiXu requested review of this revision.
Herald added subscribers: libcxx-commits, cfe-commits.
Herald added a reviewer: libc++.

Since we've decided the to not support `std::experimental::coroutine*`, we 
should tell the user they need to update.
We could emit warning on the compiler side or in libc++'s side by `#warning` 
directives.
I choose to warn on the compiler side since some people might use `libstdc++ ` 
+ self-defined `coroutine` header (Seastar is an example: 
https://github.com/scylladb/seastar/blob/master/include/seastar/core/std-coroutine.hh).
Since new warning might  break the libcxx's CI system, I add `-Wno-coroutine` 
for the legacy tests. I guess it would be OK since the legacy test would be 
removed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113977

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
  clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
  clang/test/SemaCXX/coreturn-exp-namespace.cpp
  clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
  clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
  clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
  clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
  clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
  clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
  clang/test/SemaCXX/coroutines-exp-namespace.cpp
  
libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp
  libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg

Index: libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg
===
--- libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg
+++ libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg
@@ -5,3 +5,4 @@
   config.unsupported = True
 else:
   config.test_format.addCompileFlags(config, '-fcoroutines-ts')
+  config.test_format.addCompileFlags(config, '-Wno-coroutine')
Index: libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp
===
--- libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp
+++ libcxx/test/libcxx/experimental/language.support/support.coroutines/dialect_support.pass.cpp
@@ -7,7 +7,7 @@
 //===--===//
 
 // REQUIRES: fcoroutines-ts
-// ADDITIONAL_COMPILE_FLAGS: -fcoroutines-ts
+// ADDITIONAL_COMPILE_FLAGS: -fcoroutines-ts -Wno-coroutine
 
 // A simple "breathing" test that checks that 
 // can be parsed and used in all dialects, including C++03 in order to match
Index: clang/test/SemaCXX/coroutines-exp-namespace.cpp
===
--- clang/test/SemaCXX/coroutines-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutines-exp-namespace.cpp
@@ -83,7 +83,7 @@
 
 struct DummyVoidTag {};
 DummyVoidTag no_specialization() { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits' has no member named 'promise_type'}}
-  co_await a;
+  co_await a;  // expected-warning {{Found deprecated std::experimental}}
 }
 
 template 
Index: clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
===
--- clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
@@ -66,7 +66,7 @@
 } a;
 
 task f() {
-  co_await a;
+  co_await a; // expected-warning {{Found deprecated std::experimental}}
 }
 
 int main() {
Index: clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
===
--- clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
@@ -5,7 +5,7 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts \
 // RUN:-fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify \
 // RUN:-fblocks -Wno-unreachable-code -Wno-unused-value \
-// RUN:-DDISABLE_WARNING -Wno-coroutine-missing-unhandled-exception
+// RUN:-DDISABLE_WARNING -Wno-deprecated-coroutine -Wno-coroutine-missing-unhandled-exception
 
 #if __has_feature(cxx_exceptions)
 #error This test requires exceptions be disabled
@@ -32,7 +32,7 @@
 
 #ifndef DISABLE_WARNING
 voi

[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2021-11-16 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 387554.
mizvekov added a comment.

- Fix rebuilding Template Specializations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaTemplate/deduction.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111283
Index: clang/test/SemaTemplate/deduction.cpp
===
--- clang/test/SemaTemplate/deduction.cpp
+++ clang/test/SemaTemplate/deduction.cpp
@@ -162,6 +162,15 @@
 
 } // namespace test4
 
+namespace test5 {
+
+template  class a {};
+template  void c(b, b);
+template  void c(a, a);
+void d() { c(a(), a()); }
+
+} // namespace test 5
+
 // Verify that we can deduce enum-typed arguments correctly.
 namespace test14 {
   enum E { E0, E1 };
Index: clang/test/SemaCXX/sugared-auto.cpp
===
--- clang/test/SemaCXX/sugared-auto.cpp
+++ clang/test/SemaCXX/sugared-auto.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fblocks -fenable-matrix -Wno-dynamic-exception-spec
 
 enum class N {};
 
@@ -9,6 +9,26 @@
 using Man = Animal;
 using Dog = Animal;
 
+using ManPtr = Man *;
+using DogPtr = Dog *;
+
+using SocratesPtr = ManPtr;
+
+using ConstMan = const Man;
+using ConstDog = const Dog;
+
+using Virus = void;
+using SARS = Virus;
+using Ebola = Virus;
+
+using Bacteria = float;
+using Bacilli = Bacteria;
+using Vibrio = Bacteria;
+
+struct Plant;
+using Gymnosperm = Plant;
+using Angiosperm = Plant;
+
 namespace variable {
 
 auto x1 = Animal();
@@ -41,3 +61,115 @@
 N t3 = x3; // expected-error {{lvalue of type 'Animal' (aka 'int')}}
 
 } // namespace function_basic
+
+namespace function_multiple_basic {
+
+N t1 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t2 = []() -> decltype(auto) { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t3 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Dog();
+  auto x = Man();
+  return x;
+}();
+
+N t4 = [] { // expected-error {{rvalue of type 'int'}}
+  if (true)
+return Dog();
+  return 1;
+}();
+
+N t5 = [] { // expected-error {{rvalue of type 'Virus' (aka 'void')}}
+  if (true)
+return Ebola();
+  return SARS();
+}();
+
+N t6 = [] { // expected-error {{rvalue of type 'void'}}
+  if (true)
+return SARS();
+  return;
+}();
+
+} // namespace function_multiple_basic
+
+#define TEST_AUTO(X, A, B) \
+  auto X(A a, B b) {   \
+if (0) \
+  return a;\
+if (0) \
+  return b;\
+return N();\
+  }
+#define TEST_DAUTO(X, A, B) \
+  decltype(auto) X(A a, B b) {  \
+if (0)  \
+  return static_cast(a); \
+if (0)  \
+  return static_cast(b); \
+return N(); \
+  }
+
+namespace misc {
+
+TEST_AUTO(t1, ManPtr, DogPtr)  // expected-error {{but deduced as 'Animal *' (aka 'int *')}}
+TEST_AUTO(t2, ManPtr, int *)   // expected-error {{but deduced as 'int *'}}
+TEST_AUTO(t3, SocratesPtr, ManPtr) // expected-error {{but deduced as 'ManPtr' (aka 'int *')}}
+
+TEST_AUTO(t4, _Atomic(Man), _Atomic(Dog)) // expected-error {{but deduced as '_Atomic(Animal)'}}
+
+using block_man = void (^)(Man);
+using block_dog = void (^)(Dog);
+TEST_AUTO(t5, block_man, block_dog) // expected-error {{but deduced as 'void (^)(Animal)'}}
+
+using fp1 = SARS (*)(Man, DogPtr) throw(Vibrio);
+using fp2 = Ebola (*)(Dog, ManPtr) throw(Bacilli);
+TEST_AUTO(t6, fp1, fp2); // expected-error {{but deduced as 'Virus (*)(Animal, Animal *) throw(Bacteria)' (aka 'void (*)(int, int *) throw(Bacteria)')}}
+
+using fp3 = SARS (*)() throw(Man);
+using fp4 = Ebola (*)() throw(Vibrio);
+auto t7(fp3 a, fp4 b) {
+  if (false)
+return true ? a : b;
+  if (false)
+return a;
+  return N(); // expected-error {{but deduced as 'SARS (*)() throw(Man, Vibrio)' (aka 'void (*)() throw(Man, Vibrio)')}}
+}
+
+using fp5 = void (*)(const Man);
+using fp6 = void (*)(Dog);
+TEST_AUTO(t8, fp5, fp6); // expected-error {{but deduced as 'void (*)(const Animal)' (aka 'void (*)(const int)')}}
+
+using fp6 = void (*)(ConstMan);
+using fp7 = void (*)(ConstDog

[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2021-11-16 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 387566.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaTemplate/deduction.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111283
Index: clang/test/SemaTemplate/deduction.cpp
===
--- clang/test/SemaTemplate/deduction.cpp
+++ clang/test/SemaTemplate/deduction.cpp
@@ -162,6 +162,15 @@
 
 } // namespace test4
 
+namespace test5 {
+
+template  class a {};
+template  void c(b, b);
+template  void c(a, a);
+void d() { c(a(), a()); }
+
+} // namespace test 5
+
 // Verify that we can deduce enum-typed arguments correctly.
 namespace test14 {
   enum E { E0, E1 };
Index: clang/test/SemaCXX/sugared-auto.cpp
===
--- clang/test/SemaCXX/sugared-auto.cpp
+++ clang/test/SemaCXX/sugared-auto.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fblocks -fenable-matrix -Wno-dynamic-exception-spec
 
 enum class N {};
 
@@ -9,6 +9,26 @@
 using Man = Animal;
 using Dog = Animal;
 
+using ManPtr = Man *;
+using DogPtr = Dog *;
+
+using SocratesPtr = ManPtr;
+
+using ConstMan = const Man;
+using ConstDog = const Dog;
+
+using Virus = void;
+using SARS = Virus;
+using Ebola = Virus;
+
+using Bacteria = float;
+using Bacilli = Bacteria;
+using Vibrio = Bacteria;
+
+struct Plant;
+using Gymnosperm = Plant;
+using Angiosperm = Plant;
+
 namespace variable {
 
 auto x1 = Animal();
@@ -41,3 +61,115 @@
 N t3 = x3; // expected-error {{lvalue of type 'Animal' (aka 'int')}}
 
 } // namespace function_basic
+
+namespace function_multiple_basic {
+
+N t1 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t2 = []() -> decltype(auto) { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t3 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Dog();
+  auto x = Man();
+  return x;
+}();
+
+N t4 = [] { // expected-error {{rvalue of type 'int'}}
+  if (true)
+return Dog();
+  return 1;
+}();
+
+N t5 = [] { // expected-error {{rvalue of type 'Virus' (aka 'void')}}
+  if (true)
+return Ebola();
+  return SARS();
+}();
+
+N t6 = [] { // expected-error {{rvalue of type 'void'}}
+  if (true)
+return SARS();
+  return;
+}();
+
+} // namespace function_multiple_basic
+
+#define TEST_AUTO(X, A, B) \
+  auto X(A a, B b) {   \
+if (0) \
+  return a;\
+if (0) \
+  return b;\
+return N();\
+  }
+#define TEST_DAUTO(X, A, B) \
+  decltype(auto) X(A a, B b) {  \
+if (0)  \
+  return static_cast(a); \
+if (0)  \
+  return static_cast(b); \
+return N(); \
+  }
+
+namespace misc {
+
+TEST_AUTO(t1, ManPtr, DogPtr)  // expected-error {{but deduced as 'Animal *' (aka 'int *')}}
+TEST_AUTO(t2, ManPtr, int *)   // expected-error {{but deduced as 'int *'}}
+TEST_AUTO(t3, SocratesPtr, ManPtr) // expected-error {{but deduced as 'ManPtr' (aka 'int *')}}
+
+TEST_AUTO(t4, _Atomic(Man), _Atomic(Dog)) // expected-error {{but deduced as '_Atomic(Animal)'}}
+
+using block_man = void (^)(Man);
+using block_dog = void (^)(Dog);
+TEST_AUTO(t5, block_man, block_dog) // expected-error {{but deduced as 'void (^)(Animal)'}}
+
+using fp1 = SARS (*)(Man, DogPtr) throw(Vibrio);
+using fp2 = Ebola (*)(Dog, ManPtr) throw(Bacilli);
+TEST_AUTO(t6, fp1, fp2); // expected-error {{but deduced as 'Virus (*)(Animal, Animal *) throw(Bacteria)' (aka 'void (*)(int, int *) throw(Bacteria)')}}
+
+using fp3 = SARS (*)() throw(Man);
+using fp4 = Ebola (*)() throw(Vibrio);
+auto t7(fp3 a, fp4 b) {
+  if (false)
+return true ? a : b;
+  if (false)
+return a;
+  return N(); // expected-error {{but deduced as 'SARS (*)() throw(Man, Vibrio)' (aka 'void (*)() throw(Man, Vibrio)')}}
+}
+
+using fp5 = void (*)(const Man);
+using fp6 = void (*)(Dog);
+TEST_AUTO(t8, fp5, fp6); // expected-error {{but deduced as 'void (*)(const Animal)' (aka 'void (*)(const int)')}}
+
+using fp6 = void (*)(ConstMan);
+using fp7 = void (*)(ConstDog);
+TEST_AUTO(t10, fp6, fp7); // expecte

[PATCH] D112453: [Sema] When dereferencing a pointer of dependent type, infer the result type.

2021-11-16 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112453

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


[clang-tools-extra] 738e7f1 - Fix false positive in `bugprone-throw-keyword-missing` check

2021-11-16 Thread Aaron Ballman via cfe-commits
Author: Fabian Wolff
Date: 2021-11-16T07:09:17-05:00
New Revision: 738e7f1231949ec248c1d8d154783338215613d1

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

LOG: Fix false positive in `bugprone-throw-keyword-missing` check

Fixes PR#52400. The tests for bugprone-throw-keyword-missing actually
already contain exceptions as class members, but not as members with
initializers, which was probably just an oversight.

Added: 


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

clang-tools-extra/test/clang-tidy/checkers/bugprone-throw-keyword-missing.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
index 462a33a374a5f..5327a0c8d4c6b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
@@ -26,7 +26,7 @@ void ThrowKeywordMissingCheck::registerMatchers(MatchFinder 
*Finder) {
   isSameOrDerivedFrom(matchesName("[Ee]xception|EXCEPTION",
   unless(anyOf(hasAncestor(stmt(
anyOf(cxxThrowExpr(), callExpr(), returnStmt(,
-   hasAncestor(varDecl()),
+   hasAncestor(decl(anyOf(varDecl(), fieldDecl(,
allOf(hasAncestor(CtorInitializerList),
  unless(hasAncestor(cxxCatchStmt()))
   .bind("temporary-exception-not-thrown"),

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-throw-keyword-missing.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-throw-keyword-missing.cpp
index 5fae036fc5a39..dff600c947070 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-throw-keyword-missing.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-throw-keyword-missing.cpp
@@ -118,6 +118,7 @@ void localVariableInitTest() {
 
 class CtorInitializerListTest {
   RegularException exc;
+  RegularException exc2{};
 
   CtorInitializerListTest() : exc(RegularException()) {}
 



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


[PATCH] D113585: [clang-tidy] Fix false positive in `bugprone-throw-keyword-missing` check

2021-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit on your behalf in 738e7f1231949ec248c1d8d154783338215613d1 
, thank 
you for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113585

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


[PATCH] D106876: Remove non-affecting module maps from PCM files.

2021-11-16 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D106876#3066924 , @ilyakuteev 
wrote:

> Hello everyone, can somebody please help me commit this patch to trunk?

Hi, I'm happy to commit this for you. What author name and email would you like 
to be associated with the commit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106876

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


[PATCH] D106876: Remove non-affecting module maps from PCM files.

2021-11-16 Thread Ilya Kuteev via Phabricator via cfe-commits
ilyakuteev added a comment.

Hi, I am very glad for your help. :)
Author name: `Ilya Kuteev`
email: `ilyakut...@icloud.com`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106876

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


[clang-tools-extra] d2da1a2 - [NFC][clangd] cleaning up unused "using"

2021-11-16 Thread Christian Kühnel via cfe-commits
Author: Christian Kühnel
Date: 2021-11-16T13:09:49Z
New Revision: d2da1a2f400ab54a874c1ba5430adc07a5249563

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

LOG: [NFC][clangd] cleaning up unused "using"

Cleaning up unused "using" declarations.
This patch was generated from automatically applyning clang-tidy fixes.

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

Added: 


Modified: 
clang-tools-extra/clangd/index/YAMLSerialization.cpp
clang-tools-extra/clangd/unittests/ClangdTests.cpp
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
clang-tools-extra/clangd/unittests/HeadersTests.cpp
clang-tools-extra/clangd/unittests/IndexTests.cpp
clang-tools-extra/clangd/unittests/RIFFTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/YAMLSerialization.cpp 
b/clang-tools-extra/clangd/index/YAMLSerialization.cpp
index d269a3b36eb48..86293aba13297 100644
--- a/clang-tools-extra/clangd/index/YAMLSerialization.cpp
+++ b/clang-tools-extra/clangd/index/YAMLSerialization.cpp
@@ -73,7 +73,6 @@ using clang::clangd::SymbolOrigin;
 using clang::index::SymbolInfo;
 using clang::index::SymbolKind;
 using clang::index::SymbolLanguage;
-using clang::index::SymbolRole;
 using clang::tooling::CompileCommand;
 
 // Helper to (de)serialize the SymbolID. We serialize it as a hex string.

diff  --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
index 4a2cba52f93ab..9a4727d32b459 100644
--- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -54,10 +54,8 @@ namespace clangd {
 namespace {
 
 using ::testing::AllOf;
-using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::Field;
-using ::testing::Gt;
 using ::testing::IsEmpty;
 using ::testing::Pair;
 using ::testing::SizeIs;

diff  --git 
a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp 
b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
index 9c02f697d46c6..fcb2e68f6f2a6 100644
--- a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -40,7 +40,6 @@ using ::testing::EndsWith;
 using ::testing::HasSubstr;
 using ::testing::IsEmpty;
 using ::testing::Not;
-using ::testing::StartsWith;
 using ::testing::UnorderedElementsAre;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {

diff  --git a/clang-tools-extra/clangd/unittests/HeadersTests.cpp 
b/clang-tools-extra/clangd/unittests/HeadersTests.cpp
index fabdd26382a17..85c3e88ae05bb 100644
--- a/clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -33,7 +33,6 @@ using ::testing::ElementsAre;
 using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::UnorderedElementsAre;
-using ::testing::UnorderedElementsAreArray;
 
 class HeadersTest : public ::testing::Test {
 public:

diff  --git a/clang-tools-extra/clangd/unittests/IndexTests.cpp 
b/clang-tools-extra/clangd/unittests/IndexTests.cpp
index 5b6223a0ddc56..18eedcb7498b9 100644
--- a/clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -22,7 +22,6 @@
 
 using ::testing::_;
 using ::testing::AllOf;
-using ::testing::AnyOf;
 using ::testing::ElementsAre;
 using ::testing::IsEmpty;
 using ::testing::Pair;

diff  --git a/clang-tools-extra/clangd/unittests/RIFFTests.cpp 
b/clang-tools-extra/clangd/unittests/RIFFTests.cpp
index 4cd54f401d5bb..004918b68db5c 100644
--- a/clang-tools-extra/clangd/unittests/RIFFTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RIFFTests.cpp
@@ -13,7 +13,6 @@
 namespace clang {
 namespace clangd {
 namespace {
-using ::testing::ElementsAre;
 
 TEST(RIFFTest, File) {
   riff::File File{riff::fourCC("test"),



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


[PATCH] D113891: [NFC][clangd] cleaning up unused "using"

2021-11-16 Thread Christian Kühnel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd2da1a2f400a: [NFC][clangd] cleaning up unused 
"using" (authored by kuhnel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113891

Files:
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RIFFTests.cpp


Index: clang-tools-extra/clangd/unittests/RIFFTests.cpp
===
--- clang-tools-extra/clangd/unittests/RIFFTests.cpp
+++ clang-tools-extra/clangd/unittests/RIFFTests.cpp
@@ -13,7 +13,6 @@
 namespace clang {
 namespace clangd {
 namespace {
-using ::testing::ElementsAre;
 
 TEST(RIFFTest, File) {
   riff::File File{riff::fourCC("test"),
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -22,7 +22,6 @@
 
 using ::testing::_;
 using ::testing::AllOf;
-using ::testing::AnyOf;
 using ::testing::ElementsAre;
 using ::testing::IsEmpty;
 using ::testing::Pair;
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -33,7 +33,6 @@
 using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::UnorderedElementsAre;
-using ::testing::UnorderedElementsAreArray;
 
 class HeadersTest : public ::testing::Test {
 public:
Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -40,7 +40,6 @@
 using ::testing::HasSubstr;
 using ::testing::IsEmpty;
 using ::testing::Not;
-using ::testing::StartsWith;
 using ::testing::UnorderedElementsAre;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -54,10 +54,8 @@
 namespace {
 
 using ::testing::AllOf;
-using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::Field;
-using ::testing::Gt;
 using ::testing::IsEmpty;
 using ::testing::Pair;
 using ::testing::SizeIs;
Index: clang-tools-extra/clangd/index/YAMLSerialization.cpp
===
--- clang-tools-extra/clangd/index/YAMLSerialization.cpp
+++ clang-tools-extra/clangd/index/YAMLSerialization.cpp
@@ -73,7 +73,6 @@
 using clang::index::SymbolInfo;
 using clang::index::SymbolKind;
 using clang::index::SymbolLanguage;
-using clang::index::SymbolRole;
 using clang::tooling::CompileCommand;
 
 // Helper to (de)serialize the SymbolID. We serialize it as a hex string.


Index: clang-tools-extra/clangd/unittests/RIFFTests.cpp
===
--- clang-tools-extra/clangd/unittests/RIFFTests.cpp
+++ clang-tools-extra/clangd/unittests/RIFFTests.cpp
@@ -13,7 +13,6 @@
 namespace clang {
 namespace clangd {
 namespace {
-using ::testing::ElementsAre;
 
 TEST(RIFFTest, File) {
   riff::File File{riff::fourCC("test"),
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -22,7 +22,6 @@
 
 using ::testing::_;
 using ::testing::AllOf;
-using ::testing::AnyOf;
 using ::testing::ElementsAre;
 using ::testing::IsEmpty;
 using ::testing::Pair;
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -33,7 +33,6 @@
 using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::UnorderedElementsAre;
-using ::testing::UnorderedElementsAreArray;
 
 class HeadersTest : public ::testing::Test {
 public:
Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -40,7 +40,6 @@
 using ::testi

[PATCH] D113892: [NFC][clangd] cleanup llvm-else-after-return findings

2021-11-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Discussed offline, I believe the plan is to NOLINT the locations where we're 
handling several cases exhaustively.




Comment at: clang-tools-extra/clangd/Selection.cpp:350
   }
+  /* fall through and treat as part of the macro body */
 }

sammccall wrote:
> FWIW I find this one *much* less clear :-(
> I'd personally prefer to ignore the rule in this case, but curious what 
> others think
I think this is a nolint


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113892

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


[PATCH] D113641: [llvm] Add a SFINAE template parameter to DenseMapInfo

2021-11-16 Thread River Riddle via Phabricator via cfe-commits
rriddle updated this revision to Diff 387386.
rriddle added a comment.
Herald added subscribers: lldb-commits, hiraditya.
Herald added a project: LLDB.

resolve comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113641

Files:
  clang/include/clang/AST/TypeOrdering.h
  clang/include/clang/Basic/SourceLocation.h
  clang/include/clang/Sema/Sema.h
  lldb/include/lldb/Utility/ConstString.h
  llvm/include/llvm/ADT/APInt.h
  llvm/include/llvm/ADT/APSInt.h
  llvm/include/llvm/ADT/ArrayRef.h
  llvm/include/llvm/ADT/DenseMapInfo.h
  llvm/include/llvm/ADT/Hashing.h
  llvm/include/llvm/ADT/ImmutableList.h
  llvm/include/llvm/ADT/PointerIntPair.h
  llvm/include/llvm/ADT/StringRef.h
  llvm/include/llvm/BinaryFormat/WasmTraits.h
  llvm/include/llvm/CodeGen/SelectionDAGNodes.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/Support/TypeSize.h
  llvm/lib/Support/APInt.cpp
  llvm/unittests/ADT/DenseMapTest.cpp
  mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
  mlir/include/mlir/IR/Attributes.h
  mlir/include/mlir/IR/BuiltinOps.h
  mlir/include/mlir/IR/OpDefinition.h
  mlir/include/mlir/IR/Types.h
  mlir/include/mlir/Support/LLVM.h

Index: mlir/include/mlir/Support/LLVM.h
===
--- mlir/include/mlir/Support/LLVM.h
+++ mlir/include/mlir/Support/LLVM.h
@@ -46,7 +46,8 @@
 } // namespace detail
 template 
 class DenseMap;
-template  struct DenseMapInfo;
+template 
+struct DenseMapInfo;
 template  class DenseSet;
 class MallocAllocator;
 template  class MutableArrayRef;
@@ -90,7 +91,8 @@
 //
 // Containers.
 using llvm::ArrayRef;
-using llvm::DenseMapInfo;
+template 
+using DenseMapInfo = llvm::DenseMapInfo;
 template ,
   typename BucketT = llvm::detail::DenseMapPair>
Index: mlir/include/mlir/IR/Types.h
===
--- mlir/include/mlir/IR/Types.h
+++ mlir/include/mlir/IR/Types.h
@@ -269,6 +269,18 @@
   static unsigned getHashValue(mlir::Type val) { return mlir::hash_value(val); }
   static bool isEqual(mlir::Type LHS, mlir::Type RHS) { return LHS == RHS; }
 };
+template 
+struct DenseMapInfo::value>>
+: public DenseMapInfo {
+  static T getEmptyKey() {
+const void *pointer = llvm::DenseMapInfo::getEmptyKey();
+return T::getFromOpaquePointer(pointer);
+  }
+  static T getTombstoneKey() {
+const void *pointer = llvm::DenseMapInfo::getTombstoneKey();
+return T::getFromOpaquePointer(pointer);
+  }
+};
 
 /// We align TypeStorage by 8, so allow LLVM to steal the low bits.
 template <> struct PointerLikeTypeTraits {
Index: mlir/include/mlir/IR/OpDefinition.h
===
--- mlir/include/mlir/IR/OpDefinition.h
+++ mlir/include/mlir/IR/OpDefinition.h
@@ -1906,4 +1906,25 @@
 } // namespace impl
 } // end namespace mlir
 
+namespace llvm {
+
+template 
+struct DenseMapInfo<
+T, std::enable_if_t::value>> {
+  static inline T getEmptyKey() {
+auto *pointer = llvm::DenseMapInfo::getEmptyKey();
+return T::getFromOpaquePointer(pointer);
+  }
+  static inline T getTombstoneKey() {
+auto *pointer = llvm::DenseMapInfo::getTombstoneKey();
+return T::getFromOpaquePointer(pointer);
+  }
+  static unsigned getHashValue(T val) {
+return hash_value(val.getAsOpaquePointer());
+  }
+  static bool isEqual(T lhs, T rhs) { return lhs == rhs; }
+};
+
+} // end namespace llvm
+
 #endif
Index: mlir/include/mlir/IR/BuiltinOps.h
===
--- mlir/include/mlir/IR/BuiltinOps.h
+++ mlir/include/mlir/IR/BuiltinOps.h
@@ -49,23 +49,6 @@
 } // end namespace mlir
 
 namespace llvm {
-// Functions hash just like pointers.
-template <>
-struct DenseMapInfo {
-  static mlir::FuncOp getEmptyKey() {
-auto *pointer = llvm::DenseMapInfo::getEmptyKey();
-return mlir::FuncOp::getFromOpaquePointer(pointer);
-  }
-  static mlir::FuncOp getTombstoneKey() {
-auto *pointer = llvm::DenseMapInfo::getTombstoneKey();
-return mlir::FuncOp::getFromOpaquePointer(pointer);
-  }
-  static unsigned getHashValue(mlir::FuncOp val) {
-return hash_value(val.getAsOpaquePointer());
-  }
-  static bool isEqual(mlir::FuncOp lhs, mlir::FuncOp rhs) { return lhs == rhs; }
-};
-
 /// Allow stealing the low bits of FuncOp.
 template <>
 struct PointerLikeTypeTraits {
Index: mlir/include/mlir/IR/Attributes.h
===
--- mlir/include/mlir/IR/Attributes.h
+++ mlir/include/mlir/IR/Attributes.h
@@ -201,6 +201,19 @@
 return LHS == RHS;
   }
 };
+template 
+struct DenseMapInfo<
+T, std::enable_if_t::value>>
+: public DenseMapInfo {
+  static T getEmptyKey() {
+const void *pointer = llvm::DenseMapInfo::getEmptyKey();
+return T::getFromOpaquePointer(pointer);
+  }
+  static T getTombstoneKey() {
+const void *pointer = llvm::DenseMapIn

[PATCH] D110216: [clang] retain type sugar in auto / template argument deduction

2021-11-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

LGTM from the libc++ perspective.

Unsubscribing to reduce spam, please ping me on Discord if you need further 
input. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110216

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


[PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2021-11-16 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 387579.
mizvekov added a comment.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
This revision now requires review to proceed.

- Run libcxx CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

Files:
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1 +1,2 @@
 D111283
+D111509
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
@@ -18,7 +18,7 @@
 
 #ifdef ADD_I64
   (void)(uint64_t(1000ull) + uint64_t(900ull));
-  // CHECK-ADD_I64: 1000 + 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-ADD_I64: 1000 + 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef ADD_I128
@@ -27,6 +27,6 @@
 # else
   puts("__int128 not supported");
 # endif
-  // CHECK-ADD_I128: {{0x8000 \+ 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-ADD_I128: {{0x8000 \+ 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef S

[PATCH] D113889: [NFC] disabling clang-tidy check readability-identifier-naming in Protocol.h

2021-11-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

This looks the best we can do, please address Kirill's comment.

I spotted a related crash bug (https://github.com/clangd/clangd/issues/929) in 
clangd, but I think this patch should be fine to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113889

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


[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-16 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D110257#3133866 , @hsmhsm wrote:

> This is not something specific to AMDGPU backend, but  AMDGPU backend at 
> present requires this canonical form.

I must emphasize this is not a hard requirement, just a nice to have


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-16 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D110257#3134001 , @JonChesterfield 
wrote:

> So you won't articulate or document the new invariant and you think there's a 
> llvm-dev discussion that says we can't verify the invariant which you won't 
> reference, but means you won't add this to the verifier.

The verifier does not check for whether or things are canonical or not. We 
don't really have formal definitions for what's considered canonical, it's just 
what people think make later optimizations easier. This is not a change in the 
IR rules.

> Request changes doesn't really work after you've applied the patch.
>
> @rnk do you object to me reverting this? I don't think we can add an 
> invariant to IR which is undocumented and unverified/unverifiable and the 
> patch author seems opposed to fixing either omission.

I object to reverting this as this has nothing which the verifier should be 
checking


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D113993: WIP: [clang] customizable build-id style

2021-11-16 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk created this revision.
kwk added reviewers: tbaeder, tstellar.
kwk added projects: clang, lld.
Herald added a subscriber: mgorny.
kwk requested review of this revision.
Herald added a subscriber: cfe-commits.

**This is work in progress. I'm evaluating the patch now.**

This change introduces the possibility to specify a style of build-id
generation that must be one of "md5", "sha1", "fast", "uuid", or
"0x". To set this style, one can set
`ENABLE_LINKER_BUILD_ID_STYLE`. Setting the style will  automatically
turn `ON` `ENABLE_LINKER_BUILD_ID`.

The effect is that invocations of the compiler will link with
`--build-id=

[PATCH] D113925: [HIP] Add HIP scope atomic operations

2021-11-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/CGAtomic.cpp:1347-1348
   break; // Avoid crashing on code with undefined behavior
+if (!OrderFail)
+  llvm::errs() << "FOO\n";
 EmitAtomicOp(*this, E, Dest, Ptr, Val1, Val2, IsWeak, OrderFail, Size,

debugging code should be removed



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:510-514
+  Builder.defineMacro("__HIP_MEMORY_SCOPE_SINGLETHREAD", "1");
+  Builder.defineMacro("__HIP_MEMORY_SCOPE_WAVEFRONT", "2");
+  Builder.defineMacro("__HIP_MEMORY_SCOPE_WORKGROUP", "3");
+  Builder.defineMacro("__HIP_MEMORY_SCOPE_AGENT", "4");
+  Builder.defineMacro("__HIP_MEMORY_SCOPE_SYSTEM", "5");

these should be moved outside of if (LangOpts.CUDAIsDevice) as they need to be 
visible to both device and host compilation. The downstream amd-stg-open branch 
already did this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113925

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


[PATCH] D113993: WIP: [clang] customizable build-id style

2021-11-16 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 387606.
kwk edited the summary of this revision.
kwk added a comment.

Renamed: `ENABLE_LINKER_BUILD_ID_STYLE` to `DEFAULT_LINKER_BUILD_ID_STYLE`.
Fixed issues with CMake (not done yet)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113993

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/ToolChains/Hurd.cpp


Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -82,7 +82,11 @@
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
 #ifdef ENABLE_LINKER_BUILD_ID
-  ExtraOpts.push_back("--build-id");
+  #ifdef ENABLE_LINKER_BUILD_ID_STYLE
+ExtraOpts.push_back("--build-id=" ENABLE_LINKER_BUILD_ID_STYLE);
+  #else
+ExtraOpts.push_back("--build-id");
+  #endif
 #endif
 
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
Index: clang/include/clang/Config/config.h.cmake
===
--- clang/include/clang/Config/config.h.cmake
+++ clang/include/clang/Config/config.h.cmake
@@ -69,9 +69,12 @@
 /* Linker version detected at compile time. */
 #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
 
-/* pass --build-id to ld */
+/* Pass --build-id or --build-id=

[clang] 83727f2 - [AArch64][SVE] Remove arm-registered-target requirement on bfloat tests

2021-11-16 Thread Matt Devereau via cfe-commits
Author: Matt Devereau
Date: 2021-11-16T14:38:21Z
New Revision: 83727f27719d3f319f746b473ce09be7e1d99b32

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

LOG: [AArch64][SVE] Remove arm-registered-target requirement on bfloat tests

Changes in https://reviews.llvm.org/D113489 caused buildbot failures

Added: 


Modified: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c
index f2dc5c1d4d6d..38a959fc2917 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c
@@ -5,7 +5,7 @@
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s 
-check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
 
-// REQUIRES: aarch64-registered-target || arm-registered-target
+// REQUIRES: aarch64-registered-target
 
 #include 
 

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
index a05da764de44..7a57a3ebf354 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
@@ -5,7 +5,7 @@
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s 
-check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
 
-// REQUIRES: aarch64-registered-target || arm-registered-target
+// REQUIRES: aarch64-registered-target
 
 #include 
 



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


[PATCH] D113489: [AArch64][SVE] Instcombine SVE LD1/ST1 to stock LLVM IR

2021-11-16 Thread Matt Devereau via Phabricator via cfe-commits
MattDevereau added a comment.

This caused buildbot failures which failed on the bfloat tests. Pushed commit 
83727f27719d3f319f746b473ce09be7e1d99b32 
 to fix 
the issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113489

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


[PATCH] D113993: WIP: [clang] customizable build-id style

2021-11-16 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 387608.
kwk added a comment.

Use correct CMake variable type: BOOLEAN -> BOOL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113993

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -219,7 +219,7 @@
 set(DEFAULT_SYSROOT "" CACHE STRING
   "Default  to all compiler invocations for --sysroot=." )
 
-set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOLEAN
+set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL
   "Pass --build-id or --build-id=

[PATCH] D113977: [Coroutine] Warn deprecated 'std::experimental::coro' uses

2021-11-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

LGTM with some suggestions, thanks for adding this notice!




Comment at: clang/include/clang/Basic/DiagnosticGroups.td:57-59
+def DeprecatedCorotuine :
+  DiagGroup<"deprecated-coroutine">;
+def Coroutine : DiagGroup<"coroutine", [CoroutineMissingUnhandledException, 
DeprecatedCorotuine]>;





Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11015-11017
+  "Found deprecated std::experimental::%0. Consider to update your libc++ "
+  "or move coroutine components into std namespace in case you are using "
+  "self-defined coroutine components">,

I would simply reword as "Please move from std::experimental::%0 to std::%0. 
Support for std::experimental::%0 will be removed in LLVM 15."

IMO the set of users defining their own coroutines header is small and it's not 
worth making the warning more obtuse for that corner case.



Comment at: 
libcxx/test/std/experimental/language.support/support.coroutines/lit.local.cfg:8
   config.test_format.addCompileFlags(config, '-fcoroutines-ts')
+  config.test_format.addCompileFlags(config, '-Wno-coroutine')




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113977

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


[PATCH] D113993: WIP: [clang] customizable build-id style

2021-11-16 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 387610.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113993

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/ToolChains/Hurd.cpp


Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -82,7 +82,11 @@
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
 #ifdef ENABLE_LINKER_BUILD_ID
-  ExtraOpts.push_back("--build-id");
+  #ifdef ENABLE_LINKER_BUILD_ID_STYLE
+ExtraOpts.push_back("--build-id=" ENABLE_LINKER_BUILD_ID_STYLE);
+  #else
+ExtraOpts.push_back("--build-id");
+  #endif
 #endif
 
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
Index: clang/include/clang/Config/config.h.cmake
===
--- clang/include/clang/Config/config.h.cmake
+++ clang/include/clang/Config/config.h.cmake
@@ -69,9 +69,12 @@
 /* Linker version detected at compile time. */
 #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
 
-/* pass --build-id to ld */
+/* Pass --build-id or --build-id=

[PATCH] D113995: [clangd] Dex Trigrams: Improve query trigram generation

2021-11-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

These are the trigrams for queries right now:

- "va" -> {Trigram("va")}
- "va_" -> {} (empty)

This is suboptimal since the resulting query will discard the query information
and return all symbols, some of which will be later be scored expensively
(fuzzy matching score). This is related to
https://github.com/clangd/clangd/issues/39 but does not fix it. Accidentally,
because of that incorrect behavior, when user types "tok::va" there are no
results (the issue is that `tok::kw___builtin_va_arg` does not have "va" token)
but when "tok::va_" is typed, expected result (`tok::kw___builtin_va_arg`)
shows up by accident. This is because the dex query transformer will only
lookup symbols within the `tok::` namespace. There won't be many, so the
returned results will contain symbol we need; this symbol will be filtered out
by the expensive checks and that will be displayed in the editor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113995

Files:
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp


Index: clang-tools-extra/clangd/unittests/DexTests.cpp
===
--- clang-tools-extra/clangd/unittests/DexTests.cpp
+++ clang-tools-extra/clangd/unittests/DexTests.cpp
@@ -404,6 +404,9 @@
   EXPECT_THAT(identifierTrigramTokens("IsOK"),
   trigramsAre({"i", "is", "io", "iso", "iok", "sok"}));
 
+  EXPECT_THAT(identifierTrigramTokens("_pb"), trigramsAre({"_", "_p"}));
+  EXPECT_THAT(identifierTrigramTokens("__pb"), trigramsAre({"_", "__", "_p"}));
+
   EXPECT_THAT(
   identifierTrigramTokens("abc_defGhij__klm"),
   trigramsAre({"a",   "ab",  "ad",  "abc", "abd", "ade", "adg", "bcd",
@@ -422,6 +425,14 @@
   EXPECT_THAT(generateQueryTrigrams("__"), trigramsAre({"__"}));
   EXPECT_THAT(generateQueryTrigrams("___"), trigramsAre({}));
 
+  EXPECT_THAT(generateQueryTrigrams("m_"), trigramsAre({"m_"}));
+
+  EXPECT_THAT(generateQueryTrigrams("p_b"), trigramsAre({"pb"}));
+  EXPECT_THAT(generateQueryTrigrams("pb_"), trigramsAre({"pb"}));
+  EXPECT_THAT(generateQueryTrigrams("_p"), trigramsAre({"_p"}));
+  EXPECT_THAT(generateQueryTrigrams("_pb_"), trigramsAre({"_p"}));
+  EXPECT_THAT(generateQueryTrigrams("__pb"), trigramsAre({"_p"}));
+
   EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
 
   EXPECT_THAT(generateQueryTrigrams("clangd"),
@@ -545,6 +556,18 @@
   Req.Query = "ttf";
   EXPECT_THAT(match(*I, Req, &Incomplete), ElementsAre("OneTwoThreeFour"));
   EXPECT_FALSE(Incomplete) << "3-char string is not a short query";
+
+  I = Dex::build(generateSymbols({"tok::kw_builtin_va_arg", "bar::whatever"}),
+ RefSlab(), RelationSlab());
+
+  Req.Query = "kw_";
+  EXPECT_THAT(match(*I, Req, &Incomplete),
+  ElementsAre("tok::kw_builtin_va_arg"));
+  EXPECT_FALSE(Incomplete) << "kw_ is enough to match the whole symbol";
+  Req.Scopes = {"tok::"};
+  EXPECT_THAT(match(*I, Req, &Incomplete),
+  ElementsAre("tok::kw_builtin_va_arg"));
+  EXPECT_FALSE(Incomplete) << "kw_ is enough to match the whole symbol";
 }
 
 TEST(DexTest, MatchQualifiedNamesWithoutSpecificScope) {
Index: clang-tools-extra/clangd/index/dex/Trigram.cpp
===
--- clang-tools-extra/clangd/index/dex/Trigram.cpp
+++ clang-tools-extra/clangd/index/dex/Trigram.cpp
@@ -101,17 +101,42 @@
 std::vector generateQueryTrigrams(llvm::StringRef Query) {
   if (Query.empty())
 return {};
-  std::string LowercaseQuery = Query.lower();
-  if (Query.size() < 3) // short-query trigrams only
-return {Token(Token::Kind::Trigram, LowercaseQuery)};
 
   // Apply fuzzy matching text segmentation.
   std::vector Roles(Query.size());
   calculateRoles(Query, llvm::makeMutableArrayRef(Roles.data(), Query.size()));
 
+  std::string LowercaseQuery = Query.lower();
+
+  if (LowercaseQuery.size() < 3) // short-query trigrams only.
+return {Token(Token::Kind::Trigram, LowercaseQuery)};
+
+  unsigned ValidSymbols =
+  llvm::count_if(Roles, [](CharRole R) { return R == Head || R == Tail; });
+  // If the query does not have any alphanumeric symbols, don't restrict the
+  // result to the names.
+  if (ValidSymbols == 0)
+return {};
+  //
+  if (ValidSymbols < 3) {
+std::string Letters =
+Roles.front() == Separator ? std::string(1, Query.front()) : "";
+for (unsigned I = 0; I < LowercaseQuery.size(); ++I) {
+  if (Roles[I] == Head || Roles[I] == Tail) {
+Letters += LowercaseQuery[I];
+// Similar to the identifier trigram generation, stop here for the
+// queries starting with the separator, i.e. "_va" will only outpu

[PATCH] D113995: [clangd] Dex Trigrams: Improve query trigram generation

2021-11-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 387615.
kbobyrev added a comment.

Add a small comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113995

Files:
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp


Index: clang-tools-extra/clangd/unittests/DexTests.cpp
===
--- clang-tools-extra/clangd/unittests/DexTests.cpp
+++ clang-tools-extra/clangd/unittests/DexTests.cpp
@@ -404,6 +404,9 @@
   EXPECT_THAT(identifierTrigramTokens("IsOK"),
   trigramsAre({"i", "is", "io", "iso", "iok", "sok"}));
 
+  EXPECT_THAT(identifierTrigramTokens("_pb"), trigramsAre({"_", "_p"}));
+  EXPECT_THAT(identifierTrigramTokens("__pb"), trigramsAre({"_", "__", "_p"}));
+
   EXPECT_THAT(
   identifierTrigramTokens("abc_defGhij__klm"),
   trigramsAre({"a",   "ab",  "ad",  "abc", "abd", "ade", "adg", "bcd",
@@ -422,6 +425,14 @@
   EXPECT_THAT(generateQueryTrigrams("__"), trigramsAre({"__"}));
   EXPECT_THAT(generateQueryTrigrams("___"), trigramsAre({}));
 
+  EXPECT_THAT(generateQueryTrigrams("m_"), trigramsAre({"m_"}));
+
+  EXPECT_THAT(generateQueryTrigrams("p_b"), trigramsAre({"pb"}));
+  EXPECT_THAT(generateQueryTrigrams("pb_"), trigramsAre({"pb"}));
+  EXPECT_THAT(generateQueryTrigrams("_p"), trigramsAre({"_p"}));
+  EXPECT_THAT(generateQueryTrigrams("_pb_"), trigramsAre({"_p"}));
+  EXPECT_THAT(generateQueryTrigrams("__pb"), trigramsAre({"_p"}));
+
   EXPECT_THAT(generateQueryTrigrams("X86"), trigramsAre({"x86"}));
 
   EXPECT_THAT(generateQueryTrigrams("clangd"),
@@ -545,6 +556,18 @@
   Req.Query = "ttf";
   EXPECT_THAT(match(*I, Req, &Incomplete), ElementsAre("OneTwoThreeFour"));
   EXPECT_FALSE(Incomplete) << "3-char string is not a short query";
+
+  I = Dex::build(generateSymbols({"tok::kw_builtin_va_arg", "bar::whatever"}),
+ RefSlab(), RelationSlab());
+
+  Req.Query = "kw_";
+  EXPECT_THAT(match(*I, Req, &Incomplete),
+  ElementsAre("tok::kw_builtin_va_arg"));
+  EXPECT_FALSE(Incomplete) << "kw_ is enough to match the whole symbol";
+  Req.Scopes = {"tok::"};
+  EXPECT_THAT(match(*I, Req, &Incomplete),
+  ElementsAre("tok::kw_builtin_va_arg"));
+  EXPECT_FALSE(Incomplete) << "kw_ is enough to match the whole symbol";
 }
 
 TEST(DexTest, MatchQualifiedNamesWithoutSpecificScope) {
Index: clang-tools-extra/clangd/index/dex/Trigram.cpp
===
--- clang-tools-extra/clangd/index/dex/Trigram.cpp
+++ clang-tools-extra/clangd/index/dex/Trigram.cpp
@@ -101,17 +101,43 @@
 std::vector generateQueryTrigrams(llvm::StringRef Query) {
   if (Query.empty())
 return {};
-  std::string LowercaseQuery = Query.lower();
-  if (Query.size() < 3) // short-query trigrams only
-return {Token(Token::Kind::Trigram, LowercaseQuery)};
 
   // Apply fuzzy matching text segmentation.
   std::vector Roles(Query.size());
   calculateRoles(Query, llvm::makeMutableArrayRef(Roles.data(), Query.size()));
 
+  std::string LowercaseQuery = Query.lower();
+
+  if (LowercaseQuery.size() < 3) // short-query trigrams only.
+return {Token(Token::Kind::Trigram, LowercaseQuery)};
+
+  unsigned ValidSymbols =
+  llvm::count_if(Roles, [](CharRole R) { return R == Head || R == Tail; });
+  // If the query does not have any alphanumeric symbols, don't restrict the
+  // result to the names.
+  if (ValidSymbols == 0)
+return {};
+  // For queries with very few letters, emulate what generateIdentifierTrigrams
+  // outputs for the beginning of the Identifier.
+  if (ValidSymbols < 3) {
+std::string Letters =
+Roles.front() == Separator ? std::string(1, Query.front()) : "";
+for (unsigned I = 0; I < LowercaseQuery.size(); ++I) {
+  if (Roles[I] == Head || Roles[I] == Tail) {
+Letters += LowercaseQuery[I];
+// Similar to the identifier trigram generation, stop here for the
+// queries starting with the separator, i.e. "_va" will only output
+// "_v" here, identifier trigram generator will output "_" and "_v"
+if (Roles.front() == Separator)
+  break;
+  }
+}
+return {Token(Token::Kind::Trigram, Letters)};
+  }
+
   llvm::DenseSet UniqueTrigrams;
   std::string Chars;
-  for (unsigned I = 0; I < Query.size(); ++I) {
+  for (unsigned I = 0; I < LowercaseQuery.size(); ++I) {
 if (Roles[I] != Head && Roles[I] != Tail)
   continue; // Skip delimiters.
 Chars.push_back(LowercaseQuery[I]);


Index: clang-tools-extra/clangd/unittests/DexTests.cpp
===
--- clang-tools-extra/clangd/unittests/DexTests.cpp
+++ clang-tools-extra/clangd/unittests/DexTests.cpp
@@ -404,6 +404,9 @@
   EXPECT_THAT(identifierTrigramTokens("IsOK"),
   trigramsAre({"i", "is", "io", "iso", "iok", "sok"}));
 
+  E

[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

If the amdgpu backend doesn't require this then it doesn't matter much if other 
passes undo it. If it's not an invariant, we don't need the verifier to alert 
people to passes that break it.

Git blame on the new code in clang will lead people here where they may be able 
to work out from the comments why this change was made.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D113538: OpenMP: Start calling setTargetAttributes for generated kernels

2021-11-16 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D113538

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


[PATCH] D113538: OpenMP: Start calling setTargetAttributes for generated kernels

2021-11-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Apologies, I thought I had already accepted this. Thanks for the patch!


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

https://reviews.llvm.org/D113538

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


[PATCH] D113999: [clangd] Fix assertion crashes on unmatched NOLINTBEGIN comments.

2021-11-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: carlosgalvezp, usaxena95, kadircet, arphaman.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

The overload shouldSuppressDiagnostic seems unnecessary, and it is only
used in clangd.

This patch removes it and use the real one (suppression diagnostics are
discarded in clangd at the moment).

Fixes https://github.com/clangd/clangd/issues/929


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113999

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -476,6 +476,13 @@
   double g = [[8]] / i;
   #define BAD2 BAD
   double h = BAD2;  // NOLINT
+  // NOLINTBEGIN
+  double x = BAD2;
+  double y = BAD2;
+  // NOLINTEND
+
+  // verify no crashes on unmatched nolints.
+  // NOLINTBEIGN
 }
   )cpp");
   TestTU TU = TestTU::withCode(Main.code());
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -391,9 +391,13 @@
   bool IsInsideMainFile =
   Info.hasSourceManager() &&
   isInsideMainFile(Info.getLocation(), Info.getSourceManager());
+  SmallVector TidySuppressedErrors;
   if (IsInsideMainFile &&
   tidy::shouldSuppressDiagnostic(DiagLevel, Info, *CTContext,
+ TidySuppressedErrors,
  /*AllowIO=*/false)) {
+// FIXME: should we expose the suppression error (invalid use of
+// NOLINT comments)?
 return DiagnosticsEngine::Ignored;
   }
 
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -228,10 +228,6 @@
 /// for example, the use of a "NOLINTBEGIN" comment that is not followed by a
 /// "NOLINTEND" comment - a diagnostic regarding the improper use is returned
 /// via the output argument `SuppressionErrors`.
-bool shouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel,
-  const Diagnostic &Info, ClangTidyContext 
&Context,
-  bool AllowIO = true);
-
 bool shouldSuppressDiagnostic(
 DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info,
 ClangTidyContext &Context,
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -517,16 +517,6 @@
 namespace clang {
 namespace tidy {
 
-bool shouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel,
-  const Diagnostic &Info, ClangTidyContext 
&Context,
-  bool AllowIO) {
-  SmallVector Unused;
-  bool ShouldSuppress =
-  shouldSuppressDiagnostic(DiagLevel, Info, Context, Unused, AllowIO);
-  assert(Unused.empty());
-  return ShouldSuppress;
-}
-
 bool shouldSuppressDiagnostic(
 DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info,
 ClangTidyContext &Context,


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -476,6 +476,13 @@
   double g = [[8]] / i;
   #define BAD2 BAD
   double h = BAD2;  // NOLINT
+  // NOLINTBEGIN
+  double x = BAD2;
+  double y = BAD2;
+  // NOLINTEND
+
+  // verify no crashes on unmatched nolints.
+  // NOLINTBEIGN
 }
   )cpp");
   TestTU TU = TestTU::withCode(Main.code());
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -391,9 +391,13 @@
   bool IsInsideMainFile =
   Info.hasSourceManager() &&
   isInsideMainFile(Info.getLocation(), Info.getSourceManager());
+  SmallVector TidySuppressedErrors;
   if (IsInsideMainFile &&
   tidy::shouldSuppressDi

[clang-tools-extra] 274f12a - [NFC][clangd] fix llvm-namespace-comment finding

2021-11-16 Thread Christian Kühnel via cfe-commits
Author: Christian Kühnel
Date: 2021-11-16T15:10:32Z
New Revision: 274f12a44c606ecd20152f3e63c4f186793d9a8c

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

LOG: [NFC][clangd] fix llvm-namespace-comment finding

Fixing the clang-tidy finding.

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

Added: 


Modified: 
clang-tools-extra/clangd/xpc/XPCTransport.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/xpc/XPCTransport.cpp 
b/clang-tools-extra/clangd/xpc/XPCTransport.cpp
index 9eb083953b965..4c6308b3acae7 100644
--- a/clang-tools-extra/clangd/xpc/XPCTransport.cpp
+++ b/clang-tools-extra/clangd/xpc/XPCTransport.cpp
@@ -47,7 +47,7 @@ Error decodeError(const json::Object &O) {
 // C "closure" for XPCTransport::loop() method
 namespace xpcClosure {
 void connection_handler(xpc_connection_t clientConnection);
-}
+} // namespace xpcClosure
 
 class XPCTransport : public Transport {
 public:



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


[PATCH] D113895: [NFC][clangd] fix llvm-namespace-comment finding

2021-11-16 Thread Christian Kühnel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG274f12a44c60: [NFC][clangd] fix llvm-namespace-comment 
finding (authored by kuhnel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113895

Files:
  clang-tools-extra/clangd/xpc/XPCTransport.cpp


Index: clang-tools-extra/clangd/xpc/XPCTransport.cpp
===
--- clang-tools-extra/clangd/xpc/XPCTransport.cpp
+++ clang-tools-extra/clangd/xpc/XPCTransport.cpp
@@ -47,7 +47,7 @@
 // C "closure" for XPCTransport::loop() method
 namespace xpcClosure {
 void connection_handler(xpc_connection_t clientConnection);
-}
+} // namespace xpcClosure
 
 class XPCTransport : public Transport {
 public:


Index: clang-tools-extra/clangd/xpc/XPCTransport.cpp
===
--- clang-tools-extra/clangd/xpc/XPCTransport.cpp
+++ clang-tools-extra/clangd/xpc/XPCTransport.cpp
@@ -47,7 +47,7 @@
 // C "closure" for XPCTransport::loop() method
 namespace xpcClosure {
 void connection_handler(xpc_connection_t clientConnection);
-}
+} // namespace xpcClosure
 
 class XPCTransport : public Transport {
 public:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4c8b8e0 - [PowerPC] Allow MMA built-ins to accept non-void pointers and arrays

2021-11-16 Thread Ahsan Saghir via cfe-commits
Author: Ahsan Saghir
Date: 2021-11-16T09:14:41-06:00
New Revision: 4c8b8e0154f075e463428acc0640388c40d60097

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

LOG: [PowerPC] Allow MMA built-ins to accept non-void pointers and arrays

Calls to MMA builtins that take pointer to void
do not accept other pointers/arrays whereas normal
functions with the same parameter do. This patch
allows MMA built-ins to accept non-void pointers
and arrays.

Reviewed By: nemanjai

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/ppc-pair-mma-types.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 18e429cf3efd2..849423c8b9bae 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -15171,8 +15171,12 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
const CallExpr *E) {
   SmallVector Ops;
 
-  for (unsigned i = 0, e = E->getNumArgs(); i != e; i++)
-Ops.push_back(EmitScalarExpr(E->getArg(i)));
+  for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
+if (E->getArg(i)->getType()->isArrayType())
+  Ops.push_back(EmitArrayToPointerDecay(E->getArg(i)).getPointer());
+else
+  Ops.push_back(EmitScalarExpr(E->getArg(i)));
+  }
 
   Intrinsic::ID ID = Intrinsic::not_intrinsic;
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 6b38877bee114..3fe7303cb4458 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -7553,11 +7553,11 @@ bool Sema::SemaBuiltinPPCMMACall(CallExpr *TheCall, 
unsigned BuiltinID,
   StrippedRVType = StrippedRVType.getCanonicalType().getUnqualifiedType();
 
 // The only case where the argument type and expected type are allowed to
-// mismatch is if the argument type is a non-void pointer and expected type
-// is a void pointer.
+// mismatch is if the argument type is a non-void pointer (or array) and
+// expected type is a void pointer.
 if (StrippedRVType != ExpectedType)
   if (!(ExpectedType->isVoidPointerType() &&
-StrippedRVType->isPointerType()))
+(StrippedRVType->isPointerType() || 
StrippedRVType->isArrayType(
 return Diag(Arg->getBeginLoc(),
 diag::err_typecheck_convert_incompatible)
<< PassedType << ExpectedType << 1 << 0 << 0;

diff  --git a/clang/test/Sema/ppc-pair-mma-types.c 
b/clang/test/Sema/ppc-pair-mma-types.c
index 5f259b9780ae2..2ad1079bd966b 100644
--- a/clang/test/Sema/ppc-pair-mma-types.c
+++ b/clang/test/Sema/ppc-pair-mma-types.c
@@ -339,20 +339,20 @@ void testBuiltinTypes3(vector int v, __vector_pair *vp2, 
signed long l, unsigned
 
 void testRestrictQualifiedPointer1(int *__restrict acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc); // expected-error {{passing 
'int *restrict' to parameter of incompatible type '__vector_quad *'}}
+  __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int 
*restrict' to parameter of incompatible type '__vector_quad *'}}
 }
 
 void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc);
+  __builtin_mma_disassemble_acc(arr, acc);
 }
 
 void testVolatileQualifiedPointer1(int *__volatile acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc); // expected-error {{passing 
'int *volatile' to parameter of incompatible type '__vector_quad *'}}
+  __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int 
*volatile' to parameter of incompatible type '__vector_quad *'}}
 }
 
 void testVolatileQualifiedPointer2(__vector_quad *__volatile acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc);
+  __builtin_mma_disassemble_acc(arr, acc);
 }



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


[PATCH] D113306: [PowerPC] Allow MMA built-ins to accept non-void pointers and arrays

2021-11-16 Thread Ahsan Saghir via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c8b8e0154f0: [PowerPC] Allow MMA built-ins to accept 
non-void pointers and arrays (authored by saghir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113306

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/ppc-pair-mma-types.c


Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -339,20 +339,20 @@
 
 void testRestrictQualifiedPointer1(int *__restrict acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc); // expected-error {{passing 
'int *restrict' to parameter of incompatible type '__vector_quad *'}}
+  __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int 
*restrict' to parameter of incompatible type '__vector_quad *'}}
 }
 
 void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc);
+  __builtin_mma_disassemble_acc(arr, acc);
 }
 
 void testVolatileQualifiedPointer1(int *__volatile acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc); // expected-error {{passing 
'int *volatile' to parameter of incompatible type '__vector_quad *'}}
+  __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int 
*volatile' to parameter of incompatible type '__vector_quad *'}}
 }
 
 void testVolatileQualifiedPointer2(__vector_quad *__volatile acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc);
+  __builtin_mma_disassemble_acc(arr, acc);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7553,11 +7553,11 @@
   StrippedRVType = StrippedRVType.getCanonicalType().getUnqualifiedType();
 
 // The only case where the argument type and expected type are allowed to
-// mismatch is if the argument type is a non-void pointer and expected type
-// is a void pointer.
+// mismatch is if the argument type is a non-void pointer (or array) and
+// expected type is a void pointer.
 if (StrippedRVType != ExpectedType)
   if (!(ExpectedType->isVoidPointerType() &&
-StrippedRVType->isPointerType()))
+(StrippedRVType->isPointerType() || 
StrippedRVType->isArrayType(
 return Diag(Arg->getBeginLoc(),
 diag::err_typecheck_convert_incompatible)
<< PassedType << ExpectedType << 1 << 0 << 0;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -15171,8 +15171,12 @@
const CallExpr *E) {
   SmallVector Ops;
 
-  for (unsigned i = 0, e = E->getNumArgs(); i != e; i++)
-Ops.push_back(EmitScalarExpr(E->getArg(i)));
+  for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
+if (E->getArg(i)->getType()->isArrayType())
+  Ops.push_back(EmitArrayToPointerDecay(E->getArg(i)).getPointer());
+else
+  Ops.push_back(EmitScalarExpr(E->getArg(i)));
+  }
 
   Intrinsic::ID ID = Intrinsic::not_intrinsic;
 


Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -339,20 +339,20 @@
 
 void testRestrictQualifiedPointer1(int *__restrict acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}}
+  __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}}
 }
 
 void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc);
+  __builtin_mma_disassemble_acc(arr, acc);
 }
 
 void testVolatileQualifiedPointer1(int *__volatile acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc); // expected-error {{passing 'int *volatile' to parameter of incompatible type '__vector_quad *'}}
+  __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int *volatile' to parameter of incompatible type '__vector_quad *'}}
 }
 
 void testVolatileQualifiedPointer2(__vector_quad *__volatile acc) {
   vector float arr[4];
-  __builtin_mma_disassemble_acc((void *)arr, acc);
+  __builtin_mma_disassemble_acc(arr, acc);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/Sema

[clang-tools-extra] 75a0784 - [NFC] disabling clang-tidy check readability-identifier-naming in Protocol.h

2021-11-16 Thread Christian Kühnel via cfe-commits
Author: Christian Kühnel
Date: 2021-11-16T15:25:43Z
New Revision: 75a078455fc71cddc5e04b709b349125b610e1bb

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

LOG: [NFC] disabling clang-tidy check readability-identifier-naming in 
Protocol.h

The file follows the LSP syntax, so we're intentially deviating
from the LLVM coding standard.

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

Added: 


Modified: 
clang-tools-extra/clangd/Protocol.h

Removed: 




diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 3a1eae587554..5ce7b4e4da73 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -36,6 +36,11 @@
 #include 
 #include 
 
+// This file is using the LSP syntax for identifier names which is 
diff erent
+// from the LLVM coding standard. To avoid the clang-tidy warnings, we're
+// disabling one check here.
+// NOLINTBEGIN(readability-identifier-naming)
+
 namespace clang {
 namespace clangd {
 
@@ -1794,4 +1799,6 @@ template <> struct 
format_provider {
 };
 } // namespace llvm
 
+// NOLINTEND(readability-identifier-naming)
+
 #endif



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


[PATCH] D113889: [NFC] disabling clang-tidy check readability-identifier-naming in Protocol.h

2021-11-16 Thread Christian Kühnel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG75a078455fc7: [NFC] disabling clang-tidy check 
readability-identifier-naming in Protocol.h (authored by kuhnel).

Changed prior to commit:
  https://reviews.llvm.org/D113889?vs=387239&id=387634#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113889

Files:
  clang-tools-extra/clangd/Protocol.h


Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -36,6 +36,11 @@
 #include 
 #include 
 
+// This file is using the LSP syntax for identifier names which is different
+// from the LLVM coding standard. To avoid the clang-tidy warnings, we're
+// disabling one check here.
+// NOLINTBEGIN(readability-identifier-naming)
+
 namespace clang {
 namespace clangd {
 
@@ -1794,4 +1799,6 @@
 };
 } // namespace llvm
 
+// NOLINTEND(readability-identifier-naming)
+
 #endif


Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -36,6 +36,11 @@
 #include 
 #include 
 
+// This file is using the LSP syntax for identifier names which is different
+// from the LLVM coding standard. To avoid the clang-tidy warnings, we're
+// disabling one check here.
+// NOLINTBEGIN(readability-identifier-naming)
+
 namespace clang {
 namespace clangd {
 
@@ -1794,4 +1799,6 @@
 };
 } // namespace llvm
 
+// NOLINTEND(readability-identifier-naming)
+
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113889: [NFC] disabling clang-tidy check readability-identifier-naming in Protocol.h

2021-11-16 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel added a comment.

I just checked with my local clangd and it does not crash on this file...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113889

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


[PATCH] D113977: [Coroutine] Warn deprecated 'std::experimental::coro' uses

2021-11-16 Thread Mark de Wever via Phabricator via cfe-commits
Mordante accepted this revision.
Mordante added a comment.

Thanks for working on this and landing the coroutines. LGTM after applying 
@ldionne's suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113977

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


[PATCH] D113977: [Coroutine] Warn deprecated 'std::experimental::coro' uses

2021-11-16 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone requested changes to this revision.
Quuxplusone added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11015-11017
+  "Found deprecated std::experimental::%0. Consider to update your libc++ "
+  "or move coroutine components into std namespace in case you are using "
+  "self-defined coroutine components">,

ldionne wrote:
> I would simply reword as "Please move from std::experimental::%0 to std::%0. 
> Support for std::experimental::%0 will be removed in LLVM 15."
> 
> IMO the set of users defining their own coroutines header is small and it's 
> not worth making the warning more obtuse for that corner case.
+1; people who write their own "coroutine.h" header are also operating outside 
of standard C++ //and// outside of the Clang/libc++ ecosystem, so they should 
be quite used to figuring things out for themselves. If they want friendly help 
from the toolchain, they should use the toolchain's headers.



Comment at: clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp:54
   for
-co_await(auto i : arr) {}
+co_await(auto i : arr) {} // expected-warning {{Found deprecated 
std::experimental}}
   // expected-error@-1 {{call to deleted member function 'await_transform'}}

I'd like to see the next word in this diagnostic. (Ditto throughout. I'd also 
like to make sure that the diagnostic is not being printed with single-quotes 
in the wrong place, e.g. `Found deprecated 
std::experimental::'coroutine_handle'`; if it is, please fix that.)

This code is also misindented; please fix it up, as long as you're touching it. 
Should be
```
for co_await (auto i : arr) {}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113977

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


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

2021-11-16 Thread Daan De Meyer via Phabricator via cfe-commits
DaanDeMeyer created this revision.
DaanDeMeyer added reviewers: eduucaldas, beccadax, sammccall, kadircet.
DaanDeMeyer added a project: clang.
Herald added a subscriber: usaxena95.
DaanDeMeyer requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.

  When using clangd, it's possible to trigger assertions in
  NumericLiteralParser and CharLiteralParser when switching git branches.
  This commit removes the initial asserts on invalid input and replaces
  those asserts with the error handling mechanism from those respective
  classes instead. This allows clangd to gracefully recover without
  crashing.
  
  See https://github.com/clangd/clangd/issues/888 for more information
  on the clangd crashes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114003

Files:
  clang/lib/Lex/LiteralSupport.cpp


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -693,12 +693,6 @@
 : SM(SM), LangOpts(LangOpts), Diags(Diags),
   ThisTokBegin(TokSpelling.begin()), ThisTokEnd(TokSpelling.end()) {
 
-  // This routine assumes that the range begin/end matches the regex for 
integer
-  // and FP constants (specifically, the 'pp-number' regex), and assumes that
-  // the byte at "*end" is both valid and not part of the regex.  Because of
-  // this, it doesn't have to check for 'overscan' in various places.
-  assert(!isPreprocessingNumberBody(*ThisTokEnd) && "didn't maximally munch?");
-
   s = DigitsBegin = ThisTokBegin;
   saw_exponent = false;
   saw_period = false;
@@ -718,6 +712,16 @@
   isAccum = false;
   hadError = false;
 
+  // This routine assumes that the range begin/end matches the regex for 
integer
+  // and FP constants (specifically, the 'pp-number' regex), and assumes that
+  // the byte at "*end" is both valid and not part of the regex.  Because of
+  // this, it doesn't have to check for 'overscan' in various places.
+  if (isPreprocessingNumberBody(*ThisTokEnd)) {
+  Diags.Report(TokLoc, diag::err_lexing_string);
+  hadError = true;
+  return;
+  }
+
   if (*s == '0') { // parse radix
 ParseNumberStartingWithZero(TokLoc);
 if (hadError)
@@ -1432,7 +1436,12 @@
 ++begin;
 
   // Skip over the entry quote.
-  assert(begin[0] == '\'' && "Invalid token lexed");
+  if (begin[0] != '\'') {
+PP.Diag(Loc, diag::err_lexing_string);
+HadError = true;
+return;
+  }
+
   ++begin;
 
   // Remove an optional ud-suffix.


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -693,12 +693,6 @@
 : SM(SM), LangOpts(LangOpts), Diags(Diags),
   ThisTokBegin(TokSpelling.begin()), ThisTokEnd(TokSpelling.end()) {
 
-  // This routine assumes that the range begin/end matches the regex for integer
-  // and FP constants (specifically, the 'pp-number' regex), and assumes that
-  // the byte at "*end" is both valid and not part of the regex.  Because of
-  // this, it doesn't have to check for 'overscan' in various places.
-  assert(!isPreprocessingNumberBody(*ThisTokEnd) && "didn't maximally munch?");
-
   s = DigitsBegin = ThisTokBegin;
   saw_exponent = false;
   saw_period = false;
@@ -718,6 +712,16 @@
   isAccum = false;
   hadError = false;
 
+  // This routine assumes that the range begin/end matches the regex for integer
+  // and FP constants (specifically, the 'pp-number' regex), and assumes that
+  // the byte at "*end" is both valid and not part of the regex.  Because of
+  // this, it doesn't have to check for 'overscan' in various places.
+  if (isPreprocessingNumberBody(*ThisTokEnd)) {
+  Diags.Report(TokLoc, diag::err_lexing_string);
+  hadError = true;
+  return;
+  }
+
   if (*s == '0') { // parse radix
 ParseNumberStartingWithZero(TokLoc);
 if (hadError)
@@ -1432,7 +1436,12 @@
 ++begin;
 
   // Skip over the entry quote.
-  assert(begin[0] == '\'' && "Invalid token lexed");
+  if (begin[0] != '\'') {
+PP.Diag(Loc, diag::err_lexing_string);
+HadError = true;
+return;
+  }
+
   ++begin;
 
   // Remove an optional ud-suffix.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-11-16 Thread Daan De Meyer via Phabricator via cfe-commits
DaanDeMeyer added a comment.

Added some people that were recent reviewers of changes to this file and some 
clangd folks.

I don't have the time to properly test this unfortunately (aside from verifying 
that it fixes all the clangd crashes I'm having), but putting the patch up 
anyway in case anyone's interested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114003

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


[PATCH] D111434: [PowerPC] PPC backend optimization on conditional trap intrustions

2021-11-16 Thread Victor Huang via Phabricator via cfe-commits
NeHuang marked 7 inline comments as done.
NeHuang added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:1020
+// We can only do the optimization for the "reg + reg" form.
+if (!(LiMI1 && (Opcode1 == PPC::LI || Opcode1 == PPC::LI8)))
+  break;

amyk wrote:
> Do we still need to take into account of the lis+ori that Nemanja mentioned?
IIUC, the optimization will be triggered if the immediate is a s16Immediate. We 
had the similar check and conversion in this patch 
https://reviews.llvm.org/D112285 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

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


[clang] d4b28a0 - [NFC][clang] Inclusive language: replace master with main in convert_arm_neon.py

2021-11-16 Thread Quinn Pham via cfe-commits
Author: Quinn Pham
Date: 2021-11-16T10:11:06-06:00
New Revision: d4b28a0fe6857e0404d07b0989eeced05eaa45e7

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

LOG: [NFC][clang] Inclusive language: replace master with main in 
convert_arm_neon.py

[NFC] As part of using inclusive language within the llvm project and to
match the renamed master branch, this patch replaces master with main in
`convert_arm_neon.py`.

Reviewed By: kristof.beyls

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

Added: 


Modified: 
clang/utils/convert_arm_neon.py

Removed: 




diff  --git a/clang/utils/convert_arm_neon.py b/clang/utils/convert_arm_neon.py
index c4b3645294573..bb3516b07b577 100644
--- a/clang/utils/convert_arm_neon.py
+++ b/clang/utils/convert_arm_neon.py
@@ -7,7 +7,7 @@
 # using the old single-char type modifiers to an equivalent new-style form 
where
 # each modifier is orthogonal and they can be composed.
 #
-# It was used to directly generate the .td files on master, so if you have any
+# It was used to directly generate the .td files on main, so if you have any
 # local additions I would suggest implementing any modifiers here, and running
 # it over your entire pre-merge .td files rather than trying to resolve any
 # conflicts manually.



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


[PATCH] D113942: [NFC][clang] Inclusive language: replace master with main in convert_arm_neon.py

2021-11-16 Thread Quinn Pham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4b28a0fe685: [NFC][clang] Inclusive language: replace 
master with main in convert_arm_neon.py (authored by quinnp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113942

Files:
  clang/utils/convert_arm_neon.py


Index: clang/utils/convert_arm_neon.py
===
--- clang/utils/convert_arm_neon.py
+++ clang/utils/convert_arm_neon.py
@@ -7,7 +7,7 @@
 # using the old single-char type modifiers to an equivalent new-style form 
where
 # each modifier is orthogonal and they can be composed.
 #
-# It was used to directly generate the .td files on master, so if you have any
+# It was used to directly generate the .td files on main, so if you have any
 # local additions I would suggest implementing any modifiers here, and running
 # it over your entire pre-merge .td files rather than trying to resolve any
 # conflicts manually.


Index: clang/utils/convert_arm_neon.py
===
--- clang/utils/convert_arm_neon.py
+++ clang/utils/convert_arm_neon.py
@@ -7,7 +7,7 @@
 # using the old single-char type modifiers to an equivalent new-style form where
 # each modifier is orthogonal and they can be composed.
 #
-# It was used to directly generate the .td files on master, so if you have any
+# It was used to directly generate the .td files on main, so if you have any
 # local additions I would suggest implementing any modifiers here, and running
 # it over your entire pre-merge .td files rather than trying to resolve any
 # conflicts manually.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113993: WIP: [clang] customizable build-id style

2021-11-16 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 387650.
kwk added a comment.

enabled DEFAULT_LINKER_BUILD_ID_STYLE in linux


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113993

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -245,7 +245,11 @@
   }
 
 #ifdef ENABLE_LINKER_BUILD_ID
-  ExtraOpts.push_back("--build-id");
+  #ifdef ENABLE_LINKER_BUILD_ID_STYLE
+ExtraOpts.push_back("--build-id=" ENABLE_LINKER_BUILD_ID_STYLE);
+  #else
+ExtraOpts.push_back("--build-id");
+  #endif
 #endif
 
   if (IsAndroid || Distro.IsOpenSUSE())
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -82,7 +82,11 @@
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
 #ifdef ENABLE_LINKER_BUILD_ID
-  ExtraOpts.push_back("--build-id");
+  #ifdef ENABLE_LINKER_BUILD_ID_STYLE
+ExtraOpts.push_back("--build-id=" ENABLE_LINKER_BUILD_ID_STYLE);
+  #else
+ExtraOpts.push_back("--build-id");
+  #endif
 #endif
 
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
Index: clang/include/clang/Config/config.h.cmake
===
--- clang/include/clang/Config/config.h.cmake
+++ clang/include/clang/Config/config.h.cmake
@@ -69,9 +69,12 @@
 /* Linker version detected at compile time. */
 #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
 
-/* pass --build-id to ld */
+/* Pass --build-id or --build-id=

[PATCH] D111434: [PowerPC] PPC backend optimization on conditional trap intrustions

2021-11-16 Thread Victor Huang via Phabricator via cfe-commits
NeHuang updated this revision to Diff 387652.
NeHuang added a comment.

Addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

Files:
  llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
  llvm/test/CodeGen/PowerPC/mi-peepholes-trap-opt.mir

Index: llvm/test/CodeGen/PowerPC/mi-peepholes-trap-opt.mir
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/mi-peepholes-trap-opt.mir
@@ -0,0 +1,747 @@
+# RUN: llc -mtriple powerpc64le-unknown-linux-gnu -mcpu=pwr8 -x mir < %s \
+# RUN:   -verify-machineinstrs -start-before=ppc-mi-peepholes | FileCheck %s
+
+---
+name:conditional_trap_opt_reg_implicit_def
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = IMPLICIT_DEF
+%1:gprc = IMPLICIT_DEF
+%2:g8rc = IMPLICIT_DEF
+%3:g8rc = IMPLICIT_DEF
+TW 8, %0, %1
+TD 8, %2, %3
+TWI 24, %0, 0
+TDI 24, %2, 0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_reg_implicit_def
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  twgt3, 3
+  # CHECK-NEXT:  tdgt3, 3
+  # CHECK-NEXT:  twnei   3, 0
+  # CHECK-NEXT:  tdnei   3, 0
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_31
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 3
+%1:gprc = LI 0
+TW 31, %1, %0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_31
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_24
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 3
+%1:gprc = LI 0
+TW 24, %1, %0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_24
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_no_trap_TW_24
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 3
+%1:gprc = LI 3
+TW 24, %1, %0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_no_trap_TW_24
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_20
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 3
+%1:gprc = LI 3
+TW 20, %1, %0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_20
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_no_trap_TW_20
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 3
+%1:gprc = LI 5
+TW 20, %1, %0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_no_trap_TW_20
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_no_trap_TW_16
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 5
+%1:gprc = LI 1
+TW 16, %0, %1
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_no_trap_TW_16
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_16
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 5
+%1:gprc = LI 1
+TW 16, %1, %0
+TW 16, %0, %1
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_16
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_8
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI -1
+%1:gprc = LI 10
+TW 8, %1, %0
+TW 8, %0, %1
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_8
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_2
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI -1
+%1:gprc = LI 2
+TW 2, %1, %0
+TW 2, %0, %1
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_2
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_1
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI -3
+%1:gprc = LI 4
+TW 1, %1, %0
+TW 1, %0, %1
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_1
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_4
+alignment:   16

[PATCH] D111434: [PowerPC] PPC backend optimization on conditional trap intrustions

2021-11-16 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision.
amyk added a comment.

Thanks for addressing the review comments and answering my question. This LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

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


[PATCH] D113433: [NFC][clang] Inclusive language: Rename myMaster in testcase

2021-11-16 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA accepted this revision.
ZarkoCA added a comment.
This revision is now accepted and ready to land.

LGTM, thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113433

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


[PATCH] D114006: [analyzer]{NFC} Enable access to CodeGenOptions from analyzer's instances.

2021-11-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: martong, steakhal, Charusso, Szelethus, NoQ.
ASDenysPetrov added a project: clang.
Herald added subscribers: manas, dkrupp, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.
Herald added a subscriber: cfe-commits.

Passed a `CodeGenOptions` reference from `CompilerInstance` to 
`AnalysisConsumer` and then to `AnalysisManager` to enable access to the 
options for CSA instances such as `StoreManager`, `ConstraintManager` and 
others, This patch is a preliminary one for D110927 
.

NOTE: The half of the changes is just formatting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114006

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -88,6 +88,7 @@
   Preprocessor &PP;
   const std::string OutDir;
   AnalyzerOptionsRef Opts;
+  const CodeGenOptions &CodeGenOpts;
   ArrayRef Plugins;
   CodeInjector *Injector;
   cross_tu::CrossTranslationUnitContext CTU;
@@ -121,11 +122,11 @@
   FunctionSummariesTy FunctionSummaries;
 
   AnalysisConsumer(CompilerInstance &CI, const std::string &outdir,
-   AnalyzerOptionsRef opts, ArrayRef plugins,
-   CodeInjector *injector)
+   AnalyzerOptionsRef opts, const CodeGenOptions &CGOpts,
+   ArrayRef plugins, CodeInjector *injector)
   : RecVisitorMode(0), RecVisitorBR(nullptr), Ctx(nullptr),
 PP(CI.getPreprocessor()), OutDir(outdir), Opts(std::move(opts)),
-Plugins(plugins), Injector(injector), CTU(CI),
+CodeGenOpts(CGOpts), Plugins(plugins), Injector(injector), CTU(CI),
 MacroExpansions(CI.getLangOpts()) {
 DigestAnalyzerOptions();
 if (Opts->AnalyzerDisplayProgress || Opts->PrintStats ||
@@ -231,9 +232,9 @@
 checkerMgr = std::make_unique(*Ctx, *Opts, PP, Plugins,
   CheckerRegistrationFns);
 
-Mgr = std::make_unique(*Ctx, PP, PathConsumers,
-CreateStoreMgr, CreateConstraintMgr,
-checkerMgr.get(), *Opts, Injector);
+Mgr = std::make_unique(
+*Ctx, PP, PathConsumers, CreateStoreMgr, CreateConstraintMgr,
+checkerMgr.get(), *Opts, CodeGenOpts, Injector);
   }
 
   /// Store the top level decls in the set to be processed later on.
@@ -712,7 +713,7 @@
   bool hasModelPath = analyzerOpts->Config.count("model-path") > 0;
 
   return std::make_unique(
-  CI, CI.getFrontendOpts().OutputFile, analyzerOpts,
+  CI, CI.getFrontendOpts().OutputFile, analyzerOpts, CI.getCodeGenOpts(),
   CI.getFrontendOpts().Plugins,
   hasModelPath ? new ModelInjector(CI) : nullptr);
 }
Index: clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
+++ clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
@@ -13,32 +13,26 @@
 
 void AnalysisManager::anchor() { }
 
-AnalysisManager::AnalysisManager(ASTContext &ASTCtx, Preprocessor &PP,
- const PathDiagnosticConsumers &PDC,
- StoreManagerCreator storemgr,
- ConstraintManagerCreator constraintmgr,
- CheckerManager *checkerMgr,
- AnalyzerOptions &Options,
- CodeInjector *injector)
+AnalysisManager::AnalysisManager(
+ASTContext &ASTCtx, Preprocessor &PP, const PathDiagnosticConsumers &PDC,
+StoreManagerCreator storemgr, ConstraintManagerCreator constraintmgr,
+CheckerManager *checkerMgr, AnalyzerOptions &Options,
+const CodeGenOptions &CGOpts, CodeInjector *injector)
 : AnaCtxMgr(
   ASTCtx, Options.UnoptimizedCFG,
   Options.ShouldIncludeImplicitDtorsInCFG,
-  /*addInitializers=*/true,
-  Options.ShouldIncludeTemporaryDtorsInCFG,
+  /*addInitializers=*/true, Options.ShouldIncludeTemporaryDtorsInCFG,
   Options.ShouldIncludeLifetimeInCFG,
   // Adding LoopExit elements to the CFG is a requirement for loop
   // unrolling.
-  Options.ShouldIncludeLoopExitInCFG ||
-Options.ShouldUnrollLoops,
-  Options.ShouldIncludeScopesInCFG,
-  Options.ShouldSynthesizeBodies,
+  Options.ShouldIncludeLoopExitInCFG || Options.ShouldUnrollLoops,
+  Options.ShouldIncludeScopesI

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

2021-11-16 Thread Daan De Meyer via Phabricator via cfe-commits
DaanDeMeyer updated this revision to Diff 387667.
DaanDeMeyer added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114003

Files:
  clang/lib/Lex/LiteralSupport.cpp


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -693,12 +693,6 @@
 : SM(SM), LangOpts(LangOpts), Diags(Diags),
   ThisTokBegin(TokSpelling.begin()), ThisTokEnd(TokSpelling.end()) {
 
-  // This routine assumes that the range begin/end matches the regex for 
integer
-  // and FP constants (specifically, the 'pp-number' regex), and assumes that
-  // the byte at "*end" is both valid and not part of the regex.  Because of
-  // this, it doesn't have to check for 'overscan' in various places.
-  assert(!isPreprocessingNumberBody(*ThisTokEnd) && "didn't maximally munch?");
-
   s = DigitsBegin = ThisTokBegin;
   saw_exponent = false;
   saw_period = false;
@@ -718,6 +712,16 @@
   isAccum = false;
   hadError = false;
 
+  // This routine assumes that the range begin/end matches the regex for 
integer
+  // and FP constants (specifically, the 'pp-number' regex), and assumes that
+  // the byte at "*end" is both valid and not part of the regex.  Because of
+  // this, it doesn't have to check for 'overscan' in various places.
+  if (isPreprocessingNumberBody(*ThisTokEnd)) {
+Diags.Report(TokLoc, diag::err_lexing_string);
+hadError = true;
+return;
+  }
+
   if (*s == '0') { // parse radix
 ParseNumberStartingWithZero(TokLoc);
 if (hadError)
@@ -1432,7 +1436,12 @@
 ++begin;
 
   // Skip over the entry quote.
-  assert(begin[0] == '\'' && "Invalid token lexed");
+  if (begin[0] != '\'') {
+PP.Diag(Loc, diag::err_lexing_string);
+HadError = true;
+return;
+  }
+
   ++begin;
 
   // Remove an optional ud-suffix.


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -693,12 +693,6 @@
 : SM(SM), LangOpts(LangOpts), Diags(Diags),
   ThisTokBegin(TokSpelling.begin()), ThisTokEnd(TokSpelling.end()) {
 
-  // This routine assumes that the range begin/end matches the regex for integer
-  // and FP constants (specifically, the 'pp-number' regex), and assumes that
-  // the byte at "*end" is both valid and not part of the regex.  Because of
-  // this, it doesn't have to check for 'overscan' in various places.
-  assert(!isPreprocessingNumberBody(*ThisTokEnd) && "didn't maximally munch?");
-
   s = DigitsBegin = ThisTokBegin;
   saw_exponent = false;
   saw_period = false;
@@ -718,6 +712,16 @@
   isAccum = false;
   hadError = false;
 
+  // This routine assumes that the range begin/end matches the regex for integer
+  // and FP constants (specifically, the 'pp-number' regex), and assumes that
+  // the byte at "*end" is both valid and not part of the regex.  Because of
+  // this, it doesn't have to check for 'overscan' in various places.
+  if (isPreprocessingNumberBody(*ThisTokEnd)) {
+Diags.Report(TokLoc, diag::err_lexing_string);
+hadError = true;
+return;
+  }
+
   if (*s == '0') { // parse radix
 ParseNumberStartingWithZero(TokLoc);
 if (hadError)
@@ -1432,7 +1436,12 @@
 ++begin;
 
   // Skip over the entry quote.
-  assert(begin[0] == '\'' && "Invalid token lexed");
+  if (begin[0] != '\'') {
+PP.Diag(Loc, diag::err_lexing_string);
+HadError = true;
+return;
+  }
+
   ++begin;
 
   // Remove an optional ud-suffix.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113925: [HIP] Add HIP scope atomic operations

2021-11-16 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 387668.
gandhi21299 marked an inline comment as done.
gandhi21299 added a comment.

- removed debug code
- some macro definitions need to be defined for HIP-only compilation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113925

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/SyncScope.h
  clang/lib/AST/Expr.cpp
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCUDA/atomic-ops.cu

Index: clang/test/CodeGenCUDA/atomic-ops.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/atomic-ops.cu
@@ -0,0 +1,302 @@
+// RUN: %clang_cc1 -x hip -std=c++11 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s
+#include "Inputs/cuda.h"
+
+// CHECK-LABEL: @_Z24atomic32_op_singlethreadPiii
+// CHECK: cmpxchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+// CHECK: atomicrmw xchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+// CHECK: atomicrmw add i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+// CHECK: atomicrmw and i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+// CHECK: atomicrmw or i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+// CHECK: atomicrmw xor i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+// CHECK: atomicrmw min i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+// CHECK: atomicrmw max i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+__device__ int atomic32_op_singlethread(int *ptr, int val, int desired) {
+  bool flag = __hip_atomic_compare_exchange_strong(ptr, &val, desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_fetch_and(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_fetch_or(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_fetch_min(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_fetch_max(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  return flag ? val : desired;
+}
+
+// CHECK-LABEL: @_Z25atomicu32_op_singlethreadPjjj
+// CHECK: atomicrmw umin i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+// CHECK: atomicrmw umax i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("singlethread-one-as")
+__device__ unsigned int atomicu32_op_singlethread(unsigned int *ptr, unsigned int val, unsigned int desired) {
+  val = __hip_atomic_fetch_min(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  val = __hip_atomic_fetch_max(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_SINGLETHREAD);
+  return val;
+}
+
+// CHECK-LABEL: @_Z21atomic32_op_wavefrontPiii
+// CHECK: cmpxchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
+// CHECK: atomicrmw xchg i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
+// CHECK: atomicrmw add i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
+// CHECK: atomicrmw and i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
+// CHECK: atomicrmw or i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
+// CHECK: atomicrmw xor i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
+// CHECK: atomicrmw min i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
+// CHECK: atomicrmw max i32* {{%[0-9]+}}, i32 {{%[0-9]+}} syncscope("wavefront-one-as")
+__device__ int atomic32_op_wavefront(int *ptr, int val, int desired) {
+  bool flag = __hip_atomic_compare_exchange_strong(ptr, &val, desired, __ATOMIC_RELAXED, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
+  val = __hip_atomic_exchange(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
+  val = __hip_atomic_fetch_add(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
+  val = __hip_atomic_fetch_and(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
+  val = __hip_atomic_fetch_or(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
+  val = __hip_atomic_fetch_xor(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
+  val = __hip_atomic_fetch_min(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
+  val = __hip_atomic_fetch_max(ptr, val, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_WAVEFRONT);
+  return flag ? val : desired;
+}
+
+// CHECK-LABEL: @_Z22atomicu32_op_wavefrontPjjj
+// CHECK: atomicrmw umin

[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D110257#3134001 , @JonChesterfield 
wrote:

> So you won't articulate or document the new invariant and you think there's a 
> llvm-dev discussion that says we can't verify the invariant which you won't 
> reference, but means you won't add this to the verifier.
>
> Request changes doesn't really work after you've applied the patch.
>
> @rnk do you object to me reverting this? I don't think we can add an 
> invariant to IR which is undocumented and unverified/unverifiable and the 
> patch author seems opposed to fixing either omission.

Is this patch actually causing issues in practice? I think the decision to 
revert should be based on that.

I don't think this patch creates a new invariant that other passes have to 
respect, if that's what you're worried about. The way I see it, this patch just 
makes AMDGPU IR output look "nicer". Middle-end passes are free to insert casts 
between static allocas if they want.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[clang] 5ed404a - [NFC][clang] Inclusive language: Rename myMaster in testcase

2021-11-16 Thread Quinn Pham via cfe-commits
Author: Quinn Pham
Date: 2021-11-16T11:46:43-06:00
New Revision: 5ed404a4abd3fc3559ecc9dfc6cee83fcc3796e6

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

LOG: [NFC][clang] Inclusive language: Rename myMaster in testcase

[NFC] As part of using inclusive language within the llvm project, this patch
replaces `_myMaster` with `_myLeader` in these testcases.

Reviewed By: ZarkoCA

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

Added: 


Modified: 
clang/test/Rewriter/line-generation-test.m
clang/test/SemaObjC/warn-direct-ivar-access.m

Removed: 




diff  --git a/clang/test/Rewriter/line-generation-test.m 
b/clang/test/Rewriter/line-generation-test.m
index cafdba2808479..5193775fbedb2 100644
--- a/clang/test/Rewriter/line-generation-test.m
+++ b/clang/test/Rewriter/line-generation-test.m
@@ -7,20 +7,20 @@
 
 __attribute__((objc_root_class)) @interface MyObject {
 @public
-id _myMaster;
+id _myLeader;
 id _isTickledPink;
 }
-@property(retain) id myMaster;
+@property(retain) id myLeader;
 @property(assign) id isTickledPink;
 @end
 
 @implementation MyObject
 
-@synthesize myMaster = _myMaster;
+@synthesize myLeader = _myLeader;
 @synthesize isTickledPink = _isTickledPink;
 
 - (void) doSomething {
-_myMaster = _isTickledPink;
+_myLeader = _isTickledPink;
 }
 
 @end
@@ -28,8 +28,8 @@ - (void) doSomething {
 MyObject * foo ()
 {
MyObject* p;
-p.isTickledPink = p.myMaster;  // ok
-   p->_isTickledPink = p->_myMaster;
+p.isTickledPink = p.myLeader;  // ok
+   p->_isTickledPink = p->_myLeader;
return p->_isTickledPink;
 }
 

diff  --git a/clang/test/SemaObjC/warn-direct-ivar-access.m 
b/clang/test/SemaObjC/warn-direct-ivar-access.m
index d34e5f1894d2e..946e516aad8fb 100644
--- a/clang/test/SemaObjC/warn-direct-ivar-access.m
+++ b/clang/test/SemaObjC/warn-direct-ivar-access.m
@@ -3,39 +3,39 @@
 
 __attribute__((objc_root_class)) @interface MyObject {
 @public
-id _myMaster;
+id _myLeader;
 id _isTickledPink; // expected-error {{existing instance variable 
'_isTickledPink' for property 'isTickledPink'}}
 int _myIntProp;
 }
-@property(retain) id myMaster;
+@property(retain) id myLeader;
 @property(assign) id isTickledPink; // expected-note {{property declared here}}
 @property int myIntProp;
 @end
 
 @implementation MyObject
 
-@synthesize myMaster = _myMaster;
+@synthesize myLeader = _myLeader;
 @synthesize isTickledPink = _isTickledPink; // expected-note {{property 
synthesized here}}
 @synthesize myIntProp = _myIntProp;
 
 - (void) doSomething {
-_myMaster = _isTickledPink; // expected-warning {{instance variable 
'_myMaster' is being directly accessed}} \
+_myLeader = _isTickledPink; // expected-warning {{instance variable 
'_myLeader' is being directly accessed}} \
 // expected-warning {{instance variable '_isTickledPink' is being directly 
accessed}}
 }
 
 - (id) init {
-_myMaster=0;
-return _myMaster;
+_myLeader=0;
+return _myLeader;
 }
-- (void) dealloc { _myMaster = 0; }
+- (void) dealloc { _myLeader = 0; }
 @end
 
 MyObject * foo ()
 {
MyObject* p=0;
-p.isTickledPink = p.myMaster;  // ok
-   p->_isTickledPink = (*p)._myMaster; // expected-warning {{instance 
variable '_isTickledPink' is being directly accessed}} \
-// expected-warning {{instance variable '_myMaster' is being directly 
accessed}}
+p.isTickledPink = p.myLeader;  // ok
+   p->_isTickledPink = (*p)._myLeader; // expected-warning {{instance 
variable '_isTickledPink' is being directly accessed}} \
+// expected-warning {{instance variable '_myLeader' is being directly 
accessed}}
 if (p->_myIntProp) // expected-warning {{instance variable 
'_myIntProp' is being directly accessed}}
   p->_myIntProp = 0; // expected-warning {{instance variable 
'_myIntProp' is being directly accessed}}
return p->_isTickledPink; // expected-warning {{instance variable 
'_isTickledPink' is being directly accessed}}



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


[PATCH] D113433: [NFC][clang] Inclusive language: Rename myMaster in testcase

2021-11-16 Thread Quinn Pham 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 rG5ed404a4abd3: [NFC][clang] Inclusive language: Rename 
myMaster in testcase (authored by quinnp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113433

Files:
  clang/test/Rewriter/line-generation-test.m
  clang/test/SemaObjC/warn-direct-ivar-access.m


Index: clang/test/SemaObjC/warn-direct-ivar-access.m
===
--- clang/test/SemaObjC/warn-direct-ivar-access.m
+++ clang/test/SemaObjC/warn-direct-ivar-access.m
@@ -3,39 +3,39 @@
 
 __attribute__((objc_root_class)) @interface MyObject {
 @public
-id _myMaster;
+id _myLeader;
 id _isTickledPink; // expected-error {{existing instance variable 
'_isTickledPink' for property 'isTickledPink'}}
 int _myIntProp;
 }
-@property(retain) id myMaster;
+@property(retain) id myLeader;
 @property(assign) id isTickledPink; // expected-note {{property declared here}}
 @property int myIntProp;
 @end
 
 @implementation MyObject
 
-@synthesize myMaster = _myMaster;
+@synthesize myLeader = _myLeader;
 @synthesize isTickledPink = _isTickledPink; // expected-note {{property 
synthesized here}}
 @synthesize myIntProp = _myIntProp;
 
 - (void) doSomething {
-_myMaster = _isTickledPink; // expected-warning {{instance variable 
'_myMaster' is being directly accessed}} \
+_myLeader = _isTickledPink; // expected-warning {{instance variable 
'_myLeader' is being directly accessed}} \
 // expected-warning {{instance variable '_isTickledPink' is being directly 
accessed}}
 }
 
 - (id) init {
-_myMaster=0;
-return _myMaster;
+_myLeader=0;
+return _myLeader;
 }
-- (void) dealloc { _myMaster = 0; }
+- (void) dealloc { _myLeader = 0; }
 @end
 
 MyObject * foo ()
 {
MyObject* p=0;
-p.isTickledPink = p.myMaster;  // ok
-   p->_isTickledPink = (*p)._myMaster; // expected-warning {{instance 
variable '_isTickledPink' is being directly accessed}} \
-// expected-warning {{instance variable '_myMaster' is being directly 
accessed}}
+p.isTickledPink = p.myLeader;  // ok
+   p->_isTickledPink = (*p)._myLeader; // expected-warning {{instance 
variable '_isTickledPink' is being directly accessed}} \
+// expected-warning {{instance variable '_myLeader' is being directly 
accessed}}
 if (p->_myIntProp) // expected-warning {{instance variable 
'_myIntProp' is being directly accessed}}
   p->_myIntProp = 0; // expected-warning {{instance variable 
'_myIntProp' is being directly accessed}}
return p->_isTickledPink; // expected-warning {{instance variable 
'_isTickledPink' is being directly accessed}}
Index: clang/test/Rewriter/line-generation-test.m
===
--- clang/test/Rewriter/line-generation-test.m
+++ clang/test/Rewriter/line-generation-test.m
@@ -7,20 +7,20 @@
 
 __attribute__((objc_root_class)) @interface MyObject {
 @public
-id _myMaster;
+id _myLeader;
 id _isTickledPink;
 }
-@property(retain) id myMaster;
+@property(retain) id myLeader;
 @property(assign) id isTickledPink;
 @end
 
 @implementation MyObject
 
-@synthesize myMaster = _myMaster;
+@synthesize myLeader = _myLeader;
 @synthesize isTickledPink = _isTickledPink;
 
 - (void) doSomething {
-_myMaster = _isTickledPink;
+_myLeader = _isTickledPink;
 }
 
 @end
@@ -28,8 +28,8 @@
 MyObject * foo ()
 {
MyObject* p;
-p.isTickledPink = p.myMaster;  // ok
-   p->_isTickledPink = p->_myMaster;
+p.isTickledPink = p.myLeader;  // ok
+   p->_isTickledPink = p->_myLeader;
return p->_isTickledPink;
 }
 


Index: clang/test/SemaObjC/warn-direct-ivar-access.m
===
--- clang/test/SemaObjC/warn-direct-ivar-access.m
+++ clang/test/SemaObjC/warn-direct-ivar-access.m
@@ -3,39 +3,39 @@
 
 __attribute__((objc_root_class)) @interface MyObject {
 @public
-id _myMaster;
+id _myLeader;
 id _isTickledPink; // expected-error {{existing instance variable '_isTickledPink' for property 'isTickledPink'}}
 int _myIntProp;
 }
-@property(retain) id myMaster;
+@property(retain) id myLeader;
 @property(assign) id isTickledPink; // expected-note {{property declared here}}
 @property int myIntProp;
 @end
 
 @implementation MyObject
 
-@synthesize myMaster = _myMaster;
+@synthesize myLeader = _myLeader;
 @synthesize isTickledPink = _isTickledPink; // expected-note {{property synthesized here}}
 @synthesize myIntProp = _myIntProp;
 
 - (void) doSomething {
-_myMaster = _isTickledPink; // expected-warning {{instance variable '_myMaster' is being directly accessed}} \
+_myLeader = _isTickledPink; // expected-warning {{instance variable '_myLeader' is being directly accessed}} \

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

2021-11-16 Thread Becca Royal-Gordon via Phabricator via cfe-commits
beccadax requested changes to this revision.
beccadax added a comment.
This revision now requires changes to proceed.

err_lexing_string’s message is “failure when lexing a string” 
,
 which isn’t accurate here since you’re lexing a character literal or numeric 
literal instead. Could you emit a more appropriate message for this? That might 
mean adding additional diagnostics or modifying the existing one so you can 
insert information about the kind of literal.

(err_lexing_string is only used for “can’t happen” errors, so maybe you could 
change the message to something like `“failure when lexing a %0 literal; a file 
may have been modified during compilation”`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114003

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


[PATCH] D113776: [Clang][SVE] Properly enable/disable dependant SVE target features based upon +(no)sve.* options

2021-11-16 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:73
 static bool DecodeAArch64Features(const Driver &D, StringRef text,
   std::vector &Features,
   llvm::AArch64::ArchKind ArchKind) {

does the order of the features matter?
```+sve,+nosve => disables sve
+nosve,+sve => enables sve
+nosve,+sve2 => enables sve and sve2```





Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:66
 
+typedef enum { Unset, True, False } OptState;
+bool isUnset(OptState State) { return State == OptState::Unset; }

tschuett wrote:
> This is almost an enum class.
> ```
> enum class OptState { Unset, True, False };
> ```
You can use `Optional` to avoid adding a new enum class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113776

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


[PATCH] D113776: [Clang][SVE] Properly enable/disable dependant SVE target features based upon +(no)sve.* options

2021-11-16 Thread Bradley Smith via Phabricator via cfe-commits
bsmith added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:73
 static bool DecodeAArch64Features(const Driver &D, StringRef text,
   std::vector &Features,
   llvm::AArch64::ArchKind ArchKind) {

sdesmalen wrote:
> does the order of the features matter?
> ```+sve,+nosve => disables sve
> +nosve,+sve => enables sve
> +nosve,+sve2 => enables sve and sve2```
> 
> 
Yes it does, but I believe that is the desired behaviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113776

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


[PATCH] D113776: [Clang][SVE] Properly enable/disable dependant SVE target features based upon +(no)sve.* options

2021-11-16 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:73
 static bool DecodeAArch64Features(const Driver &D, StringRef text,
   std::vector &Features,
   llvm::AArch64::ArchKind ArchKind) {

bsmith wrote:
> sdesmalen wrote:
> > does the order of the features matter?
> > ```+sve,+nosve => disables sve
> > +nosve,+sve => enables sve
> > +nosve,+sve2 => enables sve and sve2```
> > 
> > 
> Yes it does, but I believe that is the desired behaviour.
Doesn't your patch change this behaviour? The condition on line 147 no longer 
considers the original order of the flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113776

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


[PATCH] D112374: [clang] WIP: Implement ElaboratedType sugaring for types written bare

2021-11-16 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added subscribers: lxfind, jdoerfert.
mizvekov updated this revision to Diff 382454.
mizvekov added a comment.
Herald added subscribers: carlosgalvezp, arphaman.
mizvekov edited the summary of this revision.
Herald added a subscriber: kristof.beyls.
mizvekov updated this revision to Diff 382467.
mizvekov updated this revision to Diff 383770.
Herald added subscribers: usaxena95, kadircet.
Herald added a reviewer: shafik.
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 383916.
Herald added a subscriber: martong.
mizvekov updated this revision to Diff 383923.
mizvekov updated this revision to Diff 383927.
mizvekov updated this revision to Diff 385354.
mizvekov updated this revision to Diff 385355.
mizvekov updated this revision to Diff 385359.
mizvekov updated this revision to Diff 385363.
mizvekov updated this revision to Diff 385365.
mizvekov updated this revision to Diff 385373.
mizvekov updated this revision to Diff 385376.
mizvekov updated this revision to Diff 385659.
mizvekov updated this revision to Diff 385665.
mizvekov updated this revision to Diff 386181.
mizvekov updated this revision to Diff 386278.
mizvekov updated this revision to Diff 386295.
mizvekov updated this revision to Diff 386317.
mizvekov updated this revision to Diff 386333.
mizvekov marked 5 inline comments as done.
mizvekov marked an inline comment as done.
mizvekov updated this revision to Diff 387661.
mizvekov published this revision for review.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, libcxx-commits, sstefan1.
Herald added projects: clang, libc++, clang-tools-extra.
Herald added a reviewer: libc++.

.


mizvekov added a comment.

.


mizvekov added a comment.

..


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

..


mizvekov added a comment.

- Run libcxx CI.




Comment at: clang/lib/Sema/SemaDecl.cpp:278
+/// Build a ParsedType for a simple-type-specifier with a 
nested-name-specifier.
+static ParsedType buildNestedType(Sema &S, const CXXScopeSpec *SS, QualType T,
+  SourceLocation NameLoc,

Maybe `buildNamedType` given that this also covers the non-nested case now?



Comment at: clang/lib/Sema/SemaDecl.cpp:291
+  case Type::TemplateTypeParm:
+return ParsedType::make(T);
+  default:

It'd be useful to add a comment such as "These can never be qualified so an 
`ElaboratedType` node would carry no additional meaning."



Comment at: clang/lib/Sema/SemaDecl.cpp:291
+  case Type::TemplateTypeParm:
+return ParsedType::make(T);
+  default:

rsmith wrote:
> It'd be useful to add a comment such as "These can never be qualified so an 
> `ElaboratedType` node would carry no additional meaning."
Sure. But even then, in the current implementation of the type printer, adding 
this node would not be a no-op, it would incorrectly change meaning as we would 
suppress printing the scope of not just the type under the Elaborated node, but 
for any children of that as well. So for example a template parameter which is 
sugar for a CXXRecordDecl would be printed with scope suppressed.



Comment at: clang/lib/Sema/SemaDecl.cpp:296
+
+  if (!SS || !SS->isNotEmpty())
+return ParsedType::make(





Comment at: clang/lib/Sema/SemaDecl.cpp:545
 
-  // NOTE: avoid constructing an ElaboratedType(Loc) if this is a
-  // constructor or destructor name (in such a case, the scope specifier
-  // will be attached to the enclosing Expr or Decl node).
-  if (SS && SS->isNotEmpty() && !IsCtorOrDtorName &&
-  !isa(IIDecl)) {
-if (WantNontrivialTypeSourceInfo) {
-  // Construct a type with type-source information.
-  TypeLocBuilder Builder;
-  Builder.pushTypeSpec(T).setNameLoc(NameLoc);
-
-  T = getElaboratedType(ETK_None, *SS, T);
-  ElaboratedTypeLoc ElabTL = Builder.push(T);
-  ElabTL.setElaboratedKeywordLoc(SourceLocation());
-  ElabTL.setQualifierLoc(SS->getWithLocInContext(Context));
-  return CreateParsedType(T, Builder.getTypeSourceInfo(Context, T));
-} else {
-  T = getElaboratedType(ETK_None, *SS, T);
-}
-  }
-
-  return ParsedType::make(T);
+  if (isa(IIDecl))
+return ParsedType::make(T);

Can we add these to the `switch` above and unconditionally call 
`buildNestedType`?



Comment at: clang/lib/Sema/Sem

[PATCH] D111100: enable plugins for clang-tidy

2021-11-16 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

Yes, this header does everything


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

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


[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-11-16 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang updated this revision to Diff 387698.
avogelsgesang marked 11 inline comments as done.
avogelsgesang added a comment.

Address review comments by @whisperity:

- "containment" -> "membership"
- "C++ 20" -> "C++20"
- double-backticks in rst files
- additonal test cases (both positive and negative)

Also:

- use `hasUnqualifiedDesugaredType` -> handle typedefs better


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.h
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-container-contains.rst
  clang-tools-extra/test/clang-tidy/checkers/readability-container-contains.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-container-contains.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-container-contains.cpp
@@ -0,0 +1,192 @@
+// RUN: %check_clang_tidy -std=c++20 %s readability-container-contains %t
+
+// Some *very* simplified versions of `map` etc.
+namespace std {
+
+template 
+struct map {
+  unsigned count(const Key &K) const;
+  bool contains(const Key &K) const;
+  void *find(const Key &K);
+  void *end();
+};
+
+template 
+struct set {
+  unsigned count(const Key &K) const;
+  bool contains(const Key &K) const;
+};
+
+template 
+struct unordered_set {
+  unsigned count(const Key &K) const;
+  bool contains(const Key &K) const;
+};
+
+template 
+struct multimap {
+  unsigned count(const Key &K) const;
+  bool contains(const Key &K) const;
+};
+
+} // namespace std
+
+// Check that we detect various common ways to check for membership
+int testDifferentCheckTypes(std::map &MyMap) {
+  if (MyMap.count(0))
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use 'contains' to check for membership [readability-container-contains]
+// CHECK-FIXES: if (MyMap.contains(0))
+return 1;
+  bool C1 = MyMap.count(1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: bool C1 = MyMap.contains(1);
+  auto C2 = static_cast(MyMap.count(1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: auto C2 = static_cast(MyMap.contains(1));
+  auto C3 = MyMap.count(2) != 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: auto C3 = MyMap.contains(2);
+  auto C4 = MyMap.count(3) > 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: auto C4 = MyMap.contains(3);
+  auto C5 = MyMap.count(4) >= 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: auto C5 = MyMap.contains(4);
+  auto C6 = MyMap.find(5) != MyMap.end();
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: auto C6 = MyMap.contains(5);
+  return C1 + C2 + C3 + C4 + C5 + C6;
+}
+
+// Check that we detect various common ways to check for non-membership
+int testNegativeChecks(std::map &MyMap) {
+  bool C1 = !MyMap.count(-1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: bool C1 = !MyMap.contains(-1);
+  auto C2 = MyMap.count(-2) == 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: auto C2 = !MyMap.contains(-2);
+  auto C3 = MyMap.count(-3) <= 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: auto C3 = !MyMap.contains(-3);
+  auto C4 = MyMap.count(-4) < 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: auto C4 = !MyMap.contains(-4);
+  auto C5 = MyMap.find(-5) == MyMap.end();
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for membership [readability-container-contains]
+  // CHECK-FIXES: auto C5 = !MyMap.contains(-5);
+  return C1 + C2 + C3 + C4 + C5;
+}
+
+// Check for various types
+int testDifferentTypes(std::map &M, std::unordered_set &US, std::set &S, std::multimap &MM) {
+  bool C1 = M.count(1001);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use 'contains' to check for membership 

[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2021-11-16 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 387699.
mizvekov retitled this revision from "[clang] WIP: Implement ElaboratedType 
sugaring for types written bare" to "[clang] Implement ElaboratedType sugaring 
for types written bare".
mizvekov edited the summary of this revision.
mizvekov added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-copy-constructor-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-const-return-type.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance-nesting-threshold.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang/bindings/python/tests/cindex/test_type.py
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/float16.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
  clang/test/Analysis/analyzer-display-progress.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/bug_hash_test.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
  clang/test/Analysis/initializers-cfg-output.cpp
  clang/test/

[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-11-16 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang marked 2 inline comments as not done.
avogelsgesang added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:105-108
+  const auto *PositiveCheck = Result.Nodes.getNodeAs("positive");
+  const auto *NegativeCheck = Result.Nodes.getNodeAs("negative");
+  bool Negated = NegativeCheck != nullptr;
+  const auto *Check = Negated ? NegativeCheck : PositiveCheck;

whisperity wrote:
> `Comparison` instead of `Check`? These should be matching the 
> `binaryOperator`, right?
In most cases, they match the `binaryOperator`. For the first pattern they 
match the `implicitCastExpr`, though

Given this is not always a `binaryOperator`, should I still rename it to 
`Comparison`?



Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:110
+
+  // Diagnose the issue
+  auto Diag =

whisperity wrote:
> I'm not sure if these comments are useful, though. The business logic flow of 
> the implementation is straightforward.
Agree, not sure how much value they provide.
Let me know if I should delete them, or if we want to keep them for the 
structure they introduce...



Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp:113
+  diag(Call->getExprLoc(),
+   "use `contains` instead of `count` to check for containment");
+

whisperity wrote:
> whisperity wrote:
> > This might be a bit nitpicking, but `containment` sounds off here: it 
> > usually comes up with regards to superset/subset relationships. Perhaps 
> > phrasing in `membership` or `element` somehow would ease this.
> We use single apostrophe (`'`) instead of backtick (`) in the diagnostics for 
> symbol names.
> but containment sounds off here

Agree. Thanks for catching this!



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-container-contains.rst:6
+
+Finds usages of `container.count()` and `container.find() == container.end()` 
which should be replaced by a call to the `container.contains()` method 
introduced in C++ 20.
+

whisperity wrote:
> whisperity wrote:
> > Same comment about the backtick count and how you would like the rendering 
> > to be. Please build the documentation locally and verify visually, as both 
> > ways most likely compile without warnings or errors.
> 
> Please build the documentation locally [...]

How do I actually do that?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-container-contains.cpp:33-35
+
+using namespace std;
+

whisperity wrote:
> Tests are to guard our future selves from breaking the system, so perhaps two 
> tests that involve having `std::` typed out, and also using a different 
> container that's not `std::whatever` would be useful.
> 
> 
> 
> Do you think it would be worthwhile to add matching any user-defined object 
> which has a `count()` and a `contains()` method (with the appropriate number 
> of parameters) later? So match not only the few standard containers, but more 
> stuff?
> 
> It doesn't have to be done now, but having a test for `MyContainer` not in 
> `std::` being marked `// NO-WARNING.` or something could indicate that we 
> purposefully don't want to go down that road just yet.
> so perhaps two tests that involve having std:: typed out

rewrote the tests, such that most of them use fully-qualified types. Also added 
a few test cases involving type defs and namespace aliases (this actually 
uncovered a mistake in the matcher)

> Do you think it would be worthwhile to add matching any user-defined object 
> which has a count() and a contains() method (with the appropriate number of 
> parameters) later?

Not sure. At least not for the code base I wrote this check for...

> having a test for MyContainer not in std:: being marked // NO-WARNING. or 
> something could indicate that we purposefully don't want to go down that road 
> just yet

added such a test case and commented it as "not currently supported"




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-container-contains.cpp:111
+  // CHECK-FIXES: return M.count(21);
+}

whisperity wrote:
> Similarly, the test file could use at least some //negative// examples. 
> Things like `count(X) >= 2` and such, to ensure that the matchers aren't 
> inadvertently broken by someone which would result in a lot of false 
> positives in production.
Added a couple of negative test cases. Please let me know if you have 
additional additional test cases in mind which I should also add


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

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


[clang] 4c484f1 - [llvm] Add a SFINAE template parameter to DenseMapInfo

2021-11-16 Thread River Riddle via cfe-commits
Author: River Riddle
Date: 2021-11-16T18:54:14Z
New Revision: 4c484f11d355e4293f7b245a9330f0a1e89630ac

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

LOG: [llvm] Add a SFINAE template parameter to DenseMapInfo

This allows for using SFINAE partial specialization for DenseMapInfo.
In MLIR, this is particularly useful as it will allow for defining partial
specializations that support all Attribute, Op, and Type classes without
needing to specialize DenseMapInfo for each individual class.

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

Added: 


Modified: 
clang/include/clang/AST/TypeOrdering.h
clang/include/clang/Basic/SourceLocation.h
clang/include/clang/Sema/Sema.h
lldb/include/lldb/Utility/ConstString.h
llvm/include/llvm/ADT/APInt.h
llvm/include/llvm/ADT/APSInt.h
llvm/include/llvm/ADT/ArrayRef.h
llvm/include/llvm/ADT/DenseMapInfo.h
llvm/include/llvm/ADT/Hashing.h
llvm/include/llvm/ADT/ImmutableList.h
llvm/include/llvm/ADT/PointerIntPair.h
llvm/include/llvm/ADT/StringRef.h
llvm/include/llvm/BinaryFormat/WasmTraits.h
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/include/llvm/IR/Attributes.h
llvm/include/llvm/Support/TypeSize.h
llvm/lib/Support/APInt.cpp
llvm/unittests/ADT/DenseMapTest.cpp
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
mlir/include/mlir/IR/Attributes.h
mlir/include/mlir/IR/BuiltinOps.h
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/Types.h
mlir/include/mlir/Support/LLVM.h

Removed: 




diff  --git a/clang/include/clang/AST/TypeOrdering.h 
b/clang/include/clang/AST/TypeOrdering.h
index 6630105136f5c..8037f98cc9651 100644
--- a/clang/include/clang/AST/TypeOrdering.h
+++ b/clang/include/clang/AST/TypeOrdering.h
@@ -34,7 +34,6 @@ struct QualTypeOrdering {
 }
 
 namespace llvm {
-  template struct DenseMapInfo;
 
   template<> struct DenseMapInfo {
 static inline clang::QualType getEmptyKey() { return clang::QualType(); }

diff  --git a/clang/include/clang/Basic/SourceLocation.h 
b/clang/include/clang/Basic/SourceLocation.h
index ba2e9156a2b12..543245a811db5 100644
--- a/clang/include/clang/Basic/SourceLocation.h
+++ b/clang/include/clang/Basic/SourceLocation.h
@@ -23,8 +23,6 @@
 
 namespace llvm {
 
-template  struct DenseMapInfo;
-
 class FoldingSetNodeID;
 template  struct FoldingSetTrait;
 
@@ -467,7 +465,7 @@ namespace llvm {
   /// Define DenseMapInfo so that FileID's can be used as keys in DenseMap and
   /// DenseSets.
   template <>
-  struct DenseMapInfo {
+  struct DenseMapInfo {
 static clang::FileID getEmptyKey() {
   return {};
 }
@@ -488,7 +486,7 @@ namespace llvm {
   /// Define DenseMapInfo so that SourceLocation's can be used as keys in
   /// DenseMap and DenseSet. This trait class is eqivalent to
   /// DenseMapInfo which uses SourceLocation::ID is used as a key.
-  template <> struct DenseMapInfo {
+  template <> struct DenseMapInfo {
 static clang::SourceLocation getEmptyKey() {
   constexpr clang::SourceLocation::UIntTy Zero = 0;
   return clang::SourceLocation::getFromRawEncoding(~Zero);

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5f5755ef13435..a159be2b5fb17 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -74,7 +74,6 @@
 
 namespace llvm {
   class APSInt;
-  template  struct DenseMapInfo;
   template  class DenseSet;
   class SmallBitVector;
   struct InlineAsmIdentifierInfo;

diff  --git a/lldb/include/lldb/Utility/ConstString.h 
b/lldb/include/lldb/Utility/ConstString.h
index 52d3556418f6c..2756f1fd72038 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -409,7 +409,7 @@ class ConstString {
   static size_t StaticMemorySize();
 
 protected:
-  template  friend struct ::llvm::DenseMapInfo;
+  template  friend struct ::llvm::DenseMapInfo;
   /// Only used by DenseMapInfo.
   static ConstString FromStringPoolPointer(const char *ptr) {
 ConstString s;

diff  --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 71d75db91c103..595cd94b6b8f6 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -31,7 +31,7 @@ class raw_ostream;
 template  class SmallVectorImpl;
 template  class ArrayRef;
 template  class Optional;
-template  struct DenseMapInfo;
+template  struct DenseMapInfo;
 
 class APInt;
 
@@ -1817,7 +1817,7 @@ class LLVM_NODISCARD APInt {
 
   unsigned BitWidth; ///< The number of bits in this APInt.
 
-  friend struct DenseMapInfo;
+  friend struct DenseMapInfo;
   friend class APSInt;
 
   /// This constructor is used only internally for speed of construction of
@@ -2251,7 +2251,7 @@ void StoreIntToMemory(const

[PATCH] D113946: [libc][clang-tidy] fix namespace check for externals

2021-11-16 Thread Michael Jones via Phabricator via cfe-commits
michaelrj updated this revision to Diff 387703.
michaelrj marked 6 inline comments as done.
michaelrj added a comment.

clean up the code and remove debug statements


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113946

Files:
  clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
  libc/docs/clang_tidy_checks.rst
  libc/src/__support/FPUtil/NearestIntegerOperations.h
  libc/src/__support/str_to_float.h
  libc/src/__support/str_to_integer.h
  libc/src/math/generic/math_utils.h
  libc/src/string/strdup.cpp
  libc/src/string/strndup.cpp

Index: libc/src/string/strndup.cpp
===
--- libc/src/string/strndup.cpp
+++ libc/src/string/strndup.cpp
@@ -23,7 +23,7 @@
   size_t len = internal::string_length(src);
   if (len > size)
 len = size;
-  char *dest = reinterpret_cast(::malloc(len + 1)); // NOLINT
+  char *dest = reinterpret_cast(::malloc(len + 1));
   if (dest == nullptr)
 return nullptr;
   char *result =
Index: libc/src/string/strdup.cpp
===
--- libc/src/string/strdup.cpp
+++ libc/src/string/strdup.cpp
@@ -21,7 +21,7 @@
 return nullptr;
   }
   size_t len = internal::string_length(src) + 1;
-  char *dest = reinterpret_cast(::malloc(len)); // NOLINT
+  char *dest = reinterpret_cast(::malloc(len));
   if (dest == nullptr) {
 return nullptr;
   }
Index: libc/src/math/generic/math_utils.h
===
--- libc/src/math/generic/math_utils.h
+++ libc/src/math/generic/math_utils.h
@@ -55,7 +55,7 @@
 
 template  static inline T with_errno(T x, int err) {
   if (math_errhandling & MATH_ERRNO)
-errno = err; // NOLINT
+errno = err;
   return x;
 }
 
Index: libc/src/__support/str_to_integer.h
===
--- libc/src/__support/str_to_integer.h
+++ libc/src/__support/str_to_integer.h
@@ -74,7 +74,7 @@
   const char *original_src = src;
 
   if (base < 0 || base == 1 || base > 36) {
-errno = EINVAL; // NOLINT
+errno = EINVAL;
 return 0;
   }
 
@@ -114,19 +114,19 @@
 // the result cannot change, but we still need to advance src to the end of
 // the number.
 if (result == ABS_MAX) {
-  errno = ERANGE; // NOLINT
+  errno = ERANGE;
   continue;
 }
 
 if (result > ABS_MAX_DIV_BY_BASE) {
   result = ABS_MAX;
-  errno = ERANGE; // NOLINT
+  errno = ERANGE;
 } else {
   result = result * base;
 }
 if (result > ABS_MAX - cur_digit) {
   result = ABS_MAX;
-  errno = ERANGE; // NOLINT
+  errno = ERANGE;
 } else {
   result = result + cur_digit;
 }
Index: libc/src/__support/str_to_float.h
===
--- libc/src/__support/str_to_float.h
+++ libc/src/__support/str_to_float.h
@@ -220,7 +220,7 @@
   static_cast(fputil::FloatProperties::exponentBias)) {
 *outputMantissa = 0;
 *outputExp2 = fputil::FPBits::maxExponent;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
 return;
   }
   // If the exponent is too small even for a subnormal, return 0.
@@ -230,7 +230,7 @@
fputil::FloatProperties::mantissaWidth)) {
 *outputMantissa = 0;
 *outputExp2 = 0;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
 return;
   }
 
@@ -273,7 +273,7 @@
   if (exp2 >= fputil::FPBits::maxExponent) {
 *outputMantissa = 0;
 *outputExp2 = fputil::FPBits::maxExponent;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
 return;
   }
 
@@ -309,7 +309,7 @@
   }
 
   if (exp2 == 0) {
-errno = ERANGE; // NOLINT
+errno = ERANGE;
   }
 
   *outputMantissa = finalMantissa;
@@ -411,7 +411,7 @@
   static_cast(fputil::FloatProperties::exponentBias) / 3) {
 *outputMantissa = 0;
 *outputExp2 = fputil::FPBits::maxExponent;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
 return;
   }
   // If the exponent is too small even for a subnormal, return 0.
@@ -422,7 +422,7 @@
   2) {
 *outputMantissa = 0;
 *outputExp2 = 0;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
 return;
   }
 
@@ -508,7 +508,7 @@
 // If we cut off any bits to fit this number into a subnormal, then it's
 // out of range for this size of float.
 if ((mantissa & ((1 << amountToShift) - 1)) > 0) {
-  errno = ERANGE; // NOLINT
+  errno = ERANGE;
 }
 mantissa = shiftRightAndRound(mantissa, amountToShift);
 if (mantissa == OVERFLOWED_MANTISSA) {
@@ -524,7 +524,7 @@
 // This indicates an overflow, so we make the result INF and set errno.
 biasedExponent = (1 << fputil::FloatProperties::exponentWidth) - 1;
 mantissa = 0;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
   }
   *outputMantissa = mantissa;
   *outputExp2 = biasedExpon

[PATCH] D113946: [libc][clang-tidy] fix namespace check for externals

2021-11-16 Thread Michael Jones via Phabricator via cfe-commits
michaelrj added inline comments.



Comment at: clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp:13
 
+#include 
+

sivachandra wrote:
> Eugene.Zelenko wrote:
> > Should  be `` and without newline separation form rest of headers.
> Looks like this is present only for the debug `printf`?
yes, I didn't mean to leave that in there.



Comment at: clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp:39
+// intercepted.
+static const char *FUNCTIONS_TO_IGNORE_NAMESPACE[] = {
+"__errno_location", "malloc", "calloc", "realloc", "free"};

sivachandra wrote:
> Eugene.Zelenko wrote:
> > Why not `std::array` of appropriate LLVM container?
> May be `static const std::uordered_set`? It would likely 
> make the lookup below much neater.
an unordered set is a good idea, but the documentation for `StringRef` says 
it's best not to use them for storage, so I went with `std::string` instead. 
The code is still a lot nicer.



Comment at: clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp:59
+llvm::StringRef(FUNCTIONS_TO_IGNORE_NAMESPACE[i]))) {
+  printf("String found %s\n", FuncDecl->getName().str().c_str());
+  return;

sivachandra wrote:
> lntue wrote:
> > Look like diag() is used to print messages in this module?
> This looks like a debug `printf`?
yes, I didn't mean to leave that in there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113946

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


[PATCH] D113107: Support of expression granularity for _Float16.

2021-11-16 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1315
+  if ((SrcType->isHalfType() || iSFloat16Allowed) &&
+  !CGF.getContext().getLangOpts().NativeHalfType) {
 // Cast to FP using the intrinsic if the half type itself isn't supported.

pengfei wrote:
> rjmccall wrote:
> > pengfei wrote:
> > > rjmccall wrote:
> > > > pengfei wrote:
> > > > > rjmccall wrote:
> > > > > > Okay, this condition is pretty ridiculous to be repeating in three 
> > > > > > different places across the compiler.  Especially since you're 
> > > > > > going to change it when you implement the new option, right?
> > > > > > 
> > > > > > Can we state this condition more generally?  I'm not sure why this 
> > > > > > is so narrowly restricted, and the variable name isn't telling me 
> > > > > > anything, since `_Float16` must by definition be "allowed" if we 
> > > > > > have an expression of `_Float16` type.
> > > > > > since _Float16 must by definition be "allowed" if we have an 
> > > > > > expression of _Float16 type.
> > > > > 
> > > > > _Float16 is allowed only on a few targets. 
> > > > > https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point
> > > > > By the way, we should update for X86 since it's not limited to 
> > > > > avx512fp16 now.
> > > > > _Float16 is allowed only on a few targets.
> > > > 
> > > > Yes, I know that.  But if `SrcType->isFloat16Type()` is true, we must 
> > > > be on one of those targets, because the type doesn't otherwise exist.
> > > I see your point now. The problem here is we want to allow the `_Float16` 
> > > to be used more broadly. But the target doesn't really support it 
> > > sometime. Currently full arithmatic operations are supported only on 
> > > target with AVX512FP16.
> > > We should cast for those targets without AVX512FP16 while avoid to do on 
> > > AVX512FP16.
> > I agree that many targets don't natively support arithmetic on this format, 
> > but x86 is not the first one that does.  Unless I'm misunderstanding, we 
> > already track this property in Clang's TargetInfo as `hasLegalHalfType()`.  
> > `+avx512fp16` presumably ought to set this.
> > 
> > I'm not sure what the interaction with the `NativeHalfType` LangOpt is 
> > supposed to be here.  My understanding is that that option is just supposed 
> > to affect `__fp16`, basically turning it into a proper arithmetic type, 
> > i.e. essentially `_Float16`.  Whatever effect you want to apply to 
> > `_Float16` should presumably happen even if that option not set.
> > 
> > More broadly, I don't think your approach in this patch is correct.  The 
> > type of operations on `_Float16` should not change based on whether the 
> > target natively supports `_Float16`.  If we need to emulate those 
> > operations on targets that don't provide them natively, we should do that 
> > at a lower level than the type system.
> > 
> > The most appropriate place to do that is going to depend on the exact 
> > semantics we want.
> > 
> > If we want to preserve `half` semantics exactly regardless of target, we 
> > should have Clang's IR generation actually emit `half` operations.  Targets 
> > that don't support those operations natively will have to lower at least 
> > some of those operations into compiler-rt calls, but that's not at all 
> > unprecedented.
> > 
> > If we're okay with playing loose for performance reasons, we can promote to 
> > `float` immediately around individual arithmetic operations.  IR generation 
> > is probably the most appropriate place to do that.  But I'm quite concerned 
> > about that making `_Float16` feel like an unpredictable/unportable type; it 
> > seems to me that software emulation is much better.
> > 
> > If you're proposing the latter, I think you need to raise that more widely 
> > than a code review; please make a post on llvm-dev.
> > we already track this property in Clang's TargetInfo as `hasLegalHalfType()`
> 
> That sounds a good approch. Thank you.
> 
> > The type of operations on `_Float16` should not change based on whether the 
> > target natively supports `_Float16`. If we need to emulate those operations 
> > on targets that don't provide them natively, we should do that at a lower 
> > level than the type system.
> 
> Unfortunately, we can't do it at low level. The reason is (I'm not expert in 
> frontend, just recalled from last disscussion with GCC folks) we have to do 
> expresssion emulation to respect C/C++ semantics. GCC has option 
> `-fexcess-precision=16` to match the same result with native instructions, 
> but the default is `-fexcess-precision=fast` according to language semantics.
> 
> > The most appropriate place to do that is going to depend on the exact 
> > semantics we want...
> 
> Note, we are not simply doing emulation in the frontend. It's backend's 
> responsibility to emulate a single `half` operation. But it's frontend's 
> responsibility to choose whether to emit several `h

[PATCH] D114006: [analyzer][NFC] Enable access to CodeGenOptions from analyzer's instances.

2021-11-16 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Sweet!
I think commit titles are not punctuated, even though they start with an 
uppercase letter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114006

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


[PATCH] D113641: [llvm] Add a SFINAE template parameter to DenseMapInfo

2021-11-16 Thread River Riddle 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 rG4c484f11d355: [llvm] Add a SFINAE template parameter to 
DenseMapInfo (authored by rriddle).

Changed prior to commit:
  https://reviews.llvm.org/D113641?vs=387386&id=387702#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113641

Files:
  clang/include/clang/AST/TypeOrdering.h
  clang/include/clang/Basic/SourceLocation.h
  clang/include/clang/Sema/Sema.h
  lldb/include/lldb/Utility/ConstString.h
  llvm/include/llvm/ADT/APInt.h
  llvm/include/llvm/ADT/APSInt.h
  llvm/include/llvm/ADT/ArrayRef.h
  llvm/include/llvm/ADT/DenseMapInfo.h
  llvm/include/llvm/ADT/Hashing.h
  llvm/include/llvm/ADT/ImmutableList.h
  llvm/include/llvm/ADT/PointerIntPair.h
  llvm/include/llvm/ADT/StringRef.h
  llvm/include/llvm/BinaryFormat/WasmTraits.h
  llvm/include/llvm/CodeGen/SelectionDAGNodes.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/Support/TypeSize.h
  llvm/lib/Support/APInt.cpp
  llvm/unittests/ADT/DenseMapTest.cpp
  mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
  mlir/include/mlir/IR/Attributes.h
  mlir/include/mlir/IR/BuiltinOps.h
  mlir/include/mlir/IR/OpDefinition.h
  mlir/include/mlir/IR/Types.h
  mlir/include/mlir/Support/LLVM.h

Index: mlir/include/mlir/Support/LLVM.h
===
--- mlir/include/mlir/Support/LLVM.h
+++ mlir/include/mlir/Support/LLVM.h
@@ -46,7 +46,7 @@
 } // namespace detail
 template 
 class DenseMap;
-template  struct DenseMapInfo;
+template  struct DenseMapInfo;
 template  class DenseSet;
 class MallocAllocator;
 template  class MutableArrayRef;
@@ -90,7 +90,8 @@
 //
 // Containers.
 using llvm::ArrayRef;
-using llvm::DenseMapInfo;
+template 
+using DenseMapInfo = llvm::DenseMapInfo;
 template ,
   typename BucketT = llvm::detail::DenseMapPair>
Index: mlir/include/mlir/IR/Types.h
===
--- mlir/include/mlir/IR/Types.h
+++ mlir/include/mlir/IR/Types.h
@@ -269,6 +269,18 @@
   static unsigned getHashValue(mlir::Type val) { return mlir::hash_value(val); }
   static bool isEqual(mlir::Type LHS, mlir::Type RHS) { return LHS == RHS; }
 };
+template 
+struct DenseMapInfo::value>>
+: public DenseMapInfo {
+  static T getEmptyKey() {
+const void *pointer = llvm::DenseMapInfo::getEmptyKey();
+return T::getFromOpaquePointer(pointer);
+  }
+  static T getTombstoneKey() {
+const void *pointer = llvm::DenseMapInfo::getTombstoneKey();
+return T::getFromOpaquePointer(pointer);
+  }
+};
 
 /// We align TypeStorage by 8, so allow LLVM to steal the low bits.
 template <> struct PointerLikeTypeTraits {
Index: mlir/include/mlir/IR/OpDefinition.h
===
--- mlir/include/mlir/IR/OpDefinition.h
+++ mlir/include/mlir/IR/OpDefinition.h
@@ -1906,4 +1906,25 @@
 } // namespace impl
 } // end namespace mlir
 
+namespace llvm {
+
+template 
+struct DenseMapInfo<
+T, std::enable_if_t::value>> {
+  static inline T getEmptyKey() {
+auto *pointer = llvm::DenseMapInfo::getEmptyKey();
+return T::getFromOpaquePointer(pointer);
+  }
+  static inline T getTombstoneKey() {
+auto *pointer = llvm::DenseMapInfo::getTombstoneKey();
+return T::getFromOpaquePointer(pointer);
+  }
+  static unsigned getHashValue(T val) {
+return hash_value(val.getAsOpaquePointer());
+  }
+  static bool isEqual(T lhs, T rhs) { return lhs == rhs; }
+};
+
+} // end namespace llvm
+
 #endif
Index: mlir/include/mlir/IR/BuiltinOps.h
===
--- mlir/include/mlir/IR/BuiltinOps.h
+++ mlir/include/mlir/IR/BuiltinOps.h
@@ -49,23 +49,6 @@
 } // end namespace mlir
 
 namespace llvm {
-// Functions hash just like pointers.
-template <>
-struct DenseMapInfo {
-  static mlir::FuncOp getEmptyKey() {
-auto *pointer = llvm::DenseMapInfo::getEmptyKey();
-return mlir::FuncOp::getFromOpaquePointer(pointer);
-  }
-  static mlir::FuncOp getTombstoneKey() {
-auto *pointer = llvm::DenseMapInfo::getTombstoneKey();
-return mlir::FuncOp::getFromOpaquePointer(pointer);
-  }
-  static unsigned getHashValue(mlir::FuncOp val) {
-return hash_value(val.getAsOpaquePointer());
-  }
-  static bool isEqual(mlir::FuncOp lhs, mlir::FuncOp rhs) { return lhs == rhs; }
-};
-
 /// Allow stealing the low bits of FuncOp.
 template <>
 struct PointerLikeTypeTraits {
Index: mlir/include/mlir/IR/Attributes.h
===
--- mlir/include/mlir/IR/Attributes.h
+++ mlir/include/mlir/IR/Attributes.h
@@ -201,6 +201,19 @@
 return LHS == RHS;
   }
 };
+template 
+struct DenseMapInfo<
+T, std::enable_if_t::value>>
+: public DenseMapInfo {
+  static T getEmptyKey() {
+const void *pointer = llvm::

[PATCH] D110216: [clang] retain type sugar in auto / template argument deduction

2021-11-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

We're seeing a diagnostic change in Chromium which looks funny. For the 
following code (span<> is our own class):

  int WontCompile() {
const std::vector v;
span s = make_span(v);
  }

the diagnostic changes from:

  fatal error: no viable conversion from 'span' to 'span

to

  fatal error: no viable conversion from 'span' to 'span

This looks very strange.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110216

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


[PATCH] D111434: [PowerPC] PPC backend optimization on conditional trap intrustions

2021-11-16 Thread Victor Huang 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 rGae27ca9a6783: [PowerPC] PPC backend optimization on 
conditional trap intrustions (authored by NeHuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

Files:
  llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
  llvm/test/CodeGen/PowerPC/mi-peepholes-trap-opt.mir

Index: llvm/test/CodeGen/PowerPC/mi-peepholes-trap-opt.mir
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/mi-peepholes-trap-opt.mir
@@ -0,0 +1,747 @@
+# RUN: llc -mtriple powerpc64le-unknown-linux-gnu -mcpu=pwr8 -x mir < %s \
+# RUN:   -verify-machineinstrs -start-before=ppc-mi-peepholes | FileCheck %s
+
+---
+name:conditional_trap_opt_reg_implicit_def
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = IMPLICIT_DEF
+%1:gprc = IMPLICIT_DEF
+%2:g8rc = IMPLICIT_DEF
+%3:g8rc = IMPLICIT_DEF
+TW 8, %0, %1
+TD 8, %2, %3
+TWI 24, %0, 0
+TDI 24, %2, 0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_reg_implicit_def
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  twgt3, 3
+  # CHECK-NEXT:  tdgt3, 3
+  # CHECK-NEXT:  twnei   3, 0
+  # CHECK-NEXT:  tdnei   3, 0
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_31
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 3
+%1:gprc = LI 0
+TW 31, %1, %0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_31
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_24
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 3
+%1:gprc = LI 0
+TW 24, %1, %0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_24
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_no_trap_TW_24
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 3
+%1:gprc = LI 3
+TW 24, %1, %0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_no_trap_TW_24
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_20
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 3
+%1:gprc = LI 3
+TW 20, %1, %0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_20
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_no_trap_TW_20
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 3
+%1:gprc = LI 5
+TW 20, %1, %0
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_no_trap_TW_20
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_no_trap_TW_16
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 5
+%1:gprc = LI 1
+TW 16, %0, %1
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_no_trap_TW_16
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_16
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI 5
+%1:gprc = LI 1
+TW 16, %1, %0
+TW 16, %0, %1
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_16
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_8
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI -1
+%1:gprc = LI 10
+TW 8, %1, %0
+TW 8, %0, %1
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_8
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_2
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI -1
+%1:gprc = LI 2
+TW 2, %1, %0
+TW 2, %0, %1
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_opt_TW_2
+  # CHECK: # %bb.0: # %entry
+  # CHECK-NEXT:  trap
+  # CHECK-NEXT:  blr
+
+---
+name:conditional_trap_opt_TW_1
+alignment:   16
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+%0:gprc = LI -3
+%1:gprc = LI 4
+TW 1, %1, %0
+TW 1, %0, %1
+BLR8 implicit $lr8, implicit $rm
+...
+  # CHECK-LABEL: conditional_trap_

[PATCH] D113946: [libc][clang-tidy] fix namespace check for externals

2021-11-16 Thread Michael Jones via Phabricator via cfe-commits
michaelrj updated this revision to Diff 387713.
michaelrj added a comment.

add test for the new lint behavior:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113946

Files:
  clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/llvmlibc-callee-namespace.cpp
  libc/docs/clang_tidy_checks.rst
  libc/src/__support/FPUtil/NearestIntegerOperations.h
  libc/src/__support/str_to_float.h
  libc/src/__support/str_to_integer.h
  libc/src/math/generic/math_utils.h
  libc/src/string/strdup.cpp
  libc/src/string/strndup.cpp

Index: libc/src/string/strndup.cpp
===
--- libc/src/string/strndup.cpp
+++ libc/src/string/strndup.cpp
@@ -23,7 +23,7 @@
   size_t len = internal::string_length(src);
   if (len > size)
 len = size;
-  char *dest = reinterpret_cast(::malloc(len + 1)); // NOLINT
+  char *dest = reinterpret_cast(::malloc(len + 1));
   if (dest == nullptr)
 return nullptr;
   char *result =
Index: libc/src/string/strdup.cpp
===
--- libc/src/string/strdup.cpp
+++ libc/src/string/strdup.cpp
@@ -21,7 +21,7 @@
 return nullptr;
   }
   size_t len = internal::string_length(src) + 1;
-  char *dest = reinterpret_cast(::malloc(len)); // NOLINT
+  char *dest = reinterpret_cast(::malloc(len));
   if (dest == nullptr) {
 return nullptr;
   }
Index: libc/src/math/generic/math_utils.h
===
--- libc/src/math/generic/math_utils.h
+++ libc/src/math/generic/math_utils.h
@@ -55,7 +55,7 @@
 
 template  static inline T with_errno(T x, int err) {
   if (math_errhandling & MATH_ERRNO)
-errno = err; // NOLINT
+errno = err;
   return x;
 }
 
Index: libc/src/__support/str_to_integer.h
===
--- libc/src/__support/str_to_integer.h
+++ libc/src/__support/str_to_integer.h
@@ -74,7 +74,7 @@
   const char *original_src = src;
 
   if (base < 0 || base == 1 || base > 36) {
-errno = EINVAL; // NOLINT
+errno = EINVAL;
 return 0;
   }
 
@@ -114,19 +114,19 @@
 // the result cannot change, but we still need to advance src to the end of
 // the number.
 if (result == ABS_MAX) {
-  errno = ERANGE; // NOLINT
+  errno = ERANGE;
   continue;
 }
 
 if (result > ABS_MAX_DIV_BY_BASE) {
   result = ABS_MAX;
-  errno = ERANGE; // NOLINT
+  errno = ERANGE;
 } else {
   result = result * base;
 }
 if (result > ABS_MAX - cur_digit) {
   result = ABS_MAX;
-  errno = ERANGE; // NOLINT
+  errno = ERANGE;
 } else {
   result = result + cur_digit;
 }
Index: libc/src/__support/str_to_float.h
===
--- libc/src/__support/str_to_float.h
+++ libc/src/__support/str_to_float.h
@@ -220,7 +220,7 @@
   static_cast(fputil::FloatProperties::exponentBias)) {
 *outputMantissa = 0;
 *outputExp2 = fputil::FPBits::maxExponent;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
 return;
   }
   // If the exponent is too small even for a subnormal, return 0.
@@ -230,7 +230,7 @@
fputil::FloatProperties::mantissaWidth)) {
 *outputMantissa = 0;
 *outputExp2 = 0;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
 return;
   }
 
@@ -273,7 +273,7 @@
   if (exp2 >= fputil::FPBits::maxExponent) {
 *outputMantissa = 0;
 *outputExp2 = fputil::FPBits::maxExponent;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
 return;
   }
 
@@ -309,7 +309,7 @@
   }
 
   if (exp2 == 0) {
-errno = ERANGE; // NOLINT
+errno = ERANGE;
   }
 
   *outputMantissa = finalMantissa;
@@ -411,7 +411,7 @@
   static_cast(fputil::FloatProperties::exponentBias) / 3) {
 *outputMantissa = 0;
 *outputExp2 = fputil::FPBits::maxExponent;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
 return;
   }
   // If the exponent is too small even for a subnormal, return 0.
@@ -422,7 +422,7 @@
   2) {
 *outputMantissa = 0;
 *outputExp2 = 0;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
 return;
   }
 
@@ -508,7 +508,7 @@
 // If we cut off any bits to fit this number into a subnormal, then it's
 // out of range for this size of float.
 if ((mantissa & ((1 << amountToShift) - 1)) > 0) {
-  errno = ERANGE; // NOLINT
+  errno = ERANGE;
 }
 mantissa = shiftRightAndRound(mantissa, amountToShift);
 if (mantissa == OVERFLOWED_MANTISSA) {
@@ -524,7 +524,7 @@
 // This indicates an overflow, so we make the result INF and set errno.
 biasedExponent = (1 << fputil::FloatProperties::exponentWidth) - 1;
 mantissa = 0;
-errno = ERANGE; // NOLINT
+errno = ERANGE;
   }
   *outputMantissa = mantissa;
   *out

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

2021-11-16 Thread Daan De Meyer via Phabricator via cfe-commits
DaanDeMeyer updated this revision to Diff 387723.
DaanDeMeyer added a comment.

Addressed comments by adding two new errors, one for character literals and one 
for numeric literals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114003

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/LiteralSupport.cpp


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -693,12 +693,6 @@
 : SM(SM), LangOpts(LangOpts), Diags(Diags),
   ThisTokBegin(TokSpelling.begin()), ThisTokEnd(TokSpelling.end()) {
 
-  // This routine assumes that the range begin/end matches the regex for 
integer
-  // and FP constants (specifically, the 'pp-number' regex), and assumes that
-  // the byte at "*end" is both valid and not part of the regex.  Because of
-  // this, it doesn't have to check for 'overscan' in various places.
-  assert(!isPreprocessingNumberBody(*ThisTokEnd) && "didn't maximally munch?");
-
   s = DigitsBegin = ThisTokBegin;
   saw_exponent = false;
   saw_period = false;
@@ -718,6 +712,16 @@
   isAccum = false;
   hadError = false;
 
+  // This routine assumes that the range begin/end matches the regex for 
integer
+  // and FP constants (specifically, the 'pp-number' regex), and assumes that
+  // the byte at "*end" is both valid and not part of the regex.  Because of
+  // this, it doesn't have to check for 'overscan' in various places.
+  if (isPreprocessingNumberBody(*ThisTokEnd)) {
+Diags.Report(TokLoc, diag::err_lexing_numeric);
+hadError = true;
+return;
+  }
+
   if (*s == '0') { // parse radix
 ParseNumberStartingWithZero(TokLoc);
 if (hadError)
@@ -1432,7 +1436,12 @@
 ++begin;
 
   // Skip over the entry quote.
-  assert(begin[0] == '\'' && "Invalid token lexed");
+  if (begin[0] != '\'') {
+PP.Diag(Loc, diag::err_lexing_char);
+HadError = true;
+return;
+  }
+
   ++begin;
 
   // Remove an optional ud-suffix.
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -269,7 +269,9 @@
 def warn_bad_character_encoding : ExtWarn<
   "illegal character encoding in character literal">,
   InGroup;
-def err_lexing_string : Error<"failure when lexing a string">;
+def err_lexing_string : Error<"failure when lexing a string literal">;
+def err_lexing_char : Error<"failure when lexing a character literal">;
+def err_lexing_numeric : Error<"failure when lexing a numeric literal">;
 def err_placeholder_in_source : Error<"editor placeholder in source file">;
 
 
//===--===//


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -693,12 +693,6 @@
 : SM(SM), LangOpts(LangOpts), Diags(Diags),
   ThisTokBegin(TokSpelling.begin()), ThisTokEnd(TokSpelling.end()) {
 
-  // This routine assumes that the range begin/end matches the regex for integer
-  // and FP constants (specifically, the 'pp-number' regex), and assumes that
-  // the byte at "*end" is both valid and not part of the regex.  Because of
-  // this, it doesn't have to check for 'overscan' in various places.
-  assert(!isPreprocessingNumberBody(*ThisTokEnd) && "didn't maximally munch?");
-
   s = DigitsBegin = ThisTokBegin;
   saw_exponent = false;
   saw_period = false;
@@ -718,6 +712,16 @@
   isAccum = false;
   hadError = false;
 
+  // This routine assumes that the range begin/end matches the regex for integer
+  // and FP constants (specifically, the 'pp-number' regex), and assumes that
+  // the byte at "*end" is both valid and not part of the regex.  Because of
+  // this, it doesn't have to check for 'overscan' in various places.
+  if (isPreprocessingNumberBody(*ThisTokEnd)) {
+Diags.Report(TokLoc, diag::err_lexing_numeric);
+hadError = true;
+return;
+  }
+
   if (*s == '0') { // parse radix
 ParseNumberStartingWithZero(TokLoc);
 if (hadError)
@@ -1432,7 +1436,12 @@
 ++begin;
 
   // Skip over the entry quote.
-  assert(begin[0] == '\'' && "Invalid token lexed");
+  if (begin[0] != '\'') {
+PP.Diag(Loc, diag::err_lexing_char);
+HadError = true;
+return;
+  }
+
   ++begin;
 
   // Remove an optional ud-suffix.
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -269,7 +269,9 @@
 def warn_bad_character_encoding : ExtWarn<
   "illegal character encoding in character literal">,
   InGroup;
-def 

[PATCH] D114011: Add a clang-transformer tutorial

2021-11-16 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
Herald added a subscriber: arphaman.
ymandel updated this revision to Diff 387719.
ymandel added a comment.
ymandel edited the summary of this revision.
ymandel added reviewers: gribozavr2, aaron.ballman.
ymandel changed the edit policy from "All Users" to "Only User: ymandel 
(Yitzhak Mandelbaum)".
ymandel added a project: clang.
ymandel published this revision for review.
Herald added a subscriber: cfe-commits.

tweaks


This patch adds a tutorial for the ClangTransformer library in libTooling 
(`clang/Tooling/Transformer`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114011

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

Index: clang/docs/index.rst
===
--- clang/docs/index.rst
+++ clang/docs/index.rst
@@ -64,6 +64,7 @@
RAVFrontendAction
LibASTMatchersTutorial
LibASTMatchers
+   ClangTransformerTutorial
LibASTImporter
HowToSetupToolingForLLVM
JSONCompilationDatabase
Index: clang/docs/ClangTransformerTutorial.rst
===
--- /dev/null
+++ clang/docs/ClangTransformerTutorial.rst
@@ -0,0 +1,402 @@
+==
+Clang Transformer Tutorial
+==
+
+A tutorial on how to write a source-to-source translation tool using Clang Transformer.
+
+.. contents::
+   :local:
+
+What is Clang Transformer?
+--
+
+Clang Transformer is a framework for writing C++ diagnostics and program
+transformations. It is built on the clang toolchain and the LibTooling library,
+but aims to hide much of the complexity of clang's native, low-level libraries.
+
+The core abstraction of Transformer is the *rewrite rule*, which specifies how
+to change a given program pattern into a new form. Here are some examples of
+tasks you can achieve with Transformer:
+
+*   warn against using the name ``MkX`` for a declared function,
+*   change ``MkX`` to ``MakeX``, where ``MkX`` is the name of a declared function,
+*   change ``s.size()`` to ``Size(s)``, where ``s`` is a ``string``,
+*   collapse ``e.child().m()`` to ``e.m()``, for any expression ``e`` and method named
+``m``.
+
+All of the examples have a common form: they identify a pattern that is the
+target of the transformation, they specify an *edit* to the code identified by
+the pattern, and their pattern and edit refer to common variables, like ``s``,
+``e``, and ``m``, that range over code fragments. Our first and second examples also
+specify constraints on the pattern that aren't apparent from the syntax alone,
+like "``s`` is a ``string``." Even the first example ("warn ...") shares this form,
+even though it doesn't change any of the code -- it's "edit" is simply a no-op.
+
+Transformer helps users succinctly specify rules of this sort and easily execute
+them locally over a collection of files, apply them to selected portions of
+google3, or even bundle them as a clang-tidy check for ongoing application.
+
+Who is Clang Transformer for?
+-
+
+Clang Transformer is for developers who want to write clang-tidy checks or write
+tools to modify a large number of C++ files in (roughly) the same way. What
+qualifies as "large" really depends on the nature of the change and your
+patience for repetitive editing. In our experience, automated solutions become
+worthwhile somewhere between 100 and 500 files.
+
+Getting Started
+---
+
+Patterns in Transformer are expressed with
+`clang's AST matchers `_.
+Matchers are a language of combinators for describing portions of a clang
+Abstract Syntax Tree (AST). Since clang's AST includes complete type information
+(within the limits of single `Translation Unit (TU)`_,
+these patterns can even encode rich constraints on the type properties of AST
+nodes.
+
+.. _`Translation Unit (TU)`: https://en.wikipedia.org/wiki/Translation_unit_\(programming\)
+
+We assume a familiarity with the clang AST and the corresponding AST matchers
+for the purpose of this tutorial. Users who are unfamiliar with either are
+encouraged to start with the recommended references in
+[Related Reading](#related-reading).
+
+Example: style-checking names
+^
+
+Assume you have an API which forbids functions from being named "MkX" and you
+want to write a check that catches any violations of this rule. We can express
+this a Transformer rewrite rule:
+
+.. code-block:: c++
+		
+   makeRule(functionDecl(hasName("MkX").bind("fun"),
+	noopEdit(node("fun")),
+	cat("The name ``MkX`` is not allowed for functions; please rename"));
+
+``makeRule`` is our go-to function for generating rewrite rules. It takes three
+arguments: the pattern, the edit, and (optionally) an explanatory note. In our
+example, the pattern (``functionDecl(...)``) identifies the declaration of the
+functi

[PATCH] D113946: [libc][clang-tidy] fix namespace check for externals

2021-11-16 Thread Siva Chandra via Phabricator via cfe-commits
sivachandra accepted this revision.
sivachandra added a comment.

For libc requirements, LGTM. Please wait for @aaron.ballman for stamping the 
clang-tidy parts.




Comment at: clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp:39
+// intercepted.
+static const char *FUNCTIONS_TO_IGNORE_NAMESPACE[] = {
+"__errno_location", "malloc", "calloc", "realloc", "free"};

michaelrj wrote:
> sivachandra wrote:
> > Eugene.Zelenko wrote:
> > > Why not `std::array` of appropriate LLVM container?
> > May be `static const std::uordered_set`? It would likely 
> > make the lookup below much neater.
> an unordered set is a good idea, but the documentation for `StringRef` says 
> it's best not to use them for storage, so I went with `std::string` instead. 
> The code is still a lot nicer.
Literal strings will not count as "storage". They are global data. On the other 
hand, `std::string` will make copies of the literals and require "storage".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113946

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


[PATCH] D113889: [NFC] disabling clang-tidy check readability-identifier-naming in Protocol.h

2021-11-16 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D113889#3134857 , @kuhnel wrote:

> I just checked with my local clangd and it does not crash on this file...

yeah, this file is fine, the crash only occurs if you use an assertion-enabled 
clangd and the code has an unmatched `NOLINTBEGIN`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113889

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


[PATCH] D113840: [Driver][Android] Remove unneeded isNoExecStackDefault

2021-11-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama edited reviewers, added: srhines; removed: pirama.
pirama added a comment.

Will defer to Dan's review.  I think these changes are safe for the Android 
platform (where we only use lld).  The NDK only supports lld but that does not 
preclude external users from using other linkers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113840

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


  1   2   >