[PATCH] D128127: [Driver][OpenBSD] Specify linker emulations

2022-06-18 Thread Brad Smith via Phabricator via cfe-commits
brad updated this revision to Diff 438173.
brad added a comment.

Further tweak tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128127

Files:
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/test/Driver/openbsd.c

Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -2,13 +2,13 @@
 // RUN: %clang --target=i686-pc-openbsd -static -### %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-STATIC-EH %s
 // CHECK-LD-STATIC-EH: "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK-LD-STATIC-EH: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bstatic" "-o" "a.out" "{{.*}}rcrt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
+// CHECK-LD-STATIC-EH: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bstatic" "-m" "elf_i386" "-o" "a.out" "{{.*}}rcrt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
 
 // Check for profiling variants of libraries when linking and -nopie
 // RUN: %clang --target=i686-pc-openbsd -pg -pthread -### %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG %s
 // CHECK-PG: "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-nopie" "-o" "a.out" "{{.*}}gcrt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lpthread_p" "-lc_p" "-lcompiler_rt" "{{.*}}crtend.o"
+// CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-nopie" "-m" "elf_i386" "-o" "a.out" "{{.*}}gcrt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lpthread_p" "-lc_p" "-lcompiler_rt" "{{.*}}crtend.o"
 
 // Check CPU type for i386
 // RUN: %clang --target=i386-unknown-openbsd -### -c %s 2>&1 \
@@ -40,15 +40,15 @@
 // CHECK-LD-R-NOT: "-l
 // CHECK-LD-R-NOT: crt{{[^./]+}}.o
 // CHECK-LD-S: "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-s" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
+// CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-m" "elf_i386" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-s" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
 // CHECK-LD-T: "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK-LD-T: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-t" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
+// CHECK-LD-T: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-m" "elf_i386" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-t" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
 // CHECK-LD-Z: "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK-LD-Z: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-Z" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
+// CHECK-LD-Z: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-m" "elf_i386" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-Z" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
 // CHECK-MIPS64-LD: "-cc1" "-triple" "mips64-unknown-openbsd"
-// CHECK-MIPS64-LD: ld{{.*}}" "-EB" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
+// CHECK-MIPS64-LD: ld{{.*}}" "-EB" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-m" "elf64btsmip" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
 // CHECK-MIPS64EL-LD: "-cc1" "-triple" "mips64el-unknown-openbsd"
-// CHECK-MIPS64EL-LD: ld{{.*}}" "-EL" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
+// CHECK-MIPS64EL-LD: ld{{.*}}" "-EL" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-m" "elf64ltsmip" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
 
 // Check that --sysroot is passed to the linker
 // RUN: %clang --target=i686-pc-openbsd -### %s 2>&1 \
@@ -56,6 +56,38 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SYSROOT %s
 // CHECK-LD-SYSROOT: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
 
+// Check the ld emulation type passed to the linker
+// 

[PATCH] D127186: [Driver] Support linking to compiler-rt for target AVR

2022-06-18 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 438171.

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

https://reviews.llvm.org/D127186

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/avr/libclang_rt.builtins-avr.a
  clang/test/Driver/avr-toolchain.c

Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -72,3 +72,18 @@
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -mmcu=atmega328 %s -fuse-ld=%S/Inputs/basic_avr_tree/usr/bin/ld.lld -T avr.lds 2>&1 | FileCheck --check-prefix=LDS1 %s
 // LDS1: "-T" "avr.lds"
 // LDS1-NOT: "-mavr5"
+
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir 2>&1 | FileCheck --check-prefix=LIBGCC %s
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=libgcc 2>&1 | FileCheck --check-prefix=LIBGCC %s
+// LIBGCC: "-lgcc"
+// LIBGCC-NOT: libclang_rt
+
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=COMRT %s
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir -fuse-ld=%S/Inputs/basic_avr_tree/usr/bin/ld.lld --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=COMRT %s
+// COMRT: avr/libclang_rt.builtins-avr.a
+// COMRT-NOT: "-lgcc"
+
+// RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=NOMCU %s
+// RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=libgcc 2>&1 | FileCheck --check-prefix=NOMCU %s
+// NOMCU-NOT: libclang_rt
+// NOMCU-NOT: "-lgcc"
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -33,6 +33,7 @@
 
   llvm::Optional findAVRLibcInstallation() const;
   StringRef getGCCInstallPath() const { return GCCInstallPath; }
+  std::string getCompilerRTPath() const override;
 
 protected:
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -19,6 +19,7 @@
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -369,8 +370,7 @@
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
-  std::string CPU = getCPUName(D, Args, Triple);
-  if (CPU.empty())
+  if (getCPUName(D, Args, Triple).empty())
 D.Diag(diag::warn_drv_avr_mcu_not_specified);
 
   // Only add default libraries if the user hasn't explicitly opted out.
@@ -418,6 +418,14 @@
   return new tools::AVR::Linker(getTriple(), *this);
 }
 
+std::string AVRToolChain::getCompilerRTPath() const {
+  // Return the default path appended with '/avr', since AVR can never be a
+  // host environment.
+  SmallString<128> Path(ToolChain::getCompilerRTPath());
+  llvm::sys::path::append(Path, "avr");
+  return std::string(Path.str());
+}
+
 void AVR::Linker::ConstructJob(Compilation , const JobAction ,
const InputInfo ,
const InputInfoList , const ArgList ,
@@ -449,6 +457,12 @@
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);
 
+  // Currently we only support libgcc and compiler-rt.
+  auto RtLib = TC.GetRuntimeLibType(Args);
+  assert(
+  (RtLib == ToolChain::RLT_Libgcc || RtLib == ToolChain::RLT_CompilerRT) &&
+  "unknown runtime library");
+
   // Only add default libraries if the user hasn't explicitly opted out.
   bool LinkStdlib = false;
   if (!Args.hasArg(options::OPT_nostdlib) &&
@@ -464,10 +478,13 @@
 D.Diag(diag::warn_drv_avr_libc_not_found);
   } else {
 std::string SubPath = GetMCUSubPath(CPU);
+// Add path of avr-libc.
 CmdArgs.push_back(
 Args.MakeArgString(Twine("-L") + *AVRLibcRoot + "/lib/" + SubPath));
-CmdArgs.push_back(
-Args.MakeArgString("-L" + TC.getGCCInstallPath() + "/" + SubPath));
+// Add path of libgcc.
+if (RtLib == ToolChain::RLT_Libgcc)
+  

[PATCH] D127186: [Driver] Support linking to compiler-rt for target AVR

2022-06-18 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 438169.

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

https://reviews.llvm.org/D127186

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/avr/libclang_rt.builtins-avr.a
  clang/test/Driver/avr-toolchain.c

Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -72,3 +72,18 @@
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -mmcu=atmega328 %s -fuse-ld=%S/Inputs/basic_avr_tree/usr/bin/ld.lld -T avr.lds 2>&1 | FileCheck --check-prefix=LDS1 %s
 // LDS1: "-T" "avr.lds"
 // LDS1-NOT: "-mavr5"
+
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir 2>&1 | FileCheck --check-prefix=LIBGCC %s
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=libgcc 2>&1 | FileCheck --check-prefix=LIBGCC %s
+// LIBGCC: "-lgcc"
+// LIBGCC-NOT: libclang_rt
+
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=COMRT %s
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir -fuse-ld=%S/Inputs/basic_avr_tree/usr/bin/ld.lld --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=COMRT %s
+// COMRT: avr/libclang_rt.builtins-avr.a
+// COMRT-NOT: "-lgcc"
+
+// RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=NOMCU %s
+// RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=libgcc 2>&1 | FileCheck --check-prefix=NOMCU %s
+// NOMCU-NOT: libclang_rt
+// NOMCU-NOT: "-lgcc"
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -33,6 +33,7 @@
 
   llvm::Optional findAVRLibcInstallation() const;
   StringRef getGCCInstallPath() const { return GCCInstallPath; }
+  std::string getCompilerRTPath() const override;
 
 protected:
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -19,6 +19,7 @@
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -369,8 +370,7 @@
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
-  std::string CPU = getCPUName(D, Args, Triple);
-  if (CPU.empty())
+  if (getCPUName(D, Args, Triple).empty())
 D.Diag(diag::warn_drv_avr_mcu_not_specified);
 
   // Only add default libraries if the user hasn't explicitly opted out.
@@ -418,6 +418,14 @@
   return new tools::AVR::Linker(getTriple(), *this);
 }
 
+std::string AVRToolChain::getCompilerRTPath() const {
+  // Return the default path appended with '/avr', since AVR can never be a
+  // host environment.
+  SmallString<128> Path(ToolChain::getCompilerRTPath());
+  llvm::sys::path::append(Path, "avr");
+  return std::string(Path.str());
+}
+
 void AVR::Linker::ConstructJob(Compilation , const JobAction ,
const InputInfo ,
const InputInfoList , const ArgList ,
@@ -449,6 +457,12 @@
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);
 
+  // Currently we only support libgcc and compiler-rt.
+  auto RtLib = TC.GetRuntimeLibType(Args);
+  assert(
+  (RtLib == ToolChain::RLT_Libgcc || RtLib == ToolChain::RLT_CompilerRT) &&
+  "unknown runtime library");
+
   // Only add default libraries if the user hasn't explicitly opted out.
   bool LinkStdlib = false;
   if (!Args.hasArg(options::OPT_nostdlib) &&
@@ -464,10 +478,13 @@
 D.Diag(diag::warn_drv_avr_libc_not_found);
   } else {
 std::string SubPath = GetMCUSubPath(CPU);
+// Add path of avr-libc.
 CmdArgs.push_back(
 Args.MakeArgString(Twine("-L") + *AVRLibcRoot + "/lib/" + SubPath));
-CmdArgs.push_back(
-Args.MakeArgString("-L" + TC.getGCCInstallPath() + "/" + SubPath));
+// Add path of libgcc.
+if (RtLib == ToolChain::RLT_Libgcc)
+  

[PATCH] D127826: [Driver] Pass -X to ld for riscv*-{elf,freebsd,linux}

2022-06-18 Thread Brad Smith via Phabricator via cfe-commits
brad added a comment.

This should probably be applied to Fuchsia and NetBSD as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127826

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


[PATCH] D128127: [Driver][OpenBSD] Specify linker emulations

2022-06-18 Thread Brad Smith via Phabricator via cfe-commits
brad updated this revision to Diff 438160.
brad added a comment.

Update tests to conform to recent style changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128127

Files:
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/test/Driver/openbsd.c


Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -56,6 +56,38 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SYSROOT %s
 // CHECK-LD-SYSROOT: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
 
+// Check the ld emulation type passed to the linker
+// RUN: %clang --target=aarch64-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-AARCH64 %s
+// RUN: %clang --target=arm-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-ARM %s
+// RUN: %clang --target=mips64-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-MIPS64 %s
+// RUN: %clang --target=mips64el-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-MIPS64EL %s
+// RUN: %clang --target=powerpc-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-POWERPC %s
+// RUN: %clang --target=powerpc64-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-POWERPC64 %s
+// RUN: %clang --target=riscv64-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-RISCV64 %s
+// RUN: %clang --target=sparc64-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-SPARC64 %s
+// RUN: %clang --target=i386-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-i386 %s
+// RUN: %clang --target=amd64-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-AMD64 %s
+// CHECK-LD-M-AARCH64: "-m" "aarch64elf"
+// CHECK-LD-M-ARM: "-m" "armelf"
+// CHECK-LD-M-MIPS64: "-m" "elf64btsmip"
+// CHECK-LD-M-MIPS64EL: "-m" "elf64ltsmip"
+// CHECK-LD-M-POWERPC: "-m" "elf32ppc"
+// CHECK-LD-M-POWERPC64: "-m" "elf64ppc"
+// CHECK-LD-M-RISCV64: "-m" "elf64lriscv"
+// CHECK-LD-M-SPARC64: "-m" "elf64_sparc"
+// CHECK-LD-M-i386: "-m" "elf_i386"
+// CHECK-LD-M-AMD64: "-m" "elf_x86_64"
+
 // Check passing options to the assembler for various OpenBSD targets
 // RUN: %clang --target=amd64-pc-openbsd -m32 -### -no-integrated-as -c %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-AMD64-M32 %s
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -157,6 +157,52 @@
   if (Args.hasArg(options::OPT_nopie) || Args.hasArg(options::OPT_pg))
 CmdArgs.push_back("-nopie");
 
+  // Determine the correct emulation for ld.
+  switch (Arch) {
+  case llvm::Triple::aarch64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("aarch64elf");
+break;
+  case llvm::Triple::arm:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("armelf");
+break;
+  case llvm::Triple::mips64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64btsmip");
+break;
+  case llvm::Triple::mips64el:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64ltsmip");
+break;
+  case llvm::Triple::ppc:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf32ppc");
+break;
+  case llvm::Triple::ppc64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64ppc");
+break;
+  case llvm::Triple::riscv64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64lriscv");
+break;
+  case llvm::Triple::sparcv9:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64_sparc");
+break;
+  case llvm::Triple::x86:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf_i386");
+break;
+  case llvm::Triple::x86_64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf_x86_64");
+break;
+  default:
+break;
+  }
+
   if (Arch == llvm::Triple::riscv64)
 CmdArgs.push_back("-X");
 


Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -56,6 +56,38 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SYSROOT %s
 // CHECK-LD-SYSROOT: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
 
+// Check the ld emulation type passed to the linker
+// RUN: %clang --target=aarch64-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-AARCH64 %s
+// RUN: %clang --target=arm-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-ARM %s
+// RUN: %clang --target=mips64-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-MIPS64 %s
+// RUN: %clang --target=mips64el-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-MIPS64EL %s
+// RUN: %clang 

[clang] c5935af - [Toolchains] Use llvm::is_contained (NFC)

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

Author: Kazu Hirata
Date: 2022-06-18T15:57:50-07:00
New Revision: c5935af0583b6988a8e4f9fdcab1f4d29f04a021

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

LOG: [Toolchains] Use llvm::is_contained (NFC)

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 43373083f8aa..8d3584ff0ba1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5843,7 +5843,7 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   "standalone", "objc", "swift", "swift-5.0", "swift-4.2", "swift-4.1",
 };
 
-if (find(kCFABIs, StringRef(A->getValue())) == std::end(kCFABIs))
+if (!llvm::is_contained(kCFABIs, StringRef(A->getValue(
   D.Diag(diag::err_drv_invalid_cf_runtime_abi) << A->getValue();
 else
   A->render(Args, CmdArgs);



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


[PATCH] D128127: [Driver][OpenBSD] Specify linker emulations

2022-06-18 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.
brad added a reviewer: MaskRay.
brad added a project: clang.
Herald added subscribers: luke957, StephenFan, s.egerton, simoncook, 
fedor.sergeev.
Herald added a project: All.
brad requested review of this revision.
Herald added a subscriber: pcwang-thead.

Have the driver specify the linker emulations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128127

Files:
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/test/Driver/openbsd.c


Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -56,6 +56,38 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SYSROOT %s
 // CHECK-LD-SYSROOT: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
 
+// Check the ld emulation type passed to the linker
+// RUN: %clang -no-canonical-prefixes -target aarch64-unknown-openbsd %s -### 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-AARCH64 %s
+// RUN: %clang -no-canonical-prefixes -target arm-unknown-openbsd %s -### 2>&1 
\
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-ARM %s
+// RUN: %clang -no-canonical-prefixes -target mips64-unknown-openbsd %s -### 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-MIPS64 %s
+// RUN: %clang -no-canonical-prefixes -target mips64el-unknown-openbsd %s -### 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-MIPS64EL %s
+// RUN: %clang -no-canonical-prefixes -target powerpc-unknown-openbsd %s -### 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-POWERPC %s
+// RUN: %clang -no-canonical-prefixes -target powerpc64-unknown-openbsd %s 
-### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-POWERPC64 %s
+// RUN: %clang -no-canonical-prefixes -target riscv64-unknown-openbsd %s -### 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-RISCV64 %s
+// RUN: %clang -no-canonical-prefixes -target sparc64-unknown-openbsd %s -### 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-SPARC64 %s
+// RUN: %clang -no-canonical-prefixes -target i386-unknown-openbsd %s -### 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-i386 %s
+// RUN: %clang -no-canonical-prefixes -target amd64-unknown-openbsd %s -### 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-M-AMD64 %s
+// CHECK-LD-M-AARCH64: "-m" "aarch64elf"
+// CHECK-LD-M-ARM: "-m" "armelf"
+// CHECK-LD-M-MIPS64: "-m" "elf64btsmip"
+// CHECK-LD-M-MIPS64EL: "-m" "elf64ltsmip"
+// CHECK-LD-M-POWERPC: "-m" "elf32ppc"
+// CHECK-LD-M-POWERPC64: "-m" "elf64ppc"
+// CHECK-LD-M-RISCV64: "-m" "elf64lriscv"
+// CHECK-LD-M-SPARC64: "-m" "elf64_sparc"
+// CHECK-LD-M-i386: "-m" "elf_i386"
+// CHECK-LD-M-AMD64: "-m" "elf_x86_64"
+
 // Check passing options to the assembler for various OpenBSD targets
 // RUN: %clang --target=amd64-pc-openbsd -m32 -### -no-integrated-as -c %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-AMD64-M32 %s
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -157,6 +157,52 @@
   if (Args.hasArg(options::OPT_nopie) || Args.hasArg(options::OPT_pg))
 CmdArgs.push_back("-nopie");
 
+  // Determine the correct emulation for ld.
+  switch (Arch) {
+  case llvm::Triple::aarch64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("aarch64elf");
+break;
+  case llvm::Triple::arm:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("armelf");
+break;
+  case llvm::Triple::mips64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64btsmip");
+break;
+  case llvm::Triple::mips64el:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64ltsmip");
+break;
+  case llvm::Triple::ppc:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf32ppc");
+break;
+  case llvm::Triple::ppc64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64ppc");
+break;
+  case llvm::Triple::riscv64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64lriscv");
+break;
+  case llvm::Triple::sparcv9:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64_sparc");
+break;
+  case llvm::Triple::x86:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf_i386");
+break;
+  case llvm::Triple::x86_64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf_x86_64");
+break;
+  default:
+break;
+  }
+
   if (Arch == llvm::Triple::riscv64)
 CmdArgs.push_back("-X");
 


Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -56,6 +56,38 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SYSROOT %s
 // CHECK-LD-SYSROOT: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
 
+// Check the ld emulation type passed to the linker
+// RUN: %clang -no-canonical-prefixes -target aarch64-unknown-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck 

[clang] 6dd094d - [Driver][OpenBSD] Use Arch reference instead of getArch(). NFC

2022-06-18 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2022-06-18T18:11:15-04:00
New Revision: 6dd094dd435d09872687c1bdcce6845f70cf25cc

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

LOG: [Driver][OpenBSD] Use Arch reference instead of getArch(). NFC

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp 
b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index 92b91ed9d7f4..62c430b66e5f 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -113,6 +113,7 @@ void openbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
   const toolchains::OpenBSD  =
   static_cast(getToolChain());
   const Driver  = ToolChain.getDriver();
+  const llvm::Triple::ArchType Arch = ToolChain.getArch();
   ArgStringList CmdArgs;
 
   // Silence warning for "clang -g foo.o -o foo"
@@ -126,9 +127,9 @@ void openbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
-  if (ToolChain.getArch() == llvm::Triple::mips64)
+  if (Arch == llvm::Triple::mips64)
 CmdArgs.push_back("-EB");
-  else if (ToolChain.getArch() == llvm::Triple::mips64el)
+  else if (Arch == llvm::Triple::mips64el)
 CmdArgs.push_back("-EL");
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_shared)) {
@@ -156,7 +157,7 @@ void openbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
   if (Args.hasArg(options::OPT_nopie) || Args.hasArg(options::OPT_pg))
 CmdArgs.push_back("-nopie");
 
-  if (ToolChain.getArch() == llvm::Triple::riscv64)
+  if (Arch == llvm::Triple::riscv64)
 CmdArgs.push_back("-X");
 
   if (Output.isFilename()) {



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


[PATCH] D128109: [Driver] Pass -X to ld for riscv64-openbsd

2022-06-18 Thread Brad Smith 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 rG119a13199a91: [Driver] Pass -X to ld for riscv64-openbsd 
(authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128109

Files:
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/test/Driver/openbsd.c


Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -126,3 +126,8 @@
 // RUN: FileCheck -check-prefix=UNWIND-TABLES %s
 // UNWIND-TABLES: "-funwind-tables=2"
 // NO-UNWIND-TABLES-NOT: "-funwind-tables=2"
+
+// Check that the -X flag is passed to the linker on riscv64
+// RUN: %clang --target=riscv64-unknown-openbsd -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-RISCV64-FLAGS %s
+// CHECK-RISCV64-FLAGS: "-X"
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -156,6 +156,9 @@
   if (Args.hasArg(options::OPT_nopie) || Args.hasArg(options::OPT_pg))
 CmdArgs.push_back("-nopie");
 
+  if (ToolChain.getArch() == llvm::Triple::riscv64)
+CmdArgs.push_back("-X");
+
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
 CmdArgs.push_back(Output.getFilename());


Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -126,3 +126,8 @@
 // RUN: FileCheck -check-prefix=UNWIND-TABLES %s
 // UNWIND-TABLES: "-funwind-tables=2"
 // NO-UNWIND-TABLES-NOT: "-funwind-tables=2"
+
+// Check that the -X flag is passed to the linker on riscv64
+// RUN: %clang --target=riscv64-unknown-openbsd -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-RISCV64-FLAGS %s
+// CHECK-RISCV64-FLAGS: "-X"
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -156,6 +156,9 @@
   if (Args.hasArg(options::OPT_nopie) || Args.hasArg(options::OPT_pg))
 CmdArgs.push_back("-nopie");
 
+  if (ToolChain.getArch() == llvm::Triple::riscv64)
+CmdArgs.push_back("-X");
+
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
 CmdArgs.push_back(Output.getFilename());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 119a131 - [Driver] Pass -X to ld for riscv64-openbsd

2022-06-18 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2022-06-18T17:58:58-04:00
New Revision: 119a13199a91abd43818412c34b9308db3c9270d

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

LOG: [Driver] Pass -X to ld for riscv64-openbsd

Noticing D127826, add support for OpenBSD which uses lld on riscv64.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/test/Driver/openbsd.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp 
b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index 249a00ebb003a..92b91ed9d7f4e 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -156,6 +156,9 @@ void openbsd::Linker::ConstructJob(Compilation , const 
JobAction ,
   if (Args.hasArg(options::OPT_nopie) || Args.hasArg(options::OPT_pg))
 CmdArgs.push_back("-nopie");
 
+  if (ToolChain.getArch() == llvm::Triple::riscv64)
+CmdArgs.push_back("-X");
+
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
 CmdArgs.push_back(Output.getFilename());

diff  --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index e3acd2c0569cc..d57234ae0134a 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -126,3 +126,8 @@
 // RUN: FileCheck -check-prefix=UNWIND-TABLES %s
 // UNWIND-TABLES: "-funwind-tables=2"
 // NO-UNWIND-TABLES-NOT: "-funwind-tables=2"
+
+// Check that the -X flag is passed to the linker on riscv64
+// RUN: %clang --target=riscv64-unknown-openbsd -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-RISCV64-FLAGS %s
+// CHECK-RISCV64-FLAGS: "-X"



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


[PATCH] D128109: [Driver] Pass -X to ld for riscv64-openbsd

2022-06-18 Thread Brad Smith via Phabricator via cfe-commits
brad added inline comments.



Comment at: clang/test/Driver/openbsd.c:133
+// RUN:   | FileCheck -check-prefix=CHECK-RISCV64-FLAGS %s
+// CHECK-RISCV64-FLAGS: "-X"

MaskRay wrote:
> It's useful to check other values like the `-m` emulation and the dynamic 
> linker.
The dynamic linker flags are tested further up in openbsd.c. The driver 
currently does not pass back the emulation flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128109

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


[PATCH] D126194: [Concepts] Implement overload resolution for destructors (P0848)

2022-06-18 Thread Roy Jacobson 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 rG21eb1af469c3: [Concepts] Implement overload resolution for 
destructors (P0848) (authored by royjacobson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126194

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/overloaded-destructors.cpp
  clang/test/CXX/class/class.dtor/p4.cpp
  clang/test/CXX/over/over.match/over.match.viable/p3.cpp
  clang/test/SemaTemplate/destructor-template.cpp

Index: clang/test/SemaTemplate/destructor-template.cpp
===
--- clang/test/SemaTemplate/destructor-template.cpp
+++ clang/test/SemaTemplate/destructor-template.cpp
@@ -98,7 +98,7 @@
   template 
   ~S(); // expected-error{{destructor cannot be declared as a template}}
 };
-struct T : S {// expected-note{{destructor of 'T' is implicitly deleted because base class 'PR38671::S' has no destructor}}
-  ~T() = default; // expected-warning{{explicitly defaulted destructor is implicitly deleted}}
+struct T : S {
+  ~T() = default;
 };
 } // namespace PR38671
Index: clang/test/CXX/over/over.match/over.match.viable/p3.cpp
===
--- clang/test/CXX/over/over.match/over.match.viable/p3.cpp
+++ clang/test/CXX/over/over.match/over.match.viable/p3.cpp
@@ -49,7 +49,6 @@
   S(A) requires false;
   S(double) requires true;
   ~S() requires false;
-  // expected-note@-1 2{{because 'false' evaluated to false}}
   ~S() requires true;
   operator int() requires true;
   operator int() requires false;
@@ -58,11 +57,7 @@
 void bar() {
   WrapsStatics::foo(A{});
   S{1.}.foo(A{});
-  // expected-error@-1{{invalid reference to function '~S': constraints not satisfied}}
-  // Note - this behavior w.r.t. constrained dtors is a consequence of current
-  // wording, which does not invoke overload resolution when a dtor is called.
-  // P0848 is set to address this issue.
+
   S s = 1;
-  // expected-error@-1{{invalid reference to function '~S': constraints not satisfied}}
   int a = s;
 }
Index: clang/test/CXX/class/class.dtor/p4.cpp
===
--- /dev/null
+++ clang/test/CXX/class/class.dtor/p4.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+template 
+struct A {
+  ~A() = delete;  // expected-note {{explicitly marked deleted}}
+  ~A() requires(N == 1) = delete; // expected-note {{explicitly marked deleted}}
+};
+
+// FIXME: We should probably make it illegal to mix virtual and non-virtual methods
+// this way. See CWG2488 and some discussion in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105699.
+template 
+struct B {
+  ~B() requires(N == 1) = delete; // expected-note {{explicitly marked deleted}}
+  virtual ~B() = delete;  // expected-note {{explicitly marked deleted}}
+};
+
+template 
+concept CO1 = N == 1;
+
+template 
+concept CO2 = N >
+0;
+
+template 
+struct C {
+  ~C() = delete; // expected-note {{explicitly marked deleted}}
+  ~C() requires(CO1) = delete;
+  ~C() requires(CO1 &) = delete; // expected-note {{explicitly marked deleted}}
+};
+
+template 
+struct D {
+  ~D() requires(N != 0) = delete; // expected-note {{explicitly marked deleted}}
+  // expected-note@-1 {{candidate function has been explicitly deleted}}
+  // expected-note@-2 {{candidate function not viable: constraints not satisfied}}
+  // expected-note@-3 {{evaluated to false}}
+  ~D() requires(N == 1) = delete;
+  // expected-note@-1 {{candidate function has been explicitly deleted}}
+  // expected-note@-2 {{candidate function not viable: constraints not satisfied}}
+  // expected-note@-3 {{evaluated to false}}
+};
+
+template 
+concept Foo = requires(T t) {
+  {t.foo()};
+};
+
+template 
+struct E {
+  void foo();
+  ~E();
+  ~E() requires Foo = delete; // expected-note {{explicitly marked deleted}}
+};
+
+template struct A<1>;
+template struct A<2>;
+template struct B<1>;
+template struct B<2>;
+template struct C<1>;
+template struct C<2>;
+template struct D<0>; // expected-error {{no viable destructor found for class 'D<0>'}} expected-note {{in instantiation of template}}
+template struct D<1>; // expected-error {{destructor of class 'D<1>' is ambiguous}} expected-note {{in instantiation of template}}
+template struct D<2>;
+template struct E<1>;
+
+int main() {
+  A<1> a1; // 

[clang] 21eb1af - [Concepts] Implement overload resolution for destructors (P0848)

2022-06-18 Thread Roy Jacobson via cfe-commits

Author: Roy Jacobson
Date: 2022-06-19T00:30:37+03:00
New Revision: 21eb1af469c3257606aec2270d544e0e8ecf77b2

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

LOG: [Concepts] Implement overload resolution for destructors (P0848)

This patch implements a necessary part of P0848, the overload resolution for 
destructors.
It is now possible to overload destructors based on constraints, and the 
eligible destructor
will be selected at the end of the class.

The approach this patch takes is to perform the overload resolution in 
Sema::ActOnFields
and to mark the selected destructor using a new property in 
FunctionDeclBitfields.

CXXRecordDecl::getDestructor is then modified to use this property to return 
the correct
destructor.

This closes https://github.com/llvm/llvm-project/issues/45614.

Reviewed By: #clang-language-wg, erichkeane

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

Added: 
clang/test/AST/overloaded-destructors.cpp
clang/test/CXX/class/class.dtor/p4.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/AST/ast-dump-decl.cpp
clang/test/CXX/over/over.match/over.match.viable/p3.cpp
clang/test/SemaTemplate/destructor-template.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 947786a783452..e37b93e573491 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -446,6 +446,10 @@ C++20 Feature Support
   that can be used for such compatibility. The demangler now demangles
   symbols with named module attachment.
 
+- As per "Conditionally Trivial Special Member Functions" (P0848), it is
+  now possible to overload destructors using concepts. Note that the rest
+  of the paper about other special member functions is not yet implemented.
+
 C++2b Feature Support
 ^
 

diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index c2133f4e79a15..66fab94b45b8a 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -2251,6 +2251,13 @@ class FunctionDecl : public DeclaratorDecl,
  DeclAsWritten->getCanonicalDecl()->isDefaulted());
   }
 
+  bool isIneligibleOrNotSelected() const {
+return FunctionDeclBits.IsIneligibleOrNotSelected;
+  }
+  void setIneligibleOrNotSelected(bool II) {
+FunctionDeclBits.IsIneligibleOrNotSelected = II;
+  }
+
   /// Whether falling off this function implicitly returns null/zero.
   /// If a more specific implicit return value is required, front-ends
   /// should synthesize the appropriate return statements.

diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index a4a44e0b30e64..0611cf5ccb000 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1596,6 +1596,12 @@ class DeclContext {
 uint64_t IsDefaulted : 1;
 uint64_t IsExplicitlyDefaulted : 1;
 uint64_t HasDefaultedFunctionInfo : 1;
+
+/// For member functions of complete types, whether this is an ineligible
+/// special member function or an unselected destructor. See
+/// [class.mem.special].
+uint64_t IsIneligibleOrNotSelected : 1;
+
 uint64_t HasImplicitReturnZero : 1;
 uint64_t IsLateTemplateParsed : 1;
 
@@ -1631,7 +1637,7 @@ class DeclContext {
   };
 
   /// Number of non-inherited bits in FunctionDeclBitfields.
-  enum { NumFunctionDeclBits = 27 };
+  enum { NumFunctionDeclBits = 28 };
 
   /// Stores the bits used by CXXConstructorDecl. If modified
   /// NumCXXConstructorDeclBits and the accessor
@@ -1643,12 +1649,12 @@ class DeclContext {
 /// For the bits in FunctionDeclBitfields.
 uint64_t : NumFunctionDeclBits;
 
-/// 24 bits to fit in the remaining available space.
+/// 23 bits to fit in the remaining available space.
 /// Note that this makes CXXConstructorDeclBitfields take
 /// exactly 64 bits and thus the width of NumCtorInitializers
 /// will need to be shrunk if some bit is added to NumDeclContextBitfields,
 /// NumFunctionDeclBitfields or CXXConstructorDeclBitfields.
-uint64_t NumCtorInitializers : 21;
+uint64_t NumCtorInitializers : 20;
 uint64_t IsInheritingConstructor : 1;
 
 /// Whether this constructor has a trail-allocated explicit specifier.

diff  --git a/clang/include/clang/AST/DeclCXX.h 

[PATCH] D128064: [Static Analyzer] Small array binding policy

2022-06-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

There's nothing immediately wrong with this patch so no need to revert it. It 
makes sense to revert a patch if it breaks buildbots or if there's no fix 
coming soon (eg. if we're about to have an entire LLVM release broken). If 
there was a revert it would have made sense to reuse the phabricator revision 
as well. But as it is, just make a new patch :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128064

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


[PATCH] D127923: [Diagnostics] Accept newline and format diag opts on first line

2022-06-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Thanks for updating the summary.

I'm not too confident around diagnostics though.
I'm going to piggyback on @scott.linder's comments. I think they are on the 
point.

nit: I'm not sure if `size_t` is a thing in c++, `std::size_t` is though.




Comment at: clang/lib/Basic/Diagnostic.cpp:815
 for (char c : S) {
-  if (llvm::sys::locale::isPrint(c) || c == '\t') {
+  if (llvm::sys::locale::isPrint(c) || c == '\t' || c == '\n') {
 OutStr.push_back(c);

Should we account for `'\r'`-s as well? I'm not sure how it works though



Comment at: clang/lib/Frontend/TextDiagnosticPrinter.cpp:119-135
+  // If the diagnostic message is formatted into multiple lines, split the
+  // first line and feed it into printDiagnosticOptions so that we print the
+  // options only on the first line instead of the last line.
+  SmallString<100> InitStr;
+  size_t NewlinePos = OutStr.find_first_of('\n');
+  if (NewlinePos != StringRef::npos) {
+for (size_t I = 0; I != NewlinePos; ++I)

scott.linder wrote:
> Nit: I'd remove the `if`s and just use the behavior of `slice(npos, ...)` 
> returning the empty string
> 
> I also would reword "split the first line and feed it into 
> printDiagnosticOptions", as it could be interpreted as meaning the first line 
> is an input to `printDiagnosticOptions`
Use braces for both branches or no braces at all. [[ 
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
 | LLVM CodingStandards ]]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127923

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


[PATCH] D117229: [Analyzer] Produce SymbolCast for pointer to integer cast

2022-06-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: 
clang/test/Analysis/symbol-simplification-mem-region-to-int-cast.cpp:23
+  clang_analyzer_eval(p == 0);// expected-warning{{TRUE}}
+  clang_analyzer_eval(p_as_integer == 0); // expected-warning{{UNKNOWN}}
+

steakhal wrote:
> Why is this ``UNKNOWN`? I would expect `TRUE` here as well.
Hmm, I meant it for line 39 :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117229

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


[PATCH] D126779: [analyzer] Fix assertion in simplifySymbolCast

2022-06-18 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.

LGTM




Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:1082
+  // FIXME support cast from non-integers.
+  // E.g (char)(double)(double x) -> (char)(double x)
+  if (!RT->isIntegralOrEnumerationType())

martong wrote:
> steakhal wrote:
> > Well, I would expect the same, but crosscheck this with the actual dump.
> Please elaborate.
nvm



Comment at: clang/test/Analysis/produce-symbolcast_x86.cpp:16
+  double D = n / 30;
+  clang_analyzer_dump(D); // expected-warning{{(double) ((double) ((reg_$0) / 30))}}
+  char C = D;

martong wrote:
> steakhal wrote:
> > Place here a FIXME that we should not have two double casts.
> The `(double)(double)` problem is handled in the parent patch. Please check 
> that out.
Yeey, awesome!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126779

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


[PATCH] D128068: [analyzer] Do not emit redundant SymbolCasts

2022-06-18 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.

> We can't just do that check in `evalCast` because there are many additonal 
> logic before we'd end up in `makeNonLoc`.

I'm not exactly up to date. Could you please extend the summary with an example 
to underpin this statement prior to committing?




Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:116-117
   assert(!Loc::isLocType(toTy));
+  if (fromTy == toTy)
+return operand;
   return nonloc::SymbolVal(SymMgr.getCastSymbol(operand, fromTy, toTy));

Should we account for qualified types?
If not, could we assert that?



Comment at: clang/test/Analysis/symbolcast-floatingpoint.cpp:12-24
+void test_no_redundant_floating_point_cast(int n) {
+
+  double D = n / 30;
+  clang_analyzer_dump(D); // expected-warning{{(double) ((reg_$0) / 
30)}}
+
+  // There are two cast operations evaluated above:
+  // 1. (n / 30) is cast to a double during the store of `D`.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128068

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


[clang] af6d2a0 - [docs] Re-generate ClangCommandLineReference.rst

2022-06-18 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-06-18T11:01:54-07:00
New Revision: af6d2a0b6825e71965f3e2701a63c239fa0ad70f

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

LOG: [docs] Re-generate ClangCommandLineReference.rst

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 73dccf6a9a04e..7e53f45c59689 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -281,6 +281,10 @@ Generate CodeView debug information
 
 Emit type record hashes in a .debug$H section
 
+.. option:: -gen-reproducer=, -fno-crash-diagnostics (equivalent to 
-gen-reproducer=off)
+
+Emit reproducer on (option: off, crash (default), error, always)
+
 .. option:: --gpu-instrument-lib=
 
 Instrument device library for HIP, which is a LLVM bitcode containing 
\_\_cyg\_profile\_func\_enter and \_\_cyg\_profile\_func\_exit
@@ -339,7 +343,7 @@ Allow unsafe floating-point math optimizations which may 
decrease precision
 
 .. option:: -mharden-sls=
 
-Select straight-line speculation hardening scope
+Select straight-line speculation hardening scope (ARM/AArch64/X86 only).  
must be: all, none, retbr(ARM/AArch64), blr(ARM/AArch64), comdat(ARM/AArch64), 
nocomdat(ARM/AArch64), return(X86), indirect-jmp(X86)
 
 .. option:: --migrate
 
@@ -551,6 +555,10 @@ Use pipes between commands, when possible
 
 .. option:: --print-diagnostic-categories
 
+.. option:: -print-diagnostic-options, --print-diagnostic-options
+
+Print all of Clang's warning options
+
 .. option:: -print-effective-triple, --print-effective-triple
 
 Print the effective target triple
@@ -817,6 +825,10 @@ Generate Interface Stub Files, emit merged text not binary.
 
 Extract API information
 
+.. option:: -fdriver-only
+
+Only run the driver.
+
 .. option:: -fsyntax-only
 
 .. option:: -module-file-info
@@ -929,10 +941,6 @@ Inline suitable functions
 
 Inline functions which are (explicitly or implicitly) marked inline
 
-.. option:: -fno-crash-diagnostics
-
-Disable auto-generation of preprocessed source files and a script for 
reproduction during a clang crash
-
 .. option:: -fno-legacy-pass-manager, -fexperimental-new-pass-manager
 
 .. option:: -fno-sanitize-ignorelist, -fno-sanitize-blacklist
@@ -1106,7 +1114,9 @@ Include comments in preprocessed output
 
 Include comments from within macros in preprocessed output
 
-.. option:: -D=, --define-macro , --define-macro=
+.. program:: clang2
+.. option:: -D=, --D, /D, -D, --define-macro 
, --define-macro=
+.. program:: clang
 
 Define  to  (or 1 if  omitted)
 
@@ -1727,6 +1737,10 @@ Embed Offloading device-side binary into host object 
file as a section.
 
 Emit all declarations, even if unused
 
+.. option:: -femit-dwarf-unwind=
+
+When to emit DWARF unwind (EH frame) info.  must be 'always', 
'no-compact-unwind' or 'default'.
+
 .. option:: -femulated-tls, -fno-emulated-tls
 
 Use emutls functions to access thread\_local variables
@@ -1903,6 +1917,10 @@ Enable the integrated assembler
 
 Run cc1 in-process
 
+.. option:: -fintegrated-objemitter, -fno-integrated-objemitter
+
+Use internal machine object code emitter.
+
 .. option:: -fjmc, -fno-jmc
 
 Enable just-my-code debugging
@@ -2767,7 +2785,7 @@ When using -fxray-function-groups, select which group of 
functions to instrument
 
 .. option:: -fzero-call-used-regs=
 
-Clear call-used registers upon function return.  must be 'skip', 
'used-gpr-arg', 'used-gpr', 'used-arg', 'used', 'all-gpr-arg', 'all-gpr', 
'all-arg' or 'all'.
+Clear call-used registers upon function return (AArch64/x86 only).  must 
be 'skip', 'used-gpr-arg', 'used-gpr', 'used-arg', 'used', 'all-gpr-arg', 
'all-gpr', 'all-arg' or 'all'.
 
 .. option:: -fzero-initialized-in-bss, -fno-zero-initialized-in-bss
 
@@ -2795,6 +2813,10 @@ OpenCL flags
 
 OpenCL only. Allow denormals to be flushed to zero.
 
+.. option:: -cl-ext=,...
+
+OpenCL only. Enable or disable OpenCL extensions/optional features. The 
argument is a comma-separated sequence of one or more extension names, each 
prefixed by '+' or '-'.
+
 .. option:: -cl-fast-relaxed-math
 
 OpenCL only. Sets -cl-finite-math-only and -cl-unsafe-math-optimizations, and 
defines \_\_FAST\_RELAXED\_MATH\_\_.
@@ -3073,6 +3095,10 @@ Allow use of CRC instructions (ARM/Mips only)
 
 .. option:: -mdefault-build-attributes, -mno-default-build-attributes
 
+.. option:: -mdefault-visibility-export-mapping=
+
+Mapping between default visibility and export.  must be 'none', 
'explicit' or 'all'.
+
 .. option:: -mdll
 
 .. option:: -mdouble=
 
 Pass the comma separated arguments in  to the linker
 
-.. option:: --offload-link
-
-Use the linker supporting offloading device linking.
-
 .. 

[clang] 80c12bd - [clang] Call *set::insert without checking membership first (NFC)

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

Author: Kazu Hirata
Date: 2022-06-18T10:41:26-07:00
New Revision: 80c12bdb3bbdb2b0250ff6f712da65b9c7788c9d

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

LOG: [clang] Call *set::insert without checking membership first (NFC)

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Sema/SemaExpr.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 370b420b80755..4759932a696f1 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -457,8 +457,7 @@ Value *Environment::createValueUnlessSelfReferential(
 QualType PointeeType = Type->castAs()->getPointeeType();
 auto  = createStorageLocation(PointeeType);
 
-if (!Visited.contains(PointeeType.getCanonicalType())) {
-  Visited.insert(PointeeType.getCanonicalType());
+if (Visited.insert(PointeeType.getCanonicalType()).second) {
   Value *PointeeVal = createValueUnlessSelfReferential(
   PointeeType, Visited, Depth, CreatedValuesCount);
   Visited.erase(PointeeType.getCanonicalType());
@@ -475,8 +474,7 @@ Value *Environment::createValueUnlessSelfReferential(
 QualType PointeeType = Type->castAs()->getPointeeType();
 auto  = createStorageLocation(PointeeType);
 
-if (!Visited.contains(PointeeType.getCanonicalType())) {
-  Visited.insert(PointeeType.getCanonicalType());
+if (Visited.insert(PointeeType.getCanonicalType()).second) {
   Value *PointeeVal = createValueUnlessSelfReferential(
   PointeeType, Visited, Depth, CreatedValuesCount);
   Visited.erase(PointeeType.getCanonicalType());

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 68634c5495cb9..ce7706ab96cac 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14473,8 +14473,7 @@ static void RecordModifiableNonNullParam(Sema , const 
Expr *Exp) {
 if (!FD->hasAttr() && !Param->hasAttr())
   return;
   if (FunctionScopeInfo *FD = S.getCurFunction())
-if (!FD->ModifiedNonNullParams.count(Param))
-  FD->ModifiedNonNullParams.insert(Param);
+FD->ModifiedNonNullParams.insert(Param);
 }
 
 /// CheckIndirectionOperand - Type check unary indirection (prefix '*').

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 1a73b300cf9df..b6bcd851c6c1d 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -4321,9 +4321,8 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper , 
raw_ostream ) {
   if (Attr.isSubClassOf("TargetSpecificAttr") &&
   !Attr.isValueUnset("ParseKind")) {
 AttrName = std::string(Attr.getValueAsString("ParseKind"));
-if (Seen.find(AttrName) != Seen.end())
+if (!Seen.insert(AttrName).second)
   continue;
-Seen.insert(AttrName);
   } else
 AttrName = NormalizeAttrName(StringRef(Attr.getName())).str();
 



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


[PATCH] D127812: [AArch64] Function multiversioning support added.

2022-06-18 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:1086
 
+.. option:: -mno-fmv
+

ilinpv wrote:
> MaskRay wrote:
> > This file is auto-generated. Don't touch it.
> It looked out of sync with options td files:
> 
> ```
> +.. option:: -gen-reproducer=, -fno-crash-diagnostics (equivalent to 
> -gen-reproducer=off)
> +
> +Emit reproducer on (option: off, crash (default), error, always)
> +
> 
> +.. option:: -print-diagnostic-options, --print-diagnostic-options
> +
> +Print all of Clang's warning options
> +
> 
> +.. option:: -fdriver-only
> +
> +Only run the driver.
> +
> 
> ...
> ```
But it needs to be manually autogenerated..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D127509: Prefer `getCurrentFileOrBufferName` in `FrontendAction::EndSourceFile`

2022-06-18 Thread Yuki Okushi 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 rG7eb046624f2a: Prefer `getCurrentFileOrBufferName` in 
`FrontendAction::EndSourceFile` (authored by JohnTitor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127509

Files:
  clang/lib/Frontend/FrontendAction.cpp


Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -1075,7 +1075,7 @@
   }
 
   if (CI.getFrontendOpts().ShowStats) {
-llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFile() << "':\n";
+llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFileOrBufferName() << 
"':\n";
 CI.getPreprocessor().PrintStats();
 CI.getPreprocessor().getIdentifierTable().PrintStats();
 CI.getPreprocessor().getHeaderSearchInfo().PrintStats();


Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -1075,7 +1075,7 @@
   }
 
   if (CI.getFrontendOpts().ShowStats) {
-llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFile() << "':\n";
+llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFileOrBufferName() << "':\n";
 CI.getPreprocessor().PrintStats();
 CI.getPreprocessor().getIdentifierTable().PrintStats();
 CI.getPreprocessor().getHeaderSearchInfo().PrintStats();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7eb0466 - Prefer `getCurrentFileOrBufferName` in `FrontendAction::EndSourceFile`

2022-06-18 Thread Yuki Okushi via cfe-commits

Author: Yuki Okushi
Date: 2022-06-18T23:48:30+09:00
New Revision: 7eb046624f2a35f32f0821c91ad5c6a26f250e5f

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

LOG: Prefer `getCurrentFileOrBufferName` in `FrontendAction::EndSourceFile`

`getCurrentFile` here causes an assertion on some condition.
`getCurrentFileOrBufferName` is preferrable instead.

llvm#55950

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

Added: 


Modified: 
clang/lib/Frontend/FrontendAction.cpp

Removed: 




diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 6b1f6364b13c3..65160dd7e0b18 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -1075,7 +1075,7 @@ void FrontendAction::EndSourceFile() {
   }
 
   if (CI.getFrontendOpts().ShowStats) {
-llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFile() << "':\n";
+llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFileOrBufferName() << 
"':\n";
 CI.getPreprocessor().PrintStats();
 CI.getPreprocessor().getIdentifierTable().PrintStats();
 CI.getPreprocessor().getHeaderSearchInfo().PrintStats();



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


[PATCH] D127509: Prefer `getCurrentFileOrBufferName` in `FrontendAction::EndSourceFile`

2022-06-18 Thread Yuki Okushi via Phabricator via cfe-commits
JohnTitor added a comment.

Alright, let's go ahead then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127509

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


[PATCH] D128120: [Clang][VE] Add missing intrinsics

2022-06-18 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 created this revision.
kaz7 added reviewers: efocht, simoll.
kaz7 added projects: clang, VE.
Herald added a project: All.
kaz7 requested review of this revision.
Herald added a subscriber: cfe-commits.

Add missing intrinsics and tests for them.  An expanding  macro
from _vel_pack_f32p to __builtin_ve_vl_pack_f32p and others is
already defined in clang/lib/Headers/velintrin.h.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128120

Files:
  clang/include/clang/Basic/BuiltinsVE.def
  clang/test/CodeGen/VE/ve-velintrin.c


Index: clang/test/CodeGen/VE/ve-velintrin.c
===
--- clang/test/CodeGen/VE/ve-velintrin.c
+++ clang/test/CodeGen/VE/ve-velintrin.c
@@ -1,7 +1,7 @@
 // REQUIRES: ve-registered-target
 
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -triple 
ve-unknown-linux-gnu \
-// RUN:   -ffreestanding %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -emit-llvm -triple ve-unknown-linux-gnu \
+// RUN:   -no-opaque-pointers -ffreestanding %s -o - | FileCheck %s
 
 #include 
 
@@ -8811,3 +8811,48 @@
   // CHECK: call void @llvm.ve.vl.svob()
   _vel_svob();
 }
+
+void __attribute__((noinline))
+test_pack_f32p(float* p1, float* p2) {
+  // CHECK-LABEL: @test_pack_f32p
+  // CHECK: %[[VAR1:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK: %[[VAR2:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32p(i8* %[[VAR1]], i8* %[[VAR2]])
+  v1 = _vel_pack_f32p(p1, p2);
+}
+
+void __attribute__((noinline))
+test_pack_f32a(float* p) {
+  // CHECK-LABEL: @test_pack_f32a
+  // CHECK: %[[VAR3:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32a(i8* %[[VAR3]])
+  v1 = _vel_pack_f32a(p);
+}
+
+void __attribute__((noinline))
+test_extract_vm512u() {
+  // CHECK-LABEL: @test_extract_vm512u
+  // CHECK: call <256 x i1> @llvm.ve.vl.extract.vm512u(<512 x i1> %{{.*}})
+  vm1 = _vel_extract_vm512u(vm1_512);
+}
+
+void __attribute__((noinline))
+test_extract_vm512l() {
+  // CHECK-LABEL: @test_extract_vm512l
+  // CHECK: call <256 x i1> @llvm.ve.vl.extract.vm512l(<512 x i1> %{{.*}})
+  vm1 = _vel_extract_vm512l(vm1_512);
+}
+
+void __attribute__((noinline))
+test_insert_vm512u() {
+  // CHECK-LABEL: @test_insert_vm512u
+  // CHECK: call <512 x i1> @llvm.ve.vl.insert.vm512u(<512 x i1> %{{.*}}, <256 
x i1> %{{.*}})
+  vm1_512 = _vel_insert_vm512u(vm1_512, vm1);
+}
+
+void __attribute__((noinline))
+test_insert_vm512l() {
+  // CHECK-LABEL: @test_insert_vm512l
+  // CHECK: call <512 x i1> @llvm.ve.vl.insert.vm512l(<512 x i1> %{{.*}}, <256 
x i1> %{{.*}})
+  vm1_512 = _vel_insert_vm512l(vm1_512, vm1);
+}
Index: clang/include/clang/Basic/BuiltinsVE.def
===
--- clang/include/clang/Basic/BuiltinsVE.def
+++ clang/include/clang/Basic/BuiltinsVE.def
@@ -15,6 +15,16 @@
 #   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
+// The format of this database is decribed in clang/Basic/Builtins.def.
+
+BUILTIN(__builtin_ve_vl_pack_f32p, "ULifC*fC*", "n")
+BUILTIN(__builtin_ve_vl_pack_f32a, "ULifC*", "n")
+
+BUILTIN(__builtin_ve_vl_extract_vm512u, "V256bV512b", "n")
+BUILTIN(__builtin_ve_vl_extract_vm512l, "V256bV512b", "n")
+BUILTIN(__builtin_ve_vl_insert_vm512u, "V512bV512bV256b", "n")
+BUILTIN(__builtin_ve_vl_insert_vm512l, "V512bV512bV256b", "n")
+
 // Use generated BUILTIN definitions
 #include "clang/Basic/BuiltinsVEVL.gen.def"
 


Index: clang/test/CodeGen/VE/ve-velintrin.c
===
--- clang/test/CodeGen/VE/ve-velintrin.c
+++ clang/test/CodeGen/VE/ve-velintrin.c
@@ -1,7 +1,7 @@
 // REQUIRES: ve-registered-target
 
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -triple ve-unknown-linux-gnu \
-// RUN:   -ffreestanding %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -emit-llvm -triple ve-unknown-linux-gnu \
+// RUN:   -no-opaque-pointers -ffreestanding %s -o - | FileCheck %s
 
 #include 
 
@@ -8811,3 +8811,48 @@
   // CHECK: call void @llvm.ve.vl.svob()
   _vel_svob();
 }
+
+void __attribute__((noinline))
+test_pack_f32p(float* p1, float* p2) {
+  // CHECK-LABEL: @test_pack_f32p
+  // CHECK: %[[VAR1:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK: %[[VAR2:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32p(i8* %[[VAR1]], i8* %[[VAR2]])
+  v1 = _vel_pack_f32p(p1, p2);
+}
+
+void __attribute__((noinline))
+test_pack_f32a(float* p) {
+  // CHECK-LABEL: @test_pack_f32a
+  // CHECK: %[[VAR3:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32a(i8* %[[VAR3]])
+  v1 = _vel_pack_f32a(p);
+}
+
+void __attribute__((noinline))
+test_extract_vm512u() {
+  // CHECK-LABEL: @test_extract_vm512u
+  // CHECK: call <256 x i1> @llvm.ve.vl.extract.vm512u(<512 x i1> %{{.*}})
+  vm1 = _vel_extract_vm512u(vm1_512);
+}
+
+void 

[PATCH] D128113: Clang: fix AST representation of expanded template arguments.

2022-06-18 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 438118.
mizvekov added a comment.

format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128113

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/JSONNodeDumper.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/AST/ast-dump-template-decls.cpp

Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -136,13 +136,13 @@
 };
 using t1 = foo::bind;
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar pack_index 2
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar pack_index 3
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
 
 template  struct D {
@@ -152,13 +152,13 @@
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar alias B
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int (*)(char, short))' cdecl
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent contains_unexpanded_pack depth 1 index 0 pack
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent contains_unexpanded_pack depth 1 index 0 pack
 } // namespace PR56099
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4858,7 +4858,8 @@
 Replacement = SemaRef.Context.getQualifiedType(
 Replacement.getUnqualifiedType(), Qs);
 T = SemaRef.Context.getSubstTemplateTypeParmType(
-SubstTypeParam->getReplacedParameter(), Replacement);
+SubstTypeParam->getReplacedParameter(), Replacement,
+SubstTypeParam->getPackIndex());
   } else if ((AutoTy = dyn_cast(T)) && AutoTy->isDeduced()) {
 // 'auto' types behave the same way as template parameters.
 QualType Deduced = AutoTy->getDeducedType();
@@ -6414,9 +6415,8 @@
 
   // Always canonicalize the replacement type.
   Replacement = SemaRef.Context.getCanonicalType(Replacement);
-  QualType Result
-= SemaRef.Context.getSubstTemplateTypeParmType(T->getReplacedParameter(),
-   Replacement);
+  QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
+  T->getReplacedParameter(), Replacement, T->getPackIndex());
 
   // Propagate type-source information.
   SubstTemplateTypeParmTypeLoc NewTL
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ 

[PATCH] D128113: Clang: fix AST representation of expanded template arguments.

2022-06-18 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 438117.
mizvekov edited the summary of this revision.
mizvekov added a comment.
Herald added a subscriber: martong.
Herald added a reviewer: shafik.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128113

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/JSONNodeDumper.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/AST/ast-dump-template-decls.cpp

Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -136,13 +136,13 @@
 };
 using t1 = foo::bind;
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar pack_index 2
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar pack_index 3
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
 
 template  struct D {
@@ -152,13 +152,13 @@
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar alias B
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int (*)(char, short))' cdecl
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent contains_unexpanded_pack depth 1 index 0 pack
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent contains_unexpanded_pack depth 1 index 0 pack
 } // namespace PR56099
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4858,7 +4858,8 @@
 Replacement = SemaRef.Context.getQualifiedType(
 Replacement.getUnqualifiedType(), Qs);
 T = SemaRef.Context.getSubstTemplateTypeParmType(
-SubstTypeParam->getReplacedParameter(), Replacement);
+SubstTypeParam->getReplacedParameter(), Replacement,
+SubstTypeParam->getPackIndex());
   } else if ((AutoTy = dyn_cast(T)) && AutoTy->isDeduced()) {
 // 'auto' types behave the same way as template parameters.
 QualType Deduced = AutoTy->getDeducedType();
@@ -6414,9 +6415,8 @@
 
   // Always canonicalize the replacement type.
   Replacement = SemaRef.Context.getCanonicalType(Replacement);
-  QualType Result
-= SemaRef.Context.getSubstTemplateTypeParmType(T->getReplacedParameter(),
-   Replacement);
+  QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
+  T->getReplacedParameter(), Replacement, T->getPackIndex());
 
   // Propagate type-source information.
   SubstTemplateTypeParmTypeLoc NewTL
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp

[clang] cd64a42 - Reland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"

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

Author: Jun Zhang
Date: 2022-06-18T20:27:21+08:00
New Revision: cd64a427efa0baaf1bb7ae624d4301908afc07f7

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

LOG: Reland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"

This reverts commits:
d3ddc251acae631bf5ab4da13878f7e8b5b5a451
d90eecff5c9e7e9f8263de6cd72d70322400829f

It turned out there're some options turned on that leaks the memory
intentionally, which fires the asan builds after the patch being
applied. The issue has been fixed in
7bc00ce5cd41aad5fd0775f58c8e85a0a8d9ee56, so reland it.

Below is the original commit message:

The intent of this patch is to selectively carry some states over to
the Builder so we won't lose the information of the previous symbols.

This used to be several downstream patches of Cling, it aims to fix
errors in Clang Interpreter when trying to use inline functions.
Before this patch:

clang-repl> inline int foo() { return 42;}
clang-repl> int x = foo();

JIT session error: Symbols not found: [ _Z3foov ]
error: Failed to materialize symbols:
{ (main, { x, $.incr_module_1.__inits.0, __orc_init_func.incr_module_1 }) }

Co-authored-by: Axel Naumann 
Signed-off-by: Jun Zhang 

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/ModuleBuilder.cpp
clang/test/Interpreter/execute.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index f5ae83a2faca9..79e9a462a3d72 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1486,6 +1486,33 @@ class CodeGenModule : public CodeGenTypeCache {
   void printPostfixForExternalizedDecl(llvm::raw_ostream ,
const Decl *D) const;
 
+  /// Move some lazily-emitted states to the NewBuilder. This is especially
+  /// essential for the incremental parsing environment like Clang Interpreter,
+  /// because we'll lose all important information after each repl.
+  void moveLazyEmissionStates(CodeGenModule *NewBuilder) {
+assert(DeferredDeclsToEmit.empty() &&
+   "Should have emitted all decls deferred to emit.");
+assert(NewBuilder->DeferredDecls.empty() &&
+   "Newly created module should not have deferred decls");
+NewBuilder->DeferredDecls = std::move(DeferredDecls);
+
+assert(NewBuilder->DeferredVTables.empty() &&
+   "Newly created module should not have deferred vtables");
+NewBuilder->DeferredVTables = std::move(DeferredVTables);
+
+assert(NewBuilder->MangledDeclNames.empty() &&
+   "Newly created module should not have mangled decl names");
+assert(NewBuilder->Manglings.empty() &&
+   "Newly created module should not have manglings");
+NewBuilder->Manglings = std::move(Manglings);
+
+assert(WeakRefReferences.empty() &&
+   "Not all WeakRefRefs have been applied");
+NewBuilder->WeakRefReferences = std::move(WeakRefReferences);
+
+NewBuilder->TBAA = std::move(TBAA);
+  }
+
 private:
   llvm::Constant *GetOrCreateLLVMFunction(
   StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,

diff  --git a/clang/lib/CodeGen/ModuleBuilder.cpp 
b/clang/lib/CodeGen/ModuleBuilder.cpp
index 50b7fd8eb993c..8e97a298ce7fa 100644
--- a/clang/lib/CodeGen/ModuleBuilder.cpp
+++ b/clang/lib/CodeGen/ModuleBuilder.cpp
@@ -134,7 +134,14 @@ namespace {
   llvm::LLVMContext ) {
   assert(!M && "Replacing existing Module?");
   M.reset(new llvm::Module(ExpandModuleName(ModuleName, CodeGenOpts), C));
+
+  std::unique_ptr OldBuilder = std::move(Builder);
+
   Initialize(*Ctx);
+
+  if (OldBuilder)
+OldBuilder->moveLazyEmissionStates(Builder.get());
+
   return M.get();
 }
 

diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index 298046c068c37..61e68990acf96 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -13,4 +13,8 @@ struct S { float f = 1.0; S *m = nullptr;} s;
 
 auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast(s.m));
 // CHECK-NEXT: S[f=1.00, m=0x0]
+
+inline int foo() { return 42; }
+int r3 = foo();
+
 quit



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


[PATCH] D128119: [clang] enforce instantiation of constexpr template functions

2022-06-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 438114.
serge-sans-paille added a comment.

(rebased on main branch)


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

https://reviews.llvm.org/D128119

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/constexpr-late-instantiation.cpp


Index: clang/test/SemaCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,17 @@
+// Make sure foo is sinstantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+// CHECK-LABEL: define {{.*}} @main
+int main() {
+  // CHECK: call {{.*}} @_Z3fooIiET_S0_
+  int k = foo(5);
+}
+
+// CHECK-LABEL: define {{.*}} @_Z3fooIiET_S0_
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4855,6 +4855,10 @@
 if (getLangOpts().CPlusPlus11)
   Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
 << Function;
+  } else if (!Recursive) {
+Function->setInstantiationIsPending(true);
+PendingInstantiations.push_back(
+std::make_pair(Function, PointOfInstantiation));
   }
 }
 


Index: clang/test/SemaCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,17 @@
+// Make sure foo is sinstantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+// CHECK-LABEL: define {{.*}} @main
+int main() {
+  // CHECK: call {{.*}} @_Z3fooIiET_S0_
+  int k = foo(5);
+}
+
+// CHECK-LABEL: define {{.*}} @_Z3fooIiET_S0_
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4855,6 +4855,10 @@
 if (getLangOpts().CPlusPlus11)
   Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
 << Function;
+  } else if (!Recursive) {
+Function->setInstantiationIsPending(true);
+PendingInstantiations.push_back(
+std::make_pair(Function, PointOfInstantiation));
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128119: [clang] enforce instantiation of constexpr template functions

2022-06-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

I"m not 100% sure of the fix but it fixes bug #55560 and does not introduce 
regression :-/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128119

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


[PATCH] D128119: [clang] enforce instantiation of constexpr template functions

2022-06-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: aaron.ballman, tbaeder.
Herald added a project: All.
serge-sans-paille requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix #55560


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128119

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/constexpr-late-instantiation.cpp


Index: clang/test/SemaCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,17 @@
+// Make sure foo is sinstantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+// CHECK-LABEL: define {{.*}} @main
+int main() {
+  // CHECK: call {{.*}} @_Z3fooIiET_S0_
+  int k = foo(5);
+}
+
+// CHECK-LABEL: define {{.*}} @_Z3fooIiET_S0_
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4853,6 +4853,10 @@
 if (getLangOpts().CPlusPlus11)
   Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
 << Function;
+  } else if (!Recursive) {
+Function->setInstantiationIsPending(true);
+PendingInstantiations.push_back(
+std::make_pair(Function, PointOfInstantiation));
   }
 }
 


Index: clang/test/SemaCXX/constexpr-late-instantiation.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-late-instantiation.cpp
@@ -0,0 +1,17 @@
+// Make sure foo is sinstantiated and we don't get a link error
+// RUN: %clang_cc1 -S -emit-llvm %s -o- | FileCheck %s
+
+template 
+constexpr T foo(T a);
+
+// CHECK-LABEL: define {{.*}} @main
+int main() {
+  // CHECK: call {{.*}} @_Z3fooIiET_S0_
+  int k = foo(5);
+}
+
+// CHECK-LABEL: define {{.*}} @_Z3fooIiET_S0_
+template 
+constexpr T foo(T a) {
+  return a;
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4853,6 +4853,10 @@
 if (getLangOpts().CPlusPlus11)
   Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
 << Function;
+  } else if (!Recursive) {
+Function->setInstantiationIsPending(true);
+PendingInstantiations.push_back(
+std::make_pair(Function, PointOfInstantiation));
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128064: [Static Analyzer] Small array binding policy

2022-06-18 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added a comment.

What's out desired approach for that? Create a new patch, or update this one? 
Also, should I commit it as usual, or revert this commit first?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128064

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


[PATCH] D128116: [clang][docs] Sync generated command line doc with td files.

2022-06-18 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv created this revision.
ilinpv added a reviewer: MaskRay.
Herald added a subscriber: StephenFan.
Herald added a project: All.
ilinpv requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It seems auto-generated ClangCommandLineReference.rst is out of sync with 
options td files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128116

Files:
  clang/docs/ClangCommandLineReference.rst

Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -281,6 +281,10 @@
 
 Emit type record hashes in a .debug$H section
 
+.. option:: -gen-reproducer=, -fno-crash-diagnostics (equivalent to -gen-reproducer=off)
+
+Emit reproducer on (option: off, crash (default), error, always)
+
 .. option:: --gpu-instrument-lib=
 
 Instrument device library for HIP, which is a LLVM bitcode containing \_\_cyg\_profile\_func\_enter and \_\_cyg\_profile\_func\_exit
@@ -339,7 +343,7 @@
 
 .. option:: -mharden-sls=
 
-Select straight-line speculation hardening scope
+Select straight-line speculation hardening scope (ARM/AArch64/X86 only).  must be: all, none, retbr(ARM/AArch64), blr(ARM/AArch64), comdat(ARM/AArch64), nocomdat(ARM/AArch64), return(X86), indirect-jmp(X86)
 
 .. option:: --migrate
 
@@ -551,6 +555,10 @@
 
 .. option:: --print-diagnostic-categories
 
+.. option:: -print-diagnostic-options, --print-diagnostic-options
+
+Print all of Clang's warning options
+
 .. option:: -print-effective-triple, --print-effective-triple
 
 Print the effective target triple
@@ -817,6 +825,10 @@
 
 Extract API information
 
+.. option:: -fdriver-only
+
+Only run the driver.
+
 .. option:: -fsyntax-only
 
 .. option:: -module-file-info
@@ -929,10 +941,6 @@
 
 Inline functions which are (explicitly or implicitly) marked inline
 
-.. option:: -fno-crash-diagnostics
-
-Disable auto-generation of preprocessed source files and a script for reproduction during a clang crash
-
 .. option:: -fno-legacy-pass-manager, -fexperimental-new-pass-manager
 
 .. option:: -fno-sanitize-ignorelist, -fno-sanitize-blacklist
@@ -1106,7 +1114,9 @@
 
 Include comments from within macros in preprocessed output
 
-.. option:: -D=, --define-macro , --define-macro=
+.. program:: clang2
+.. option:: -D=, --D, /D, -D, --define-macro , --define-macro=
+.. program:: clang
 
 Define  to  (or 1 if  omitted)
 
@@ -1727,6 +1737,10 @@
 
 Emit all declarations, even if unused
 
+.. option:: -femit-dwarf-unwind=
+
+When to emit DWARF unwind (EH frame) info.  must be 'always', 'no-compact-unwind' or 'default'.
+
 .. option:: -femulated-tls, -fno-emulated-tls
 
 Use emutls functions to access thread\_local variables
@@ -1903,6 +1917,10 @@
 
 Run cc1 in-process
 
+.. option:: -fintegrated-objemitter, -fno-integrated-objemitter
+
+Use internal machine object code emitter.
+
 .. option:: -fjmc, -fno-jmc
 
 Enable just-my-code debugging
@@ -2767,7 +2785,7 @@
 
 .. option:: -fzero-call-used-regs=
 
-Clear call-used registers upon function return.  must be 'skip', 'used-gpr-arg', 'used-gpr', 'used-arg', 'used', 'all-gpr-arg', 'all-gpr', 'all-arg' or 'all'.
+Clear call-used registers upon function return (AArch64/x86 only).  must be 'skip', 'used-gpr-arg', 'used-gpr', 'used-arg', 'used', 'all-gpr-arg', 'all-gpr', 'all-arg' or 'all'.
 
 .. option:: -fzero-initialized-in-bss, -fno-zero-initialized-in-bss
 
@@ -2795,6 +2813,10 @@
 
 OpenCL only. Allow denormals to be flushed to zero.
 
+.. option:: -cl-ext=,...
+
+OpenCL only. Enable or disable OpenCL extensions/optional features. The argument is a comma-separated sequence of one or more extension names, each prefixed by '+' or '-'.
+
 .. option:: -cl-fast-relaxed-math
 
 OpenCL only. Sets -cl-finite-math-only and -cl-unsafe-math-optimizations, and defines \_\_FAST\_RELAXED\_MATH\_\_.
@@ -3073,6 +3095,10 @@
 
 .. option:: -mdefault-build-attributes, -mno-default-build-attributes
 
+.. option:: -mdefault-visibility-export-mapping=
+
+Mapping between default visibility and export.  must be 'none', 'explicit' or 'all'.
+
 .. option:: -mdll
 
 .. option:: -mdouble= to the linker
 
-.. option:: --offload-link
-
-Use the linker supporting offloading device linking.
-
 .. option:: -X
 
 .. option:: -Xlinker , --for-linker , --for-linker=
 
 Pass  to the linker
 
-.. option:: -Xoffload-linker , -Xoffload-linker- 
+.. option:: -Xoffload-linker 
 
-Pass  to all the device linking jobs, or for only  if specified.
+Pass  to the offload linkers or the ones idenfied by -
 
 .. program:: clang1
 .. option:: -Z
@@ -4255,6 +4277,10 @@
 .. option:: -nostdlib, --no-standard-libraries
 .. program:: clang
 
+.. option:: --offload-link
+
+Use the new offloading linker to perform the link job.
+
 .. option:: -pie
 
 .. option:: -r
@@ -4295,15 +4321,21 @@
 ===
 dxc compatibility options
 
-.. program:: clang2
+.. program:: clang3
 

[clang] 6e070c3 - [NFC] Specifing clang namespace for builtins.

2022-06-18 Thread Pavel Iliin via cfe-commits

Author: Pavel Iliin
Date: 2022-06-18T10:44:25+01:00
New Revision: 6e070c3c9101ac7b7a3736021bff98e9a1f5a362

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

LOG: [NFC] Specifing clang namespace for builtins.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ce4ecc5c3284..48207edfe576 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1169,141 +1169,141 @@ translateArmToMsvcIntrin(unsigned BuiltinID) {
   switch (BuiltinID) {
   default:
 return None;
-  case ARM::BI_BitScanForward:
-  case ARM::BI_BitScanForward64:
+  case clang::ARM::BI_BitScanForward:
+  case clang::ARM::BI_BitScanForward64:
 return MSVCIntrin::_BitScanForward;
-  case ARM::BI_BitScanReverse:
-  case ARM::BI_BitScanReverse64:
+  case clang::ARM::BI_BitScanReverse:
+  case clang::ARM::BI_BitScanReverse64:
 return MSVCIntrin::_BitScanReverse;
-  case ARM::BI_InterlockedAnd64:
+  case clang::ARM::BI_InterlockedAnd64:
 return MSVCIntrin::_InterlockedAnd;
-  case ARM::BI_InterlockedExchange64:
+  case clang::ARM::BI_InterlockedExchange64:
 return MSVCIntrin::_InterlockedExchange;
-  case ARM::BI_InterlockedExchangeAdd64:
+  case clang::ARM::BI_InterlockedExchangeAdd64:
 return MSVCIntrin::_InterlockedExchangeAdd;
-  case ARM::BI_InterlockedExchangeSub64:
+  case clang::ARM::BI_InterlockedExchangeSub64:
 return MSVCIntrin::_InterlockedExchangeSub;
-  case ARM::BI_InterlockedOr64:
+  case clang::ARM::BI_InterlockedOr64:
 return MSVCIntrin::_InterlockedOr;
-  case ARM::BI_InterlockedXor64:
+  case clang::ARM::BI_InterlockedXor64:
 return MSVCIntrin::_InterlockedXor;
-  case ARM::BI_InterlockedDecrement64:
+  case clang::ARM::BI_InterlockedDecrement64:
 return MSVCIntrin::_InterlockedDecrement;
-  case ARM::BI_InterlockedIncrement64:
+  case clang::ARM::BI_InterlockedIncrement64:
 return MSVCIntrin::_InterlockedIncrement;
-  case ARM::BI_InterlockedExchangeAdd8_acq:
-  case ARM::BI_InterlockedExchangeAdd16_acq:
-  case ARM::BI_InterlockedExchangeAdd_acq:
-  case ARM::BI_InterlockedExchangeAdd64_acq:
+  case clang::ARM::BI_InterlockedExchangeAdd8_acq:
+  case clang::ARM::BI_InterlockedExchangeAdd16_acq:
+  case clang::ARM::BI_InterlockedExchangeAdd_acq:
+  case clang::ARM::BI_InterlockedExchangeAdd64_acq:
 return MSVCIntrin::_InterlockedExchangeAdd_acq;
-  case ARM::BI_InterlockedExchangeAdd8_rel:
-  case ARM::BI_InterlockedExchangeAdd16_rel:
-  case ARM::BI_InterlockedExchangeAdd_rel:
-  case ARM::BI_InterlockedExchangeAdd64_rel:
+  case clang::ARM::BI_InterlockedExchangeAdd8_rel:
+  case clang::ARM::BI_InterlockedExchangeAdd16_rel:
+  case clang::ARM::BI_InterlockedExchangeAdd_rel:
+  case clang::ARM::BI_InterlockedExchangeAdd64_rel:
 return MSVCIntrin::_InterlockedExchangeAdd_rel;
-  case ARM::BI_InterlockedExchangeAdd8_nf:
-  case ARM::BI_InterlockedExchangeAdd16_nf:
-  case ARM::BI_InterlockedExchangeAdd_nf:
-  case ARM::BI_InterlockedExchangeAdd64_nf:
+  case clang::ARM::BI_InterlockedExchangeAdd8_nf:
+  case clang::ARM::BI_InterlockedExchangeAdd16_nf:
+  case clang::ARM::BI_InterlockedExchangeAdd_nf:
+  case clang::ARM::BI_InterlockedExchangeAdd64_nf:
 return MSVCIntrin::_InterlockedExchangeAdd_nf;
-  case ARM::BI_InterlockedExchange8_acq:
-  case ARM::BI_InterlockedExchange16_acq:
-  case ARM::BI_InterlockedExchange_acq:
-  case ARM::BI_InterlockedExchange64_acq:
+  case clang::ARM::BI_InterlockedExchange8_acq:
+  case clang::ARM::BI_InterlockedExchange16_acq:
+  case clang::ARM::BI_InterlockedExchange_acq:
+  case clang::ARM::BI_InterlockedExchange64_acq:
 return MSVCIntrin::_InterlockedExchange_acq;
-  case ARM::BI_InterlockedExchange8_rel:
-  case ARM::BI_InterlockedExchange16_rel:
-  case ARM::BI_InterlockedExchange_rel:
-  case ARM::BI_InterlockedExchange64_rel:
+  case clang::ARM::BI_InterlockedExchange8_rel:
+  case clang::ARM::BI_InterlockedExchange16_rel:
+  case clang::ARM::BI_InterlockedExchange_rel:
+  case clang::ARM::BI_InterlockedExchange64_rel:
 return MSVCIntrin::_InterlockedExchange_rel;
-  case ARM::BI_InterlockedExchange8_nf:
-  case ARM::BI_InterlockedExchange16_nf:
-  case ARM::BI_InterlockedExchange_nf:
-  case ARM::BI_InterlockedExchange64_nf:
+  case clang::ARM::BI_InterlockedExchange8_nf:
+  case clang::ARM::BI_InterlockedExchange16_nf:
+  case clang::ARM::BI_InterlockedExchange_nf:
+  case clang::ARM::BI_InterlockedExchange64_nf:
 return MSVCIntrin::_InterlockedExchange_nf;
-  case ARM::BI_InterlockedCompareExchange8_acq:
-  case ARM::BI_InterlockedCompareExchange16_acq:
-  case ARM::BI_InterlockedCompareExchange_acq:
-  case ARM::BI_InterlockedCompareExchange64_acq:
+  case 

[PATCH] D109621: [clang][Driver] Default to loading clang.cfg if config file not specified

2022-06-18 Thread Matthew Smith via Phabricator via cfe-commits
asymptotically updated this revision to Diff 438106.
asymptotically added a comment.
Herald added a subscriber: MaskRay.
Herald added a project: All.

Updated users' manual following Arfrever's feedback.


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

https://reviews.llvm.org/D109621

Files:
  clang/docs/UsersManual.rst
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1032,7 +1032,7 @@
 CfgFileName = ClangNameParts.TargetPrefix + '-' + 
ClangNameParts.ModeSuffix;
 
   if (CfgFileName.empty())
-return false;
+CfgFileName = "clang";
 
   // Determine architecture part of the file name, if it is present.
   StringRef CfgFileArch = CfgFileName;
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -876,8 +876,9 @@
 
 Another way to specify a configuration file is to encode it in executable name.
 For example, if the Clang executable is named `armv7l-clang` (it may be a
-symbolic link to `clang`), then Clang will search for file `armv7l.cfg` in the
-directory where Clang resides.
+symbolic link to `clang`), then Clang will search for file `armv7l-clang.cfg` 
in
+the directories mentioned above. If the executable is named `clang`, the Clang
+will attempt to load the configuration file named `clang.cfg`.
 
 If a driver mode is specified in invocation, Clang tries to find a file 
specific
 for the specified mode. For example, if the executable file is named


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1032,7 +1032,7 @@
 CfgFileName = ClangNameParts.TargetPrefix + '-' + ClangNameParts.ModeSuffix;
 
   if (CfgFileName.empty())
-return false;
+CfgFileName = "clang";
 
   // Determine architecture part of the file name, if it is present.
   StringRef CfgFileArch = CfgFileName;
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -876,8 +876,9 @@
 
 Another way to specify a configuration file is to encode it in executable name.
 For example, if the Clang executable is named `armv7l-clang` (it may be a
-symbolic link to `clang`), then Clang will search for file `armv7l.cfg` in the
-directory where Clang resides.
+symbolic link to `clang`), then Clang will search for file `armv7l-clang.cfg` in
+the directories mentioned above. If the executable is named `clang`, the Clang
+will attempt to load the configuration file named `clang.cfg`.
 
 If a driver mode is specified in invocation, Clang tries to find a file specific
 for the specified mode. For example, if the executable file is named
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127207: [flang][driver] Fix support for `-x`

2022-06-18 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D127207#3593665 , @sunho wrote:

> Hi! I'm not exactly sure what's going on. But, seems like build is failing 
> here? https://lab.llvm.org/buildbot/#/builders/177/builds/5571

Thanks for flagging this up! I am also rather confused. I checked the list of 
changes for that buildbot job  and it all looks totally unrelated to `flang-new 
-x`. The error is:

   TEST 'Flang :: Driver/input-from-stdin-llvm.ll' FAILED 

  Script:
  --
  : 'RUN: at line 10';   cat 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Driver/input-from-stdin-llvm.ll
 | /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/not 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang-new -S - -o -
  : 'RUN: at line 11';   cat 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Driver/input-from-stdin-llvm.ll
 | /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/not 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang-new -fc1 -S - -o 
-
  : 'RUN: at line 14';   cat 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Driver/input-from-stdin-llvm.ll
 | /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang-new -x ir -S 
-target aarch64-unknown-linux-gnu - -o - | 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/FileCheck 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Driver/input-from-stdin-llvm.ll
  : 'RUN: at line 15';   cat 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Driver/input-from-stdin-llvm.ll
 | /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang-new -fc1 -x 
ir -S -triple aarch64-unknown-linux-gnu - -o - | 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/FileCheck 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Driver/input-from-stdin-llvm.ll
  --
  Exit Code: 141
  Command Output (stderr):
  --
  + : 'RUN: at line 10'
  + /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/not 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang-new -S - -o -
  + cat 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Driver/input-from-stdin-llvm.ll
  error: Could not scan -
  standard input:10:15: error: bad character ('|') in Fortran token
; RUN: cat %s | not %flang -S - -o -
  ^
  standard input:11:15: error: bad character ('|') in Fortran token
; RUN: cat %s | not %flang_fc1 -S - -o -
  ^
  standard input:14:15: error: bad character ('|') in Fortran token
; RUN: cat %s | %flang -x ir -S -target aarch64-unknown-linux-gnu - -o - | 
FileCheck %s
  ^
  standard input:14:74: error: bad character ('|') in Fortran token
; RUN: cat %s | %flang -x ir -S -target aarch64-unknown-linux-gnu - -o - | 
FileCheck %s
 ^
  standard input:15:15: error: bad character ('|') in Fortran token
; RUN: cat %s | %flang_fc1 -x ir -S -triple aarch64-unknown-linux-gnu - -o 
- | FileCheck %s
  ^
  standard input:15:78: error: bad character ('|') in Fortran token
; RUN: cat %s | %flang_fc1 -x ir -S -triple aarch64-unknown-linux-gnu - -o 
- | FileCheck %s

 ^
  standard input:26:20: error: bad character ('{') in Fortran token
define void @foo() {
   ^
  standard input:28:1: error: bad character ('}') in Fortran token
}
^
  + : 'RUN: at line 11'
  + /home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/not 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/bin/flang-new -fc1 -S - -o 
-
  + cat 
/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/flang/test/Driver/input-from-stdin-llvm.ll
  error: Invalid input type - expecting a Fortran file
  --
  

But lines 10 and 11 in input-from-stdin-llvm.ll 

 //are expected to fail// and hence there's `not %flang` rather than `%flang` 樂 
. The subsequent buildbot job 
 is fine, so probably 
no need to change anything just now. But I will monitor this!

Thanks again for letting me know!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127207

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


[PATCH] D127509: Prefer `getCurrentFileOrBufferName` in `FrontendAction::EndSourceFile`

2022-06-18 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder accepted this revision.
tbaeder added a comment.
This revision is now accepted and ready to land.

Those are all libomp tests, I doubt they are related. I think it's fine to just 
push this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127509

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